SHA256
1
0
forked from pool/ignition

Accepting request 904616 from home:fos:branches:home:susnux:branches:devel:kubic:ignition

Implement missing ignition-kargs-helper script for kernel argument support

OBS-URL: https://build.opensuse.org/request/show/904616
OBS-URL: https://build.opensuse.org/package/show/devel:kubic:ignition/ignition?expand=0&rev=73
This commit is contained in:
Ignaz Forster 2021-07-07 16:27:38 +00:00 committed by Git OBS Bridge
parent 2a7ae9b190
commit b6323ddc45
4 changed files with 81 additions and 1 deletions

View File

@ -35,3 +35,5 @@ Changes for openSUSE / SLE:
to avoid having to boot with networking enabled even when it isn't to avoid having to boot with networking enabled even when it isn't
necessary; the actual implementation to start the network is left to the necessary; the actual implementation to start the network is left to the
distribution. distribution.
* ignition-kargs-helper:
Distribution specific helper script to implement kernel argument support.

70
ignition-kargs-helper Normal file
View File

@ -0,0 +1,70 @@
#!/bin/bash
# Based on Ignition's examples/ignition-kargs-helper
set -euxo pipefail
grubcfg="/sysroot/etc/default/grub"
# Mount root file system. Note that we mount /boot but we don't unmount it
# because we are run in a systemd unit with MountFlags=slave so it is unmounted
# for us.
. /dracut-state.sh
mount "${root#block:}" "${NEWROOT}"
# Also mount x-initrd.mount flagged mounts to get the current /etc state
awk '$4 ~ /x-initrd.mount/ { system("findmnt /sysroot" $2 " >/dev/null || mount -t " $3 " -o " $4 " " $1 " /sysroot" $2) }' /sysroot/etc/fstab
orig_kernelopts="$(grep GRUB_CMDLINE_LINUX_DEFAULT "${grubcfg}")"
orig_kernelopts="${orig_kernelopts#*=}"
# trim the leading and trailing quote
orig_kernelopts="${orig_kernelopts:1:-1}"
# add leading and trailing whitespace to allow for easy sed replacements
kernelopts=" $orig_kernelopts "
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--should-exist)
arg="$2"
# don't repeat the arg
if [[ ! "${kernelopts[*]}" =~ " ${arg} " ]]; then
kernelopts="$kernelopts$arg "
fi
shift 2
;;
--should-not-exist)
kernelopts="$(echo "$kernelopts" | sed "s| $2 | |g")"
shift 2
;;
*)
echo "Unknown option"
exit 1
;;
esac
done
# trim the leading and trailing whitespace
kernelopts="$(echo "$kernelopts" | sed -e 's,^[[:space:]]*,,' -e 's,[[:space:]]*$,,')"
# only apply the changes & reboot if changes have been made
if [[ "$kernelopts" != "$orig_kernelopts" ]]; then
combustiondir="/run/combustion/mount/combustion"
mkdir -p "${combustiondir}"
# escape escapes to survive the multiple shell invocations
kernelopts="${kernelopts//\\/\\\\\\\\}"
kernelopts="${kernelopts//$/\\\$}"
cat << EOF > "${combustiondir}/script"
sed -i "s|^\(GRUB_CMDLINE_LINUX_DEFAULT=\).*|\1\"$kernelopts\"|" /etc/default/grub
/usr/sbin/grub2-mkconfig > /boot/grub2/grub.cfg
EOF
SYSTEMD_OFFLINE=1 combustion
# Reset health-checker to prevent an unintended rollback
echo "Clearing GRUB flag"
chroot /sysroot grub2-editenv - set health_checker_flag=0 || true
reboot
fi

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Jul 7 16:05:49 UTC 2021 - Ignaz Forster <iforster@suse.com>
- Implement missing ignition-kargs-helper script for kernel
argument support
------------------------------------------------------------------- -------------------------------------------------------------------
Mon May 31 14:57:06 UTC 2021 - rpm@fthiessen.de Mon May 31 14:57:06 UTC 2021 - rpm@fthiessen.de

View File

@ -34,6 +34,7 @@ Source7: README.SUSE
Source8: ignition-setup-user-suse.sh Source8: ignition-setup-user-suse.sh
Source9: ignition-enable-network.service Source9: ignition-enable-network.service
Source10: ignition-enable-network.sh Source10: ignition-enable-network.sh
Source11: ignition-kargs-helper
Source20: ignition-userconfig-timeout.conf Source20: ignition-userconfig-timeout.conf
Source21: ignition-userconfig-timeout-arm.conf Source21: ignition-userconfig-timeout-arm.conf
Patch2: 0002-allow-multiple-mounts-of-same-device.patch Patch2: 0002-allow-multiple-mounts-of-same-device.patch
@ -85,7 +86,7 @@ which creates firstboot_happened after the first boot.
%patch2 -p1 %patch2 -p1
mkdir dracut/30ignition-microos grub systemd_suse mkdir dracut/30ignition-microos grub systemd_suse
chmod +x %{SOURCE3} %{SOURCE4} %{SOURCE8} chmod +x %{SOURCE3} %{SOURCE4} %{SOURCE8} %{SOURCE11}
cp %{SOURCE1} %{SOURCE3} %{SOURCE4} %{SOURCE8} %{SOURCE9} %{SOURCE10} dracut/30ignition-microos/ cp %{SOURCE1} %{SOURCE3} %{SOURCE4} %{SOURCE8} %{SOURCE9} %{SOURCE10} dracut/30ignition-microos/
%ifarch aarch64 %{arm} %ifarch aarch64 %{arm}
cp %{SOURCE21} dracut/30ignition-microos/ignition-userconfig-timeout.conf cp %{SOURCE21} dracut/30ignition-microos/ignition-userconfig-timeout.conf
@ -95,6 +96,7 @@ cp %{SOURCE20} dracut/30ignition-microos/ignition-userconfig-timeout.conf
cp %{SOURCE5} grub/ cp %{SOURCE5} grub/
cp %{SOURCE6} systemd_suse/ cp %{SOURCE6} systemd_suse/
cp %{SOURCE7} . cp %{SOURCE7} .
cp %{SOURCE11} dracut/30ignition/ignition-kargs-helper.sh
%build %build
sed -i -e 's|go build -ldflags|go build -buildmode=pie -ldflags|g' build sed -i -e 's|go build -ldflags|go build -buildmode=pie -ldflags|g' build