= Packaging recipes for OBS

== Overview

This directory holds reference NUT packaging recipes for RPM, DEB and
other formats, and is primarily aimed at automation of builds with the
link:https://openbuildservice.org/[Open Build Service (OBS)].

Note that beside the on-line service, the software is open-source and
any project may install and run their own server instance. The `osc build`
command can also be used on a workstation to iterate recipe nuances for
different distributions. In theory, back-end scripts may be added to
support more operating systems over time (even not necessarily Linux).

NOTE: The layout of files and directories here is dictated by current
expectations of the OBS software (if at some point it has to be a flat
mess with no structure -- so be it).

== Practical setup

The copy of `_service` file represents the directly maintained OBS recipe
in an OBS packaging project, and is the only file needed there (triggering
service runs updates the temporary tarball from git).

Beside that, a `_config` file in the OBS project repository or live settings
in `osc meta prjconf --edit` can be used to specify unambiguous preferences
for certain packages, when a distro actually offers a choice via conditional
`BuildRequires` statements (and other options), e.g.:

----
Prefer: libusbx-devel
Prefer: libusb-1.0-dev
Prefer: neon-devel
----

* For more details on this, see
  https://openbuildservice.org/help/manuals/obs-user-guide/cha-obs-prjconfig

A parent project must be used to define OBS Repositories we build for, which
should usually include a layer with `openSUSE:Tools` to have the OBS helper
scripts needed for package and tarball transformations in the build area,
for example: https://build.opensuse.org/projects/home:jimklimov/meta

The list of known distros and repositories massaged with these tools can be
seen at https://build.opensuse.org/repositories/openSUSE:Tools

For some historical and/or practical details see:

* https://github.com/networkupstools/nut/issues/1209

== Preinstall images

OBS builds can be sped up by use of `preinstallimage` recipes seen in the
sibling or "upstream" build dependency repositories for a built project,
if such image contains a subset of the packages that the current build
aims to use.

TODO: Document actually getting PR builds to see such prepared images.

A recipe can be generated from current `nut.spec` and `nut.dsc` files
via `make _preinstallimage` and uploaded into a dedicated package near
the `nut` package in an OBS project.

== Other notes

The recipe files themselves would likely cross-pollinate with popular
distributions, to allow easier replacement of standard, supported and
stale package builds with those of experimental development iterations.

This should be in part facilitated by the NUT Semantic Versioning scheme (see
linkdoc:developer-guide[NUT Semantic Versioning,versioning,docs/nut-versioning.adoc])
which adds version number components to expose the "age" of each such
iteration as a number of commits merged into the common development trunk
since a preceding release, and a number of commits unique to a feature
branch.

Maybe some way of pre-making a dist tarball (with `VERSION_DEFAULT`, man
pages pre-built, etc.) and using that would be better, to be explored
(ideally if we can do this within OBS).
