mirror of
https://github.com/unifi-utilities/unifios-utilities.git
synced 2024-08-30 18:32:21 +00:00
Some build and package improvements (#45)
* add missing package version to change log * fix some warnings of lintian during deb build * simplification of the debian package * introduce build script with docker/podman support * use already existing ssh proxy, has the nice effect of not displaying the welcome message * update readme for 1.0.2 * fix missing argument in apt-get autoremove
This commit is contained in:
parent
e53af92641
commit
282b9bd3ce
4
.gitignore
vendored
4
.gitignore
vendored
@ -1 +1,5 @@
|
||||
/.idea/
|
||||
/**/debian/files
|
||||
/**/debian/*.substvars
|
||||
debhelper-build-stamp
|
||||
.debhelper
|
||||
|
18
on-boot-script/Dockerfile
Normal file
18
on-boot-script/Dockerfile
Normal file
@ -0,0 +1,18 @@
|
||||
FROM debian:stretch-slim
|
||||
|
||||
RUN set -ex \
|
||||
&& echo 'deb http://deb.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/backports.list \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
devscripts \
|
||||
fakeroot \
|
||||
debhelper=12.\* dh-autoreconf=17\* \
|
||||
&& apt-get -y autoremove \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /tmp/* /var/tmp/* /var/log/* /var/lib/apt/lists/* /var/log/alternatives.log
|
||||
|
||||
RUN chmod a+rwx,u+t /tmp
|
||||
|
||||
ENTRYPOINT []
|
||||
CMD ["/bin/sh"]
|
@ -8,7 +8,7 @@
|
||||
## Compatibility
|
||||
|
||||
1. Should work on any UDM/UDMPro after 1.6.3
|
||||
2. Tested and confirmed on 1.6.6, 1.7.0, 1.7.2rc4, 1.7.3rc1, 1.8.0rc7
|
||||
2. Tested and confirmed on 1.6.6, 1.7.0, 1.7.2rc4, 1.7.3rc1, 1.8.0rc7, 1.8.0
|
||||
|
||||
### Upgrade from earlier way
|
||||
|
||||
@ -20,8 +20,12 @@
|
||||
rm /etc/systemd/system/udmboot.service
|
||||
```
|
||||
|
||||
* The new package is exactly the old steps packaged in a debian package
|
||||
* [dpkg-build-files](dpkg-build-files) contains the scripts that build the package (using dh_make and debuild) if you want to build it yourself / change it
|
||||
* [build_deb.sh](build_deb.sh) can be used to build the package by yourself.
|
||||
* [dpkg-build-files](dpkg-build-files) contains the sources that debuild uses to build the package if you want to build it yourself / change it
|
||||
* by default it uses docker or podman to build the debian package
|
||||
* use ```./build_deb.sh build``` to not using a container
|
||||
* the resulting package will be in [packages/](packages/)
|
||||
|
||||
* Built on Ubuntu-20.04 on Windows 10/WSL2
|
||||
|
||||
## Steps
|
||||
@ -32,11 +36,11 @@
|
||||
unifi-os shell
|
||||
```
|
||||
|
||||
2. Download [udm-boot_1.0.1-1_all.deb](packages/udm-boot_1.0.1-1_all.deb) and install it and go back to the UDM
|
||||
2. Download [udm-boot_1.0.2_all.deb](packages/udm-boot_1.0.2_all.deb) and install it and go back to the UDM
|
||||
|
||||
```bash
|
||||
curl -L https://raw.githubusercontent.com/boostchicken/udm-utilities/master/on-boot-script/packages/udm-boot_1.0.1-1_all.deb -o udm-boot_1.0.1-1_all.deb
|
||||
dpkg -i udm-boot_1.0.1-1_all.deb
|
||||
curl -L https://raw.githubusercontent.com/boostchicken/udm-utilities/master/on-boot-script/packages/udm-boot_1.0.2_all.deb -o udm-boot_1.0.2_all.deb
|
||||
dpkg -i udm-boot_1.0.2_all.deb
|
||||
exit
|
||||
```
|
||||
|
||||
@ -48,6 +52,10 @@
|
||||
|
||||
## Version History
|
||||
|
||||
### 1.0.2
|
||||
|
||||
* Some build improvements and more clean installation
|
||||
|
||||
### 1.0.1
|
||||
|
||||
* Fully automated install, all that is left is populating /mnt/data/on_boot.d
|
||||
|
101
on-boot-script/build_deb.sh
Executable file
101
on-boot-script/build_deb.sh
Executable file
@ -0,0 +1,101 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
WORK_DIR="$(cd "$(dirname "$0")" && echo "${PWD}")"
|
||||
TARGET_DIR="${WORK_DIR}/packages"
|
||||
SOURCE_DIR="${WORK_DIR}/dpkg-build-files"
|
||||
CONTAINER_FILE="${WORK_DIR}/Dockerfile"
|
||||
CONTAINER_CONTEXT="${WORK_DIR}"
|
||||
|
||||
fatal() {
|
||||
echo "ERROR: ${1}" 1>&2
|
||||
exit ${2-1}
|
||||
}
|
||||
|
||||
build_in_container=false
|
||||
build=false
|
||||
build_container=false
|
||||
if [ $# -eq 0 ]; then
|
||||
build_in_container=true
|
||||
fi
|
||||
if [ "${1}" = "build" ]; then
|
||||
build=true
|
||||
fi
|
||||
if [ "${1}" = "build_container" ]; then
|
||||
build_container=true
|
||||
fi
|
||||
|
||||
|
||||
build_in_container() {
|
||||
docker_exec="$(command -v docker || true)"
|
||||
podman_exec="$(command -v podman || true)"
|
||||
container_exec="${docker_exec:-"${podman_exec}"}"
|
||||
container_args=""
|
||||
|
||||
if [ ! -f "${container_exec}" ]; then
|
||||
fatal "docker or podman not found"
|
||||
fi
|
||||
if [ ! -f "${CONTAINER_FILE}" ]; then
|
||||
fatal "container file ${CONTAINER_FILE} not found"
|
||||
fi
|
||||
|
||||
if [ "${container_exec}" = "${docker_exec}" ]; then
|
||||
# docker does not map user, so we run it as user
|
||||
container_args="--user "$(id -u):$(id -g)""
|
||||
fi
|
||||
"${container_exec}" build --file "${CONTAINER_FILE}" --tag udm-boot-deb-builder "${CONTAINER_CONTEXT}"
|
||||
"${container_exec}" run -it \
|
||||
${container_args} \
|
||||
-v "${SOURCE_DIR}:/source:ro" \
|
||||
-v "${TARGET_DIR}:/target:rw" \
|
||||
-v "${WORK_DIR}/build_deb.sh:/build_deb.sh:ro" \
|
||||
--rm \
|
||||
udm-boot-deb-builder \
|
||||
/build_deb.sh build_container
|
||||
}
|
||||
|
||||
|
||||
build() {
|
||||
source_dir=$1
|
||||
target_dir=$2
|
||||
version="$(dpkg-parsechangelog --show-field version -l "${source_dir}/debian/changelog")"
|
||||
name="$(dpkg-parsechangelog --show-field source -l "${source_dir}/debian/changelog")"
|
||||
package_name="${name}-${version}"
|
||||
build_dir="$(mktemp --tmpdir="/tmp" --directory "${name}.XXXXXXXXXX")"
|
||||
build_package_dir="${build_dir}/${package_name}"
|
||||
|
||||
if [ ! -d "${source_dir}" ]; then
|
||||
fatal "source dir ${source_dir} not found"
|
||||
fi
|
||||
if [ ! -d "${target_dir}" ]; then
|
||||
fatal "target dir ${target_dir} not found"
|
||||
fi
|
||||
|
||||
mkdir -p "${build_package_dir}"
|
||||
cp -r "${source_dir}"/* "${build_package_dir}"
|
||||
(
|
||||
cd "${build_package_dir}"
|
||||
# we could exclude "source" here to skip building the source,
|
||||
# but lintian warns only in the source build about some stuff
|
||||
debuild -us -uc --build=source,all --lintian-opts --profile debian
|
||||
)
|
||||
|
||||
find "${build_dir}" -maxdepth 1 -type f -exec mv {} "${target_dir}" \;
|
||||
rm -rf "${build_dir}"
|
||||
}
|
||||
|
||||
build_container() {
|
||||
build "/source" "/target"
|
||||
}
|
||||
|
||||
if [ $build_in_container = true ]; then
|
||||
build_in_container
|
||||
fi
|
||||
if [ $build = true ]; then
|
||||
build "${SOURCE_DIR}" "${TARGET_DIR}"
|
||||
fi
|
||||
if [ $build_container = true ]; then
|
||||
build_container
|
||||
fi
|
||||
|
@ -1,3 +1,15 @@
|
||||
udm-boot (1.0.2) unstable; urgency=medium
|
||||
|
||||
* optimized package structure
|
||||
|
||||
-- spali <spali@spali.ch> Thu, 03 Sep 2020 16:28:40 +0200
|
||||
|
||||
udm-boot (1.0.1-1) unstable; urgency=medium
|
||||
|
||||
* Full automation
|
||||
|
||||
-- Boostchicken <dorman@ataxia.cloud> Sun, 05 Jul 2020 18:46:14 -0700
|
||||
|
||||
udm-boot (1.0.0-1) unstable; urgency=medium
|
||||
|
||||
* Initial release, happy firmware persisting!
|
||||
|
@ -1,5 +1,5 @@
|
||||
Source: udm-boot
|
||||
Section: unknown
|
||||
Section: contrib/utils
|
||||
Priority: optional
|
||||
Maintainer: Boostchicken <dorman@ataxia.cloud>
|
||||
Build-Depends: debhelper-compat (= 12)
|
||||
@ -10,5 +10,6 @@ Homepage: https://github.com/boostchicken/udm-utilities
|
||||
|
||||
Package: udm-boot
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}
|
||||
Description: Run things on boot on UDM
|
||||
Run things on boot!
|
||||
|
@ -5,5 +5,5 @@ Source: https://github.com/boostchicken/udm-utilities
|
||||
|
||||
Files: *
|
||||
Copyright: 2020 dorman@ataxia.cloud
|
||||
License: GPLv3
|
||||
License: GPL-3
|
||||
https://github.com/boostchicken/udm-utilities/blob/master/LICENSE
|
||||
|
@ -1,2 +0,0 @@
|
||||
udm-boot_1.0.0-1_all.deb unknown optional
|
||||
udm-boot_1.0.0-1_amd64.buildinfo unknown optional
|
@ -0,0 +1,2 @@
|
||||
on_boot.sh usr/share/udm-boot/
|
||||
udm-boot.service lib/systemd/system/
|
@ -1,38 +1,30 @@
|
||||
#!/bin/sh
|
||||
# postinst script for udm-boot
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
||||
set -e
|
||||
|
||||
# summary of how this script can be called:
|
||||
# * <postinst> `configure' <most-recently-configured-version>
|
||||
# * <old-postinst> `abort-upgrade' <new version>
|
||||
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
||||
# <new-version>
|
||||
# * <postinst> `abort-remove'
|
||||
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
||||
# <failed-install-package> <version> `removing'
|
||||
# <conflicting-package> <version>
|
||||
# for details, see https://www.debian.org/doc/debian-policy/ or
|
||||
# the debian-policy package
|
||||
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
echo '#!/bin/sh
|
||||
scp -P "$(cat /etc/unifi-os/ssh_proxy_port)" -o StrictHostKeyChecking=no -q /usr/share/udm-boot/on_boot.sh root@localhost:/mnt/data/on_boot.sh
|
||||
/sbin/ssh-proxy 'chmod +x /mnt/data/on_boot.sh && mkdir -p /mnt/data/on_boot.d'
|
||||
|
||||
if [ -d /mnt/data/on_boot.d ]; then
|
||||
for i in /mnt/data/on_boot.d/*.sh; do
|
||||
if [ -r $i ]; then
|
||||
. $i
|
||||
fi
|
||||
done
|
||||
fi
|
||||
' > /tmp/on_boot.sh
|
||||
scp -o StrictHostKeyChecking=no /tmp/on_boot.sh root@127.0.1.1:/mnt/data/on_boot.sh
|
||||
ssh -o StrictHostKeyChecking=no root@127.0.1.1 'chmod +x /mnt/data/on_boot.sh'
|
||||
ssh -o StrictHostKeyChecking=no root@127.0.1.1 'mkdir -p /mnt/data/on_boot.d'
|
||||
|
||||
rm /tmp/on_boot.sh
|
||||
|
||||
echo "#!/bin/sh
|
||||
ssh -o StrictHostKeyChecking=no root@127.0.1.1 '/mnt/data/on_boot.sh'" > /etc/init.d/udm.sh
|
||||
chmod +x /etc/init.d/udm.sh
|
||||
echo "[Unit]
|
||||
Description=Run On Startup UDM
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/etc/init.d/udm.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target" > /etc/systemd/system/udmboot.service
|
||||
systemctl enable udmboot
|
||||
systemctl start udmboot
|
||||
deb-systemd-invoke enable udm-boot
|
||||
deb-systemd-invoke start udm-boot
|
||||
;;
|
||||
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
@ -44,4 +36,9 @@ case "$1" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# dh_installdeb will replace this with shell code automatically
|
||||
# generated by other debhelper scripts.
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
|
39
on-boot-script/dpkg-build-files/debian/postrm
Executable file
39
on-boot-script/dpkg-build-files/debian/postrm
Executable file
@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
# postrm script for udm-boot
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
||||
set -e
|
||||
|
||||
# summary of how this script can be called:
|
||||
# * <postrm> `remove'
|
||||
# * <postrm> `purge'
|
||||
# * <old-postrm> `upgrade' <new-version>
|
||||
# * <new-postrm> `failed-upgrade' <old-version>
|
||||
# * <new-postrm> `abort-install'
|
||||
# * <new-postrm> `abort-install' <old-version>
|
||||
# * <new-postrm> `abort-upgrade' <old-version>
|
||||
# * <disappearer's-postrm> `disappear' <overwriter>
|
||||
# <overwriter-version>
|
||||
# for details, see https://www.debian.org/doc/debian-policy/ or
|
||||
# the debian-policy package
|
||||
|
||||
|
||||
case "$1" in
|
||||
purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
||||
# reserved for future use
|
||||
true
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "postrm called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# dh_installdeb will replace this with shell code automatically
|
||||
# generated by other debhelper scripts.
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
37
on-boot-script/dpkg-build-files/debian/preinst
Executable file
37
on-boot-script/dpkg-build-files/debian/preinst
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# preinst script for udm-boot
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
||||
set -e
|
||||
|
||||
# summary of how this script can be called:
|
||||
# * <new-preinst> `install'
|
||||
# * <new-preinst> `install' <old-version>
|
||||
# * <new-preinst> `upgrade' <old-version>
|
||||
# * <old-preinst> `abort-upgrade' <new-version>
|
||||
# for details, see https://www.debian.org/doc/debian-policy/ or
|
||||
# the debian-policy package
|
||||
|
||||
|
||||
case "$1" in
|
||||
install|upgrade)
|
||||
# reserved for future use
|
||||
true
|
||||
;;
|
||||
|
||||
abort-upgrade)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "preinst called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# dh_installdeb will replace this with shell code automatically
|
||||
# generated by other debhelper scripts.
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
40
on-boot-script/dpkg-build-files/debian/prerm
Executable file
40
on-boot-script/dpkg-build-files/debian/prerm
Executable file
@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
# prerm script for udm-boot
|
||||
#
|
||||
# see: dh_installdeb(1)
|
||||
|
||||
set -e
|
||||
|
||||
# summary of how this script can be called:
|
||||
# * <prerm> `remove'
|
||||
# * <old-prerm> `upgrade' <new-version>
|
||||
# * <new-prerm> `failed-upgrade' <old-version>
|
||||
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
|
||||
# * <deconfigured's-prerm> `deconfigure' `in-favour'
|
||||
# <package-being-installed> <version> `removing'
|
||||
# <conflicting-package> <version>
|
||||
# for details, see https://www.debian.org/doc/debian-policy/ or
|
||||
# the debian-policy package
|
||||
|
||||
|
||||
case "$1" in
|
||||
remove|upgrade|deconfigure)
|
||||
# reserved for future use
|
||||
true
|
||||
;;
|
||||
|
||||
failed-upgrade)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "prerm called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# dh_installdeb will replace this with shell code automatically
|
||||
# generated by other debhelper scripts.
|
||||
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
19
on-boot-script/dpkg-build-files/debian/rules
Normal file → Executable file
19
on-boot-script/dpkg-build-files/debian/rules
Normal file → Executable file
@ -1,24 +1,5 @@
|
||||
#!/usr/bin/make -f
|
||||
# See debhelper(7) (uncomment to enable)
|
||||
# output every command that modifies files on the build system.
|
||||
#export DH_VERBOSE = 1
|
||||
|
||||
|
||||
# see FEATURE AREAS in dpkg-buildflags(1)
|
||||
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
|
||||
|
||||
# see ENVIRONMENT in dpkg-buildflags(1)
|
||||
# package maintainers to append CFLAGS
|
||||
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
|
||||
# package maintainers to append LDFLAGS
|
||||
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
|
||||
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
||||
|
||||
# dh_make generated override targets
|
||||
# This is example for Cmake (See https://bugs.debian.org/641051 )
|
||||
#override_dh_auto_configure:
|
||||
# dh_auto_configure -- # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
|
||||
|
@ -1 +1 @@
|
||||
3.0 (quilt)
|
||||
3.0 (native)
|
||||
|
@ -0,0 +1,3 @@
|
||||
udm-boot source: changelog-should-mention-nmu
|
||||
udm-boot source: source-nmu-has-incorrect-version-number
|
||||
udm-boot source: odd-historical-debian-changelog-version
|
9
on-boot-script/dpkg-build-files/on_boot.sh
Executable file
9
on-boot-script/dpkg-build-files/on_boot.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -d /mnt/data/on_boot.d ]; then
|
||||
for i in /mnt/data/on_boot.d/*.sh; do
|
||||
if [ -r $i ]; then
|
||||
. $i
|
||||
fi
|
||||
done
|
||||
fi
|
13
on-boot-script/dpkg-build-files/udm-boot.service
Normal file
13
on-boot-script/dpkg-build-files/udm-boot.service
Normal file
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Run On Startup UDM
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/sbin/ssh-proxy '/mnt/data/on_boot.sh'
|
||||
RemainAfterExit=true
|
||||
StandardOutput=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
BIN
on-boot-script/packages/udm-boot_1.0.2_all.deb
Normal file
BIN
on-boot-script/packages/udm-boot_1.0.2_all.deb
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user