live-install: preserve BASE_BOOTARGS in installed system

parent 210ded5b
#!/bin/sh -efu
# BASE_BOOTARGS are profile-provided arguments for installed systems.
# install2 does not consume them directly, so store the materialized profile
# value and add a preinstall hook that updates the target GRUB configuration.
[ -n "${GLOBAL_BASE_BOOTARGS-}" ] || exit 0
hookdir="/usr/share/install2/preinstall.d"
args_file="/usr/share/install2/base-bootargs"
hook="$hookdir/72-base-bootargs"
install -d "$hookdir"
printf '%s\n' "$GLOBAL_BASE_BOOTARGS" > "$args_file"
cat > "$hook" << 'EOF'
#!/bin/sh -efu
. install2-init-functions
args_file="@BASE_BOOTARGS_FILE@"
grubcfg="$destdir"/etc/sysconfig/grub2
[ -s "$args_file" ] || exit 0
[ -f "$grubcfg" ] || exit 0
base_bootargs="$(cat "$args_file")"
[ -n "$base_bootargs" ] || exit 0
current_bootargs="$(sed -n \
"s/^GRUB_CMDLINE_LINUX_DEFAULT='\\(.*\\)'$/\\1/p" \
"$grubcfg")"
missing_bootargs=
for arg in $base_bootargs; do
case " $current_bootargs$missing_bootargs " in
*" $arg "*) ;;
*) missing_bootargs="$missing_bootargs $arg" ;;
esac
done
[ -n "$missing_bootargs" ] || exit 0
subst "s|^GRUB_CMDLINE_LINUX_DEFAULT='|&$missing_bootargs |" "$grubcfg" ||:
:
EOF
sed -i "s|@BASE_BOOTARGS_FILE@|$args_file|" "$hook"
chmod +x "$hook"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment