From 750e67d835ae919717a97241700a8861f5f7cfa5 Mon Sep 17 00:00:00 2001 From: NLsdt <98735725+nlsdt@users.noreply.github.com> Date: Thu, 2 Oct 2025 18:39:42 +0800 Subject: [PATCH] feat: add deb build (#1422) --- .github/workflows/linux.yml | 59 ++++++++++++++++++++++++++++++++--- assets/linux/DEBIAN/control | 16 ++++++++++ assets/linux/DEBIAN/postinst | 21 +++++++++++++ assets/linux/DEBIAN/postrm | 26 +++++++++++++++ assets/linux/DEBIAN/prerm | 8 +++++ assets/linux/piliplus.desktop | 9 ++++++ 6 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 assets/linux/DEBIAN/control create mode 100644 assets/linux/DEBIAN/postinst create mode 100644 assets/linux/DEBIAN/postrm create mode 100644 assets/linux/DEBIAN/prerm create mode 100644 assets/linux/piliplus.desktop diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 5ecd66c6..1dd9328c 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -67,12 +67,61 @@ jobs: - name: Build Linux run: flutter build linux --release -v - - name: Package linux build output + - name: Package .tar.gz run: tar -zcvf PiliPlus_linux_${{ env.version }}_amd64.tar.gz -C build/linux/x64/release/bundle . - - name: Upload linux outputs + - name: Packege deb + run: | + printf "建立构建目录...\n" + mkdir "PiliPlus_linux_${{ env.version }}_amd64" + pushd "PiliPlus_linux_${{ env.version }}_amd64" + mkdir -p opt/PiliPlus + mkdir -p usr/share/applications + mkdir -p usr/share/icons/hicolor/512x512/apps + + printf "复制文件...\n" + cp -r ../build/linux/x64/release/bundle/* opt/PiliPlus + cp -r ../assets/linux/DEBIAN . + cp ../assets/linux/piliplus.desktop usr/share/applications + cp ../assets/images/logo/logo.png usr/share/icons/hicolor/512x512/apps/piliplus.png + + printf "修改控制文件...\n" + # 替换版本号 + sed -i "2s/version_need_change/${{ env.version }}/g" DEBIAN/control + # 计算安装大小并替换 + SIZE_KB=$(du -s -b --apparent-size . | awk '{print int($1)}') + SIZE_KB=$(($SIZE_KB - $(du -s -b --apparent-size DEBIAN | awk '{print int($1)}'))) + SIZE_KB=$(echo $SIZE_KB | awk '{print int($1/1024 + 0.999)}') + printf "\t安装大小: %s KB\n" "$SIZE_KB" + sed -i "9s/size_need_change/${SIZE_KB}/g" DEBIAN/control + + printf "生成并写入 md5sums ...\n" + md5sum opt/PiliPlus/piliplus >> DEBIAN/md5sums + md5sum opt/PiliPlus/lib/* >> DEBIAN/md5sums + md5sum opt/PiliPlus/data/icudtl.dat >> DEBIAN/md5sums + + printf "设置权限...\n" + chmod 0644 DEBIAN/control + chmod 0644 DEBIAN/md5sums + chmod 0755 DEBIAN/postinst + chmod 0755 DEBIAN/postrm + chmod 0755 DEBIAN/prerm + + printf "打包 deb 文件...\n" + popd + dpkg-deb --build --verbose --root-owner-group "PiliPlus_linux_${{ env.version }}_amd64" + printf "完成: PiliPlus_linux_%s_amd64.deb\n" "${{ env.version }}" + shell: bash + + - name: Upload linux targz package uses: actions/upload-artifact@v4 with: - name: linux_outputs - path: | - PiliPlus_linux_*.tar.gz + name: Linux_targz_packege + path: PiliPlus_linux_*.tar.gz + + - name: Upload linux deb package + uses: actions/upload-artifact@v4 + with: + name: Linux_deb_package + path: PiliPlus_linux_*.deb + diff --git a/assets/linux/DEBIAN/control b/assets/linux/DEBIAN/control new file mode 100644 index 00000000..484ad25d --- /dev/null +++ b/assets/linux/DEBIAN/control @@ -0,0 +1,16 @@ +Package: PiliPlus +Version: version_need_change +Maintainer: gh-MzA4Nzk +Original-Maintainer: bggRGjQaUbCoE +Section: x11 +Priority: optional +Architecture: amd64 +Essential: no +Installed-Size: size_need_change +Description: third-party Bilibili client developed in Flutter +Homepage: https://github.com/bggRGjQaUbCoE/PiliPlus +Depends: libgtk-3-0t64, + libmpv2, + gir1.2-ayatanaappindicator3-0.1, + libayatana-appindicator3-1 + diff --git a/assets/linux/DEBIAN/postinst b/assets/linux/DEBIAN/postinst new file mode 100644 index 00000000..7d0aff83 --- /dev/null +++ b/assets/linux/DEBIAN/postinst @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +ln -sf /opt/PiliPlus/piliplus /usr/bin/piliplus +chmod +x /usr/bin/piliplus + +if [ $1 == "config" ] && [ -x /usr/binupdate-mime-database ]; then + echo "updating mime database..." + update-mime-database /usr/share/mime || true +fi + +if [ $1 == "config" ] && [ -x /usr/bin/gtk-update-icon-cache ]; then + echo "updating icon cache..." + gtk-update-icon-cache -q -f -t /usr/share/icons/hicolor || true +fi + +if [ $1 == "config" ] && [ -x /usr/bin/update-desktop-database ]; then + echo "updating desktop database..." + update-desktop-database -q /usr/share/applications || true +fi + +exit 0 diff --git a/assets/linux/DEBIAN/postrm b/assets/linux/DEBIAN/postrm new file mode 100644 index 00000000..1d2892a7 --- /dev/null +++ b/assets/linux/DEBIAN/postrm @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +rm /usr/bin/piliplus +if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then + if [ -x /usr/bin/update-desktop-database ]; then + echo "updating desktop database..." + update-desktop-database -q /usr/share/applications || true + fi + + if [ -x /usr/bin/gtk-update-icon-cache ]; then + echo "updating icon cache..." + gtk-update-icon-cache -q -t /usr/share/icons/hicolor || true + fi + + if [ -x /usr/bin/update-mime-database ]; then + echo "updating mime database..." + update-mime-database /usr/share/mime || true + fi +fi + +if [ $1 = "purge" ]; then + echo "Removing user data..." + rm -rf /home/*/.local/share/com.example.PiliPlus || true + rm -rf /root/.local/share/com.example.PiliPlus || true +fi + +exit 0 diff --git a/assets/linux/DEBIAN/prerm b/assets/linux/DEBIAN/prerm new file mode 100644 index 00000000..6cb73834 --- /dev/null +++ b/assets/linux/DEBIAN/prerm @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +if [ "$1" = "remove" ] || [ "$1" = "deconfigure" ]; then + echo "Stopping PiliPlus if running..." + pkill -x piliplus || true +fi + +exit 0 diff --git a/assets/linux/piliplus.desktop b/assets/linux/piliplus.desktop new file mode 100644 index 00000000..92fd6c95 --- /dev/null +++ b/assets/linux/piliplus.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +Name=PiliPlus +Comment=A third-party Bilibili Client developed in Flutter +Comment[zh_CN]=使用 Flutter 开发的 BiliBili 第三方客户端 +Exec=piliplus +Icon=piliplus +Terminal=false +Categories=Video;AudioVideo;Player;