howto: repack RPM for nicer name or add extra files

  • 17 February 2021
  • 2 replies



here is my steps how to change name of rpm custom packer be default it is custom-linux.Instance001. You can change it as Commvault.Instance001 but still it is not standard for Linux world.


Prepare two session on machine where you will build classic rpm package.

2nd session go to path where you will have stagging folder and run this command:

while true; do find . -name \*.spec -exec cp {} . \;;done

1st session run normal wizard for create custom rpm package use stagginf folder where you are standing in 2nd session. After successul create package on this sesssion you should find spec file in current folder of second session. Just press CTRL-C for quit from loop.

Now we have spec file and rpm package.

Exact package like this:

cd ~/extracted_rpm

rpm2cpio commvault.rpm | cpio -idmv

prepare environment for rpmbuilder

mkdir rpmbuild

cd rpmbuild


cp /path_to/file.spec SPECS

create file ~/.rpmmacros with this content:

%_topdir /full_path_to/rpmbuild

%__prelink_undo_cmd /bin/cat cat library

%_smp_mflags -j3

%__arch_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot

Now you can add more files to file structure in ~/extracted_rpm/opt/commvault

and you can modify spec file.


Name: commvault.Instance001


Summary: Commvault file system agent package - decoupled mode

Name: commvault

or add/change anything else there.

You have to modified section %prep to this:

mkdir -p %{buildroot}/

cp -pR ~/extracted_rpm/* %{buildroot}/ #linux

cp -prh ~/extracted_rpm/* %{buildroot}/ #AIX

Now rpm structure and modification are ready to create new your rpm custome package. Run these commands to create package:

cd ~/rpmbuild

rpmbuild --buildroot=$PWD/BUILD -ba SPECS/commvault_linux-x8664.spec # Linux

rpmbuild --buildroot=$PWD/BUILD -ba SPECS/commvault_aix-ppc.spec # AIX


rpmbuild --buildroot=$PWD/BUILD -ba SPECS/Commvault_linux-x8664.spec --define 'dist .el6'

rpmbuild --buildroot=$PWD/BUILD -ba SPECS/Commvault_linux-x8664.spec --define 'dist .el7'

This will create rpm package under folder RPMS. You can check result by command:

find . -name \*rpm -exec echo rpm -qip {} \;

Recommendation is build package for specific distribution o this distribution.

  • aix 7 on aix 7etc

Any feedback is welcome.

Thank you

Filip Hasa

2 replies

Userlevel 3
Badge +7

Tnx for this

Userlevel 5
Badge +10

Awesome! thank you