Yuan Yijun (bbbush) wrote,
Yuan Yijun
bbbush

rpm -qac

Jason L Tibbitts III <tibbs ## math.uh.edu> 2005-12-2



  1. #!/usr/bin/perl
  2. use Getopt::Std;
  3. getopts('dq');
  4.  
  5. $| = 1;
  6. @DIFF = qw(/usr/bin/diff -u);
  7. @LS = qw(/bin/ls -l);
  8.  
  9. @configfiles = `rpm -qac`;
  10.  
  11. for $i (@configfiles) {
  12. chomp $i;
  13. $old = -f "$i.rpmsave";
  14. $new = -f "$i.rpmnew";
  15. if ($old || $new) {
  16.  
  17. # If running quietly, we can just exit the first time we see a difference
  18. if ($opt_q) {
  19. exit 1;
  20. }
  21.  
  22. $package = `rpm -qf $i`;
  23. chomp $package;
  24.  
  25. push @{$updates{$package}}, {file => $i,
  26. old => $old,
  27. new => $new,
  28. };
  29. }
  30. }
  31.  
  32. exit 0 unless %updates;
  33.  
  34. for $package (sort keys %updates) {
  35. print "Updated files in package $package:\n";
  36.  
  37. for $i (@{$updates{$package}}) {
  38. if ($i->{old}) {
  39. show ($i->{file}, "$i->{file}.rpmsave");
  40. }
  41. if ($i->{new}) {
  42. show ($i->{file}, "$i->{file}.rpmnew");
  43. }
  44. }
  45. print "\n";
  46. }
  47.  
  48. exit 1;
  49.  
  50. sub show {
  51. my($old, $new) = @_;
  52.  
  53. print " " if $opt_d;
  54. system(@LS, $old);
  55. print " " if $opt_d;
  56. system(@LS, $new);
  57.  
  58. if ($opt_d) {
  59. print "Differences:\n", "="x40, "\n";
  60. system(@DIFF, $old, $new);
  61. print "="x40, "\n";
  62. }
  63. }


Tags: linux, 转载
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments