Accepting request 706196 from home:gary_lin:branches:Base:System

support kernel module compression (bsc#1135854)

OBS-URL: https://build.opensuse.org/request/show/706196
OBS-URL: https://build.opensuse.org/package/show/Base:System/pesign-obs-integration?expand=0&rev=77
This commit is contained in:
Gary Ching-Pang Lin 2019-05-29 07:12:18 +00:00 committed by Git OBS Bridge
parent b67e7b42c2
commit 5350328eee
3 changed files with 130 additions and 0 deletions

View File

@ -0,0 +1,122 @@
From b6855233b8f131531b8d55761ed709890632b417 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Tue, 28 May 2019 07:07:56 +0200
Subject: [PATCH] Add support for kernel module compression
This adds the support for kernel module compression in
pesign-obs-integration infrastructure. The kernel-binary spec needs
to pass $BRP_PESIGN_COMPRESS_KERNEL for enabling the compression.
Currently only "xz" is supported.
pesign-gen-repackage-spec received a new option --compress, which is
passed from pesign-repackage.spec, where brp-99-pesign enables it per
the variable above.
With --compress option, pesign-gen-repackage-spec script just
compresses the kernel object at the last repackaging phase.
Bugzilla: http://bugzilla.suse.com/show_bug.cgi?id=1135854
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
README | 7 +++++++
brp-99-pesign | 8 ++++++++
pesign-gen-repackage-spec | 13 ++++++++++++-
pesign-repackage.spec.in | 3 ++-
4 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/README b/README
index 7593302..32afb8f 100644
--- a/README
+++ b/README
@@ -36,3 +36,10 @@ Debian packages can use the dh-signobs debhelper to automate signing and
repacking. Build-depend on dh-signobs and add --with signobs to the dh line
in debian/rules to use the fully automated helper.
Consult the dh_signobs manpage for more information.
+
+When BRP_PESIGN_COMPRESS_MODULE is passed, the script tries to compress the
+kernel modules at the repackaging phase. Currently only xz format is supported.
+For enable the compression feature, put the following along with
+BRP_PESIGN_FILES setup:
+
+export BRP_PESIGN_COMPRESS_MODULE="xz"
diff --git a/brp-99-pesign b/brp-99-pesign
index 2ebb261..68d9f45 100644
--- a/brp-99-pesign
+++ b/brp-99-pesign
@@ -57,6 +57,13 @@ if ! mkdir -p "$output"; then
echo "$0: warning: $output cannot be created, giving up" >&2
exit 0
fi
+
+if test "${BRP_PESIGN_COMPRESS_MODULE}" = "xz"; then
+ pesign_repackage_compress="--compress xz"
+else
+ pesign_repackage_compress=""
+fi
+
cert=$RPM_SOURCE_DIR/_projectcert.crt
if test -e "$cert"; then
echo "Using signing certificate $cert"
@@ -66,6 +73,7 @@ else
fi
sed "
s:@NAME@:$RPM_PACKAGE_NAME:g
+ s:@PESIGN_REPACKAGE_COMPRESS@:$pesign_repackage_compress:g
/@CERT@/ {
r $cert
d
diff --git a/pesign-gen-repackage-spec b/pesign-gen-repackage-spec
index 9cd374a..fef0a9d 100755
--- a/pesign-gen-repackage-spec
+++ b/pesign-gen-repackage-spec
@@ -30,6 +30,7 @@ my $directory;
my $output = ".";
my $cert_subpackage;
my $kmp_basename;
+my $compress;
my @rpms;
$ENV{LC_ALL} = "en_US.UTF-8";
@@ -39,6 +40,7 @@ GetOptions(
"directory|d=s" => \$directory,
"output|o=s" => \$output,
"cert-subpackage|c=s" => \$cert_subpackage,
+ "compress|C=s" => \$compress,
) or die $USAGE;
@rpms = @ARGV;
if (!@rpms) {
@@ -417,7 +419,16 @@ sub print_files {
$attrs .= "%verify(not $verify_attrs) ";
}
- print SPEC "$attrs " . quote($f->{name}) . "\n";
+ if ($compress eq "xz" &&
+ $f->{name} =~ /\.ko$/ && S_ISREG($f->{mode})) {
+ system("xz", "-f", "-9", $path);
+ chmod($f->{mode}, $path . ".xz");
+ utime($f->{mtime}, $f->{mtime}, $path . ".xz");
+ print SPEC "$attrs " . quote($f->{name}) . ".xz\n";
+ } else {
+ print SPEC "$attrs " . quote($f->{name}) . "\n";
+ }
+
if (-e "$path.sig") {
print SPEC "$attrs " . quote($f->{name}) . ".sig\n";
}
diff --git a/pesign-repackage.spec.in b/pesign-repackage.spec.in
index bcaa0e1..ca8d325 100644
--- a/pesign-repackage.spec.in
+++ b/pesign-repackage.spec.in
@@ -145,7 +145,8 @@ for sig in "${sigs[@]}"; do
esac
done
popd
-/usr/lib/rpm/pesign/pesign-gen-repackage-spec --directory=%buildroot "${rpms[@]}"
+/usr/lib/rpm/pesign/pesign-gen-repackage-spec @PESIGN_REPACKAGE_COMPRESS@ \
+ --directory=%buildroot "${rpms[@]}"
rpmbuild --define "%%buildroot %buildroot" --define "%%disturl $disturl" \
--define "%%_builddir $PWD" \
--define "%_suse_insert_debug_package %%{nil}" -bb repackage.spec
--
2.21.0

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed May 29 06:01:20 UTC 2019 - Gary Ching-Pang Lin <glin@suse.com>
- Add 0001-Add-support-for-kernel-module-compression.patch to
support kernel module compression (bsc#1135854)
-------------------------------------------------------------------
Fri May 17 14:00:08 UTC 2019 - Guillaume GARDET <guillaume.gardet@opensuse.org>

View File

@ -33,6 +33,7 @@ BuildRequires: openssl
Url: http://en.opensuse.org/openSUSE:UEFI_Image_File_Sign_Tools
Source: %{name}_%{version}.tar.gz
Patch1: 0001-Passthrough-license-tag.patch
Patch2: 0001-Add-support-for-kernel-module-compression.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# suse-module-tools <= 15.0.10 contains modsign-verify
Requires: suse-module-tools >= 15.0.10
@ -44,6 +45,7 @@ boot loader, kernel and kernel modules in the openSUSE Buildservice.
%prep
%setup -D -n %{name}
%patch1 -p1
%patch2 -p1
%build