]> git.proxmox.com Git - pve-kernel.git/blame - debian/scripts/abi-generate
debian/scripts: add patchqueue scripts
[pve-kernel.git] / debian / scripts / abi-generate
CommitLineData
2132f071
FG
1#!/usr/bin/perl -w
2
3use PVE::Tools;
4
5use IO::File;
6
7my $input_file = shift;
8my $output_file = shift;
9my $abi = shift;
10my $extract_deb = shift;
11
12die "input file '$input_file' does not exist\n" if ! -e $input_file;
13
14my $modules_symver_fh;
15
16if ($extract_deb) {
17 my $cmd = [];
18 push @$cmd, ['dpkg', '--fsys-tarfile', $input_file];
19 push @$cmd, ['tar', '-xOf', '-', "./usr/src/linux-headers-${abi}/Module.symvers"];
20 $modules_symver_fh = IO::File->new_tmpfile();
21 PVE::Tools::run_command($cmd, output => '>&'.fileno($modules_symver_fh));
22 seek($modules_symver_fh, 0, 0);
23} else {
24 open($modules_symver_fh, '<', $input_file) or die "can't open '$input_file' - $!\n";
25}
26
27my $lines = [];
28while(my $line = <$modules_symver_fh>) {
29 if ($line =~ /^(.+)\s+(.+)\s+(.+)$/) {
30 push @$lines, "$3 $2 $1";
31 } else {
32 warn "malformed symvers line: '$line'\n";
33 }
34}
35close($modules_symver_fh);
36
37PVE::Tools::file_set_contents($output_file, join("\n", sort @$lines));