Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package combustion for openSUSE:Factory checked in at 2023-08-04 15:02:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/combustion (Old) and /work/SRC/openSUSE:Factory/.combustion.new.22712 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "combustion" Fri Aug 4 15:02:52 2023 rev:19 rq:1102122 version:1.1+git0 Changes: -------- --- /work/SRC/openSUSE:Factory/combustion/combustion.changes 2023-07-12 17:26:37.674241353 +0200 +++ /work/SRC/openSUSE:Factory/.combustion.new.22712/combustion.changes 2023-08-04 15:02:59.876121428 +0200 @@ -1,0 +2,10 @@ +Thu Aug 03 07:32:20 UTC 2023 - Fabian Vogt <fv...@suse.com> + +- Update to version 1.1+git0: + * Add option to run the script in the prepare phase as well + * Add compatibility for ignition-kargs-helper + * Populate /dev/shm/combustion/ in the --prepare stage + * Small README.md improvements + * combustion.rules: Match /module/qemu_fw_cfg instead of the namespace within + +------------------------------------------------------------------- Old: ---- combustion-1.0+git4.obscpio New: ---- combustion-1.1+git0.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ combustion.spec ++++++ --- /var/tmp/diff_new_pack.eiVPz8/_old 2023-08-04 15:03:00.612126016 +0200 +++ /var/tmp/diff_new_pack.eiVPz8/_new 2023-08-04 15:03:00.620126066 +0200 @@ -17,7 +17,7 @@ Name: combustion -Version: 1.0+git4 +Version: 1.1+git0 Release: 0 Summary: System for initial configuration of appliances License: GPL-2.0-or-later ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.eiVPz8/_old 2023-08-04 15:03:00.664126340 +0200 +++ /var/tmp/diff_new_pack.eiVPz8/_new 2023-08-04 15:03:00.668126365 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/openSUSE/combustion.git</param> - <param name="changesrevision">bb130f1ab716c1b174589f5405fe040a9eae357d</param></service></servicedata> + <param name="changesrevision">a7be9f0f6e3d85fb44f36f809a734cae0e455fca</param></service></servicedata> (No newline at EOF) ++++++ combustion-1.0+git4.obscpio -> combustion-1.1+git0.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/combustion-1.0+git4/README.md new/combustion-1.1+git0/README.md --- old/combustion-1.0+git4/README.md 2023-07-11 14:22:36.000000000 +0200 +++ new/combustion-1.1+git0/README.md 2023-08-03 09:17:48.000000000 +0200 @@ -22,6 +22,7 @@ The configuration files are copied from a filesystem with the LABEL "combustion", but to be compatible and co-installable with ignition (https://github.com/coreos/ignition), the LABEL "ignition" is used as fallback. +All-uppercase labels are accepted as well. It expects a directory "combustion" at the root level of the filesystem and a file "script" inside, which is executed inside a transactional-update shell. @@ -65,7 +66,7 @@ umount /mnt ``` -The "# combustion: network" comment triggers networking initialization before +The `# combustion: network` comment triggers networking initialization before running the script. This is equivalent to passing "rd.neednet=1" on the kernel cmdline and so the network configuration parameters (man dracut.cmdline) apply here as well. If those aren't specified, it defaults to "ip=dhcp" for each @@ -94,6 +95,52 @@ echo "Configured with combustion" > /etc/issue.d/combustion ``` +Perform modifications in the initrd environment +----------------------------------------------- + +Using the `# combustion: prepare` marker, the initrd environment can be modified +for instance to perform tasks before `/sysroot` is mounted or to write +NetworkManager connection configuration into +`/etc/NetworkManager/system-connections/`. If the marker is present, the script +is invoked with `--prepare` as parameter from `combustion-prepare.service`, in +addition to the main invocation inside the transaction later. +Example: + +```bash +#!/bin/bash +# combustion: network prepare +set -euxo pipefail + +nm_config() { + umask 077 # Required for NM config + mkdir -p /etc/NetworkManager/system-connections/ + cat >/etc/NetworkManager/system-connections/static.nmconnection <<-EOF + [connection] + id=static + type=ethernet + autoconnect=true + + [ipv4] + method=manual + dns=192.168.100.1 + address1=192.168.100.42/24,192.168.100.1 +EOF +} + +if [ "${1-}" = "--prepare" ]; then + nm_config # Configure NM in the initrd + exit 0 +fi + +# Redirect output to the console +exec > >(exec tee -a /dev/tty0) 2>&1 + +nm_config # Configure NM in the system +curl example.com +# Leave a marker +echo "Configured with combustion" > /etc/issue.d/combustion +``` + How it works ------------ @@ -104,8 +151,11 @@ If this option is found on the kernel cmdline, combustion.service's ConditionKernelCommandLine is fulfilled and it'll be required by initrd.target. This pulls in combustion-prepare.service, which runs after the config drive or -QEMU fw_cfg blob appears (see combustion.rules for details). It is read and if -the "network" flag comment is present, enables networking for later. +QEMU fw_cfg blob appears (see combustion.rules for details). The combustion +configuration is copied from the config source into /dev/shm/combustion/config +(this is accessible in `transactional-update shell` later). If the script +contains the `prepare` flag, it's executed now with the `--prepare` option. +If the `network` flag is present, networking is enabled in the initrd. After /sysroot is mounted and network is up (if enabled), combustion.service runs, which tries to activate all mountpoints in the system's /etc/fstab and then calls transactional-update in a chroot. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/combustion-1.0+git4/combustion new/combustion-1.1+git0/combustion --- old/combustion-1.0+git4/combustion 2023-07-11 14:22:36.000000000 +0200 +++ new/combustion-1.1+git0/combustion 2023-08-03 09:17:48.000000000 +0200 @@ -4,52 +4,84 @@ set -euo pipefail config_mount="/run/combustion/mount" +# Use /dev/shm for data exchange +exchangedir="/dev/shm/combustion/" +config_dir="${exchangedir}/config" if [ "${1-}" = "--prepare" ]; then - # Mount config drive - mkdir -p "${config_mount}" - - config_drive_found=0 + rm -rf "${exchangedir}" + mkdir "${exchangedir}" # Try fw_cfg first if [ -e "/sys/firmware/qemu_fw_cfg/by_name/opt/org.opensuse.combustion" ]; then - mkdir -p "${config_mount}/combustion" + mkdir -p "${config_dir}" if ! cp /sys/firmware/qemu_fw_cfg/by_name/opt/org.opensuse.combustion/script/raw \ - "${config_mount}/combustion/script"; then + "${config_dir}/script"; then echo "Failed to copy script from fw_cfg!" exit 1 fi # TODO: Support other files, e.g. with a tarball or fs image? - - config_drive_found=1 fi # Try disks next - both lower and upper case for label in combustion COMBUSTION ignition IGNITION; do - [ "${config_drive_found}" = "1" ] && break + [ -d "${config_dir}" ] && break [ -e "/dev/disk/by-label/${label}" ] || continue + mkdir -p "${config_mount}" if ! mount -o ro /dev/disk/by-label/${label} "${config_mount}"; then echo "Failed to mount config drive!" + rmdir "${config_mount}" exit 1 fi - config_drive_found=1 + if [ -d "${config_mount}/combustion" ]; then + if ! cp -R "${config_mount}/combustion" "${config_dir}"; then + echo "Failed to copy config!" + rm -rf "${config_dir}" + umount "${config_mount}" + rmdir "${config_mount}" + exit 1 + fi + else + echo "No config found on drive." + fi + + umount "${config_mount}" + rmdir "${config_mount}" done - if [ "${config_drive_found}" = "0" ]; then - echo "No config drive found" + if ! [ -d "${config_dir}" ]; then + echo "No config source found" exit 0 fi + if ! [ -e "${config_dir}/script" ]; then + echo "No config script found!" + exit 1 + fi + + chmod a+x "${config_dir}/script" + + # Check for the magic flag "# combustion: prepare" in the script + if grep -qE '^# combustion:(.*)\<prepare\>' "${config_dir}/script"; then + # Run the script with the --prepare option + if ! (cd "${config_dir}"; exec ./script --prepare); then + echo "script --prepare failed with $?" + exit 1 + fi + fi + # Note: In case ^ creates a NM config by writing to + # /etc/NetworkManager/system-connections/, nm-initrd-generator must not generate a + # default configuration anymore. This happens automatically since 1.36.0 (79885656d3). + # Check for the magic flag "# combustion: network" in the script - if [ -e "${config_mount}/combustion/script" ] \ - && grep -qE '^# combustion:(.*)\<network\>' "${config_mount}/combustion/script"; then + if grep -qE '^# combustion:(.*)\<network\>' "${config_dir}/script"; then sh -s <<EOF . /lib/dracut-lib.sh # Set rd.neednet if not already done and reevaluate it (module-specific) getargbool 0 'rd.neednet' && exit 0 - echo rd.neednet=1 > /etc/cmdline.d/40-combustion-neednet.conf + echo rd.neednet=1 > /etc/cmdline.d/40-combustion-neednet.conf if [ -e /lib/dracut/hooks/pre-udev/60-net-genrules.sh ]; then # Wicked . /lib/dracut/hooks/pre-udev/60-net-genrules.sh @@ -66,18 +98,9 @@ exit 0 fi -# Use /dev/shm for data exchange -exchangedir="/dev/shm/combustion/" delete_resolv_conf=0 cleanup() { - if findmnt "${config_mount}" >/dev/null; then - umount "${config_mount}" || true - rmdir "${config_mount}" || true - else - rm -rf "${config_mount}" || true - fi - rm -rf "${exchangedir}" || true if [ "${delete_resolv_conf}" -eq 1 ]; then @@ -102,11 +125,16 @@ # This is needed as ignition-mount.service's ExecStop is also disabled unconditionally. trap cleanup EXIT -if ! [ -d "${config_mount}/combustion" ]; then - echo "No config found - doing nothing." - exit 0 +# Compatibility for ignition-kargs-helper, which drops a script into +# "/run/combustion/mount/combustion" and then calls combustion +if [ -d "${config_mount}/combustion" ]; then + rm -rf "${config_dir}" + cp -R "${config_mount}/combustion" "${config_dir}" + chmod a+x "${config_dir}/script" fi +[ -d "${config_dir}" ] || exit 0 + # Make sure /sysroot is mounted systemctl start sysroot.mount @@ -115,16 +143,6 @@ systemctl start sysroot-usr.mount fi -# Copy config -mkdir "${exchangedir}" -config_dir="${exchangedir}/config" -cp -R "${config_mount}/combustion" "${config_dir}" - -if ! [ -e "${config_dir}/script" ]; then - echo "No config script found." - exit 1 -fi - # Have to take care of x-initrd.mount first and from the outside awk '$4 ~ /x-initrd.mount/ { system("findmnt /sysroot" $2 " >/dev/null || mount -t " $3 " -o " $4 " " $1 " /sysroot" $2) }' /sysroot/etc/fstab @@ -165,7 +183,6 @@ # also ignores the shell's exit code, so DIY. if ! chroot /sysroot transactional-update shell <<EOF; then cd "${config_dir}" - chmod a+x script ./script echo \$? > "${exchangedir}/retval" # Snapshot got touched while the policy isn't active, needs relabeling again. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/combustion-1.0+git4/combustion.rules new/combustion-1.1+git0/combustion.rules --- old/combustion-1.0+git4/combustion.rules 2023-07-11 14:22:36.000000000 +0200 +++ new/combustion-1.1+git0/combustion.rules 2023-08-03 09:17:48.000000000 +0200 @@ -14,7 +14,9 @@ ACTION=="add", SUBSYSTEM=="block", ENV{ID_FS_LABEL}=="ignition", ENV{SYSTEMD_ALIAS}+="/dev/combustion/config" ACTION=="add", SUBSYSTEM=="block", ENV{ID_FS_LABEL}=="IGNITION", ENV{SYSTEMD_ALIAS}+="/dev/combustion/config" # QEMU fw_cfg blob with key opt/org.opensuse.combustion -ACTION=="add", SUBSYSTEM=="opt", ENV{DEVPATH}=="/firmware/qemu_fw_cfg/by_name/opt/org.opensuse.combustion", ENV{SYSTEMD_ALIAS}+="/dev/combustion/config", TAG+="systemd" +# There are add events for keys inside fw_cfg, but they are unreliable: https://github.com/systemd/systemd/issues/28638 +# Using the platform device with add|bind does not work with TAG+="systemd" for some reason, so use the module... +ACTION=="add", SUBSYSTEM=="module", KERNEL=="qemu_fw_cfg", TEST=="/sys/firmware/qemu_fw_cfg/by_name/opt/org.opensuse.combustion", ENV{SYSTEMD_ALIAS}+="/dev/combustion/config", TAG+="systemd" # If combustion won't run, alias it to /dev/null to avoid waiting ACTION=="add", SUBSYSTEM=="mem", ENV{DEVPATH}=="/devices/virtual/mem/null", GOTO="combustion_dev_null" ++++++ combustion.obsinfo ++++++ --- /var/tmp/diff_new_pack.eiVPz8/_old 2023-08-04 15:03:00.776127039 +0200 +++ /var/tmp/diff_new_pack.eiVPz8/_new 2023-08-04 15:03:00.780127063 +0200 @@ -1,5 +1,5 @@ name: combustion -version: 1.0+git4 -mtime: 1689078156 -commit: bb130f1ab716c1b174589f5405fe040a9eae357d +version: 1.1+git0 +mtime: 1691047068 +commit: a7be9f0f6e3d85fb44f36f809a734cae0e455fca