Created
July 10, 2012 13:36
-
-
Save jiphex/3083285 to your computer and use it in GitHub Desktop.
CentOS Yum Upgrade Diff script
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
# upgdiff.rb | |
# | |
# Prints the change in versions that will happen if "yum upgrade" is | |
# run on this CentOS/RHEL server, and if any of the upgrades will come | |
# from third party repositories. | |
# | |
# For example: | |
# | |
# [root@server] $ ruby upgdiff.rb | |
# yum-utils: 1.1.16-14.el5.centos.1 ==> 1.1.16-21.el5.centos | |
# zlib: 1.2.3-3 ==> 1.2.3-4.el5 **somecustomrepo* | |
# [root@server] $ | |
# | |
# James Hannah - 2012 | |
pkgcache = {} | |
`rpm -qa --qf "%{NAME} %{VERSION}-%{RELEASE} %{VENDOR}\n"`.each_line do |l| | |
(name,current,vendor) = l.split(" ") | |
pkgcache[name] = {:current=>current,:vendor=>vendor} | |
end | |
`yum check-update`.each_line do |up| | |
(name,upgrade,repo) = up.split | |
next if name == nil | |
pkgname = name.split(".")[0] | |
if pkgcache.keys.include?(pkgname) | |
pkgcache[pkgname][:upgrade] = upgrade | |
pkgcache[pkgname][:repo] = repo | |
end | |
end | |
pkgcache.sort.each do |pkgname,info| | |
next unless info.keys.include? :upgrade | |
next if info[:current] == info[:upgrade] | |
unless ["base","updates","extra"].include?(info[:repo]) | |
# check if we previously had CentOS as the vendor, but are now going to 3rd party repo | |
repowarn = (info[:vendor]=="CentOS") ? "!!!! UPGRADE TO 3RD PARTY !!!!" : "" | |
repo = "**#{info[:repo]}**#{repowarn}" | |
end | |
puts "#{pkgname.rjust(30)}: #{info[:current]} ==> #{info[:upgrade]} #{repo}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment