OSC helpers for lazy packagers


#1

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() {
  pkg_dir=$1
  shift
  repo=$1
  shift
  osc build -x vim -k ../rpms/$pkg_dir -p ../rpms/$pkg_dir $repo x86_64 $@
}

ob-42.3() {
  osc_build 42.3 openSUSE_Leap_42.3 $@
}

ob-42.2() {
  osc_build 42.2 openSUSE_Leap_42.2 $@
}

ob-42.1() {
  osc_build 42.1 openSUSE_Leap_42.1 $@
}

ob-13.2() {
  osc_build 13.2 openSUSE_13.2 $@
}

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-42.2 --with=somefeature

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 will show you the full spec file with everything expanded for the specific distribution.