diff options
author | Oliver Smith <osmith@sysmocom.de> | 2023-05-10 12:05:24 +0200 |
---|---|---|
committer | Oliver Smith <osmith@sysmocom.de> | 2023-05-10 12:13:27 +0200 |
commit | 106120cace3630a1b99c26dba5b8d646dd962a79 (patch) | |
tree | 50ade252b4050c17c029fdf70bd8f03c4f3c5c24 | |
parent | 3dff9ee40c6e5d15dc4b9ccc1002272059ae3c00 (diff) |
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
-rwxr-xr-x | scripts/obs/build_binpkg.py | 5 | ||||
-rw-r--r-- | scripts/obs/data/build_binpkg.Dockerfile | 19 | ||||
-rw-r--r-- | scripts/obs/lib/docker.py | 13 |
3 files changed, 26 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 @@ def main(): 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 @@ RUN set -x; \ 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 @@ def build_image(distro, image_type): 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"]) |