0

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.

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

1 Answer 1

0

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 :

#!/bin/bash
# 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

2
  • 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? May 16, 2017 at 14:50
  • Not source. The files can actually be copied to any new folder. Or to BUILDROOT/ . See my edited answer. May 16, 2017 at 16:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .