Is there a way to extract an installed RPM from an RPM database on Red Hat Enterprise Linux to reproduce the original .rpm file?
- 41,734
- 35
- 103
- 130
- 209
- 1
- 2
- 6
-
Why was this title modified? Red Hat is the name of the software not **RedcHat** – Ramhound Dec 13 '18 at 01:40
2 Answers
If you want to save a copy of the package as currently installed before upgrading or removing it, use rpm --repackage -- it'll save the RPMs in /var/tmp or /var/spool/repackage or elsewhere, depending on your configuration.
Otherwise, there exists rpmrebuild, which does exactly what you ask for.
Word of caution: with neither of these tools do you obtain the exact same *.rpm as the one you started from. Any changes to the installed files belong to the package will be in the RPMs generated.
- 24,884
- 4
- 30
- 20
-
1I believe it's worthwhile to note that `rpm --repackage` will `Re-package the files before erasing` http://www.rpm.org/max-rpm-snapshot/rpm.8.html I almost ran this command blindly, but looked at the linked docs first. – Kevin Meredith May 31 '13 at 12:25
-
2`rpm --repackage` doesn't appear to be available on newer (e.g., RHEL 7) systems. `rpmrebuild` is available in the EPEL for RHEL 7 and did the trick for me. – jayhendren Dec 28 '17 at 19:54
Producing the original rpm file isn't possible, it's been extracted and possibly discarded. The rpm database has information about what files it's installed and their checksums, permissions, and the postinst scripts:
# verify package contents
rpm -q packagename --verify
# read the scripts that run on installation and removal
rpm -q packagename --scripts
will give you some information.
If you want to obtain an rpm from the respository, I recommend using yumdownloader, from the yum-utils package.
yum install yum-utils
yumdownloader packagename
This will download the latest rpm, not the one that is installed currently.