代码拉取完成,页面将自动刷新
#!/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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。