You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

listpackages.pl 1.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/perl
  2. #
  3. # listpackages directory [field]
  4. #
  5. # This program spits out a list of all the packages listed in the tasks.
  6. #
  7. # If you go to auric, this command is then useful:
  8. #
  9. # for package in $(listpackages); do
  10. # madison -s testing -a "i386 all" $package >/dev/null || echo "No $package!"
  11. # done
  12. #
  13. # Or to see just key packages:
  14. #
  15. # listpackages tasks key
  16. my $dir=shift or die "no directory specified\n";
  17. my @toshow=qw{packages-list key};
  18. @toshow=@ARGV if @ARGV;
  19. use File::Find;
  20. find(\&processfile, $dir);
  21. sub processfile {
  22. my $file=$_; # File::Find craziness.
  23. $file eq 'po' && -d $file && ($File::Find::prune = 1);
  24. return if $File::Find::dir=~/\.(svn|git)/;
  25. return unless $file =~ /^[-+_.a-z0-9]+$/ and -f $file;
  26. open (IN, $file) or die "$file: $!";
  27. my %fields;
  28. my $field="";
  29. while (<IN>) {
  30. chomp;
  31. next if /^\s*#/;
  32. s/#.*//;
  33. if (/^\s/) {
  34. $fields{$field}.="\n$_";
  35. }
  36. else {
  37. ($field, my $value)=split(/:\s*/, $_, 2);
  38. $field=lc($field);
  39. $fields{$field}=$value;
  40. }
  41. }
  42. close IN;
  43. my @list;
  44. push @list, split(' ', $fields{$_}) foreach @toshow;
  45. print join("\n", @list)."\n" if @list;
  46. }