Build source rpms with Mock to avoid compiler problems


toolbox

Are you building source rpms with rpmbuild? If you’ve ever run into a dreaded configure problem such as

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':
configure: error: C compiler cannot create executables
See
config.log’ for more details.
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:

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

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



Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">