rpmbuild


 2020-11-20 2 minute read 0 Comments improve this post #command line | #linux

Summary

To build an rpm, the following packages need to be installed:

# yum install rpm-build rpmdevtools libpcap-devel

Once the packages are installed:

# rpmdev-setuptree

The above command will create an rpmbuild folder in your home director that will have 5 other directories in it (BUILD, RPMS, SOURCES, SPECS, and SRPMS). This is where the rpm building magic will happen.

The process to build an rpm is as follows:

  1. Download source package
  2. Extract the .spec file
  3. Put the tared source into the SOURCES folder
  4. Put the .spec file in the SPECS folder
  5. Then, run the below command:
# rpmbuild -ba <program>.spec
 
# rpmbuild --define "_topdir `pwd`" -ba SPECS/project.spec # RHEL5

If a spec file is not found, it is possible to create one; and luckily, a template can be generated to help with getting started.

To create a template run the below command:

# rpmdev-newspec <spec file name>

Once you have the spec file created, run the below command to attempt to build and fix any errors:

# rpmbuild -ba <spec file name>

Building an rpm from a src rpm

These are just great… if done correctly.

# yum install rpm-build rpmdevtools libpcap-devel
# rpmdev-setuptree

The above will need to be complete first, but then…

# rpmbuild --rebuild <package>.src.rpm

The above will create an RPM located in the rpmbuild folder for you to install! To install the rpm package, use the rpm command.

Other references:

Referenced commands: rpm


 Categories: #linux


Tech tips and command line fu found within this dojo

 2023