abi-generate 947 B

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