SUSE Blog

OSC Helpers for Lazy Packagers

chabowski

By: chabowski

July 26, 2017 4:26 am

Reads:1,893

Comments:1

Score:5

Print/PDF

The following article has been contributed by Marcus “Darix” Rückert, Senior Software Engineer in the Operations & Services Team at SUSE. It first appeared on his personal homepage.

 

OSC, the openSUSE Commander, is the Command Line Interface that lets you work with the Open Build Service.

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 provide 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

Now I can make edits inside the build environment. There is actually a really nice helper to get into the build environment:

osc chroot <repos> <arch>

But back to the command line:

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

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

Important note: You should regularly clean up those directories. This prevents you from using stale or older packages after a while.

If you need more custom “osc” options you can pass them on:

$ 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 you 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.

That’s it 😁!

 

1 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 51 vote, average: 5.00 out of 5 (1 votes, average: 5.00 out of 5)
You need to be a registered member to rate this post.
Loading...

Tags: , , , , , , , ,
Categories: SUSE News, Technical Solutions

Disclaimer: As with everything else in the SUSE Blog, this content is definitely not supported by SUSE (so don't even think of calling Support if you try something and it blows up).  It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.

1 Comment

  1. By:okurz

    wow, these were really a lot of helpful hints. Thanks!

Comment

RSS