13 May 2008

Define the different installed packages between GNU/Linux installations

Let's call one installation local, and the other remote.
On the first one, use rpm to get the list of installed packages:
rpm -qa --qf "%{NAME}.%{ARCH}\n" |sort > /tmp/localInstallationInstalledPackages

Idem, on the second one:
rpm -qa --qf "%{NAME}.%{ARCH}\n" |sort > /tmp/remoteInstallationInstalledPackages

Then, get the differences between each list using diff.

To see the package installed on the local installation, but not on the remote one:
diff /tmp/localInstallationInstalledPackages /tmp/remoteInstallationInstalledPackages |grep "^<"

To see the package installed on the remote installation, but not on the local one:
diff /tmp/localInstallationInstalledPackages /tmp/remoteInstallationInstalledPackages |grep "^>"

In the two cases, to get a list of regarded packages on one line, use the following instructions.
For instance, for the local installation:
diff /tmp/localInstallationInstalledPackages /tmp/remoteInstallationInstalledPackages |grep "^<" |awk '{print $2}' |sed -e 's/$/ /' |tr -d '\n'

Then, you can use this list to [un]install corresponding packages on local or remote installation.

In addition to this post, those instructions allow to get exactly the same installed packages between GNU/Linux installations.

No comments:

Post a Comment

Thank you for your visit, let's share your point of view: