RPM useful commands

If you wanna start to build your own RPMs I recommend this video:

https://www.youtube.com/watch?v=CTTbu_q2xiQ

Here I document some useful information you can find on the video.

Package: rpmdevtools

a serie of useful tools to help you building your RPMs.

Package: mock

a tool to help you build rpm for different architectures.

Command:  $ echo ‘%_topdir /your/directory/to/rpmbuild’ > .rpmmacros

set your rpmbuild default directory

Command: $ rpmdev-setuptree

build the tree of directories you will use build your RPMs.

Command: $ rpm –eval ‘%{__python}’

show the value of  %{__python} macro. Something like ‘/usr/bin/python’

Command: $ cd ~/RPMBUILD/SOURCES && spectool -g ../SPECS/python-dateutil.spec

download all the sources on the spec file

Command: $ rpmbuild -bp SPECS/python-dateutil.spec

runs just your %prep step. The %prep can include %setup, %patch and any command before the %build step.

Command: $ rpmbuild [short-circuit] -bc SPECS/python-dateutil.spec

with short-circuit => runs just your %build step, skipping %prep
without short-circuit => runs your %prep and then runs %build

Command: $ rpmbuild [short-circuit] -bi SPECS/python-dateutil.spec

with short-circuit => runs just your %install step, skipping %prep
without short-circuit => runs %prep, %build and then runs %install

Command: $ rpmbuild -bb SPECS/python-dateutil.spec

build the rpm your package

Command: $ rpmbuild -bs SPECS/python-dateutil.spec

build the SOURCE rpm of your package

Command: $ rpmbuild -ba SPECS/python-dateutil.spec

build both rpm package and rpm SOURCE package

Command: $ rpmbuild -ba SPECS/python-dateutil.spec

build both rpm package and rpm SOURCE package

Commands:

Initiate mock repository
$ mock -r centos-7-x86_64  –init
Install dependencies
$ mock -r centos-7-x86_64  –install …
Buid your package without clean your recently installed dependencies
$ mock -r centos-7-x86_64  –no-clean –rebuild …

Command: mock -r centos-7-x86_64  –shell

prompt a shell on the specific mock config.

PATH: /var/lib/mock/archtecture/result

logs and builded RPMs.