Skip to content

Instantly share code, notes, and snippets.

@XooR
Created November 19, 2011 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XooR/1378729 to your computer and use it in GitHub Desktop.
Save XooR/1378729 to your computer and use it in GitHub Desktop.
yum updates...
#!/usr/bin/env perl
# To list versions before and after update
# it doesn't work yet, it doesn't prints all packages
# only some of them, need some fixing
use strict;
use warnings;
sub extract_name_version {
my ($input_ref) = @_;
my $ret_hash;
for my $update_line (@$input_ref) {
#xmlrpc.x86_64 2.0.1-3jpp.1 installed
my $el_hash;
my ($name, $version, $repo)
= $update_line =~ /^(\w\S+)\s+(\d\S+)\s+(\w\S+)$/;
next
if not defined $name;
$ret_hash->{$name}{version} = $version;
}
return $ret_hash;
}
my @updates_lines = `yum list updates`;
my @installed_lines = `yum list installed`;
my $updated_version_for = extract_name_version(\@updates_lines);
my $installed_version_for = extract_name_version(\@installed_lines);
for my $name (keys %$updated_version_for) {
print $name, "\t", $installed_version_for->{$name}{version}, "\t",$updated_version_for->{$name}{version}, "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment