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
This commit is contained in:
Oliver Smith 2023-05-10 12:05:24 +02:00
parent 3dff9ee40c
commit 106120cace
3 changed files with 26 additions and 11 deletions

View File

@ -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",

View File

@ -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" && \

View File

@ -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"])