- February 5th, 2009
- Write comment
We often told that building an RPM as root is a bad thing. While this is very true, how do you build it as a normal user?
The trick is to use rpmdev-setuptree. This will create a empty build tree in ~/rpmbuild as well as sort out you .rpmmacro file so rpmbuild knows to use it.
It’s really simple actually, so here goes.
- As root, install rpm-build, rpmdevtools and yum-utils.
yum -y install rpm-build rpmdevtools yum-utils
- Now as a user, create a rpmbuild tree:
- Now as a user, download your RPM source:
yumdownloader -source sox
- Again as a normal user, install the source rpm
rpm -ivh <rpm>.src.rpm
- Go in to ~/rpmbuild and make whatever changes you need to. The Spec file will be in ~/rpmbuild/SPECS and the source will be gzipped in ~/rpmbuild/SOURCES
- Now build it!
rpmbuild -ba ~/rpmbuild/SPECS/<spec file>
- Assuming everything went OK, the RPMs will be in ~/rpmbuild/RPMS/, but you’ll need to install them as root.
- If you find your rpmbuild is getting full of crap, you can either delete it and rebuild it, or a slightly more elegant way would be to use