dpkg-parsechangelog.pl 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/usr/bin/perl
  2. $dpkglibdir= ".";
  3. $version= '1.3.0'; # This line modified by Makefile
  4. $format='debian';
  5. $changelogfile='debian/changelog';
  6. @parserpath= ("/usr/local/lib/dpkg/parsechangelog",
  7. "$dpkglibdir/parsechangelog");
  8. use POSIX;
  9. use POSIX qw(:errno_h);
  10. push(@INC,$dpkglibdir);
  11. require 'controllib.pl';
  12. sub usageversion {
  13. print STDERR
  14. "Debian GNU/Linux dpkg-source $version. Copyright (C) 1996
  15. Ian Jackson. This is free software; see the GNU General Public Licence
  16. version 2 or later for copying conditions. There is NO warranty.
  17. Usage: dpkg-parsechangelog [<option> ...]
  18. Options: -l<changelogfile> get per-version info from this file
  19. -v<sinceversion> include all changes later than version
  20. -F<changelogformat> force change log format
  21. -L<libdir> look for change log parsers in <libdir>
  22. -h print this message
  23. ";
  24. }
  25. @ap=();
  26. while (@ARGV) {
  27. last unless $ARGV[0] =~ m/^-/;
  28. $_= shift(@ARGV);
  29. if (m/^-L/ && length($_)>2) { $libdir=$'; next; }
  30. if (m/^-F([0-9a-z]+)$/) { $force=1; $format=$1; next; }
  31. if (m/^-l/ && length($_)>2) { $changelogfile=$'; next; }
  32. push(@ap,$_);
  33. m/^--$/ && last;
  34. m/^-v/ && next;
  35. &usageerr("unknown option \`$_'");
  36. }
  37. @ARGV && &usageerr("$progname takes no non-option arguments");
  38. $changelogfile= "./$changelogfile" if $changelogfile =~ m/^\s/;
  39. if (!$force) {
  40. open(STDIN,"< $changelogfile") ||
  41. &error("cannot open $changelogfile to find format: $!");
  42. open(P,"tail -40 |") || die "cannot fork: $!\n";
  43. while(<P>) {
  44. next unless m/\schangelog-format:\s+([0-9a-z]+)\W/;
  45. $format=$1;
  46. }
  47. close(P); $? && &subprocerr("tail of $changelogfile");
  48. }
  49. for $pd (@parserpath) {
  50. $pa= "$pd/$format";
  51. if (!stat("$pa")) {
  52. $! == ENOENT || &syserr("failed to check for format parser $pa");
  53. } elsif (!-x _) {
  54. &warn("format parser $pa not executable");
  55. } else {
  56. $pf= $pa;
  57. }
  58. }
  59. defined($pf) || &error("format $pa unknown");
  60. open(STDIN,"< $changelogfile") || die "cannot open $changelogfile: $!\n";
  61. exec($pf,@ap); die "cannot exec format parser: $!\n";