Product SiteDocumentation Site

6.3. Saving Old Packages

When installing, removing, or upgrading, you can use the --repackage command-line option to save a version of something like the old package to a file, making a backup of the older package contents.
Warning
The package created by the --repackage option is not a complete RPM package. You can use the rpmbuild command to make it into a complete package, but by itself, it will not be a complete package. See Chapter 9, Working with Spec Files, Chapter 10, Advanced RPM Packaging, and Chapter 11, Controlling the Build with rpmbuild for more on building packages.
You can later reinstall the old files, once they have been made into a complete package. This can be quite useful if something goes wrong or the upgraded package has bugs. You can fall back to the old package if needed.
By default, the --repackage option puts the old package in the /var/spool/repackage directory. Other common directories are /var/spool/up2date or /var/tmp. Your RPM configuration determines the directory used by this option.
Note
The up2date name comes from the Red Hat service for keeping a system up to date with regard to package versions.
For example, say you have a package, jikes (a Java programming language compiler used in previous examples) that you want to upgrade. But you are worried that the new version may not work properly.
First, check the version you have. For example:
# rpm -q jikes
jikes-1.14-1
This shows you are at version 1.14 of the jikes Java compiler. You can then upgrade to version 1.17 while repackaging the old version, as shown following:
# rpm -Uhv --repackage jikes-1.17-glibc2.2-1.i386.rpm
Preparing... ########################################### [100%]
Repackaging...
1:jikes ########################################### [100%]
Upgrading...
1:jikes ########################################### [100%]
This upgrade has kept a copy of the old package in the /var/spool/repackage directory. You can verify this with the following command:
$ ls -l /var/spool/repackage/
total 692
-rw-r--r-- 1 root root 703037 Oct 25 18:49 jikes-1.14-1.i386.rpm
You can see a version of the old package, with the old version number.
Warning
This is not the same as the original package. This is not a complete package.
The repackaged RPM contains a snapshot of the package’s files as they were on your hard disk, not as they were when you originally installed the package. Thus, the contents may differ if the files have changed on your hard disk. In addition, the --repackage option may not properly sign the package as the original was.
In addition to the --repackage option with the rpm command, you can use a free tool called rpmrebuild to make snapshots of any installed packages.
Written by Eric Gerbier, rpmrebuild allows you to create an RPM from the installed, and perhaps modified, version of a package. You don’t have to upgrade, remove, or install a new package, as you do with the --repackage option.
Download rpmrebuild from http://rpmrebuild.sourceforge.net/.