1 Star 0 Fork 0

星火构建服务 Spark Building Service/firefox-spark-ace

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
create_deb_package.sh 5.08 KB
一键复制 编辑 原始数据 按行查看 历史
shenmo 提交于 2023-11-25 11:37 +08:00 . mod+
#!/bin/bash
set -e
# Function to validate version number format
validate_version() {
echo "I should have used dpkg to check but i'm too lazy so you should check yourselves input"
}
# Parse arguments
for i in "$@"; do
case $i in
--new-pkg-name=*)
NEW_PKG_NAME="${i#*=}"
shift
;;
--orig-pkg-name=*)
ORIG_PKG_NAME="${i#*=}"
shift
;;
--version=*)
VERSION="${i#*=}"
validate_version $VERSION || exit 1
shift
;;
*)
echo "Usage: $0 [--new-pkg-name=NAME --orig-pkg-name=NAME --version=VERSION]"
echo "or"
echo "Usage: $0 new-pkg-name orig-pkg-name"
exit 1
;;
esac
done
# Check argument count and types
if [ "$#" -gt 0 ] && { [ -n "$NEW_PKG_NAME" ] || [ -n "$ORIG_PKG_NAME" ] || [ -n "$VERSION" ]; }; then
echo "Error: Mixed argument types."
exit 1
fi
if [ "$(which wget)" = "" ]; then
echo "Nope, you need wget first"
exit
fi
if [ "$(which bookworm-run)" = "" ]; then
if [ "$(which spark-store)" = "" ]; then
echo "Nope, you need spark-store first"
exit
fi
xdg-open spk://store/tools/cn.flamescion.bookworm-compatibility-mode
echo "Nope, you need bookworm-run first"
exit
fi
IS_ACE_ENV=1 bookworm-run echo "Welcome to BCM! Trying to create integrate package"
if [ -z "$(bookworm-run which aptss)" ]; then
wget https://zunyun01.store.deepinos.org.cn/store/depends/spark-store-console-in-container_latest_all.deb -O /tmp/ssconsole.deb
IS_ACE_ENV=1 bookworm-run apt install /tmp/ssconsole.deb -y
rm /tmp/ssconsole.deb -f
fi
# Step 1: Get the version number and other details of the original package
sudo bookworm-run aptss update
sudo bookworm-run aptss install spark-store-console-in-container --only-upgrade -y
ORIG_PKG_DETAILS=$(bookworm-run aptss show $ORIG_PKG_NAME)
# Only retrieve version number if not provided by argument
if [ -z "$VERSION" ]; then
VERSION=$(echo "$ORIG_PKG_DETAILS" | grep Version | cut -d ' ' -f 2)
fi
MAINTAINER=$(echo "$ORIG_PKG_DETAILS" | grep Maintainer | cut -d ':' -f 2 | sed 's/^\s*//')
DESCRIPTION=$(echo "$ORIG_PKG_DETAILS" | grep Description | cut -d ':' -f 2- | sed 's/^\s*//')
HOMEPAGE="https://gitee.com/spark-building-service/ace-host-package-creator"
# Check if the version number was retrieved successfully
if [ -z "$VERSION" ]; then
echo "Error: Unable to retrieve the version number for the package $ORIG_PKG_NAME."
exit 1
fi
# Step 2: Create the directory structure for the new package
PKG_DIR="$(mktemp -d)"
DEBIAN_DIR="${PKG_DIR}/DEBIAN"
mkdir -p "$DEBIAN_DIR"
# Step 3: Create and modify the control file with the details from the original package
cat > "${DEBIAN_DIR}/control" << EOF
Package: $NEW_PKG_NAME
Version: $VERSION
Maintainer: $MAINTAINER
Priority: optional
Section: utils
Installed-Size: 10
Depends: cn.flamescion.bookworm-compatibility-mode,bash,wget,sudo,libnotify-bin
Description: $DESCRIPTION
Architecture: all
Homepage: $HOMEPAGE
EOF
# Step 4: Create and write the postinst and postrm scripts
echo "#!/bin/bash " > "${DEBIAN_DIR}/postinst"
echo "REAL_PACKAGE=$ORIG_PKG_NAME" >> "${DEBIAN_DIR}/postinst"
cat >> "${DEBIAN_DIR}/postinst" << 'EOF'
function notify-send(){
#Detect the user using such display
local user=$(who | awk '{print $1}' | head -n 1)
#Detect the id of the user
local uid=$(id -u $user)
sudo -u $user DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus notify-send "$@"
}
function zenity(){
#Detect the user using such display
local user=$(who | awk '{print $1}' | head -n 1)
#Detect the id of the user
local uid=$(id -u $user)
sudo -u $user DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus zenity "$@"
}
###检查aptss在不在
if [ -z `which bookworm-run` ];then
echo "Oh no, ssinstall have not installed bookworm-run dependency yet! Exit"
exit 1
fi
IS_ACE_ENV=1 bookworm-run echo "Welcome to BCM! Trying to install package"
if [ -z "`bookworm-run which aptss`" ];then
wget https://zunyun01.store.deepinos.org.cn/store/depends/spark-store-console-in-container_latest_all.deb -O /tmp/ssconsole.deb
IS_ACE_ENV=1 bookworm-run apt install /tmp/ssconsole.deb -y
rm /tmp/ssconsole.deb -f
fi
notify-send "Installing $REAL_PACKAGE ACE, may cost some time please ensure your network is fine"
notify-send "正在ACE兼容环境中安装$REAL_PACKAGE,可能会花费一些时间,请保持网络畅通"
IS_ACE_ENV=1 bookworm-run aptss update
IS_ACE_ENV=1 bookworm-run aptss install spark-store-console-in-container --only-upgrade -y
IS_ACE_ENV=1 bookworm-run aptss install $REAL_PACKAGE -y
IS_ACE_ENV=1 bookworm-run aptss clean
EOF
echo "#!/bin/bash" > "${DEBIAN_DIR}/postrm"
echo "REAL_PACKAGE=$ORIG_PKG_NAME" >> "${DEBIAN_DIR}/postrm"
cat >> "${DEBIAN_DIR}/postrm" << 'EOF'
bookworm-run echo "Welcome to ACE! Trying to remove package"
if [ "$1" = "remove" ] || [ "$1" = "purge" ];then
bookworm-run aptss autopurge $REAL_PACKAGE -y
bookworm-run aptss clean
else
echo "非卸载,跳过卸载"
fi
true
EOF
chmod +x "${DEBIAN_DIR}/postinst"
chmod +x "${DEBIAN_DIR}/postrm"
# Step 5: Build the new .deb package
dpkg-deb --build $PKG_DIR "$(pwd)"
rm -rf $PKG_DIR
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/spark-building-service/firefox-spark-ace.git
git@gitee.com:spark-building-service/firefox-spark-ace.git
spark-building-service
firefox-spark-ace
firefox-spark-ace
master

搜索帮助