home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / bin / dpkg-parsechangelog < prev    next >
Encoding:
Text File  |  2001-09-18  |  2.3 KB  |  82 lines

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