2019-03-19 09:08:50 +01:00
|
|
|
#!/bin/bash -xe
|
|
|
|
# %scriptdir/kernel-subpackage-build %kernel_package_name %rpm_kver-%rpm_krel %package_name-%version-%release
|
|
|
|
|
|
|
|
scriptdir=$(dirname $0)
|
|
|
|
kernel_package_name=$1
|
|
|
|
kernel_nvrq=$(echo $1-$2 | sed -e 's/[.]/[.]/g')
|
|
|
|
package_nvr=$3
|
|
|
|
|
|
|
|
|
|
|
|
set -o pipefail
|
|
|
|
install -d -m 0755 $RPM_BUILD_ROOT/boot
|
|
|
|
|
|
|
|
$scriptdir/splitflist $kernel_package_name kernel.flist kernel-ghost.flist
|
2021-07-13 08:23:02 +02:00
|
|
|
echo Missing files:
|
2019-03-19 09:08:50 +01:00
|
|
|
cat kernel-ghost.flist
|
|
|
|
|
|
|
|
rpm -q --qf '%{PREIN}' $kernel_package_name | sed -e "s/$kernel_nvrq/$package_nvr/g" > prein.sh
|
|
|
|
rpm -q --qf '%{PREUN}' $kernel_package_name | sed -e "s/$kernel_nvrq/$package_nvr/g" > preun.sh
|
|
|
|
rpm -q --qf '%{POSTIN}' $kernel_package_name | sed -e "s/$kernel_nvrq/$package_nvr/g" > postin.sh
|
|
|
|
rpm -q --qf '%{POSTUN}' $kernel_package_name | sed -e "s/$kernel_nvrq/$package_nvr/g" > postun.sh
|
|
|
|
|
|
|
|
[ -z "$(rpm -q --triggers $kernel_package_name)" ] # not handled
|
|
|
|
|
2021-07-13 08:23:02 +02:00
|
|
|
KREL=$(cat kernel.flist | grep ^/lib/modules | { sort -r ||: ;} | head -n 1 | sed -e s,^/lib/modules/,, -e 's,/.*,,')
|
2019-03-19 09:08:50 +01:00
|
|
|
|
|
|
|
$scriptdir/mergedep $KREL > modules.dep
|
|
|
|
|
|
|
|
|
|
|
|
$scriptdir/moddep modules.dep request-modules modules
|
|
|
|
|
|
|
|
$scriptdir/modflist kernel.flist modules modules.flist /lib/modules/$KREL/modules.builtin
|
2021-07-13 08:23:02 +02:00
|
|
|
cat kernel.flist | grep -v ^/lib/modules >> modules.flist
|
|
|
|
[ -d /lib/modules/$KREL/vdso ] && echo /lib/modules/$KREL/vdso >> modules.flist ||:
|
|
|
|
echo /lib/modules/$KREL/modules.* | tr ' ' '\n' >> modules.flist
|
2019-03-19 09:08:50 +01:00
|
|
|
|
|
|
|
tar -C / -cf- -T modules.flist | tar -C $RPM_BUILD_ROOT -xvf-
|
|
|
|
|
|
|
|
moderr="$(/usr/sbin/depmod -b $RPM_BUILD_ROOT -e -F /boot/System.map-$KREL $KREL 2>&1 > /dev/null)"
|
|
|
|
|
|
|
|
if [ "$moderr" ] ; then
|
|
|
|
echo Picked modules have errors:
|
|
|
|
echo $moderr
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "%defattr(-,root,root)" > subpackage.flist
|
2021-07-13 08:23:02 +02:00
|
|
|
cat kernel.flist | grep -v ^/lib/modules >> subpackage.flist
|
|
|
|
echo /lib/modules/$KREL >> subpackage.flist
|
|
|
|
cat kernel-ghost.flist | sed -e 's/^/%ghost /' >> subpackage.flist
|
|
|
|
|
|
|
|
cat kernel-ghost.flist | while read ghost ; do
|
|
|
|
case $ghost in
|
|
|
|
/boot/image-%build_flavor | /boot/vmlinux-%build_flavor | /boot/vmlinuz-%build_flavor | \
|
|
|
|
/boot/Image-%build_flavor | /boot/initrd-%build_flavor)
|
|
|
|
;;
|
|
|
|
/boot/vmlinux | /boot/vmlinuz | /boot/zImage | /boot/Image | /boot/image | /boot/initrd)
|
|
|
|
;;
|
|
|
|
/boot/vmlinux-$KREL)
|
|
|
|
[ -f /boot/vmlinux-$KREL.gz ] && touch vmlinux-$KREL
|
|
|
|
;;
|
|
|
|
/boot/initrd-$KREL | /boot/initrd-$KREL-kdump)
|
|
|
|
# Create a dummy initrd with roughly the size the real one will have.
|
|
|
|
# That way, YaST will know that this package requires some additional
|
|
|
|
# space in /boot.
|
|
|
|
dd if=/dev/zero of=$RPM_BUILD_ROOT$ghost \
|
|
|
|
bs=1024 seek=2047 count=1
|
|
|
|
chmod 0600 $RPM_BUILD_ROOT$ghost
|
|
|
|
;;
|
|
|
|
/lib/modules/$KREL/modules.*)
|
|
|
|
[ -f $RPM_BUILD_ROOT$ghost ]
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo Missing file "$ghost" not handled.
|
|
|
|
exit 1;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|