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