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

  • zz: 墙、感染、信任和欺骗 by 霍炬 (歪理邪说 2015-09-21)

    (全文转载自 墙、感染、信任和欺骗 2015-09-21 霍炬 歪理邪说) 先跟读者道个歉,最近一段时间有点忙,好久没更新。 而写文章这事,一旦有一段时间不写就会越来越写不下去。 很长一段时间我甚至不敢打开公众帐号后台,一怕被催稿, 二怕看到惨烈的退订数字以至于更不敢写……

  • zz:Pragmatism

    DDJ_1306, "Orthodoxy vs. Pragmatism, or How I Became a Better Developer" By Andrew Binstock "[...]When young I was and green, I had…

  • zz:回来后,一些搞不懂的“共识”

    http://www.mitbbs.com/article_t/Returnee/13379685.html 共识一:欧美搞设计、掌握技术和市场,中国只会生产。利润都被欧美赚走了。 但是结果是中国越来越有钱,欧美越来越没钱,这算是共识吗? 共识二:中国贫富差距大,钱都被少数人赚去了;…

  • 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