I have an RPM that we install on our production systems that I would like to modify so that that the OS installer does not have to make any changes to the system after installation. The distro is pretty old (and sadly we cannot update it to a newer one) - Fedora 11.

Is there a method for me to be able to unpack the RPM, change the file, and then repack it?

Other solutions I have seen make reference to utilities "mock" and "mc" which I do not have.

  • 2
    Fedora 11 is 7 years after EOL. Update to something up-to-date to receive some support. – Jakuje May 16 '17 at 9:14

If the rpm package, you want to unpack, is for Fedora 11 or older, the Fedora 11 {rpm, rpm2cpio} can extract the file with e.g. unPack_rpm.sh :

# Purpose: Unpack RPM archives (by @unSpawn)
# Args: /path/to/archive
# Deps: Bash, GNU utils, RPM
rpmDetails() { for Q in changelog provides requires scripts triggers triggerscripts; do 
 rpm -q -p --${Q} "${f}" 2>&1 | grep -v NOKEY > "${Q}.log"; done; }
rpmUnpack() { f=$(readlink -f "${f}"); file "${f}"|grep -q "RPM.v" && \
 { d=$(basename "${f}" .rpm); d="./${d:=ERROR_$$}"; mkdir -p "${d}" && \
 { cd "${d}" && rpm2cpio "${f}" | cpio -idmv && rpmDetails "${f}"; }; }; }
for f in $@; do rpmUnpack "${f}"; done
exit 0

When you have edited the unpacked files, copy the top directory/directories to BUILDROOT/ . When/if rpmbuild -bb name.spec reports "not found", create the folder with the app name asked for inside BUILDROOT/, and copy your files there. And run rpmbuild -bb name.spec again.

My recommended rpmbuild setup : http://www.linuxquestions.org/questions/linux-software-2/need-rpm-package-for-php-version-5-2-7-and-up-on-redhat-5-1-a-766486/#13

  • Thanks, this is quite useful. However, I have a further question: once unpacked, I can modify the file I want to change. Is it just a case of copying the sources (in their directories) to the rpmbuild/SOURCES directory, and then creating/getting a spec file and placing into rpmbuild/SPECS before running the rpmbuild command. Or is there something else I need to do? – B. SAUNDERS May 16 '17 at 14:50
  • Not source. The files can actually be copied to any new folder. Or to BUILDROOT/ . See my edited answer. – Knud Larsen May 16 '17 at 16:08

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.