Created
July 26, 2012 15:05
-
-
Save atomic-penguin/3182593 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| ############################################################################# | |
| # Program : rpmaudit | |
| # Purpose : Provide a date as input, and a report of installed/upgraded | |
| # : RPMs since the given date will be returned. | |
| # License : Artistic Perl 2.0 | |
| # (C) 2008 : Eric G. Wolfe <wolfe21@marshall.edu> | |
| use strict; | |
| use warnings; | |
| use POSIX qw(strftime); | |
| use DateTime; | |
| sub rpmquery { | |
| my ($audit_date) = @_; | |
| # Query rpm for the unixtime, formatted time, and package name-version-release number | |
| my @audit_list | |
| = qx!rpm -qa --queryformat '%{installtime}\t(%{installtime:date})\t%{name}-%{version}-%{release}\n' | sort -n!; | |
| # For each line see if the package is newer than provided date. | |
| foreach my $line (@audit_list) { | |
| my @line = split( /\t/, $line ); | |
| if ( $line[0] >= $audit_date ) { | |
| print "$line[1] $line[2]"; | |
| } | |
| } | |
| } | |
| my $date = shift @ARGV; | |
| if ( $date =~ /(\d{4})-(\d{1,2})-(\d{1,2})/xms ) { | |
| my $year = $1; | |
| my $month = $2; | |
| my $day = $3; | |
| my $dt = DateTime->new( | |
| year => $year, | |
| month => $month, | |
| day => $day, | |
| ); | |
| rpmquery( $dt->epoch() ); | |
| } else { | |
| print "Usage: rpmaudit <YYYY-MM-DD>\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment