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
|
#!/bin/sh
set -eu
. /usr/share/debconf/confmodule
log() {
logger -t "depthcharge-tools-installer" "$@"
}
error() {
db_progress STOP
db_input critical "$1" || :
db_go
exit 1
}
depthcharge_tools_set_board() {
cat >/target/etc/depthcharge-tools/config.d/board <<EOF
# Board-detection override from debian-installer preseed.
[depthchargectl]
${1:+board = $1}
EOF
}
# Set initramfs driver-policy as in the base-installer step
initramfs_tools_conf() {
cat >/target/etc/initramfs-tools/conf.d/driver-policy <<EOF
# Driver inclusion policy selected during installation
# Note: this setting overrides the value set in the file
# /etc/initramfs-tools/initramfs.conf
MODULES=${1:-most}
EOF
}
db_progress START 0 5 depthcharge-tools-installer/progress
db_progress SET 0
db_progress INFO depthcharge-tools-installer/progress/install_tools
if ! log-output -t depthcharge-tools-installer apt-install depthcharge-tools; then
db_subst depthcharge-tools-installer/error/failed-package-install PACKAGE depthcharge-tools
error depthcharge-tools-installer/error/failed-package-install
fi
db_get depthcharge-tools-installer/board
if [ -n "${RET:-}" ]; then
depthcharge_tools_set_board "$RET"
fi
db_progress SET 1
db_progress INFO depthcharge-tools-installer/progress/check_parts
if ! in-target depthchargectl target --verbose --allow-current; then
error depthcharge-tools-installer/error/check_parts
fi
# Disable our initramfs-hook so that it doesn't make update-initramfs fail.
if [ -f "/target/etc/initramfs/post-update.d/depthcharge-tools" ]; then
trap 'chmod +x "/target/etc/initramfs/post-update.d/depthcharge-tools"' EXIT HUP INT QUIT TERM
chmod -x "/target/etc/initramfs/post-update.d/depthcharge-tools"
fi
while true; do
db_progress SET 2
db_progress INFO depthcharge-tools-installer/progress/update_initramfs
if ! in-target update-initramfs -u; then
error depthcharge-tools-installer/error/build_image
fi
db_progress SET 3
db_progress INFO depthcharge-tools-installer/progress/build_image
if IMAGE="$(in-target --pass-stdout depthchargectl build --verbose)"; then
# Successfully built.
break
elif [ "$?" -ne 3 ]; then
# Something else than initramfs size.
error depthcharge-tools-installer/error/build_image
fi
db_fset depthcharge-tools-installer/initramfs_too_big seen false
db_input critical depthcharge-tools-installer/initramfs_too_big || :
db_go || exit 1
db_get depthcharge-tools-installer/initramfs_too_big
if [ "${RET:-false}" != true ]; then
error depthcharge-tools-installer/error/build_image
fi
db_fset base-installer/initramfs-tools/driver-policy seen false
db_input critical base-installer/initramfs-tools/driver-policy || :
db_go || exit 1
db_get base-installer/initramfs-tools/driver-policy
MODULES="${RET:-most}"
initramfs_tools_conf "$MODULES"
done
db_progress SET 4
db_progress INFO depthcharge-tools-installer/progress/write_image
if ! in-target depthchargectl write --verbose --allow-current "$IMAGE"; then
error depthcharge-tools-installer/error/write_image
fi
# Re-enable the support hook if we disabled it.
if [ -f "/target/etc/initramfs/post-update.d/depthcharge-tools" ]; then
chmod +x "/target/etc/initramfs/post-update.d/depthcharge-tools"
trap - EXIT HUP INT QUIT TERM
fi
db_progress SET 5
db_progress STOP
|