OSC helpers for lazy packagers

Posted on Feb 3, 2017

If you ever discussed packaging in person with me, you might have noticed i normally don’t call “osc build” but a little shell thingie. The reason is i don’t want to maintain a long command line all the time.

So in my shell RC file i have the following:

osc_build() {
  osc build -x vim -k ../rpms/$pkg_dir -p ../rpms/$pkg_dir $repo x86_64 $@

ob-15.1() {
  osc_build 15.1 openSUSE_Leap_15.1 $@

ob-15.2() {
  osc_build 15.0 openSUSE_Leap_15.0 $@

ob-tw() {
  osc_build tw openSUSE_Tumbleweed $@
ob-twf() {
  osc_build tw openSUSE_Factory $@
-x vim

So i can edit inside the build environment. There is actually really a nice helper to get into the build env:

osc chroot <repos> <arch>

But back to the command line:

-k ../rpms/$pkg_dir -p ../rpms/$pkg_dir

the “-k” part is “keep built rpms in this directory” and the “-p” part is “prefer packages from this directory”. This is especially useful if you built a stack of packages, which depend on each other.

Important note: You should regulary clean up those directories. So you don’t use stale/older packages after a while.

If you need more custom osc options you can pass them:

$ ob-15.2 --with=somefeature

If you only need rebuild your local package without any changes to your buildinfo or buildroot you can use:

$ ob-15.2 --offline --no-init

And while we are at it ….

If you are in the build chroot you can also do things like

rpm --eval '%{_tmppath}'

This shows you to what a certain rpm variable/macro expands to. And of course we can do something like

$ cd rpmbuild/SOURCES/
$ rpm --eval "$(< *spec)"

This doesn’t evaluate all macros recursively. To do that we will need:

$ cd rpmbuild/SOURCES/
$ rpmspec -P *spec

This will show you the full spec file with everything expanded for the specific distribution.