Commit Graph

98 Commits

Author SHA1 Message Date
Oliver Smith 57a9e54524 obs: put git submodules into source packages
We started using git submodules with osmo-trx. Adjust the obs scripts
to actually make the git submodules part of the source packages.

Note that this didn't fail in jenkins before with the rpm build
verification, as jenkins updates git submodules on its own.

Fix for:
[  165s] Makefile.am:32: error: required directory ./osmocom-bb/src/host/trxcon does not exist

Change-Id: I51b423f3885d6ead5c21a83bdf8ef6051dc34fe3
2022-12-23 15:10:19 +01:00
Oliver Smith 4fe56c0968 obs: build_deb/rpm: show contents after build
After building packages with the OBS scripts, show their contents. This
allows easy checking if config files were correctly packaged etc. By
adding it here, it will also show up at the end of the related jenkins
jobs for gerrit verifications.

Related: OS#5817
Change-Id: Ie30b07f35f7e41990fa352523427d86458291d4d
2022-12-08 15:42:59 +01:00
Oliver Smith 1263d6e0b9 obs/srcpkg: open5gs: download all subprojects
With recent changes in open5gs, building the source packages we
generated fails:
[   45s] ../lib/metrics/meson.build:52:4: ERROR: Automatic wrap-based subproject downloading is disabled
[   45s] dh_auto_configure: error: cd obj-x86_64-linux-gnu && LC_ALL=C.UTF-8 meson .. --wrap-mode=nodownload --buildtype=plain --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=lib/x86_64-linux-gnu --libexecdir=lib/x86_64-linux-gnu returned exit code 1

Fix this by downloading all subprojects. This is now possible as I added
a meson.build file to the prometheus-client-c repository that open5gs
uses: https://github.com/open5gs/prometheus-client-c/pull/2

Change-Id: If3910b520382b177a77b216c93771ea88414723d
2022-11-21 16:48:35 +01:00
Oliver Smith 288fa2d51e obs: check_builders: at least 10, fail on error
The number of builders connected to the OBS server seems to fluctuate a
bit (used to be 14, then 17 now 16). Make sure that we have at least 10
builders connected. Fix that the test didn't exit with 1 on error.

Related: https://obs.osmocom.org/monitor
Change-Id: Iedd506601a5450550e21bf701309b4ea79a3d897
2022-11-04 15:08:00 +00:00
Oliver Smith 8d7596a311 obs: build_binpkg: add --run-shell-on-error arg
Allow easy inspection of the build dir inside docker on error.

Related: OS#5737
Change-Id: I218c3189d36d24c64cbd7b9eab379aff8ce2bee2
2022-11-03 13:01:43 +01:00
Oliver Smith 13b76cced1 obs: fix building rpms with man pages
Add the "%ext_man .gz" macro from OBS, so building rpms with man pages
does not fail with errors like:
  File not found: /home/user/rpmbuild/BUILDROOT/osmo-ggsn-1.9.0.3.0d3b-0.x86_64/usr/share/man/man8/osmo-ggsn.8

Fixes: OS#5737
Change-Id: Ib6950fb46e9f94aabae98021b215f69838557045
2022-11-03 12:22:45 +01:00
Oliver Smith f52c26a695 jobs: add osmocom-obs-check-builders
Add a job that checks if the amount of connected builders to the OBS
server matches what we expect. This should prevent what we had today,
that it only was noticed by chance several days after all builders
failed to connect and the packages were outdated since then.

I'm not sure if there is a proper api to do this check, but I don't
expect the string we check for to change often so this should work fine.

Change-Id: I6e7c1f206551722d6bfe1631b9c1da8d34d85ba8
2022-10-26 08:35:05 +00:00
Oliver Smith 5be9a7442b obs: fix master rpm repository description
Instead of having the description of the nightly repository (copy paste
error), put in "osmocom:master". This gets printed a few times in the
log of the gerrit-binpkgs-rpm jenkins job and may lead to confusion -
the nightly repository is not used, it's a separate master repository.

Related: OS#2385
Change-Id: Ia5a88b064da66d7bf5cebe910961f752262b1bac
2022-10-19 10:46:11 +02:00
Oliver Smith 9c2e2575a9 obs: support Osmocom projects without prefix
Allow running build_srcpkg.py with "osmo_dia2gsup" instead of
"erlang/osmo_dia2gsup", because that's how it gets passed along from
jobs/gerrit-verifications.yml for the binary package build
verifications.

Related: OS#2385
Change-Id: I09304b219e7002495bd3fcce61bc68c34d5ffcd8
2022-10-11 12:07:40 +02:00
Oliver Smith d0ef24c3c6 obs: config: update note about testing packages
Related: OS#2385
Change-Id: If6d772052ca64ef93536bf8729a72271f67fbecb
2022-10-11 12:07:40 +02:00
Oliver Smith 38109f8429 obs/README: add overview with build_binpkg.py
Related: OS#2385
Change-Id: I1b741ad325e6541e6d59dfd50de66bee805e56fe
2022-10-11 12:07:40 +02:00
Oliver Smith 7614916a72 obs: build_binpkg: use almalinux:8 naming
Instead of using "--docker centos:8" as argument and translating it
later on in the code to use "almalinux:8" as base distribution, use
"--docker almalinux:8" as argument. It was brought up in code review
that this makes it less confusing.

Related: OS#2385
Change-Id: Id8298e8bafe065010f7bc00f1ff261aa6431ed4c
2022-10-11 12:07:40 +02:00
Oliver Smith c449c5de8d obs: build_binpkg: optimize osmo-gsm-manuals-dev
Installing osmo-gsm-manuals-dev plus depends takes a long time. Don't do
this for every build, instead do it once when building a second docker
container and then use that.

Related: OS#2385
Change-Id: I8475bd954352b572197795ad4cd9461e39896d48
2022-10-06 09:45:02 +02:00
Oliver Smith 6298cbbe0f obs: build_binpkg: debian: don't install manpages
Configure dpkg to not extract man pages. Otherwise it will spend some
time regenerating the man page index whenever installing build
dependencies before starting to build a package.

Related: OS#2385
Change-Id: I1c9e3883b976e023c96dfd59eb147770f7ad99a7
2022-10-06 09:45:02 +02:00
Oliver Smith 449dae8c13 obs: add build_binpkg.py
Add a script to build deb/rpm packages, as it would be done on
obs.osmocom.org. This will be used by jenkins to verify deb and rpm
builds for each submitted gerrit patch.

I have attempted to use 'osc build' instead of directly calling
apt-get build-dep and dpkg-buildpackage (and rpm equivalents). Using
'osc build' would have the advantage that the build works as close to
the OBS build as possible. However it would try to install dependencies
with sudo, so we would need to have sudo available in the docker
container that builds the untrusted code from gerrit. Let's not do that.

Related: OS#2385
Change-Id: I4c6b5d61af35df98cbc70d9ddc8ad36d38a9ce18
2022-10-06 09:45:02 +02:00
Oliver Smith d423d17e07 obs: lib.docker: fix redundant get_image_name()
Related: OS#2385
Change-Id: Ifa4e316db63c1a3bb9e0d845e7f755d04cf1297e
2022-10-06 09:45:02 +02:00
Oliver Smith 1816b47606 obs: run_in_docker_and_exit: no os.path.basename
Don't use os.path.basename on the script_path parameter passed to the
function. A future patch will pass a script that is inside the data
subdirectory to this function, therefore this is needed.

Related: OS#2385
Change-Id: Ide78d976f9af445c4c8d8748bc274d7289064769
2022-10-06 07:44:31 +00:00
Oliver Smith b88200546a obs: prepare for multiple dockerfiles
Rename Dockerfile to build_srcpkg.Dockerfile and adjust related code to
allow using a different Dockerfile for building the binary packages in a
future patch.

Related: OS#2385
Change-Id: I8ef7944a4a81acd6c915998f37139eebad2b2d3e
2022-10-06 07:44:31 +00:00
Oliver Smith 10bd88ab54 obs: run_in_docker_and_exit: remove args param
No need to pass args here. It was only used for args.verbose, and that
isn't necessary since we don't need to restore the verbose mode.

Related: OS#2385
Change-Id: I620cdef46e18f4c66644f14003caf2183c89686f
2022-10-06 07:44:31 +00:00
Oliver Smith 9ffc482315 obs: run_in_docker_and_exit: --rm on extra line
Put it on an extra line like the other arguments to prevent it from
getting overlooked.

Related: OS#2385
Change-Id: Ie7dea2734e7c47766dfe64b7091bc4f5f72d53a5
2022-10-06 07:44:31 +00:00
Oliver Smith b5d65e6dae jobs/osmocom-obs: add job for master feed
Add one new job for building source packages and sending them to
obs.osmocom.org. Trigger it from all master-* jobs.

I've also considered adding one job per existing master job that would
only update one package at a time (master-libosmocore-obs,
master-osmo-bsc-obs, ...). With some additional development effort it
should be possible, and it would make each individual master OBS job
faster. But given that with the current implementation it only takes
20s to 30s for *all* packages if there are no changes, as it compares
git remote HEAD with the version currently on OBS before starting to
clone repositories and building the source packages (similar to
Osmocom_OBS_latest_obs.osmocom.org), it didn't seem worth optimizing.

Set concurrent to false as the triggers from master-builds will likely
cause it to run multiple times in parallel otherwise.

Related: https://jenkins.osmocom.org/jenkins/view/OBS/job/Osmocom_OBS_master_obs.osmocom.org/
Related: https://obs.osmocom.org/project/show/osmocom:master
Related: OS#2385
Change-Id: I53a494f13f81ae837f2d362c54e1bdf13f121db3
2022-10-06 07:44:31 +00:00
Oliver Smith 3a6250a9fb obs: update_obs_project: add master feed
Add a new master feed, where packages are updated as soon as patches get
merged to master. Upload a commit_$COMMIT.txt file for each package in
this feed and use it to determine if the package needs to be updated or
not.

In most packages the commit is already part of the version in the dsc
file, e.g. "libosmocore_1.7.0.38.c3b90.dsc", but that's harder to parse
and is more likely to have a hash collision (just 5 characters).

Related: OS#2385
Change-Id: I3b0b4f4876b8c1eeb61f20d903a6f2cac6e99638
2022-10-06 07:44:31 +00:00
Oliver Smith a91667d04c obs: build_srcpkg_if_needed: switch if branches
Make it slightly easier to read, before extending the latest branch with
master too in a follow-up patch.

Related: OS#2385
Change-Id: I4f1d4e250eb4d8163f1ded29106a44deb0d0feff
2022-10-06 07:44:31 +00:00
Oliver Smith ba8df68397 obs: lib.git.get_default_branch: add function
Refactor checkout_default_branch so the get_default_branch logic can be
used from another function in a future patch.

Related: OS#2385
Change-Id: If3f0ab500ff165d81f61b19ad41af90bd39dce8f
2022-10-06 07:44:31 +00:00
Oliver Smith ad447c5379 Revert "scripts/obs: make shallow git clones"
I didn't realize during code review that the git-version-gen script we
use in Osmocom repositories need the git history to generate a proper
version string.

For example (libosmocore):
  1.7.0.38-c3b90.202209240002
With a shallow clone, it is:
  1.7.0.202209250002

Revert the shallow git clone patch to get the proper version strings
again. This reverts commit 115262d841.

Related: https://jenkins.osmocom.org/jenkins/job/Osmocom_OBS_nightly_obs.osmocom.org/102/console
Related: https://jenkins.osmocom.org/jenkins/job/Osmocom_OBS_nightly_obs.osmocom.org/103/console
Change-Id: I6176e52187d12d264eee82e238051ca65e0c8f4d
2022-09-26 12:44:54 +02:00
Max 115262d841 scripts/obs: make shallow git clones
While generating srcpkg we're not really interested in entire
project history (which can be quite heavy) - let's only get
the bare minimum from git.

Change-Id: I71629c244d2c29728a88871e83b20493341321c8
2022-09-23 21:40:32 +07:00
Max d19d4da914 build_srcpkg.py: add option to use git-review
Having an option to explicitly checkout sources for package from gerrit
using numeric ID comes in handy for testing changes.

Related: OS#4107
Change-Id: I403c2083ef8c3f6f966c5b376fb13ea46d8a7a2b
2022-09-21 14:27:59 +00:00
Max f2efe48110 scripts/obs/*.py: add option to ignore required programs check
Not all the required programs are actually required to build subset of packages.
Add option to ignore the default check.

Change-Id: I8b5eaedab87b586fb1ca4c22746be4dfbb3c2176
2022-09-21 14:27:42 +00:00
Oliver Smith f067b7a4d9 obs: lib.run_cmd: set stdin to subprocess.DEVNULL
Don't pass stdin to the programs, as we expect them to run
non-interactively and also don't show the program's output unless -v is
used or the exit code is not 0.

Change-Id: I7e893101c2a3e7b005659ec72aa44fa932b7ccd9
2022-09-21 14:17:37 +00:00
Oliver Smith 910cf06220 obs: update_obs_project: check if oscrc exists
Check if the oscrc exists, as otherwise the osc command will
interactively prompt for the credentials. If running without verbose
mode (the default), the command output is hidden and so it would just
appear to be hanging without this patch if the config doesn't exist.

Change-Id: I6f140b2c1d171d3019fd259399e6a46da9c6451f
2022-09-21 14:17:37 +00:00
Oliver Smith 34b97c7aa6 obs: don't print verbose output twice on error
When running in verbose mode, it's enough that the output is displayed
while the command is running. Don't print it again on error.

Change-Id: I4fcf2421a6f82bd94ba098b39f58e5d3f18aa8fd
2022-09-21 14:17:37 +00:00
Max 29b9881ff1 scripts/obs/*.py: log name of function calling command
Change-Id: If4ccc0eb44da4ea743f3858b09c762ee6a138f1d
2022-09-21 11:26:01 +07:00
Neels Hofmeyr cf0d92ff21 obs/lib/config.py: add osmo-upf
Depends: libosmo-pfcp 0.1.2 I6ae6cf59e769214e11447107316d38fe5fad583d
Depends: osmo-upf 0.1.1 I1d73255f8cc30feabd3c251bdc3af1682ed4694a
Change-Id: Ia65508eaf241b799b5d4b1b81eebdeaa40f4381e
2022-08-24 16:58:42 +02:00
Oliver Smith 945ec9a0b3 obs: Cosmetic: verify new projects on OBS first
Related: OS#5654
Change-Id: I4a2ebf65de09e08cf3883ae4de9e7e8c952c2182
2022-08-22 12:52:07 +02:00
Oliver Smith 9d6e43a7c7 obs: disable osmo-upf
Deb and rpm packages don't build for osmo-upf so disable it again until
it is fixed.

Related: OS#5655, OS#5654
Change-Id: Idf18159b786c51154fda9b40758b08a8656fc215
2022-08-22 12:42:16 +02:00
Oliver Smith 65cc10c602 obs: meaningful error if debian/changelog is empty
If there's an empty debian/changelog, packaging needs to be fixed in the
git repository of the project. Print a meaningful error instead of:

    File "/obs/lib/srcpkg.py", line 68, in get_version_for_feed
      if ":" in ret:
  TypeError: argument of type 'NoneType' is not iterable

Change-Id: I294d844ccccfa12599b6ba1def087e4a32d289e7
2022-08-19 14:03:10 +00:00
Oliver Smith a8536d8847 obs: prepend origin/ to branch selected with -b
Doing this makes more sense and is less prone to errors.

Change-Id: I2fa9c457e0e17cdd1b5946dc27ae232ec13bfa25
2022-08-18 13:18:25 +00:00
Oliver Smith fb1f39e0c9 obs: make git fetch the default
As discussed with Neels, it makes more sense to fetch git repos by
default.

Change-Id: Ib8adfbcf59d66b26f322ad22b2df1ccbeaf15af7
2022-08-18 13:18:25 +00:00
Oliver Smith 3a41a4c1b8 obs: checkout_for_feed + fetch: fix for 2022q1 etc
As Neels pointed out, with the current code the 2022q1 and similar feeds
do not get checked out properly if:
* the repository was not freshly cloned (like jenkins would do)
* the repository was fetched (--git-fetch)

Instead of the last revision of that branch from origin, we get the
revision that was previously checked out on the branch. Fix this by
prepending origin/.

Change-Id: I2e265fc84abd4596c386bb56cbabb2af121dc7ca
2022-08-18 13:18:25 +00:00
Vadim Yanitskiy dbd1e02ca3 obs: add libosmo-gprs
Change-Id: I96f48cfc328f61bcbee98c4675896cc4c4e9a48f
2022-08-18 09:32:39 +00:00
Neels Hofmeyr 7057a9f55d obs: tweak logging output
Change-Id: I203cb7f0aa21b59b06973e8f329cffdc64aa8d47
2022-08-17 15:32:07 +02:00
Neels Hofmeyr 39cde7f098 obs: add README
Explain how to use the obs/ scripts to test a private git branch.

Change-Id: I4d1303e0c04e827200b48a9fe4aea3680c9c9f84
2022-08-17 15:32:07 +02:00
Neels Hofmeyr 60fe5c86b5 obs: expand help for --feed
Change-Id: Iabd165e4f7a8c17b30f01ad27abd1a878233dabf
2022-08-17 15:32:07 +02:00
Neels Hofmeyr 872dbbd58b obs: add explicit --git-branch arg
Change-Id: I612c18e533542f442e0571927fee8b8be9fb8c2b
2022-08-17 15:32:07 +02:00
Neels Hofmeyr c90ee51321 obs: add libosmo-pfcp, osmo-upf
Change-Id: I7192f4c9e77035cebb147b8186296bcd741d419b
2022-08-16 23:14:57 +02:00
Oliver Smith 3f4ee14898 obs: add osmo-bsc-nat, osmo-fl2k
Looks like I copied the list of packages from the old latest script, so
these two that were only in nightly are missing. Once added, they will
be built for nightly again and not for latest as there's no tag matching
the patterin in the git repositories.

Change-Id: I4b96f15e95c70f1dca12a292964e6f12b04e4a04
2022-08-04 14:17:40 +00:00
Oliver Smith 72bab749e5 obs: fix_source_format: ignore missing \n
Apparently a \n at the end of debian/source/format is not required, so
don't fix it if it is missing. This avoids printing this confusing line:
  osmo-trx: fixing debian/source/format (3.0 (native) => 3.0 (native))

Change-Id: I7f9bb22a389a2109109f7fecd3b7ae0413fe6f5b
2022-08-03 15:24:24 +02:00
Oliver Smith 35030b7618 scripts/obs: rewrite pushing source pkgs to OBS
Harald requested that the OBS scripts should not stop if building one
specific source package fails, instead it should keep going and report
at the end a non-success exit code.

Given that the shell script code has historically grown and became hard
to maintain, I decided to rewrite the scripts for implementing this
feature. This rewrite solves additional problems:

* No full checkout of an OBS project like network:osmocom:latest
  anymore, with lots of packages that won't get updated (e.g. the uhd
  package has a uhd-images_3.14.1.1.tar.xz file that is 108 MB). With
  the old code, developers had to wait minutes during the checkout
  before the script reaches code that is currently being developed. Now
  only single packages get checked out right before they get updated.

* No need to clone git repositories over and over. With the new code,
  git repos only get cloned if needed (for latest it is not needed if
  the remote git tag is the same as the version in OBS). During
  development, the cloned git repositories are cached.

* Output from commands like "git tag -l" is not written to the log
  unless they failed. This makes the log more readable, which is
  especially important when a package fails to build, we keep going and
  need to spot the build error in the middle of the log later on.

* No more duplicated code for nightly and latest scripts that worked
  similar but had slight differences. Also the list of packages is not
  duplicated for nightly and latest anymore; nightly uses all packages
  and latest uses packages that have at least one git tag.

* Building source packages is decoupled from uploading them. A separate
  script build_srcpkg.py can be used to just build the deb + rpm spec
  source packages, without interacting with the OBS server.

* The scripts can optionally run in docker with a command-line switch,
  and this is used by jenkins. This way we don't need to install
  more dependencies on the host such as rebar3 which is now needed for
  erlang/osmo_dia2gsup.

* Add erlang/osmo_dia2gsup and run its generate_build_dep.sh (SYS#6006)

I have done the new implementation in python to make use of argparse
and to be able to use try/except and print a trace when building one
package fails.

Example output:
* https://jenkins.osmocom.org/jenkins/job/Osmocom_OBS_nightly_obs.osmocom.org/48/console
* https://jenkins.osmocom.org/jenkins/job/Osmocom_OBS_latest_obs.osmocom.org/46/console

Change-Id: I45a555d05a9da808c0fe0145aae665f583cb80d9
2022-08-01 16:29:20 +02:00