2023-11-13 20:34:28 +00:00
|
|
|
#!/bin/busybox sh
|
2022-07-09 12:34:58 +00:00
|
|
|
|
2023-11-13 20:34:28 +00:00
|
|
|
# SPDX-FileCopyrightText: Copyright 2022-2023, macmpi
|
2023-05-12 12:04:05 +00:00
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2023-11-17 09:08:04 +00:00
|
|
|
# script meant to be run on Alpine (busybox) or on Ubuntu
|
|
|
|
# verify busybox build options if eventually using other platforms
|
2023-11-13 20:34:28 +00:00
|
|
|
command -v doas > /dev/null || alias doas="/usr/bin/sudo"
|
|
|
|
|
|
|
|
build_path="$(mktemp -d)"
|
|
|
|
if [ -n "$build_path" ]; then
|
2023-11-17 09:08:04 +00:00
|
|
|
# prefer timestamp option for touch as it works on directories too
|
|
|
|
t_stamp="$( TZ=UTC date +%Y%m%d0000.00 )"
|
|
|
|
cp -a overlay "$build_path"/.
|
|
|
|
find "$build_path"/overlay/ -exec sh -c 'TZ=UTC touch -chm -t "$0" "$1"' "$t_stamp" {} \;
|
|
|
|
# setting modes and owner/groups for runtime (won't affect mtime)
|
2023-11-13 20:34:28 +00:00
|
|
|
find "$build_path"/overlay/etc -type d -exec chmod 755 {} \;
|
2023-11-17 09:08:04 +00:00
|
|
|
chmod 755 "$build_path"/overlay/etc/init.d/*
|
|
|
|
chmod 755 "$build_path"/overlay/etc/runlevels/default/*
|
2023-11-13 20:34:28 +00:00
|
|
|
chmod 777 "$build_path"/overlay/tmp
|
|
|
|
chmod 700 "$build_path"/overlay/tmp/.trash
|
2023-11-17 09:08:04 +00:00
|
|
|
chmod -R 600 "$build_path"/overlay/tmp/.trash/ssh_host_*_key
|
|
|
|
find "$build_path"/overlay/usr -type d -exec chmod 755 {} \;
|
|
|
|
chmod 755 "$build_path"/overlay/usr/local/bin/*
|
|
|
|
doas chown -Rh 0:0 "$build_path"/overlay/*
|
|
|
|
|
|
|
|
# busybox config on Alpine & Ubuntu has FEATURE_TAR_GNU_EXTENSIONS
|
|
|
|
# (will preserve user/group/modes & mtime) and FEATURE_TAR_LONG_OPTIONS
|
|
|
|
# shellcheck disable=SC2046 # we want word splitting as result of find
|
|
|
|
doas tar cv -C "$build_path"/overlay --no-recursion \
|
|
|
|
$(doas find "$build_path"/overlay/ | sed "s|$build_path/overlay/||" | sort | xargs ) | \
|
|
|
|
gzip -c9n > headless.apkovl.tar.gz
|
2023-11-23 21:13:27 +00:00
|
|
|
sha512sum headless.apkovl.tar.gz > headless.apkovl.tar.gz.sha512
|
|
|
|
TZ=UTC touch -cm -t "$t_stamp" headless.apkovl.tar.gz*
|
2023-11-13 20:34:28 +00:00
|
|
|
doas rm -rf "$build_path"
|
|
|
|
fi
|
|
|
|
|