]> git.proxmox.com Git - pve-kernel.git/blob - debian/scripts/abi-generate
44704fb598ebd1fc6c3341bb15d143578c7d400e
[pve-kernel.git] / debian / scripts / abi-generate
1 #!/usr/bin/perl -w
2
3 use PVE::Tools;
4
5 use IO::File;
6
7 my $input_file = shift;
8 my $output_file = shift;
9 my $abi = shift;
10 my $extract_deb = shift;
11
12 die "input file '$input_file' does not exist\n" if ! -e $input_file;
13
14 my $modules_symver_fh;
15
16 if ($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
27 my $lines = [];
28 while(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 }
35 close($modules_symver_fh);
36
37 PVE::Tools::file_set_contents($output_file, join("\n", sort @$lines));