-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·71 lines (56 loc) · 2.32 KB
/
build.sh
File metadata and controls
executable file
·71 lines (56 loc) · 2.32 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
#!/bin/bash
# Build script for unifi-on-boot .deb package
# Produces unifi-on-boot_<version>_all.deb
# No debhelper dependency — uses dpkg-deb directly
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
DEBIAN_DIR="${SCRIPT_DIR}/debian"
OUTPUT_DIR="${SCRIPT_DIR}/dist"
# Extract version from control file
VERSION=$(grep '^Version:' "${DEBIAN_DIR}/control" | awk '{print $2}')
PACKAGE_NAME="unifi-on-boot"
DEB_NAME="${PACKAGE_NAME}_${VERSION}_all.deb"
echo "Building ${DEB_NAME}..."
# Create build directory
BUILD_DIR=$(mktemp -d)
PKG_DIR="${BUILD_DIR}/${PACKAGE_NAME}_${VERSION}_all"
trap "rm -rf '${BUILD_DIR}'" EXIT
# Create package structure
mkdir -p "${PKG_DIR}/DEBIAN"
mkdir -p "${PKG_DIR}/lib/systemd/system"
mkdir -p "${PKG_DIR}/usr/sbin"
mkdir -p "${PKG_DIR}/usr/share/${PACKAGE_NAME}"
# Copy DEBIAN control files
cp "${DEBIAN_DIR}/control" "${PKG_DIR}/DEBIAN/control"
# Copy and set permissions on maintainer scripts
for script in postinst prerm postrm; do
if [ -f "${DEBIAN_DIR}/${script}" ]; then
cp "${DEBIAN_DIR}/${script}" "${PKG_DIR}/DEBIAN/${script}"
chmod 0755 "${PKG_DIR}/DEBIAN/${script}"
fi
done
# Install systemd service
cp "${DEBIAN_DIR}/unifi-on-boot.service" "${PKG_DIR}/lib/systemd/system/unifi-on-boot.service"
chmod 0644 "${PKG_DIR}/lib/systemd/system/unifi-on-boot.service"
# Install runner script
cp "${DEBIAN_DIR}/unifi-on-boot" "${PKG_DIR}/usr/sbin/unifi-on-boot"
chmod 0755 "${PKG_DIR}/usr/sbin/unifi-on-boot"
# Install self-restore files (postinst copies these to /data/)
cp "${DEBIAN_DIR}/unifi-on-boot-install.service" "${PKG_DIR}/usr/share/${PACKAGE_NAME}/unifi-on-boot-install.service"
chmod 0644 "${PKG_DIR}/usr/share/${PACKAGE_NAME}/unifi-on-boot-install.service"
cp "${DEBIAN_DIR}/install.sh" "${PKG_DIR}/usr/share/${PACKAGE_NAME}/install.sh"
chmod 0755 "${PKG_DIR}/usr/share/${PACKAGE_NAME}/install.sh"
# Calculate installed size (in KB)
INSTALLED_SIZE=$(du -sk "${PKG_DIR}" | cut -f1)
echo "Installed-Size: ${INSTALLED_SIZE}" >> "${PKG_DIR}/DEBIAN/control"
# Build the .deb
mkdir -p "${OUTPUT_DIR}"
dpkg-deb --root-owner-group -Zgzip --build "${PKG_DIR}" "${OUTPUT_DIR}/${DEB_NAME}"
echo ""
echo "Build complete: ${OUTPUT_DIR}/${DEB_NAME}"
echo ""
# Show package info
dpkg-deb -I "${OUTPUT_DIR}/${DEB_NAME}"
echo ""
echo "Package contents:"
dpkg-deb -c "${OUTPUT_DIR}/${DEB_NAME}"