Tuesday, August 14, 2012

Debugging Fedora builds with mock

The problem that every build engineer faces sooner or later is: what packages introduces dependency to foo to our build?

The commonly used build tool amongst Fedora packages is fedpkg, which allow for building a package in a mocked configuration, without need to install any unwanted packages.

fedpkg mockbuild creates a mock system, install everything what's needed there, and performs a build. Then deletes the mock location afterwards.

What should you do if your build has unwanted dependencies?

Abandon fedpkg in favour of mock command.

The typicall build command may then look like:
mock --no-cleanup-after --rebuild $SRPM --resultdir=$RESULT -r fedora-rawhide-x86_64 

where --no-clean-after option means that mock will not delete anything after the build. This allows us for calling:
mock -r fedora-rawhide-x86_64 --shell 
, which will open a shell that runs inside our mock system. At this point we can use regular rpm to find what packages require "foo".
rpm -q --whatrequires foo

It's that simple!

No comments:

Post a Comment