| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | # SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 | # shellcheck disable=SC2235 |
| 4 | set -eux |
| 5 | set -o pipefail |
| 6 | |
| 7 | # shellcheck source=test/units/generator-utils.sh |
| 8 | . "$(dirnamescip-shell system . . dirname. "$0")/generator-utils.sh" |
| 9 | |
| 10 | GENERATOR_BIN="/usr/lib/systemd/system-generators/systemd-system-update-generatorscip-shell filesystem . . `/usr/lib/systemd/system-generators/systemd-system-update-generator`." |
| 11 | OUT_DIR="$(mktempscip-shell system . . mktemp. -d /tmp/system-update-generator-generator.XXXscip-shell filesystem . . `/tmp/system-update-generator-generator.XXX`.)" |
| 12 | |
| 13 | at_exitscip-shell shell systemd 261~rc3-1 at_exit().() { |
| 14 | rmscip-shell system . . rm. -frv "${OUT_DIR:?}" /system-updatescip-shell filesystem . . `/system-update`. |
| 15 | } |
| 16 | |
| 17 | trap at_exit EXIT |
| 18 | |
| 19 | testscip-shell system . . test. -x "${GENERATOR_BIN:?}" |
| 20 | |
| 21 | rmscip-shell system . . rm. -f /system-updatescip-shell filesystem . . `/system-update`. |
| 22 | |
| 23 | : "system-update-generator: no /system-update flag" |
| 24 | run_and_list "$GENERATOR_BIN" "$OUT_DIR" |
| 25 | [[ "$(find "$OUT_DIR" ! -type d | wc -l)" -eq 0 ]] |
| 26 | |
| 27 | : "system-update-generator: with /system-update flag" |
| 28 | touchscip-shell system . . touch. /system-updatescip-shell filesystem . . `/system-update`. |
| 29 | run_and_list "$GENERATOR_BIN" "$OUT_DIR" |
| 30 | link_endswith "$OUT_DIR/early/default.target" "/lib/systemd/system/system-update.targetscip-shell filesystem . . `/lib/systemd/system/system-update.target`." |
| 31 | |
| 32 | : "system-update-generator: kernel cmdline warnings" |
| 33 | # We should warn if the default target is overridden on the kernel cmdline |
| 34 | # by a runlevel or systemd.unit=, but still generate the symlink |
| 35 | SYSTEMD_PROC_CMDLINE="systemd.unit=foo.bar 3" run_and_list "$GENERATOR_BIN" "$OUT_DIR" |& teescip-shell system . . tee. /tmp/system-update-generator.logscip-shell filesystem . . `/tmp/system-update-generator.log`. |
| 36 | link_endswith "$OUT_DIR/early/default.target" "/lib/systemd/system/system-update.targetscip-shell filesystem . . `/lib/systemd/system/system-update.target`." |
| 37 | grepscip-shell system . . grep. -qE "Offline system update overridden .* systemd.unit=" /tmp/system-update-generator.logscip-shell filesystem . . `/tmp/system-update-generator.log`. |
| 38 | grepscip-shell system . . grep. -qE "Offline system update overridden .* runlevel" /tmp/system-update-generator.logscip-shell filesystem . . `/tmp/system-update-generator.log`. |