rpms+.in 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #! @PERL@
  2. #
  3. # Written by Balazs Nagy (julian7@kva.hu) 1998
  4. # locale bugfix by Michal Svec (rebel@penguin.cz) 2000
  5. # (C) 1998 The Free Software Foundation.
  6. #
  7. #
  8. # override any locale for dates
  9. delete $ENV{"LC_ALL"};
  10. $ENV{"LC_TIME"}="C";
  11. #print $ENV{"LC_ALL"};
  12. #exit 0;
  13. sub gd
  14. {
  15. my ($dt) = @_;
  16. $dt =~ tr/ //s;
  17. $dt =~ s/^\w+ (\w+) (\d+) (\d+:\d+):\d+ .+\n?$/$1 $2 $3/;
  18. return $dt;
  19. }
  20. $DATE=gd(`date`);
  21. sub list
  22. {
  23. my (@rpms, %files, $i, $fn, $dn, $sz, $bt);
  24. # @rpms = `rpm -qa --qf "\%{NAME}-\%{VERSION}-\%{RELEASE}:\%{GROUP}:\%{SIZE}:\%{BUILDTIME:date}\n"`;
  25. @rpms = `rpm -qa --qf "\%{NAME}-\%{VERSION}:\%{GROUP}:\%{SIZE}:\%{BUILDTIME:date}\n"`;
  26. print @trpms;
  27. %files = ();
  28. %sizes = ();
  29. %dates = ();
  30. for $i (@rpms) {
  31. if ($i =~ /^([^:]+):([^:]+):([^:]+):(.+)$/) {
  32. ($fn, $dn, $sz, $bt) = ($1, $2, $3, $4);
  33. $dn =~ s/ /_/g;
  34. if (defined $files{$dn}) {
  35. push(@{$files{$dn}}, $fn);
  36. } else {
  37. @{$files{$dn}} = ($fn);
  38. }
  39. $sizes{$fn} = $sz;
  40. $dates{$fn} = gd($bt);
  41. }
  42. }
  43. for $i (sort keys %files) {
  44. print "dr-xr-xr-x 1 root root 0 $DATE $i/\n";
  45. for $fn (sort @{$files{$i}}) {
  46. print "-r--r--r-- 1 root root $sizes{$fn} $dates{$fn} $i/$fn.trpm\n";
  47. }
  48. }
  49. }
  50. #open O, ">>/tmp/tt";
  51. #print O "RPMS: ";
  52. #for $i (@ARGV) {
  53. # print O "$i ";
  54. #}
  55. #print O "\n";
  56. #close O;
  57. if ($ARGV[0] eq "list") { list(); exit(0); }
  58. elsif ($ARGV[0] eq "copyout") { open O, ">$ARGV[3]"; print O $ARGV[2], "\n"; close O; exit(0); }
  59. exit(1);