19 Apr
2021
19 Apr
'21
16:06
Olaf Hering wrote: >Am Mon, 12 Apr 2021 10:46:48 +0200 >schrieb Ludwig Nussel: > >> Does anyone have a better idea or can we just follow Fedora's approach here? > >Since the reasons for "/boot" are obsolete since more than a decade, just go ahead. > >Just make sure to provide the equivalent of "/boot/vmlinuz" and >"/boot/initrd", a pointer to the last installed kernel. This can >very well be stored somewhere in "/usr". Here's my suggestion to move the kernel related read-only files from /boot to /lib/modules/%kernelrelease-%build_flavor The file names in /boot are included as %ghost links. The %post script creates symlinks for the kernel, sysctl.conf and System.map in /boot as a start. Some tools require adjustments before we can drop those links. If boot is a separate partition, a copy is used instead of a link. The logic for /boot/vmlinuz and /boot/initrd doesn't change with this patch. Longer term I'd expect that logic to move out of the kernel's %post. A possibility would be to go for systemd's kernel-install for example. From 85d641c3099cc7f9e2189cb84601cbbf805c75ed Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Mon, 12 Apr 2021 13:26:04 +0200 Subject: [PATCH] Move files in /boot to modules dir --- rpm/kernel-binary.spec.in | 47 ++++++++++++++++++++++++++++----------- rpm/post.sh | 17 ++++++++++++++ rpm/postun.sh | 2 +- 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/rpm/kernel-binary.spec.in b/rpm/kernel-binary.spec.in index 40433d95cea4..068ce7dc54da 100644 --- a/rpm/kernel-binary.spec.in +++ b/rpm/kernel-binary.spec.in @@ -530,10 +530,10 @@ add_vmlinux() # sign the modules, firmware and possibly the kernel in the buildservice BRP_PESIGN_FILES="" %if "%CONFIG_EFI_STUB" == "y" -BRP_PESIGN_FILES="/boot/$image-%kernelrelease-%build_flavor" +BRP_PESIGN_FILES="/lib/modules/%kernelrelease-%build_flavor/$image" %endif %ifarch s390x ppc64 ppc64le -BRP_PESIGN_FILES="/boot/$image-%kernelrelease-%build_flavor" +BRP_PESIGN_FILES="/lib/modules/%kernelrelease-%build_flavor/$image" %endif %if "%CONFIG_MODULE_SIG" == "y" BRP_PESIGN_FILES="$BRP_PESIGN_FILES *.ko" @@ -803,7 +803,7 @@ add_dirs_to_filelist() { # print all parents :a # skip directories owned by other packages - s:^%%dir (/boot|/etc|/lib/(modules|firmware)|/usr/src)/[^/]+$:: + s:^%%dir (/boot|/etc|(/usr)?/lib/(modules|firmware)|/usr/src)/[^/]+$:: s:/[^/]+$::p ta ' "$@" | sort -u @@ -816,10 +816,19 @@ fi shopt -s nullglob dotglob > %my_builddir/kernel-devel.files -for file in %buildroot/boot/symtypes* %buildroot/lib/modules/*/{build,source}; do - f=${file##%buildroot} - echo "$f" -done | add_dirs_to_filelist >%my_builddir/kernel-devel.files +{ + echo "/lib/modules/%kernelrelease-%build_flavor/build" + echo "/lib/modules/%kernelrelease-%build_flavor/source" + cd %buildroot + for file in boot/symtypes*; do + l="${file##*/}" + l="lib/modules/%kernelrelease-%build_flavor/${l//-%kernelrelease-%build_flavor}" + mv "$file" "%{buildroot}/$l" + ln -s "../$l" $file + echo "/$l" + echo "%%ghost /$file" + done +} | add_dirs_to_filelist >%my_builddir/kernel-devel.files ( cd %buildroot ; find .%obj_install_dir/%cpu_arch_flavor -type f ; ) | \ sed -e 's/^[.]//' | grep -v -e '[.]ipa-clones$' -e '/Symbols[.]list$' -e '/ipa-clones[.]list$'| \ add_dirs_to_filelist >> %my_builddir/kernel-devel.files @@ -828,6 +837,8 @@ add_dirs_to_filelist >> %my_builddir/kernel-devel.files echo %ghost /boot/initrd$suffix cd %buildroot for f in boot/*; do + l="${f##*/}" + l="lib/modules/%kernelrelease-%build_flavor/${l//-%kernelrelease-%build_flavor}" if test -L "$f"; then echo "%%ghost /$f" continue @@ -842,16 +853,22 @@ add_dirs_to_filelist >> %my_builddir/kernel-devel.files boot/vmlinux-*.%{compress_vmlinux}) ;; boot/vmlinux-*) - if $ghost_vmlinux; then - echo "%%ghost /$f" - continue - fi + [ "$ghost_vmlinux" != 'true' ] || echo -n "%%ghost " + ;; + boot/vmlinuz-*) + echo -n "%%attr(0644, root, root) " ;; boot/symtypes*) + echo "%exclude /$l" continue ;; esac - echo "%%attr(0644, root, root) /$f" + mv "$f" "$l" + ln -s "../$l" $f + # the find in the CONFIG_MODULES condition below also finds the files + # but there's sort -u later, so this is ok + echo "/$l" + echo "%%ghost /$f" done if [ %CONFIG_MODULES = y ]; then @@ -860,7 +877,11 @@ add_dirs_to_filelist >> %my_builddir/kernel-devel.files \( -path '*/modules.*' ! -path '*/modules.order' \ ! -path '*/modules.builtin' \ ! -path '*/modules.builtin.modinfo' \) -printf '%%%%ghost /%%p\n' \ - -o -name '*.ko' -prune -o -type f -printf '/%%p\n' + -o -name '*.ko' -prune \ + -o \( -type f \ + ! -path '*/symtypes*' \ + ! -path '*/vmlinu*' \ + \) -printf '/%%p\n' cat %my_builddir/base-modules fi if test %CONFIG_MODULE_SIG = "y" -a -d etc/uefi/certs; then diff --git a/rpm/post.sh b/rpm/post.sh index 052ae5a6fdd2..b5167ed99443 100644 --- a/rpm/post.sh +++ b/rpm/post.sh @@ -10,6 +10,23 @@ for x in /boot/@IMAGE@ /boot/initrd; do rm -f $x$suffix ln -s ${x##*/}-@KERNELRELEASE@-@FLAVOR@ $x$suffix done +# compat stuff for /boot. +# if /boot is not a speparate partition we can just link the kernel +# there to save space. Otherwise copy. +if mountpoint -q /boot; then + copy_or_link="cp -a" +else + copy_or_link="ln -sf" +fi +# XXX: need to fix suse-module-tools for sysctl.conf and System.map +for x in @IMAGE@ sysctl.conf System.map; do + if [ ! -e /boot/$x-@KERNELRELEASE@-@FLAVOR@ ]; then + $copy_or_link ../lib/modules/@KERNELRELEASE@-@FLAVOR@/$x /boot/$x-@KERNELRELEASE@-@FLAVOR@ + if [ -e /lib/modules/@KERNELRELEASE@-@FLAVOR@/.$x.hmac ]; then + $copy_or_link ../lib/modules/@KERNELRELEASE@-@FLAVOR@/.$x.hmac /boot/.$x-@KERNELRELEASE@-@FLAVOR@.hmac + fi + fi +done # Add symlinks of compatible modules to /lib/modules/$krel/weak-updates/, # run depmod and mkinitrd diff --git a/rpm/postun.sh b/rpm/postun.sh index d5165044abc4..4da20759f3ff 100644 --- a/rpm/postun.sh +++ b/rpm/postun.sh @@ -6,7 +6,7 @@ rm -f /boot/do_purge_kernels wm2=/usr/lib/module-init-tools/weak-modules2 nvr=@SUBPACKAGE@-@RPM_VERSION_RELEASE@ -if [ -e /boot/System.map-@KERNELRELEASE@-@FLAVOR@ ]; then +if [ -e /lib/modules/@KERNELRELEASE@-@FLAVOR@/System.map ]; then # the same package was reinstalled or just rebuilt, otherwise the files # would have been deleted by now # do not remove anything in this case (bnc#533766) -- (o_ Ludwig Nussel //\ V_/_ http://www.suse.com/ SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer HRB 36809 (AG Nürnberg)