Chris's Wiki :: blog/sysadmin/SaveRestorePackageVersions Commentshttps://utcc.utoronto.ca/~cks/space/blog/sysadmin/SaveRestorePackageVersions?atomcommentsDWiki2010-09-15T14:30:51ZRecent comments in Chris's Wiki :: blog/sysadmin/SaveRestorePackageVersions.From 65.172.155.230 on /blog/sysadmin/SaveRestorePackageVersionstag:CSpace:blog/sysadmin/SaveRestorePackageVersions:8101e37510c29d617521102e73ea5d14465e5cb0From 65.172.155.230<div class="wikitext"><p>With yum there is also:</p>
<p>yum-debug-dump and yum-debug-restore</p>
<p>...for former is in RHEL-5, but the later didn't quite make it. For RHEL-6 there is also "yum version" to check that two machines are "packaging identical".</p>
</div>2010-09-15T14:30:51ZBy Chris Siebenmann on /blog/sysadmin/SaveRestorePackageVersionstag:CSpace:blog/sysadmin/SaveRestorePackageVersions:6236bb72aa550185fb0901da36ca30c843db92f7Chris Siebenmann<div class="wikitext"><p>The dpkg approach isn't a solution because sysadmins do very specifically
want the exact package version that is installed on system A to also be
installed on new system B.</p>
<p>RPM, Yum, apt, and so on give you the pieces that you could use to build
this (provided that the distribution preserves old now-updated packages
in their repository), but I don't know of anyone who actually provides a
canned solution to do it. Being able to assemble something isn't quite the
same as being able to run two commands and being done.</p>
<p>(Note that plain <code>rpm -qa</code> is not good enough; you really want to
put the architecture in there too.)</p>
</div>2010-09-11T16:08:08ZFrom 87.198.25.32 on /blog/sysadmin/SaveRestorePackageVersionstag:CSpace:blog/sysadmin/SaveRestorePackageVersions:74b13a5081e616f2ddfc6cab5c776f375df1b415From 87.198.25.32<div class="wikitext"><p>A better debian solution is to use dpkg --get-selections and dpkg --set-selections to restore them. Although it doesn't preserve version numbers unfortunately. However a debian release generally won't ever modify a package (except for security updates) so the effect is (usually) the same.</p>
<p>Yes, there is some handwaving here :)</p>
</div>2010-09-11T11:03:47ZFrom 70.95.101.194 on /blog/sysadmin/SaveRestorePackageVersionstag:CSpace:blog/sysadmin/SaveRestorePackageVersions:55b81e928c30526cb555a994f7cb43c65d591fb6From 70.95.101.194<div class="wikitext"><p>Unless I'm missing something, both RPM and APT allow you to do that already, with the standard tools they come with:</p>
<p>rpm -qa gives you:</p>
<p>bzip2-devel-1.0.3-4.el5_2</p>
<p>You can pass that list across to another system and just do a straigt:
cat rpmlist | xargs yum -y install</p>
<p>Provided the version is still available in the repository (should be for RHES / CentOS) then it should install.</p>
<p>Or alternatively the --qf flag allows you to specify a format using printf syntax, e.g.: </p>
<p>rpm -qa --qf '%{NAME} %{VERSION}\n'</p>
<p>which will list the installed packages in one column and the version in a second. If you're maintaining strict repository practices (i.e. all packages installed from a repository rather than downloading RPMs separately), and have all machines patched up to date, provided you copy the repo settings across to another machine you should just be able to output only the package names to a file and do the same cat | xargs trick as above.</p>
<p>Under Debian / Ubuntu dpkg -l will give you a columnar list of packages with name and version in separate columns.
apt-get will allow you to pass it specific versions to install. For example on my Ubuntu desktop I've got installed eog version 2.31.91-0ubuntu1. To get apt to do the install of that version, take the package name, append an equals sign followed by the version:</p>
<p>apt-get install eog=2.31.91-0ubuntu1</p>
</div>2010-09-11T08:43:21Z