deb-packs/linuxqq/package.sh

152 lines
3.7 KiB
Bash
Raw Normal View History

2023-05-04 13:38:10 +08:00
#!/bin/bash
app_name="linuxqq"
2023-08-02 18:02:08 +08:00
tmp_dir="/tmp/${app_name}_tmp"
2023-10-30 10:24:54 +08:00
version="3.2.1.17816"
release="3.2.1-17816"
_hash="4cb54015"
2023-05-04 13:38:10 +08:00
2023-05-17 21:25:02 +08:00
deb_url="https://dldir1.qq.com/qqfile/qq/QQNT/${_hash}/linuxqq_${release}_amd64.deb"
2023-05-10 15:57:14 +08:00
# 创建临时目录, 用于下载官方包
if [ -d $tmp_dir ]; then
rm -rf $tmp_dir
fi
if [ -d "./unpack" ]; then
sudo rm -rf ./unpack
fi
if [ -f "./${app_name}_${version}.deb" ]; then
rm "./${app_name}_${version}.deb"
fi
mkdir $tmp_dir
# 创建临时待打包目录
echo "创建待打包目录..."
mkdir -p "./unpack/DEBIAN"
mkdir -p "./unpack/usr/bin"
echo "下载官方原包..."
2023-05-10 16:13:05 +08:00
wget $deb_url -O "${tmp_dir}/linuxqq.deb"
2023-05-10 15:57:14 +08:00
echo "下载完成, 解包中..."
dpkg-deb -R "${tmp_dir}/linuxqq.deb" "${tmp_dir}/linuxqq"
echo "解包完成, 复制到待打包目录..."
cp -r "${tmp_dir}/linuxqq/opt" "./unpack/"
cp -r "${tmp_dir}/linuxqq/usr" "./unpack/"
rm -rf $tmp_dir
echo "复制完成, 创建可执行文件及程序桌面入口文件..."
echo """
[Desktop Entry]
Name=QQ
Exec=linuxqq %U
Terminal=false
Type=Application
Icon=/usr/share/icons/hicolor/512x512/apps/qq.png
StartupWMClass=QQ
Categories=Network;
Comment=QQ
""" > "./unpack/usr/share/applications/qq.desktop"
echo """
[Desktop Entry]
Type=Application
NoDisplay=true
Name=QQ Channel JSBridge URL Handler
Exec=/usr/bin/printf \"%u\"
StartupNotify=false
MimeType=x-scheme-handler/jsbridge;
""" > "./unpack/usr/share/applications/qq_channel_jsbridge_handler.desktop"
echo """
#!/bin/bash
USER_RUN_DIR=\"/run/user/\$(id -u)\"
2023-09-19 17:20:44 +08:00
DOWNLOAD_DIR=\"\$(xdg-user-dir DOWNLOAD)/QQ_Files\"
2023-05-10 15:57:14 +08:00
CONFIG_HOME=\"\${HOME}/.config\"
QQ_APP_DIR=\"\${HOME}/.config/QQ\"
if [ ! -d \"\$QQ_APP_DIR\" ]; then
mkdir \"\$QQ_APP_DIR\"
fi
if [ ! -d \"\$DOWNLOAD_DIR\" ]; then
mkdir \"\$DOWNLOAD_DIR\"
fi
bwrap --new-session --die-with-parent --cap-drop ALL --unshare-user-try --unshare-pid --unshare-cgroup-try \\
--symlink usr/lib /lib \\
--symlink usr/lib64 /lib64 \\
--symlink usr/bin /bin \\
--ro-bind /usr /usr \\
--ro-bind /opt /opt \\
--dev-bind /dev /dev \\
--ro-bind /sys /sys \\
--ro-bind /etc/passwd /etc/passwd \\
--ro-bind /etc/resolv.conf /etc/resolv.conf \\
--ro-bind /etc/localtime /etc/localtime \\
--proc /proc \\
--dev-bind /run/dbus /run/dbus \\
--bind \"\${USER_RUN_DIR}\" \"\${USER_RUN_DIR}\" \\
--ro-bind-try /etc/fonts /etc/fonts \\
--dev-bind /tmp /tmp \\
--bind-try \"\${HOME}/.pki\" \"\${HOME}/.pki\" \\
--ro-bind-try \"\${XAUTHORITY}\" \"\${XAUTHORITY}\" \\
--bind-try \"\${DOWNLOAD_DIR}\" \"\${DOWNLOAD_DIR}\" \\
--ro-bind-try \"\${CONFIG_HOME}\" \"\${CONFIG_HOME}\" \\
--bind \"\${QQ_APP_DIR}\" \"\${QQ_APP_DIR}\" \\
--ro-bind-try \"\${HOME}/.local\" \"\${HOME}/.local\" \\
--setenv DISPLAY \"\${DISPLAY}\" \\
2023-10-30 10:24:54 +08:00
--setenv QQNTIM_HOME \"\${QQ_APP_DIR}/QQNTim\" \
--setenv LITELOADERQQNT_PROFILE \"\${QQ_APP_DIR}/LiteLoaderQQNT\" \
2023-05-10 15:57:14 +08:00
/opt/QQ/qq \"\$@\"
""" > ./unpack/usr/bin/linuxqq
chmod +x ./unpack/usr/bin/linuxqq
echo "修正完成, 计算文件md5..."
cd ./unpack
# opt目录中有文件名中带有空格, ;xargs需要处理一下
find opt/ -type f | xargs -I {} md5sum {} > DEBIAN/md5sums
find usr/ -type f | xargs md5sum >> DEBIAN/md5sums
2023-05-22 14:10:49 +08:00
IFS=$'\t' read -ra size <<< "$(du -d 0)"
2023-05-10 15:57:14 +08:00
echo """
2023-08-02 18:02:08 +08:00
Package: ${app_name}
2023-05-10 15:57:14 +08:00
Version: ${version}
Architecture: amd64
Maintainer: Yutent <yutent.io@gmail.com>
2023-05-22 14:10:49 +08:00
Installed-Size: ${size[0]}
2023-05-10 15:57:14 +08:00
Depends: libgtk-3-0, libnotify4, libnss3, libxss1, libxtst6, xdg-utils, libatspi2.0-0, libuuid1, libsecret-1-0
Recommends: libappindicator3-1
Section: chat
Priority: optional
Homepage: https://im.qq.com
Description: linux QQ
""" > DEBIAN/control
echo '计算文件md5完成, 打包中...'
cd ..
sudo chown -R root:root unpack
dpkg-deb -b ./unpack "./${app_name}_${version}.deb"
2023-09-14 15:01:31 +08:00
sudo rm -rf ./unpack
2023-05-10 16:13:05 +08:00
echo "打包完成 :)"