Hello!

I have updated the yast2-schema package to use the multibuild [1] OBS feature.
This allows building multiple binary packages from the same sources.

The reason is that OBS is switching the backend VCS system to Git [2]
and it cannot support the OBS links which are usually used for building
multiple packages.

The yast2-schema sources builds two binary packages: yast2-schema-default
(with the full schema) and yast2-schema-micro (with schema subset
used for "micro" products installer with limited functionality).


OBS Multibuild
--------------

Multibuild in OBS can be use in two ways:

- Separate .spec file for each package (we already use it in libyui [3])
- Single .spec file with %if conditions which modify the build process
  for each multibuild flavor

For yast2-schema I used the second approach because the yast2-schema-default
and the yast2-schema-micro are very similar, the only difference is that the
"micro" package has less build dependencies, the rest is the same.

So I merged  yast2-schema-default.spec and yast2-schema-micro.spec files
into a single yast2-schema.spec file. This makes also maintenance much easier
as it avoids duplicates and inconsistencies.

You can find more details and an example of using multibuild
in a presentation by Max [4].

Building the Package Locally
----------------------------

For building a multibuild package locally using "osc" you need to use
the "-M" option with the name of the multibuild flavor you want to build.
In YaST we usually use the Rake "osc:build" task for building. Fortunately
it accepts additional parameters which are passed to the "osc" tool.

So for building the yast2-schema-micro package run this command:

  rake "osc:build[-M micro]"


Adapting CI
-----------

Obviously modifying the packaging also affects the related tasks like CI
or package submission process.

In GitHub Action we basically run simple "rpmbuild *.spec" which
unfortunately does not support multibuild packages. The workaround
is to manually generate a separate .spec file for each multibuild flavor.
See [5] for more details.


Adapting Jenkins Jobs
---------------------

The "rake osc:sr" command works fine with a multibuild package, it correctly
submits the package to the target OBS project. However, it only builds the
package for one empty ("") multibuild flavor.

The workaround is to explicitly build all multibuild flavors before the
package submission:

  rake "osc:build[-M default]" && rake "osc:build[-M micro]" && rake osc:sr

So the package is submitted only if all flavors are successfully built.


Notes
-----

So far we use multibuild only in one YaST package, when we use it more
we could update some tools or scripts to handle multibuild better
without that manual workarounds described above. I think currently it
does not pay off to add more logic just because of a single package.

Also keep in mind that in theory there might be "sle", "leap" or "tumbleweed"
flavors designed just for a specific product. In that case building all flavors
unconditionally might not be a good idea as the build might even fail if
running against an incorrect target. So it depends on the future use cases...





Ladislav



[1] 
https://openbuildservice.org/help/manuals/obs-user-guide/cha.obs.multibuild.html
[2] https://bugzilla.suse.com/show_bug.cgi?id=1211319
[3] https://github.com/libyui/libyui/tree/master/package
[4] https://www.slideshare.net/suselab/convert-your-package-to-multibuild-on-open-build-service [5] https://github.com/yast/yast-schema/blob/f6e28741a7a178f24ba4fff23c4a06e83950c340/.github/workflows/ci.yml#L33-L48


--
Ladislav Slezák
YaST Developer

SUSE LINUX, s.r.o.
Corso IIa
Křižíkova 148/34
18600 Praha 8

Reply via email to