| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | set -eu |
| 3 | |
| 4 | . /usr/share/debconf/confmodulescip-shell source . . `/usr/share/debconf/confmodule`. |
| 5 | |
| 6 | logscip-shell shell depthcharge-tools-installer 13 log().() { |
| 7 | loggerscip-shell system . . logger. -t "depthcharge-tools-installer" "$@" |
| 8 | } |
| 9 | |
| 10 | errorscip-shell shell depthcharge-tools-installer 13 error().() { |
| 11 | db_progress STOP |
| 12 | db_input critical "$1" || : |
| 13 | db_go |
| 14 | exit 1 |
| 15 | } |
| 16 | |
| 17 | depthcharge_tools_set_boardscip-shell shell depthcharge-tools-installer 13 depthcharge_tools_set_board().() { |
| 18 | catscip-shell system . . cat. >/target/etc/depthcharge-tools/config.d/boardscip-shell filesystem . . `/target/etc/depthcharge-tools/config.d/board`. <<EOF |
| 19 | # Board-detection override from debian-installer preseed. |
| 20 | [depthchargectl] |
| 21 | ${1:+board = $1} |
| 22 | EOF |
| 23 | } |
| 24 | |
| 25 | # Set initramfs driver-policy as in the base-installer step |
| 26 | initramfs_tools_confscip-shell shell depthcharge-tools-installer 13 initramfs_tools_conf().() { |
| 27 | catscip-shell system . . cat. >/target/etc/initramfs-tools/conf.d/driver-policyscip-shell filesystem . . `/target/etc/initramfs-tools/conf.d/driver-policy`. <<EOF |
| 28 | # Driver inclusion policy selected during installation |
| 29 | # Note: this setting overrides the value set in the file |
| 30 | # /etc/initramfs-tools/initramfs.conf |
| 31 | MODULES=${1:-most} |
| 32 | EOF |
| 33 | } |
| 34 | |
| 35 | db_progress START 0 5 depthcharge-tools-installer/progress |
| 36 | |
| 37 | db_progress SET 0 |
| 38 | db_progress INFO depthcharge-tools-installer/progress/install_tools |
| 39 | if ! log-output -t depthcharge-tools-installer apt-install depthcharge-tools; then |
| 40 | db_subst depthcharge-tools-installer/error/failed-package-install PACKAGE depthcharge-tools |
| 41 | errorscip-shell shell depthcharge-tools-installer 13 error(). depthcharge-tools-installer/error/failed-package-install |
| 42 | fi |
| 43 | |
| 44 | db_get depthcharge-tools-installer/board |
| 45 | if [scip-shell system . . `[`. -n "${RET:-}" ]; then |
| 46 | depthcharge_tools_set_boardscip-shell shell depthcharge-tools-installer 13 depthcharge_tools_set_board(). "$RET" |
| 47 | fi |
| 48 | |
| 49 | db_progress SET 1 |
| 50 | db_progress INFO depthcharge-tools-installer/progress/check_parts |
| 51 | if ! in-target depthchargectl target --verbose --allow-current; then |
| 52 | errorscip-shell shell depthcharge-tools-installer 13 error(). depthcharge-tools-installer/error/check_parts |
| 53 | fi |
| 54 | |
| 55 | # Disable our initramfs-hook so that it doesn't make update-initramfs fail. |
| 56 | if [scip-shell system . . `[`. -f "/target/etc/initramfs/post-update.d/depthcharge-toolsscip-shell filesystem . . `/target/etc/initramfs/post-update.d/depthcharge-tools`." ]; then |
| 57 | trap 'chmod +x "/target/etc/initramfs/post-update.d/depthcharge-tools"' EXIT HUP INT QUIT TERM |
| 58 | chmodscip-shell system . . chmod. -x "/target/etc/initramfs/post-update.d/depthcharge-toolsscip-shell filesystem . . `/target/etc/initramfs/post-update.d/depthcharge-tools`." |
| 59 | fi |
| 60 | |
| 61 | while truescip-shell system . . true.; do |
| 62 | db_progress SET 2 |
| 63 | db_progress INFO depthcharge-tools-installer/progress/update_initramfs |
| 64 | if ! in-target update-initramfs -u; then |
| 65 | errorscip-shell shell depthcharge-tools-installer 13 error(). depthcharge-tools-installer/error/build_image |
| 66 | fi |
| 67 | |
| 68 | db_progress SET 3 |
| 69 | db_progress INFO depthcharge-tools-installer/progress/build_image |
| 70 | if IMAGE="$(in-target --pass-stdout depthchargectl build --verbose)"; then |
| 71 | # Successfully built. |
| 72 | break |
| 73 | elif [scip-shell system . . `[`. "$?" -ne 3 ]; then |
| 74 | # Something else than initramfs size. |
| 75 | errorscip-shell shell depthcharge-tools-installer 13 error(). depthcharge-tools-installer/error/build_image |
| 76 | fi |
| 77 | |
| 78 | db_fset depthcharge-tools-installer/initramfs_too_big seen false |
| 79 | db_input critical depthcharge-tools-installer/initramfs_too_big || : |
| 80 | db_go || exit 1 |
| 81 | db_get depthcharge-tools-installer/initramfs_too_big |
| 82 | if [scip-shell system . . `[`. "${RET:-false}" != true ]; then |
| 83 | errorscip-shell shell depthcharge-tools-installer 13 error(). depthcharge-tools-installer/error/build_image |
| 84 | fi |
| 85 | |
| 86 | db_fset base-installer/initramfs-tools/driver-policy seen false |
| 87 | db_input critical base-installer/initramfs-tools/driver-policy || : |
| 88 | db_go || exit 1 |
| 89 | |
| 90 | db_get base-installer/initramfs-tools/driver-policy |
| 91 | MODULES="${RET:-most}" |
| 92 | |
| 93 | initramfs_tools_confscip-shell shell depthcharge-tools-installer 13 initramfs_tools_conf(). "$MODULES" |
| 94 | done |
| 95 | |
| 96 | db_progress SET 4 |
| 97 | db_progress INFO depthcharge-tools-installer/progress/write_image |
| 98 | if ! in-target depthchargectl write --verbose --allow-current "$IMAGE"; then |
| 99 | errorscip-shell shell depthcharge-tools-installer 13 error(). depthcharge-tools-installer/error/write_image |
| 100 | fi |
| 101 | |
| 102 | # Re-enable the support hook if we disabled it. |
| 103 | if [scip-shell system . . `[`. -f "/target/etc/initramfs/post-update.d/depthcharge-toolsscip-shell filesystem . . `/target/etc/initramfs/post-update.d/depthcharge-tools`." ]; then |
| 104 | chmodscip-shell system . . chmod. +x "/target/etc/initramfs/post-update.d/depthcharge-toolsscip-shell filesystem . . `/target/etc/initramfs/post-update.d/depthcharge-tools`." |
| 105 | trap - EXIT HUP INT QUIT TERM |
| 106 | fi |
| 107 | |
| 108 | db_progress SET 5 |
| 109 | db_progress STOP |