-
-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
19 changed files
with
324 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
/.idea/ | ||
/**/debian/files | ||
/**/debian/*.substvars | ||
debhelper-build-stamp | ||
.debhelper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
udm-boot (1.0.2) unstable; urgency=medium | ||
|
||
* optimized package structure | ||
|
||
-- spali <[email protected]> Thu, 03 Sep 2020 16:28:40 +0200 | ||
|
||
udm-boot (1.0.1-1) unstable; urgency=medium | ||
|
||
* Full automation | ||
|
||
-- Boostchicken <[email protected]> Sun, 05 Jul 2020 18:46:14 -0700 | ||
|
||
udm-boot (1.0.0-1) unstable; urgency=medium | ||
|
||
* Initial release, happy firmware persisting! | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Source: udm-boot | ||
Section: unknown | ||
Section: contrib/utils | ||
Priority: optional | ||
Maintainer: Boostchicken <[email protected]> | ||
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ Source: https://github.com/boostchicken/udm-utilities | |
|
||
Files: * | ||
Copyright: 2020 [email protected] | ||
License: GPLv3 | ||
License: GPL-3 | ||
https://github.com/boostchicken/udm-utilities/blob/master/LICENSE |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
on_boot.sh usr/share/udm-boot/ | ||
udm-boot.service lib/systemd/system/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
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 [email protected]:/mnt/data/on_boot.sh | ||
ssh -o StrictHostKeyChecking=no [email protected] 'chmod +x /mnt/data/on_boot.sh' | ||
ssh -o StrictHostKeyChecking=no [email protected] 'mkdir -p /mnt/data/on_boot.d' | ||
|
||
rm /tmp/on_boot.sh | ||
|
||
echo "#!/bin/sh | ||
ssh -o StrictHostKeyChecking=no [email protected] '/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 | ||
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' | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.