osmith submitted this change.

View Change


Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved
obs: support all debian/ubuntu/almalinux versions

Adjust the code so one can pass all versions, instead of hardcoding
only debian:11, ubuntu:22.04, almalinux:8. I'll use this for
reproducing a build error that happens on e.g. ubuntu:18.04.

Change-Id: Id85f5b67d144dc178d3fb23ff8e533a671473363
---
M scripts/obs/build_binpkg.py
M scripts/obs/data/build_binpkg.Dockerfile
M scripts/obs/lib/config.py
3 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/scripts/obs/build_binpkg.py b/scripts/obs/build_binpkg.py
index 1ee9636..f647869 100755
--- a/scripts/obs/build_binpkg.py
+++ b/scripts/obs/build_binpkg.py
@@ -2,6 +2,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright 2022 sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
import argparse
+import fnmatch
import multiprocessing
import os
import lib
@@ -13,9 +14,15 @@
import lib.srcpkg


+def arg_type_docker_distro(arg):
+ for pattern in lib.config.docker_distro_other:
+ if fnmatch.fnmatch(arg, pattern):
+ return arg
+ raise ValueError
+
+
def main():
distro_default = lib.config.docker_distro_default
- distro_choices = [distro_default] + lib.config.docker_distro_other
jobs_default = multiprocessing.cpu_count() + 1

parser = argparse.ArgumentParser(
@@ -23,10 +30,11 @@
" obs.osmocom.org. Use after building a source package"
" with build_srcpkg.py."
f" Output dir: {lib.config.path_temp}/binpkgs")
- parser.add_argument("-d", "--docker", choices=distro_choices,
+ parser.add_argument("-d", "--docker", type=arg_type_docker_distro,
const=distro_default, nargs="?",
help="build the package in docker for a specific"
- f" distro (default: {distro_default})")
+ f" distro (default: {distro_default}, other:"
+ f" almalinux:8, debian:10, ubuntu:22.04 etc.)")
parser.add_argument("-j", "--jobs", type=int, default=jobs_default,
help=f"parallel running jobs (default: {jobs_default})")
parser.add_argument("-r", "--run-shell-on-error", action="store_true",
diff --git a/scripts/obs/data/build_binpkg.Dockerfile b/scripts/obs/data/build_binpkg.Dockerfile
index bd12562..c3c1b1e 100644
--- a/scripts/obs/data/build_binpkg.Dockerfile
+++ b/scripts/obs/data/build_binpkg.Dockerfile
@@ -52,26 +52,28 @@

# Add master repository, where packages immediately get updated after merging
# patches to master.
-RUN case "$DISTRO" in \
- debian:11) \
+RUN set -x; \
+ VERSION="$(echo "$DISTRO" | cut -d : -f 2)"; \
+ case "$DISTRO" in \
+ debian:*) \
apt-key add /tmp/Release.key && \
rm /tmp/Release.key && \
- echo "deb https://downloads.osmocom.org/packages/osmocom:/master/Debian_11/ ./" \
+ echo "deb https://downloads.osmocom.org/packages/osmocom:/master/Debian_$VERSION/ ./" \
> /etc/apt/sources.list.d/osmocom-master.list \
;; \
- ubuntu:22.04) \
+ ubuntu:*) \
apt-key add /tmp/Release.key && \
rm /tmp/Release.key && \
- echo "deb https://downloads.osmocom.org/packages/osmocom:/master/xUbuntu_22.04/ ./" \
+ echo "deb https://downloads.osmocom.org/packages/osmocom:/master/xUbuntu_$VERSION/ ./" \
> /etc/apt/sources.list.d/osmocom-master.list \
;; \
- almalinux:8) \
+ almalinux:*) \
{ echo "[network_osmocom_master]"; \
echo "name=osmocom:master"; \
echo "type=rpm-md"; \
- echo "baseurl=https://downloads.osmocom.org/packages/osmocom:/master/CentOS_8/"; \
+ echo "baseurl=https://downloads.osmocom.org/packages/osmocom:/master/CentOS_$VERSION/"; \
echo "gpgcheck=1"; \
- echo "gpgkey=https://downloads.osmocom.org/packages/osmocom:/master/CentOS_8/repodata/repomd.xml.key"; \
+ echo "gpgkey=https://downloads.osmocom.org/packages/osmocom:/master/CentOS_$VERSION/repodata/repomd.xml.key"; \
echo "enabled=1"; \
} > /etc/yum.repos.d/network:osmocom:master.repo \
;; \
diff --git a/scripts/obs/lib/config.py b/scripts/obs/lib/config.py
index 15e4d44..3942f43 100644
--- a/scripts/obs/lib/config.py
+++ b/scripts/obs/lib/config.py
@@ -113,6 +113,7 @@

docker_distro_default = "debian:11"
docker_distro_other = [
- "almalinux:8", # instead of centos:8 (SYS#5818)
- "ubuntu:22.04",
+ "almalinux:*", # instead of centos (SYS#5818)
+ "debian:*",
+ "ubuntu:*",
]

To view, visit change 32680. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: Id85f5b67d144dc178d3fb23ff8e533a671473363
Gerrit-Change-Number: 32680
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <suraev@alumni.ntnu.no>
Gerrit-Reviewer: daniel <dwillmann@sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged