Repository navigation
Expand file tree
/
Copy pathbuild_deb.sh
More file actions
executable file
·118 lines (102 loc) · 4.88 KB
/
Copy pathbuild_deb.sh
File metadata and controls
executable file
·118 lines (102 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env bash
# --- [ build_deb.sh: Debian Package Builder ] ---
set -euo pipefail
SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VERSION="1.0.0-1"
PKG_NAME="debian-update_${VERSION}_all"
BUILD_ROOT="/tmp/${PKG_NAME}"
GENERIC_DEB="${SRC_DIR}/debian-update.deb"
VERSIONED_DEB="${SRC_DIR}/releases/debian-update_${VERSION}_all.deb"
echo "==> Preparing package structure in /tmp for v${VERSION}..."
rm -rf "${BUILD_ROOT}"
mkdir -p "${BUILD_ROOT}"/{DEBIAN,usr/bin,usr/lib/debian-update,usr/share/debian-update/lib,usr/share/debian-update/locales,usr/share/applications,etc/xdg/autostart,usr/share/icons/hicolor/128x128/apps,usr/share/doc/debian-update,usr/lib/systemd/system,etc/polkit-1/rules.d} "${SRC_DIR}/releases"
# --- [ File Operations ] ---
echo "==> Copying application files..."
cp "${SRC_DIR}/bin/debian-update-cli" "${BUILD_ROOT}/usr/bin/"
cp "${SRC_DIR}/lib/debian-update-tray" "${BUILD_ROOT}/usr/lib/debian-update/"
cp "${SRC_DIR}/lib/check_backend.sh" "${BUILD_ROOT}/usr/share/debian-update/lib/"
cp "${SRC_DIR}/lib/debian-update-sign" "${BUILD_ROOT}/usr/share/debian-update/lib/"
cp "${SRC_DIR}/lib/debian_update_i18n.py" "${BUILD_ROOT}/usr/share/debian-update/lib/"
cp "${SRC_DIR}"/locales/*.json "${BUILD_ROOT}/usr/share/debian-update/locales/"
cp "${SRC_DIR}/desktop/debian-update-tray.desktop" "${BUILD_ROOT}/usr/share/applications/"
cp "${SRC_DIR}/desktop/debian-update-tray.desktop" "${BUILD_ROOT}/etc/xdg/autostart/"
cp "${SRC_DIR}/systemd/debian-update-check.service" "${BUILD_ROOT}/usr/lib/systemd/system/"
cp "${SRC_DIR}/systemd/debian-update-check.timer" "${BUILD_ROOT}/usr/lib/systemd/system/"
[ -f "${SRC_DIR}/LICENSE" ] && cp "${SRC_DIR}/LICENSE" "${BUILD_ROOT}/usr/share/doc/debian-update/copyright"
[ -f "${SRC_DIR}/assets/debian-update-ok.png" ] && cp "${SRC_DIR}"/assets/debian-update-*.png "${BUILD_ROOT}/usr/share/icons/hicolor/128x128/apps/"
[ -f "${SRC_DIR}/assets/ko-fi.png" ] && cp "${SRC_DIR}/assets/ko-fi.png" "${BUILD_ROOT}/usr/share/icons/hicolor/128x128/apps/"
[ -f "${SRC_DIR}/polkit/50-debian-update.rules" ] && cp "${SRC_DIR}/polkit/50-debian-update.rules" "${BUILD_ROOT}/etc/polkit-1/rules.d/"
# --- [ DEBIAN Control Files ] ---
echo "==> Writing DEBIAN/control..."
cat << CONTROL_EOF > "${BUILD_ROOT}/DEBIAN/control"
Package: debian-update
Version: ${VERSION}
Section: admin
Priority: optional
Architecture: all
Maintainer: tux <tux@localhost>
Depends: python3:any, python3-pyqt5, python3-pyqt5.qtsvg
Recommends: needrestart, flatpak, apt-listbugs, sbsigntool
Suggests: snapd
Description: System tray indicator and CLI upgrade suite for Debian Testing/Sid
A lightweight system tray applet and CLI suite for Debian.
Periodically checks APT, Flatpak & Snap via systemd,
verifies Secure Boot and kernel/NVIDIA signatures, safely upgrades packages,
and cleans orphan dependencies.
CONTROL_EOF
echo "==> Writing DEBIAN/postinst..."
cat << 'POSTINST_EOF' > "${BUILD_ROOT}/DEBIAN/postinst"
#!/bin/sh
set -e
case "$1" in
configure)
mkdir -p /var/cache/debian-update
chmod 1777 /var/cache/debian-update
if command -v systemctl >/dev/null 2>&1; then
systemctl daemon-reload || true
systemctl enable --now debian-update-check.timer || true
systemctl start --no-block debian-update-check.service || true
fi
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
gtk-update-icon-cache -q -t -f /usr/share/icons/hicolor || true
fi
;;
esac
exit 0
POSTINST_EOF
chmod 755 "${BUILD_ROOT}/DEBIAN/postinst"
echo "==> Writing DEBIAN/prerm..."
cat << 'PRERM_EOF' > "${BUILD_ROOT}/DEBIAN/prerm"
#!/bin/sh
set -e
case "$1" in
remove|deconfigure)
if command -v systemctl >/dev/null 2>&1; then
if systemctl is-active --quiet debian-update-check.timer 2>/dev/null; then
systemctl stop debian-update-check.timer || true
fi
if systemctl is-enabled --quiet debian-update-check.timer 2>/dev/null; then
systemctl disable debian-update-check.timer || true
fi
fi
pkill -f debian-update-tray || true
;;
esac
exit 0
PRERM_EOF
chmod 755 "${BUILD_ROOT}/DEBIAN/prerm"
# --- [ Permissions & Compilation ] ---
echo "==> Setting permissions..."
find "${BUILD_ROOT}" -type d -exec chmod 755 {} \;
find "${BUILD_ROOT}" -type f -exec chmod 644 {} \;
chmod 755 "${BUILD_ROOT}/usr/bin/debian-update-cli"
chmod 755 "${BUILD_ROOT}/usr/lib/debian-update/debian-update-tray"
chmod 755 "${BUILD_ROOT}/usr/share/debian-update/lib/check_backend.sh"
chmod 755 "${BUILD_ROOT}/usr/share/debian-update/lib/debian-update-sign"
chmod 755 "${BUILD_ROOT}/DEBIAN/postinst"
chmod 755 "${BUILD_ROOT}/DEBIAN/prerm"
echo "==> Building debian-update.deb..."
dpkg-deb --root-owner-group --build "${BUILD_ROOT}" "${GENERIC_DEB}"
cp "${GENERIC_DEB}" "${VERSIONED_DEB}"
rm -rf "${BUILD_ROOT}"
echo "Package built successfully: debian-update_${VERSION}_all.deb"