Three people have asked me about this, so here goes. You will need a RHEL or CentOS 7.1 machine (perhaps a VM), and you may need to grab extra packages from this preview repository. The preview repo will go away when we release 7.2, but then again 7.2 should contain all the packages you need.
You’ll need to install
rpm-build. You could also install
mock (from EPEL), but in fact you don’t need mock to build libguestfs and it may be easier and faster without.
Please don’t build libguestfs as root. It’s not necessary to build (any) packages as root, and can even be dangerous.
Grab the source RPM. The latest at time of writing is libguestfs-1.28.1-1.55.el7.src.rpm. When 7.2 comes out, you’ll be able to get the source RPM using this command:
yumdownloader --source libguestfs
I find it helpful to build RPMs in my home directory, and also to disable the libguestfs tests. To do that, I have a
~/.rpmmacros file that contains:
%_topdir %(echo $HOME)/rpmbuild
You may wish to adjust
%_smp_mflags. A good value to choose is 1 + the number of cores on your machine.
I’ll assume at this point that the reason you want to rebuild libguestfs is to apply a patch (otherwise why aren’t you using the binaries we supply?), so first let’s unpack the source tree. Note I am running this command as non-root:
rpm -i libguestfs-1.28.1-1.55.el7.src.rpm
If you set up
~/.rpmmacros as above then the sources should be unpacked under
Take a look at least at the
libguestfs.spec file. You may wish to modify it now to add any patches you need (add the patch files to the
SOURCES/ subdirectory). You might also want to modify the
Release: tag so that your package doesn’t conflict with the official package.
You might also need to install build dependencies. This command should be run as root since it needs to install packages, and also note that you may need packages from the repo linked above.
Now you can rebuild libguestfs (non-root!):
rpmbuild -ba libguestfs.spec
With the tests disabled, on decent hardware, that should take about 10 minutes.
The final binary packages will end up in
~/rpmbuild/RPMS/ and can be installed as normal:
yum localupdate x86_64/*.rpm noarch/*.rpm
You might see errors during the build phase. If they aren’t fatal, you can ignore them, but if the build fails then post the complete log to our mailing list (you don’t need to subscribe) so we can help you out.