Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package sdbootutil for openSUSE:Factory checked in at 2023-07-28 22:20:05 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/sdbootutil (Old) and /work/SRC/openSUSE:Factory/.sdbootutil.new.32662 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "sdbootutil" Fri Jul 28 22:20:05 2023 rev:2 rq:1101096 version:1+git20230727.a0e666f Changes: -------- --- /work/SRC/openSUSE:Factory/sdbootutil/sdbootutil.changes 2023-07-19 19:11:03.976717841 +0200 +++ /work/SRC/openSUSE:Factory/.sdbootutil.new.32662/sdbootutil.changes 2023-07-28 22:20:06.769107010 +0200 @@ -1,0 +2,19 @@ +Thu Jul 27 14:32:09 UTC 2023 - [email protected] + +- Update to version 1+git20230727.a0e666f: + * Set and honor $SYSTEMD_ESP_PATH + * rpm-script: don't remove kernel on reinstalls + +------------------------------------------------------------------- +Wed Jul 26 16:22:10 UTC 2023 - [email protected] + +- Update to version 1+git20230726.a994d2e: + * Fix installing extra kernels in MicroOS + * Replace file triggers with scriptlet + * Fix cleanup of rollback files + * Don't install unchanged files + * Add is-bootable and list-kernels commands + * Add ARCHITECTURE.md which explains how the setup works + * Add default loader config when installed + +------------------------------------------------------------------- Old: ---- sdbootutil-1+git20230717.dac075e.obscpio New: ---- sdbootutil-1+git20230727.a0e666f.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ sdbootutil.spec ++++++ --- /var/tmp/diff_new_pack.IR05uy/_old 2023-07-28 22:20:07.693112626 +0200 +++ /var/tmp/diff_new_pack.IR05uy/_new 2023-07-28 22:20:07.697112651 +0200 @@ -27,28 +27,20 @@ %define git_version %{nil} %endif Name: sdbootutil -Version: 1+git20230717.dac075e%{git_version} +Version: 1+git20230727.a0e666f%{git_version} Release: 0 Summary: script to install shim with sd-boot License: MIT URL: https://en.opensuse.org/openSUSE:Usr_merge Source: %{name}-%{version}.tar -Requires: systemd-boot Requires: jq Requires: sed +Requires: systemd-boot Supplements: (systemd-boot and shim) %description Hook scripts to install shim along with systemd-boot -%package filetriggers -Summary: File triggers for sdbootutil -Requires: sdbootutil >= %{version}-%{release} -Conflicts: (suse-module-tools with suse-kernel-rpm-scriptlets) - -%description filetriggers -File trigger scripts for sdbootutil - %package snapper Summary: plugin script for snapper Requires: %{name} = %{version} @@ -67,7 +59,7 @@ Conflicts: grub2 Conflicts: suse-kernel-rpm-scriptlets Provides: suse-kernel-rpm-scriptlets -Requires: %{name}-filetriggers +Obsoletes: %{name}-filetriggers < %{version} %description rpm-scriptlets Empty scriptlets to satisfy kernel dependencies @@ -78,11 +70,16 @@ %build %install -install -D -m 644 kernelhooks.lua %{buildroot}%{_rpmconfigdir}/lua/kernelhooks.lua install -D -m 755 sdbootutil %{buildroot}%{_bindir}/sdbootutil mkdir -p %{buildroot}%{_prefix}/lib/module-init-tools/kernel-scriptlets -for a in cert inkmp kmp rpm; do +for a in rpm; do + install -m 755 "$a-script" %{buildroot}%{_prefix}/lib/module-init-tools/kernel-scriptlets + for b in post posttrans postun pre preun; do + ln -s "$a-script" %{buildroot}%{_prefix}/lib/module-init-tools/kernel-scriptlets/$a-$b + done +done +for a in cert inkmp kmp; do for b in post posttrans postun pre preun; do ln -s /bin/true %{buildroot}%{_prefix}/lib/module-init-tools/kernel-scriptlets/$a-$b done @@ -94,42 +91,10 @@ install -m 755 $i %{buildroot}%{_prefix}/lib/snapper/plugins/$i done -%transfiletriggerin filetriggers -p <lua> -- %{_prefix}/lib/modules/ -require("kernelhooks") -if posix.getenv("VERBOSE_FILETRIGGERS") then - kernelhooks.debug = "%{nvr}(in)" -end -file = rpm.next_file() -while file do - kernelhooks.filter(file) - file = rpm.next_file() -end -kernelhooks.add() -io.flush() - -%transfiletriggerun filetriggers -p <lua> -- %{_prefix}/lib/modules/ --- the module is already gone if we get called for ourselves -if pcall(require, 'kernelhooks') then - if posix.getenv("VERBOSE_FILETRIGGERS") then - kernelhooks.debug = "%{nvr}(postun)" - end - file = rpm.next_file() - while file do - kernelhooks.filter(file) - file = rpm.next_file() - end - kernelhooks.remove() - io.flush() -end - %files %license LICENSE %{_bindir}/sdbootutil -%files filetriggers -%dir %{_rpmconfigdir}/lua -%{_rpmconfigdir}/lua/kernelhooks.lua - %files rpm-scriptlets %dir %{_prefix}/lib/module-init-tools %{_prefix}/lib/module-init-tools/* ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.IR05uy/_old 2023-07-28 22:20:07.745112942 +0200 +++ /var/tmp/diff_new_pack.IR05uy/_new 2023-07-28 22:20:07.749112966 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/lnussel/sdbootutil.git</param> - <param name="changesrevision">dac075ef5bdba3304dfb2076ae9f009ffd36ad3c</param></service></servicedata> + <param name="changesrevision">a0e666f3d0a6ec524f26b7c30d0ff1ee02b9e96e</param></service></servicedata> (No newline at EOF) ++++++ sdbootutil-1+git20230717.dac075e.obscpio -> sdbootutil-1+git20230727.a0e666f.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbootutil-1+git20230717.dac075e/10-sdbootutil.snapper new/sdbootutil-1+git20230727.a0e666f/10-sdbootutil.snapper --- old/sdbootutil-1+git20230717.dac075e/10-sdbootutil.snapper 2023-07-17 11:14:34.000000000 +0200 +++ new/sdbootutil-1+git20230727.a0e666f/10-sdbootutil.snapper 2023-07-27 16:17:12.000000000 +0200 @@ -44,6 +44,8 @@ [ "$fs" = btrfs ] || return 1 + is_transactional && /usr/bin/sdbootutil add-all-kernels "$num" || : + /usr/bin/sdbootutil set-default-snapshot "$num" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbootutil-1+git20230717.dac075e/ARCHITECTURE.md new/sdbootutil-1+git20230727.a0e666f/ARCHITECTURE.md --- old/sdbootutil-1+git20230717.dac075e/ARCHITECTURE.md 1970-01-01 01:00:00.000000000 +0100 +++ new/sdbootutil-1+git20230727.a0e666f/ARCHITECTURE.md 2023-07-27 16:17:12.000000000 +0200 @@ -0,0 +1,224 @@ +systemd implementation of the bootloader spec +--------------------------------------------- + +The kernel-install script shipped with systemd can install kernels in the EFI +partition according to the [bootloader +specification](https://uapi-group.org/specifications/specs/boot_loader_specification/). + +Assuming two installed kernels, 1.2.3-1-default and 4.5.6-1-default +one would call + + kernel-install add /lib/modules/1.2.3-1-default/vmlinuz + kernel-install add /lib/modules/3.4.5-1-default/vmlinuz + +Scripts in `/usr/lib/kernel/install.d/` would copy the kernel into +the ESP, generate an initrd and create a config to boot the +specified kernel. + +With an entry token (eg machine-id) of 2ceda9f (shortened for +readability) the ESP would look like this: + + âââ 2ceda9f + â  âââ 1.2.3-1-default + â  â  âââ initrd + â  â âââ linux + â  âââ 4.5.6-1-default + â    âââ initrd + â  âââ linux + âââ EFI + â  âââ BOOT + â  â  âââ BOOTX64.EFI + â  âââ systemd + â    âââ systemd-bootx64.efi + âââ loader +   âââ entries +     âââ 2ceda9f-1.2.3-1-default.conf +     âââ 2ceda9f-4.5.6-1-default.conf + +Therefore an entry file might look like this: + + title openSUSE Tumbleweed + version 1.2.3-1-default + machine-id 2ceda9f + sort-key opensuse-tumbleweed + options root=UUID=abc... + linux /2ceda9f/1.2.3-1-default/linux + initrd /2ceda9f/1.2.3-1-default/initrd + + +This scheme is basically designed so a specific instance of an +operating system (in the example 2ceda9f) can be booted with +different kernel versions. It is assumed that a kernel with a given +version is unique and each kernel has one specific initrd. Removing +a kernel (ie kernel-install remove 1.2.3-1-default.conf) would +remove the kernel, initrd and entry file. The root filesystem can +be specified as option or discovered automatically according to the +[discoverable partition specification](https://uapi-group.org/specifications/specs/discoverable_partitions_specification/). + + +Introducing snapshots +--------------------- + +With btrfs snapshots, the same root filesystem holds multiple +generations of the operating system. It's necessary to add a +`rootflags=` parameter to the options to tell the kernel which +subvolume to mount. Absence of the parameter would boot the default +subvolume. + +So when creating a snapshot, snapper hook scripts could copy the +existing entry files, adding parameters to boot the new snapshot. So +for example if snapshot 15 was created the files would look like +this: + + âââ loader +   âââ entries +     âââ 2ceda9f-1.2.3-1-default.conf +     âââ 2ceda9f-4.5.6-1-default.conf +     âââ 2ceda9f-1.2.3-1-default-15.conf +     âââ 2ceda9f-4.5.6-1-default-15.conf + +Since the ESP is FAT, a separator like @ can't be used to add the +snapshot number to the file name. + +An entry file might now look like this: + + title openSUSE Tumbleweed + version [email protected] + machine-id 2ceda9f + sort-key opensuse-tumbleweed + options root=UUID=abc... rootflags=subvol=@/.snapshots/15/snapshot + linux /2ceda9f/1.2.3-1-default/linux + initrd /2ceda9f/1.2.3-1-default/initrd + +In this example the snapshot number is prepended to the version. +This seems to be the best way right now to get the sorting right. + +At this point the entry refers to the same kernel and initrd as used +in the running system. The system may install a different kernel +with same uname or recreate the initrd any time though. That would +potentially break booting the snapshot. So a snapshot entry must +also point to a matching kernel and initrd. FAT has no copy-on-write +features, so somehow those files need to be made unique in a +different way. It would be possible to encode the snapshot number +into the file name but then every snapshot would have it's own copy +of kernel and initrd, even when they could be shared. So a better +option is to use the file's checksum instead. + +So that makes an entry look like this + + title openSUSE Tumbleweed + version [email protected] + machine-id 2ceda9f + sort-key opensuse-tumbleweed + options root=UUID=abc... rootflags=subvol=@/.snapshots/15/snapshot + linux /2ceda9f/1.2.3-1-default/linux-b021b508eb42b2afd06de8f0242b9727aa7dc494 + initrd /2ceda9f/1.2.3-1-default/initrd-7b200fad3d005285ca914069a4740a5b6874c0ae + +To avoid wasting any space, the default entries should also use +checkums and never store plain "linux" and "initrd" files. + +With this scheme `kernel-install remove` would no longer work +though. It must especially not delete the kernel version directory +(eg 1.2.3-1-default) as it may contain files needed by other snapshots. +Therefore a `bootctl unlink` and `bootctl cleanup` features were +imlemented (https://github.com/systemd/systemd/pull/26103) to use +reference counting when deleting entries. + +Default boot entry +------------------ +So far the btrfs default subvolume flag is used to select which +subvolume to boot in absence of boot options. Now this means each +time the default subvolume is changed (ie rollback), the +systemd-boot entries that do not refer to a subvolume need to be +changed to ones that select the correct kernel and initrd combo. + +Systemd-boot itself has a mechanism to set a default entry. So +setting the btrfs default subvolume alone actually has no effect. +Therefore snapper also needs to set the systemd-boot default when +changing the default subvolume. + +Now creating a snapshot would create an entry with snapshot number +embedded anyway. Therefore the extra step to also create an entry +without snapshot number is not necessary. Instead all entries could +just have the subvolume setting. Selecting the default would only be +done based on the entry, not on the default subvolume. This would +also be the more natural way for MicroOS where no read-write +subvolume exists. + +So the ESP would look like this: + + âââ 2ceda9f + â  âââ 1.2.3-1-default + â  â  âââ initrd-6272c61615fc18d5158aadda22fb0955c98382c8 + â  â âââ linux-dcebae96db3cab7ffeb8883e78423a99d31d2bfd + â  âââ 4.5.6-1-default + â    âââ initrd-7b200fad3d005285ca914069a4740a5b6874c0ae + â    âââ initrd-1b6b609e33104d68bd543a11a0b8a4d354478f46 + â  âââ linux-b021b508eb42b2afd06de8f0242b9727aa7dc494 + âââ EFI + â  âââ BOOT + â  â  âââ BOOTX64.EFI + â  âââ systemd + â    âââ systemd-bootx64.efi + âââ loader +   âââ entries +     âââ 2ceda9f-1.2.3-1-default-1.conf +     âââ 2ceda9f-4.5.6-1-default-1.conf +     âââ 2ceda9f-1.2.3-1-default-15.conf +     âââ 2ceda9f-4.5.6-1-default-15.conf + +Distribution integration +------------------------ + +The scheme described in this document is implemented by +[sdbootutil](https://github.com/lnussel/sdbootutil). Similar to +`kernel-install` it allows to add and remove kernels to/from the +ESP but is fully snapshot aware. To speed up snapshot creation, +`sdbootutil` also tries to be smart about the initrd and reuses +existing ones from the parent snapshot if possible. +That also means initrds are not updated based on user space +changes at this point. Only kernel changes trigger initrd creation. + +`sdbootutil` is called from a [snapper +plugin](https://github.com/lnussel/sdbootutil/blob/main/10-sdbootutil.snapper) +to manage entires on snapshot creation and removal, as well as when +the default subvolume is set. + +Kernel package installation and removal also trigger calls to +`sdbootutil` via [file +triggers](https://github.com/lnussel/sdbootutil/blob/main/kernelhooks.lua). +Unfortunately the file trigger method seems to be unreliable with zypper. +Moreover, file triggers can't make an rpm transaction fail +(https://github.com/rpm-software-management/rpm/issues/2581). + +Secure boot support +------------------------ + +Upstream `bootctl` has no support for shim yet +(https://github.com/systemd/systemd/issues/27234). That's required +for secure boot support though. Therefore `sdbootutil` also +implements an `install` feature. + +If `/usr/share/efi/$(uname -m)` exists, shim and related files get +installed into the ESP + + âââ EFI + âââ boot + â  âââ BOOTX64.EFI <-- shim + â  âââ MokManager.efi + â  âââ fallback.efi + ââââ systemd +  âââ MokManager.efi +   âââ boot.csv +   âââ grub.efi <-- actually systemd-boot +   âââ shim.efi + +Future plans +------------ + +In general sdbootutil should not exist. It's features should be +implemented in `bootctl`, `kernel-install` or `snapper`. + +To simplify handling of the initrd, it would be desirable to switch +to e.g. UKIs that are built on server side. That way no guessing +would be needed as to whether an initrd needs to be updated. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbootutil-1+git20230717.dac075e/rpm-script new/sdbootutil-1+git20230727.a0e666f/rpm-script --- old/sdbootutil-1+git20230717.dac075e/rpm-script 1970-01-01 01:00:00.000000000 +0100 +++ new/sdbootutil-1+git20230727.a0e666f/rpm-script 2023-07-27 16:17:12.000000000 +0200 @@ -0,0 +1,102 @@ +#!/bin/sh + +op=${0##*-} + +name="" +version="" +release="" +kernelrelease="" +flavor="" +variant="" +usrmerged="0" +image="" +certs="" + +while true ; do + case $1 in + --name) + name="$2" + shift + ;; + --version) + version="$2" + shift + ;; + --release) + release="$2" + shift + ;; + + --kernelrelease) + kernelrelease="$2" + shift + ;; + --flavor) + flavor="$2" + shift + ;; + --variant) + variant="$2" + shift + ;; + + --usrmerged) + # legacy + shift + ;; + --image) + image="$2" + shift + ;; + --certs) + certs="$2" + shift + ;; + + *) break + ;; + esac + shift +done + +[ -z "$KERNEL_PACKAGE_SCRIPT_DEBUG" ] || \ + echo "$op" name: "$name" version: "$version" release: "$release" \ + kernelrelease: "$kernelrelease" flavor: "$flavor" variant: "$variant" \ + usrmerged: "$usrmerged" image: "$image" certs: "$certs" -- "$@" >&2 + +script_rc=0 + +case $op in + pre) + [ -z "$certs" ] || /usr/lib/module-init-tools/kernel-scriptlets/cert-"$op" --ca-check 1 --certs "$certs" "$@" || script_rc=$? + ;; + post) + if [ ! -e /.buildenv ] ; then + /usr/sbin/depmod -a "$kernelrelease-$flavor" + /usr/bin/sdbootutil --image="$image" add-kernel "$kernelrelease-$flavor" + # make sure to select the latest kernel + [ -z "$TRANSACTIONAL_UPDATE" ] && /usr/bin/sdbootutil set-default-snapshot + fi + [ -z "$certs" ] || /usr/lib/module-init-tools/kernel-scriptlets/cert-"$op" --ca-check 1 --certs "$certs" "$@" || script_rc=$? + ;; + preun) + [ -z "$certs" ] || /usr/lib/module-init-tools/kernel-scriptlets/cert-"$op" --ca-check 1 --certs "$certs" "$@" || script_rc=$? + ;; + postun) + + if [ ! -e /.buildenv ] && [ "$1" -eq 0 ] ; then + /usr/bin/sdbootutil --image="$image" remove-kernel "$kernelrelease-$flavor" + fi + [ -z "$certs" ] || /usr/lib/module-init-tools/kernel-scriptlets/cert-"$op" --ca-check 1 --certs "$certs" "$@" + ;; + posttrans) + ;; + *) + echo Unknown scriptlet "$op" >&2 + exit 255 + ;; +esac + +exit $script_rc + +# vim: set sts=4 sw=4 ts=8 noet: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbootutil-1+git20230717.dac075e/sdbootutil new/sdbootutil-1+git20230727.a0e666f/sdbootutil --- old/sdbootutil-1+git20230717.dac075e/sdbootutil 2023-07-17 11:14:34.000000000 +0200 +++ new/sdbootutil-1+git20230727.a0e666f/sdbootutil 2023-07-27 16:17:12.000000000 +0200 @@ -13,9 +13,10 @@ shimdir="/usr/share/efi/$(uname -m)" sdboot_vendor="systemd" sdboot_dst="/EFI/$sdboot_vendor" -arg_esp_path= +arg_esp_path="$SYSTEMD_ESP_PATH" arg_entry_token= arg_arch= +image=vmlinuz rollback=() @@ -61,10 +62,17 @@ remove-all-kernels [SUBVOL] Remove boot entries for all kernels in SUBVOL + list-kernels [SUBVOL] + List all kernels related to SUBVOL + set-default-snapshot [SUBVOL] Make SUBVOL the default for next boot. Also install all kernels if needed + is-bootable [SUBVOL] + Check whether SUBVOL has any kernels registered, ie + is potentially bootable + install Install systemd-boot and shim into ESP UI commands: @@ -113,7 +121,15 @@ exit 1 } - +reset_rollback() +{ + for i in "${rollback[@]}"; do + [ -e "$i.bak" ] || continue + log_info "removing $i.bak" + rm -f "$i.bak" + done + rollback=() +} run_command_live_output() { @@ -204,6 +220,10 @@ local dst="${2:?}" if [ -e "$dst" ]; then + if cmp -s "$src" "$dst"; then + log_info "$dst unchanged" + return 0 + fi mv "$dst" "$dst.bak" || return "$?" fi rollback+=("$dst") @@ -217,7 +237,7 @@ local subvol="$1" local kernel_version="$2" local dstinitrd="" - local src="${subvol#@}/lib/modules/$kernel_version/vmlinuz" + local src="${subvol#@}/lib/modules/$kernel_version/$image" test -e "$src" || err "Can't find $src" calc_chksum "$src" @@ -268,7 +288,8 @@ dstinitrd="${dst%/*}/initrd-$chksum" fi - sort_key="$ID" + # shellcheck disable=SC2154 + sort_key="$os_release_ID" entry_machine_id= [ "$entry_token" = "$machine_id" ] && entry_machine_id="$machine_id" @@ -297,7 +318,7 @@ rm -f "$tmpdir/initrd" rm -f "$tmpdir/entry.conf" [ -z "$failed" ] || err "Failed to install $failed" - rollback=() + reset_rollback } install_all_kernels() @@ -473,6 +494,8 @@ default="$n" title="\\Zb\Zu$title\\Zn" fi + update_kernels "@/.snapshots/$n/snapshot" + [ "$is_bootable" = 1 ] || title="!$title" list+=("$n" "$title") done < <(jq '.root|.[]|[.number, .default, .description]|join(" ")' -r < "$snapperfile") if [ "${#list}" = 0 ]; then @@ -502,7 +525,7 @@ show_entries "Entries for Snapshot $n" ;; kernels) - show_kernels "@/.snapshots/$n/snapshot" + show_kernels "$n" ;; esac done @@ -522,7 +545,7 @@ local subvol="${1:?}" found_kernels=() - for fn in "${subvol#@}"/usr/lib/modules/*/vmlinuz; do + for fn in "${subvol#@}"/usr/lib/modules/*/"$image"; do kv="${fn%/*}" kv="${kv##*/}" calc_chksum "$fn" @@ -534,10 +557,14 @@ # map that uses expected path on the ESP for each kernel. The value indicates # whether that kernel is installed, stale or missing in the ESP declare -A known_kernels +is_bootable= +has_stale= update_kernels() { local subvol="${1:?}" known_kernels=() + is_bootable= + has_stale= find_kernels "$subvol" for kv in "${!found_kernels[@]}"; do known_kernels["/$entry_token/$kv/linux-${found_kernels[$kv]}"]=missing @@ -548,15 +575,37 @@ # kernel in ESP that is not installed if [ -z "${known_kernels[$k]}" ]; then known_kernels["$k"]="!$id" + has_stale=1 elif [ "${known_kernels[$k]}" = missing ]; then known_kernels["$k"]="$id" + is_bootable=1 fi done < <(jq -r '.[]|select(has("linux"))|[.linux,.id]|join(" ")'< "$entryfile") } +list_kernels() +{ + subvol="@/.snapshots/${1:?}/snapshot" + update_kernels "$subvol" + local kernelfiles=("${!known_kernels[@]}") + for k in "${kernelfiles[@]}"; do + state="${known_kernels[$k]}" + printf "%-10s %s\n" "$state" "$k" + done +} + +is_bootable() +{ + subvol="@/.snapshots/${1:?}/snapshot" + update_kernels "$subvol" + + [ "$is_bootable" = 1 ] || return 1 + return 0 +} + show_kernels() { - subvol="${1:?}" + subvol="@/.snapshots/${1:?}/snapshot" while true; do update_kernels "$subvol" local list=() @@ -693,6 +742,8 @@ update_random_seed [ -s "$boot_root/loader/entries.srel" ] || echo type1 > "$boot_root/loader/entries.srel" + + [ -e "$boot_root/loader/loader.conf" ] || echo -e "#timeout 3\n#console-mode keep\n" > "$boot_root/loader/loader.conf" } settle_entry_token() @@ -793,7 +844,7 @@ case "$action" in snapper) show_snapper ;; sd-boot) update_entries cat; show_entries ;; - kernels) show_kernels "$root_subvol";; + kernels) show_kernels "$root_snapshot";; install) install_sdboot_interactive ;; esac done @@ -801,7 +852,7 @@ ####### main ####### -getopttmp=$(getopt -o hc:v --long help,flicker,verbose,esp-path:,entry-token:,arch: -n "${0##*/}" -- "$@") +getopttmp=$(getopt -o hc:v --long help,flicker,verbose,esp-path:,entry-token:,arch:,image: -n "${0##*/}" -- "$@") eval set -- "$getopttmp" while true ; do @@ -812,13 +863,14 @@ --esp-path) arg_esp_path="$2"; shift 2 ;; --arch) arg_arch="$2"; shift 2 ;; --entry-token) arg_entry_token="$2"; shift 2 ;; + --image) image="$2"; shift 2 ;; --) shift ; break ;; *) echo "Internal error!" ; exit 1 ;; esac done case "$1" in - install|needs-update|update|add-kernel|remove-kernel|set-default-snapshot|add-all-kernels|remove-all-kernels|is-installed) ;; + install|needs-update|update|add-kernel|remove-kernel|set-default-snapshot|add-all-kernels|remove-all-kernels|is-installed|list-kernels|is-bootable) ;; kernels|snapshots|entries|"") stty_size; interactive=1 ;; *) err "unknown command $1" ;; esac @@ -829,13 +881,17 @@ break done +[ -n "$arg_esp_path" ] && export SYSTEMD_ESP_PATH="$arg_esp_path" + # XXX: bootctl should have json output for that too eval "$(bootctl 2>/dev/null | sed -ne 's/Firmware Arch: *\(\w\+\)/firmware_arch="\1"/p;s/ *token: *\(\w\+\)/entry_token="\1"/p;s, *\$BOOT: *\([^ ]\+\).*,boot_root="\1",p')" root_uuid=$(findmnt / -r -n -o UUID) root_subvol=$(btrfs subvol show / 2>/dev/null|head -1) [ -s /etc/machine-id ] && read -r machine_id < /etc/machine-id -[ -n "$arg_esp_path" ] && boot_root="$arg_esp_path" +if [ -n "$arg_esp_path" ] && [ "$boot_root" != "$arg_esp_path" ]; then + err "mismatch of esp path" +fi [ -n "$arg_arch" ] && firmware_arch="$arg_arch" settle_entry_token @@ -866,8 +922,12 @@ set_default_snapshot "${2:-$root_snapshot}" elif [ "$1" = "is-installed" ]; then sdboot_version > /dev/null +elif [ "$1" = "list-kernels" ]; then + list_kernels "${2:-$root_snapshot}" +elif [ "$1" = "is-bootable" ]; then + is_bootable "${2:-$root_snapshot}" elif [ "$1" = "kernels" ]; then - show_kernels "$root_subvol" + show_kernels "${2:-$root_snapshot}" elif [ "$1" = "snapshots" ]; then show_snapper elif [ "$1" = "entries" ]; then diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbootutil-1+git20230717.dac075e/sdbootutil.spec new/sdbootutil-1+git20230727.a0e666f/sdbootutil.spec --- old/sdbootutil-1+git20230717.dac075e/sdbootutil.spec 2023-07-17 11:14:34.000000000 +0200 +++ new/sdbootutil-1+git20230727.a0e666f/sdbootutil.spec 2023-07-27 16:17:12.000000000 +0200 @@ -41,14 +41,6 @@ %description Hook scripts to install shim along with systemd-boot -%package filetriggers -Summary: File triggers for sdbootutil -Requires: sdbootutil >= %{version}-%{release} -Conflicts: (suse-module-tools with suse-kernel-rpm-scriptlets) - -%description filetriggers -File trigger scripts for sdbootutil - %package snapper Summary: plugin script for snapper Requires: %{name} = %{version} @@ -67,7 +59,7 @@ Conflicts: grub2 Conflicts: suse-kernel-rpm-scriptlets Provides: suse-kernel-rpm-scriptlets -Requires: %{name}-filetriggers +Obsoletes: %{name}-filetriggers < %{version} %description rpm-scriptlets Empty scriptlets to satisfy kernel dependencies @@ -78,11 +70,16 @@ %build %install -install -D -m 644 kernelhooks.lua %{buildroot}%{_rpmconfigdir}/lua/kernelhooks.lua install -D -m 755 sdbootutil %{buildroot}%{_bindir}/sdbootutil mkdir -p %{buildroot}%{_prefix}/lib/module-init-tools/kernel-scriptlets -for a in cert inkmp kmp rpm; do +for a in rpm; do + install -m 755 "$a-script" %{buildroot}%{_prefix}/lib/module-init-tools/kernel-scriptlets + for b in post posttrans postun pre preun; do + ln -s "$a-script" %{buildroot}%{_prefix}/lib/module-init-tools/kernel-scriptlets/$a-$b + done +done +for a in cert inkmp kmp; do for b in post posttrans postun pre preun; do ln -s /bin/true %{buildroot}%{_prefix}/lib/module-init-tools/kernel-scriptlets/$a-$b done @@ -94,42 +91,10 @@ install -m 755 $i %{buildroot}%{_prefix}/lib/snapper/plugins/$i done -%transfiletriggerin filetriggers -p <lua> -- %{_prefix}/lib/modules/ -require("kernelhooks") -if posix.getenv("VERBOSE_FILETRIGGERS") then - kernelhooks.debug = "%{nvr}(in)" -end -file = rpm.next_file() -while file do - kernelhooks.filter(file) - file = rpm.next_file() -end -kernelhooks.add() -io.flush() - -%transfiletriggerun filetriggers -p <lua> -- %{_prefix}/lib/modules/ --- the module is already gone if we get called for ourselves -if pcall(require, 'kernelhooks') then - if posix.getenv("VERBOSE_FILETRIGGERS") then - kernelhooks.debug = "%{nvr}(postun)" - end - file = rpm.next_file() - while file do - kernelhooks.filter(file) - file = rpm.next_file() - end - kernelhooks.remove() - io.flush() -end - %files %license LICENSE %{_bindir}/sdbootutil -%files filetriggers -%dir %{_rpmconfigdir}/lua -%{_rpmconfigdir}/lua/kernelhooks.lua - %files rpm-scriptlets %dir %{_prefix}/lib/module-init-tools %{_prefix}/lib/module-init-tools/* ++++++ sdbootutil.obsinfo ++++++ --- /var/tmp/diff_new_pack.IR05uy/_old 2023-07-28 22:20:07.889113817 +0200 +++ /var/tmp/diff_new_pack.IR05uy/_new 2023-07-28 22:20:07.893113842 +0200 @@ -1,5 +1,5 @@ name: sdbootutil -version: 1+git20230717.dac075e -mtime: 1689585274 -commit: dac075ef5bdba3304dfb2076ae9f009ffd36ad3c +version: 1+git20230727.a0e666f +mtime: 1690467432 +commit: a0e666f3d0a6ec524f26b7c30d0ff1ee02b9e96e
