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: build_binpkg: add feed argument

Make it possible to configure a different feed than master inside the
docker container that gets used to build the packages. This way we can
build ubuntu packages against nightly.

We don't build the Osmocom packages in the master feed for Ubuntu as we
rarely have a build error that only happens on ubuntu. With this patch,
it can be easily reproduced if it happens.

Change-Id: Ibc27459815f26e8c691c83fe594ff84962b991f5
---
M scripts/obs/build_binpkg.py
M scripts/obs/data/build_binpkg.Dockerfile
M scripts/obs/lib/docker.py
3 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/scripts/obs/build_binpkg.py b/scripts/obs/build_binpkg.py
index cda0193..37dc6be 100755
--- a/scripts/obs/build_binpkg.py
+++ b/scripts/obs/build_binpkg.py
@@ -35,6 +35,11 @@
help="build the package in docker for a specific"
f" distro (default: {distro_default}, other:"
f" almalinux:8, debian:10, ubuntu:22.04 etc.)")
+ parser.add_argument("-f", "--feed", dest="docker_feed", default="master",
+ choices=["master", "nightly", "latest"],
+ help="the OBS feed to configure inside docker, against"
+ " which the package will get built (use nightly"
+ " if master doesn't get built for DISTRO)")
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 c3c1b1e..49cdc96 100644
--- a/scripts/obs/data/build_binpkg.Dockerfile
+++ b/scripts/obs/data/build_binpkg.Dockerfile
@@ -1,6 +1,7 @@
ARG DISTRO_FROM
FROM ${DISTRO_FROM}
ARG DISTRO
+ARG FEED
ARG UID

COPY Release.key /tmp/Release.key
@@ -58,24 +59,24 @@
debian:*) \
apt-key add /tmp/Release.key && \
rm /tmp/Release.key && \
- echo "deb https://downloads.osmocom.org/packages/osmocom:/master/Debian_$VERSION/ ./" \
- > /etc/apt/sources.list.d/osmocom-master.list \
+ echo "deb https://downloads.osmocom.org/packages/osmocom:/$FEED/Debian_$VERSION/ ./" \
+ > /etc/apt/sources.list.d/osmocom-$FEED.list \
;; \
ubuntu:*) \
apt-key add /tmp/Release.key && \
rm /tmp/Release.key && \
- echo "deb https://downloads.osmocom.org/packages/osmocom:/master/xUbuntu_$VERSION/ ./" \
- > /etc/apt/sources.list.d/osmocom-master.list \
+ echo "deb https://downloads.osmocom.org/packages/osmocom:/$FEED/xUbuntu_$VERSION/ ./" \
+ > /etc/apt/sources.list.d/osmocom-$FEED.list \
;; \
almalinux:*) \
- { echo "[network_osmocom_master]"; \
- echo "name=osmocom:master"; \
+ { echo "[network_osmocom_$FEED]"; \
+ echo "name=osmocom:$FEED"; \
echo "type=rpm-md"; \
- echo "baseurl=https://downloads.osmocom.org/packages/osmocom:/master/CentOS_$VERSION/"; \
+ echo "baseurl=https://downloads.osmocom.org/packages/osmocom:/$FEED/CentOS_$VERSION/"; \
echo "gpgcheck=1"; \
- echo "gpgkey=https://downloads.osmocom.org/packages/osmocom:/master/CentOS_$VERSION/repodata/repomd.xml.key"; \
+ echo "gpgkey=https://downloads.osmocom.org/packages/osmocom:/$FEED/CentOS_$VERSION/repodata/repomd.xml.key"; \
echo "enabled=1"; \
- } > /etc/yum.repos.d/network:osmocom:master.repo \
+ } > /etc/yum.repos.d/network:osmocom:$FEED.repo \
;; \
*) \
echo "can't install repo for $DISTRO" && \
diff --git a/scripts/obs/lib/docker.py b/scripts/obs/lib/docker.py
index 6bcf024..4f9f981 100644
--- a/scripts/obs/lib/docker.py
+++ b/scripts/obs/lib/docker.py
@@ -28,11 +28,20 @@

print(f"docker: building image {image_name}")

+ # Set the feed of packages to be configured inside the docker container
+ # (master, nightly, latest). This can be set with build_binpkg.py --feed,
+ # to reproduce a build error that happens with a distro that is only in
+ # nightly but not in the master feed (all ubuntu versions as of writing).
+ build_arg_feed = []
+ if getattr(lib.args, "docker_feed", None):
+ build_arg_feed = ["--build-arg", f"FEED={lib.args.docker_feed}"]
+
lib.run_cmd(["docker", "build",
"--build-arg", f"DISTRO={distro}",
"--build-arg", f"DISTRO_FROM={distro_from}",
- "--build-arg", f"UID={os.getuid()}",
- "-t", image_name,
+ "--build-arg", f"UID={os.getuid()}"] +
+ build_arg_feed +
+ ["-t", image_name,
"-f", f"{lib.config.path_top}/data/{image_type}.Dockerfile",
f"{lib.config.path_top}/data"])


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

Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: Ibc27459815f26e8c691c83fe594ff84962b991f5
Gerrit-Change-Number: 32682
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-MessageType: merged