That’s a small trick I just worked out for the following situation:
Say you have an existing package at OBS and want to change something about its build. But it’s using using a _service
file getting the sources via tar_git
), so by making a fork or copy you won’t be able to alter the .spec
file.
But for some reason you can’t or don’t want to fork the whole original packaging repo just now.
The OBS linking feature to the rescue.
- Create a new package
example-orig
in your project (or branch the original package). Here we just copy it:
osc copypac original:project example home:me example-orig
- for that new package, disable building, publishing, … so we don’t clog the OBS workers for stuff we don’t need. This package is just the template we start our work from.
<package name="example-orig" project="home:me">
<title/>
<description/>
<build>
<disable/>
</build>
<publish>
<disable/>
</publish>
<useforbuild>
<disable/>
</useforbuild>
</package>
- Create a second empty package
example-dev
. In its empty directory, create file called_link
<link project="home:me" package="example-orig">
<patches>
</patches>
</link>
and commit (osc add _link; osc ci
) it to OBS.
- Now here comes the magic:
tar_git
creates files like_service:tar_git:example.spec
that you can’ really manipulate. We want a copy of that file we can edit, and create adiff
patch from it. So in the local package dir:
mkdir a
osc cat _service:tar_git:example.spec > a/_service:tar_git:example.spec
cp -r a b
- Edit
b/_service:tar_git:example.spec
to your liking, and when done create a patch from it:
diff -u a b > spec.patch
osc add spec.patch
- We use the
apply
feature of OBS linking to add a patch to the package that is applied before the build process starts. Edit the_link
file:
<link project="home:me" package="example-orig">
<patches>
<apply name="spec.patch" />
</patches>
</link>
- … and done. Commit your changes:
osc ci _link spec.patch
and watch OBS happily building your changed version.
At this point, continue in a similar manner in case you want to change any other files from the project.
And as you have a _link
file in there, you may use the other features of linking, like <topadd>
for small changes to .spec files
, and <add>
to include patches to the sources (as opposed to the OBS package).
See the small guide from OpenSuSE for these.
Hope this (admittedly corner case) hack/trick is useful for someone, feel free to point out a better method if you know of any.