bb54e3d376
OBS-URL: https://build.opensuse.org/package/show/Kernel:stable/kernel-source?expand=0&rev=1187
81 lines
2.8 KiB
Bash
81 lines
2.8 KiB
Bash
#!/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
|
|
echo Missing files:
|
|
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
|
|
|
|
KREL=$(cat kernel.flist | grep ^/lib/modules | { sort -r ||: ;} | head -n 1 | sed -e s,^/lib/modules/,, -e 's,/.*,,')
|
|
|
|
$scriptdir/mergedep $KREL > modules.dep
|
|
|
|
|
|
$scriptdir/moddep modules.dep request-modules modules
|
|
|
|
$scriptdir/modflist kernel.flist modules modules.flist /lib/modules/$KREL/modules.builtin
|
|
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
|
|
|
|
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
|
|
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)
|
|
ln -s $(basename $ghost -%build_flavor)-$KREL $RPM_BUILD_ROOT$ghost
|
|
;;
|
|
/boot/vmlinux | /boot/vmlinuz | /boot/zImage | /boot/Image | /boot/image | /boot/initrd)
|
|
ln -s $ghost-$KREL $RPM_BUILD_ROOT$ghost
|
|
;;
|
|
/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
|
|
|