]> git.proxmox.com Git - pve-kernel.git/commitdiff
d/scripts/abi-generate: add new helper script
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 21 Mar 2018 10:26:30 +0000 (11:26 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 21 Mar 2018 13:45:36 +0000 (14:45 +0100)
and use it in d/rules to generate the checked ABI file.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
debian/rules
debian/scripts/abi-generate [new file with mode: 0755]

index 7a0d143ea1d63bf578c8d99913ac57482f20bd41..a26cf61de5322842e6562ed6dc6b321961716695 100755 (executable)
@@ -202,7 +202,7 @@ fwcheck: fwlist-${KVNAME} fwlist-previous
 
 
 abi-${KVNAME}: .compile_mark
-       sed -e 's/^\(.\+\)[[:space:]]\+\(.\+\)[[:space:]]\(.\+\)$$/\3 \2 \1/' debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME}/Module.symvers | sort > abi-${KVNAME}
+       debian/scripts/abi-generate debian/${PVE_HEADER_PKG}/usr/src/linux-headers-${KVNAME}/Module.symvers abi-${KVNAME} ${KVNAME}
 
 .PHONY: abicheck
 abicheck: debian/scripts/abi-check abi-${KVNAME} abi-previous abi-blacklist
diff --git a/debian/scripts/abi-generate b/debian/scripts/abi-generate
new file mode 100755 (executable)
index 0000000..44704fb
--- /dev/null
@@ -0,0 +1,37 @@
+#!/usr/bin/perl -w
+
+use PVE::Tools;
+
+use IO::File;
+
+my $input_file = shift;
+my $output_file = shift;
+my $abi = shift;
+my $extract_deb = shift;
+
+die "input file '$input_file' does not exist\n" if ! -e $input_file;
+
+my $modules_symver_fh;
+
+if ($extract_deb) {
+       my $cmd = [];
+       push @$cmd, ['dpkg', '--fsys-tarfile', $input_file];
+       push @$cmd, ['tar', '-xOf', '-', "./usr/src/linux-headers-${abi}/Module.symvers"];
+       $modules_symver_fh = IO::File->new_tmpfile();
+       PVE::Tools::run_command($cmd, output => '>&'.fileno($modules_symver_fh));
+       seek($modules_symver_fh, 0, 0);
+} else {
+       open($modules_symver_fh, '<', $input_file) or die "can't open '$input_file' - $!\n";
+}
+
+my $lines = [];
+while(my $line = <$modules_symver_fh>) {
+       if ($line =~ /^(.+)\s+(.+)\s+(.+)$/) {
+               push @$lines, "$3 $2 $1";
+       } else {
+               warn "malformed symvers line: '$line'\n";
+       }
+}
+close($modules_symver_fh);
+
+PVE::Tools::file_set_contents($output_file, join("\n", sort @$lines));