Home Home > GIT Browse > packaging
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Suchanek <msuchanek@suse.de>2019-03-14 19:01:12 +0100
committerMichal Suchanek <msuchanek@suse.de>2019-03-15 22:13:19 +0100
commitad7c2270f972499a72c5331f7194e34a10cc92d6 (patch)
tree9dc44840437be0a4e5277777f9094286bd0c69da
parenta5ee24ef3f8a2258918ea18049f6fdc385ce8087 (diff)
Install extra rpm scripts for kernel subpackaging (FATE#326579,
jsc#SLE-4117, jsc#SLE-3853, bsc#1128910). Signed-off-by: Michal Suchanek <msuchanek@suse.de>
-rw-r--r--rpm/kernel-source.spec.in10
-rw-r--r--rpm/kernel-subpackage-build82
-rw-r--r--rpm/kernel-subpackage-spec70
-rwxr-xr-xrpm/modflist3
4 files changed, 164 insertions, 1 deletions
diff --git a/rpm/kernel-source.spec.in b/rpm/kernel-source.spec.in
index 2f5eb5f22a..ce8ab313c6 100644
--- a/rpm/kernel-source.spec.in
+++ b/rpm/kernel-source.spec.in
@@ -102,6 +102,9 @@ Source79: splitflist
Source80: mergedep
Source81: moddep
Source82: modflist
+Source83: kernel-subpackage-build
+Source84: kernel-subpackage-spec
+Source85: kernel-default-base.spec.txt
Source100: config.tar.bz2
Source101: config.addon.tar.bz2
Source102: patches.arch.tar.bz2
@@ -159,6 +162,7 @@ external kernel modules.
%package -n kernel-macros
Summary: RPM macros for building Kernel Module Packages
Group: Development/Sources
+Provides: kernel-subpackage-macros
%description -n kernel-macros
This package provides the rpm macros and templates for Kernel Module Pakcages
@@ -238,6 +242,10 @@ install -m 644 %_sourcedir/macros.kernel-source $RPM_BUILD_ROOT/etc/rpm/
install -m 755 -d $RPM_BUILD_ROOT/usr/lib/rpm
install -m 644 %_sourcedir/kernel-{module,cert}-subpackage \
$RPM_BUILD_ROOT/usr/lib/rpm/
+install -m 755 -d $RPM_BUILD_ROOT/usr/lib/rpm/kernel
+install -m 755 %_sourcedir/{splitflist,mergedep,moddep,modflist,kernel-subpackage-build} $RPM_BUILD_ROOT/usr/lib/rpm/kernel
+install -m 644 %_sourcedir/kernel-subpackage-spec $RPM_BUILD_ROOT/usr/lib/rpm/kernel
+install -m 644 -T %_sourcedir/kernel-default-base.spec.txt $RPM_BUILD_ROOT/usr/lib/rpm/kernel/kernel-default-base.spec
%endif
sed -e "s:@KERNELRELEASE@:%kernelrelease:g" \
@@ -275,6 +283,8 @@ find %buildroot/usr/src/linux* ! -type l | xargs touch -d "$ts"
%defattr(-,root,root)
/etc/rpm/macros.kernel-source
/usr/lib/rpm/kernel-*-subpackage
+%dir /usr/lib/rpm/kernel
+/usr/lib/rpm/kernel/*
%endif
%endif
diff --git a/rpm/kernel-subpackage-build b/rpm/kernel-subpackage-build
new file mode 100644
index 0000000000..7779cd5352
--- /dev/null
+++ b/rpm/kernel-subpackage-build
@@ -0,0 +1,82 @@
+#!/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/Image | /boot/image | /boot/initrd)
+ ln -s $ghost-$KREL $RPM_BUILD_ROOT$ghost
+ ;;
+ /boot/vmlinux-$KREL)
+ [ -f /boot/vmlinux-$KREL.gz ] && gunzip -dc < /boot/vmlinux-$KREL.gz > vmlinux-$KREL
+ size="$(ls -l vmlinux-$KREL | sed -e 's/^\([^ ]* \)\{4\}//' -e 's/ .*//')"
+ dd if=/dev/zero bs=1 count=1 seek="$(expr $size - 1)" of=$RPM_BUILD_ROOT$ghost
+ ;;
+ /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
+
diff --git a/rpm/kernel-subpackage-spec b/rpm/kernel-subpackage-spec
new file mode 100644
index 0000000000..11ce29c2f2
--- /dev/null
+++ b/rpm/kernel-subpackage-spec
@@ -0,0 +1,70 @@
+%define rpm_kver %(rpm -q --qf '%%{VERSION}' %kernel_package_name)
+%define rpm_krel %(rpm -q --qf '%%{RELEASE}' %kernel_package_name)
+
+# Force bzip2 instead of lzma compression to
+# 1) allow install on older dist versions, and
+# 2) decrease build times (bsc#962356)
+# %%define _binary_payload w9.bzdio
+# Do not recompute the build-id of vmlinux in find-debuginfo.sh (bsc#964063)
+%undefine _unique_build_ids
+%define _no_recompute_build_ids 1
+# prevent usr/lib/debug/boot/vmlinux-4.12.14-11.10-default-4.12.14-11.10.ppc64le.debug
+%undefine _unique_debug_names
+
+%define kernel_requires %(rpm -q --queryformat '[%%{REQUIREFLAGS:deptype},%%{REQUIRENEVRS}\\n]' %kernel_package_name | grep -vE 'rpmlib,|interp,' | grep -E 'manual,' | sed -e 's/.*,//' | tr '\\n' ' ')
+%define kernel_requires_pre %(rpm -q --queryformat '[%%{REQUIREFLAGS:deptype},%%{REQUIRENEVRS}\\n]' %kernel_package_name | grep -vE 'rpmlib,|interp,' | grep -E 'pre,' | sed -e 's/.*,//' | tr '\\n' ' ')
+%define kernel_requires_preun %(rpm -q --queryformat '[%%{REQUIREFLAGS:deptype},%%{REQUIRENEVRS}\\n]' %kernel_package_name | grep -vE 'rpmlib,|interp,' | grep -E 'preun,' | sed -e 's/.*,//' | tr '\\n' ' ')
+%define kernel_requires_post %(rpm -q --queryformat '[%%{REQUIREFLAGS:deptype},%%{REQUIRENEVRS}\\n]' %kernel_package_name | grep -vE 'rpmlib,|interp,' | grep -E 'post,' | sed -e 's/.*,//' | tr '\\n' ' ')
+%define kernel_requires_postun %(rpm -q --queryformat '[%%{REQUIREFLAGS:deptype},%%{REQUIRENEVRS}\\n]' %kernel_package_name | grep -vE 'rpmlib,|interp,' | grep -E 'postun,' | sed -e 's/.*,//' | tr '\\n' ' ')
+
+%if ! %(expr 1 - 1)
+%if "%{kernel_requires}" != ""
+Requires: %kernel_requires
+%endif
+%if "%{kernel_requires_pre}" != ""
+Requires(pre): %kernel_requires_pre
+%endif
+%if "%{kernel_requires_preun}" != ""
+Requires(preun):%kernel_requires_preun
+%endif
+%if "%{kernel_requires_post}" != ""
+Requires(post): %kernel_requires_post
+%endif
+%if "%{kernel_requires_postun}" != ""
+Requires(postun):%kernel_requires_postun
+%endif
+%endif
+Provides: %(rpm -q --queryformat '[%%{PROVIDENEVRS}\n]' %kernel_package_name | grep -vE '^ksym|^kmod' | tr '\n' ' ')
+Conflicts: %(rpm -q --queryformat '[%%{CONFLICTNEVRS}\n]' %kernel_package_name | grep -vE '^ksym|^kmod' | tr '\n' ' ')
+Obsoletes: %(rpm -q --queryformat '[%%{OBSOLETENEVRS}\n]' %kernel_package_name | grep -vE '^ksym|^kmod' | tr '\n' ' ')
+Recommends: %(rpm -q --queryformat '[%%{RECOMMENDNEVRS}\n]' %kernel_package_name | grep -vE '^ksym|^kmod' | tr '\n' ' ')
+# This is in place of obsolete_rebuilds. This should give Conflicts: %%kernel_package_name = %%source_rel as old kernel-default-base did.
+Conflicts: %(rpm -q --queryformat '[%%{PROVIDENEVRS}\n]' %kernel_package_name | grep '^%kernel_package_name =' | sort -V | head -n 1)
+
+%description
+%(rpm -q --qf '%%{DESCRIPTION}' %kernel_package_name)
+%extradescription
+
+This is a subpackage of %kernel_package_name. Development files are in
+%kernel_package_name-devel and sources in kernel-source%variant.
+
+%prep
+
+%build
+
+%install
+
+echo "%{?modules}" | tr ', ' '\n\n' > request-modules
+%scriptdir/kernel-subpackage-build %kernel_package_name %rpm_kver-%rpm_krel %package_name-%version-%release
+
+%preun -f preun.sh
+
+%postun -f postun.sh
+
+%pre -f prein.sh
+
+%post -f postin.sh
+
+%files -f subpackage.flist
+
+%changelog
diff --git a/rpm/modflist b/rpm/modflist
index 91097455ec..476b541c67 100755
--- a/rpm/modflist
+++ b/rpm/modflist
@@ -2,8 +2,9 @@
flist=$1
modules=$2
output=$3
+mod_builtin=$4
while read MOD ; do
[ -n "$MOD" ] || continue
- cat $flist | grep /$MOD[.]ko\$ >> $output || echo Module $MOD missing
+ cat $flist | grep /$MOD[.]ko\$ >> $output || { grep -q /$MOD[.]ko\$ $mod_builtin && echo Module $MOD built-in ;} || echo Module $MOD missing
done < $modules