To unpack the contents of an SRPM, make changes, then re-package it, follow the below steps
1) Install rpmbuild
yum install rpmbuild
2) Install the srpm
rpm -ivh http://server/package-1.0.1.src.rpm
-
This will install
- source into ~/rpmbuild/SOURCE/package-1.0.1.tar.gz
- Spec file into ~/rpmbuild/SPEC/package-1.0.1.spec
3) Unpack the tarball
cd ~/rpmbuild/SOURCE/
tar -zxf package1.0.1.tar.gz
(this will unpack to a directory with the same name, i.e. {package})
4) Edit the contents
(e.g. update the included file, add a new file, etc)
5) Re-package the files
cd ~/rpmbuild/SOURCE/
mv {package}.tar.gz package-1.0.1.tar.gz.original
tar -czf package-1.0.1.tar.gz package-1.0.1
6) Update the spec file
- Ensure the version is incremented (at least the minor number)
- Ensure some commentary is applied to the changelog, the format must be matched precisely (asterisk, space, date, author, version, then next line hyphen, comments)
7) Build the RPM
rpmbuild -ba ~/rpmbuild/SPEC/package.spec --target=noarch
- the --target is optional, but if you’re building an architecture-independent version, this is needed in some systems otherwise it will fail
- -ba will build both an SRPM and the RPM. Recommended to ensure flexibility later when changing RPM contents
8) Upload the resulting RPM and SRPM
Files are in
- ~/rpmbuild/SRPMS/package-1.0.1-1.src.rpm
- ~/rpmbuild/RPMS/package-1.0.1-1.rpm
scp them to the desired web server.