Build source rpms with Mock to avoid compiler problems

Are you building source rpms with rpmbuild? If you’ve ever run into a dreaded configure problem such as
|
1 |
C compiler cannot create executables |
and gotten lost in a tangle of glibc/cc/g++ packages, you might find that building source rpms using Mock turns a multi-step process into a breezy single step.
32-bit package compiling on 64-bit architecture isn’t the piece of cake some people make it out to be. It’s not always as easy as installing the proper glibc and moving on.
checking for C compiler default output file name…
configure: error: in/rpmbuild/BUILD/freetype-2.3.11/builds/unix':config.log’ for more details.
configure: error: C compiler cannot create executables
See
make: *** [setup] Error 77
error: Bad exit status from /var/tmp/rpm-tmp.OUa7dO (%build)
If you’re building from a Fedora platform, you can easily build using all the proper packages for the target Fedora release using mock because they include a slew of configurations to choose from right out of the box. If you’re using another distribution, mock may come preloaded for you too.
Lets look at freetype-2.3.11-7.fc12.src.rpm for example. Fedora releases this package with a few important flags missing:
|
1 2 |
--with bytecode_interpreter --with subpixel_rendering |
to avoid some patent issues. Building this package on x86_64 for the x86_64 platform is no problem. You can just call “rpmbuild -ba freetype-2.3.11-7.fc12.src.rpm” and it all works. But adding the “–target i386″ causes maximum chaos for me.
My solution is to use mock.
And it’s as easy as calling mock with the source rpm and the configuration file to use. I don’t even have to install the source rpm before hand!
~$ mock freetype-2.3.11-7.fc12.src.rpm -r fedora-12-i386
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
INFO: mock.py version 1.0.11 starting... State Changed: init plugins INFO: selinux disabled State Changed: start INFO: Start(freetype-2.3.11-7.fc12.src.rpm) Config(fedora-12-i386) State Changed: lock buildroot State Changed: clean State Changed: init State Changed: lock buildroot Mock Version: 1.0.11 INFO: Mock Version: 1.0.11 INFO: enabled root cache INFO: enabled yum cache State Changed: cleaning yum metadata INFO: enabled ccache State Changed: running yum State Changed: creating cache State Changed: setup State Changed: build INFO: Done(freetype-2.3.11-7.fc12.src.rpm) Config(fedora-12-i386) 2 minutes 54 seconds INFO: Results and/or logs in: /var/lib/mock/fedora-12-i386/result |
That’s all there is to it! I ran this to create multiple versions of the freetype rpms. Now the minty fresh packages are all waiting for me in their respective /var/lib/mock/cfg/result directories.
Fedora Configurations:
~$ ls /etc/mock
epel-4-i386.cfg fedora-13-ppc64.cfg fedora-5-ppc-epel.cfg
epel-4-ppc.cfg fedora-13-ppc.cfg fedora-5-x86_64-epel.cfg
epel-4-x86_64.cfg fedora-13-s390x.cfg fedora-devel-i386.cfg
epel-5-i386.cfg fedora-13-sparc64.cfg fedora-devel-ppc64.cfg
epel-5-ppc.cfg fedora-13-sparc.cfg fedora-devel-ppc.cfg
epel-5-x86_64.cfg fedora-13-x86_64.cfg fedora-devel-x86_64.cfg
epel-6-i386.cfg fedora-14-i386.cfg fedora-rawhide-i386.cfg
epel-6-ppc64.cfg fedora-14-ppc64.cfg fedora-rawhide-ppc64.cfg
epel-6-x86_64.cfg fedora-14-ppc.cfg fedora-rawhide-ppc.cfg
fedora-12-i386.cfg fedora-14-s390x.cfg fedora-rawhide-s390x.cfg
fedora-12-ppc64.cfg fedora-14-sparc64.cfg fedora-rawhide-sparc64.cfg
fedora-12-ppc.cfg fedora-14-sparc.cfg fedora-rawhide-sparc.cfg
fedora-12-s390x.cfg fedora-14-x86_64.cfg fedora-rawhide-x86_64.cfg
fedora-12-sparc64.cfg fedora-4-i386-epel.cfg logging.ini
fedora-12-sparc.cfg fedora-4-ppc-epel.cfg site-defaults.cfg
fedora-12-x86_64.cfg fedora-4-x86_64-epel.cfg
fedora-13-i386.cfg fedora-5-i386-epel.cfg