PDA

View Full Version : Fun with rpm and rpmbuild



enclair
10th February 2014, 11:54 PM
It is possible to install from a source RPM, without being root (almost), and without breaking his system.
But it does not work with all packages and we cannot track easily the dependencies, still it may be easier than a manual compilation.

The first step is to create a new rpm database (we need to do it only once).


$ mkdir -p ~/rpmrebuild/var/lib
$ rpmdb --initdb --dbpath ~/rpmrebuild/var/lib/rpm

Then two small scripts, let's call them myrpmbuild and myrpm.


#!/bin/sh

basedir=~/rpmrebuild

rpmbuild "$@" \
--define "_datadir $basedir/share" \
--define "_sysconfdir $basedir/etc" \
--define "_infodir $basedir/share/info" \
--define "_bindir $basedir/bin" \
--define "_mandir $basedir/share/man" \
--define "_defaultdocdir $basedir/share/doc" \
--define "_prefix $basedir" \
--define "_libexecdir $basedir/libexec" \
--define "_exec_prefix $basedir" \
--define "_sbindir $basedir/sbin" \
--define "_includedir $basedir/include" \
--define "_libdir $basedir/lib" \
--define "_localstatedir $basedir/var"


#!/bin/sh

basedir=~/rpmrebuild

rpm --dbpath "$basedir/var/lib/rpm" "$@"

We need to download the source RPM and install its build dependencies (as root this time).

$ yumdownloader --source nano --enablerepo=rawhide # useless since in rawhide and f20 they are the same
# su -c "yum-builddep nano"

Then we build it

$ myrpmbuild --rebuild nano-2.3.2-4.fc20.src.rpm

And we install it

$ myrpm -Uvh nano-2.3.2-4.fc20.x86_64.rpm --nodeps

That's it.

$ ~/rpmrebuild/bin/nano -V
GNU nano version 2.3.2 (compiled 22:40:57, Feb 10 2014)

leigh123linux
11th February 2014, 12:19 AM
I don't understand the propose of this guide :confused:

enclair
11th February 2014, 12:54 AM
I don't understand the propose of this guide :confused:

Just thought it could be useful if you need a package which is in rawhide but not in the release, and that you don't want to mess your installation.

hakova
11th February 2014, 05:38 PM
Please excuse my ignorance but can something similar be done with the source obtained from say sourceforge rather than source rpm? Would it be even harder to figure out the dependencies?

Thanks.

leigh123linux
11th February 2014, 06:29 PM
Just thought it could be useful if you need a package which is in rawhide but not in the release, and that you don't want to mess your installation.


I use mock or the koji build server to avoid that.

enclair
11th February 2014, 07:21 PM
Please excuse my ignorance but can something similar be done with the source obtained from say sourceforge rather than source rpm? Would it be even harder to figure out the dependencies?

Thanks.

If the software use autoconf you can use:
./configure --prefix=/where/to/install && make && make install
For the dependencies it's harder yes.


I use mock or the koji build server to avoid that.

Can you explain?

leigh123linux
11th February 2014, 07:56 PM
yum info mock
Loaded plugins: langpacks, merge-conf, refresh-packagekit, remove-with-leaves
Installed Packages
Name : mock
Arch : noarch
Version : 1.1.36
Release : 1.fc20
Size : 664 k
Repo : installed
From repo : updates
Summary : Builds packages inside chroots
URL : http://fedoraproject.org/wiki/Projects/Mock
Licence : GPLv2+
Description : Mock takes an SRPM and builds it in a chroot


http://fedoraproject.org/wiki/Projects/Mock

and

https://fedoraproject.org/wiki/Using_the_Koji_build_system?rd=PackageMaintainers/UsingKoji#Using_Koji_in_Fedora


You don't need to be an official packager, only requirement is a FAS account.

https://admin.fedoraproject.org/accounts/user/new



.

enclair
11th February 2014, 08:25 PM
It will build inside a chroot or on koji but I'm not sure you can install a package outside of /usr then.

enclair
2nd March 2014, 11:40 AM
Another way to run rawhide applications without recompiling:
http://mizdebsk.fedorapeople.org/blog/eclipse-chroot/