From 62aeb6eec9d84c7f3cee30956c71caec2ac41268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Lehmann?= Date: Mon, 25 Aug 2025 10:09:25 +0200 Subject: [PATCH] Add the --disable-upstream-repos option (-U for short). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to generate an error when a dependency is not aleardy packaged in XCP-ng. The developer can then decide if the dependency should be either imported or removed. Signed-off-by: Gaƫtan Lehmann --- src/xcp_ng_dev/cli.py | 3 +++ src/xcp_ng_dev/files/Dockerfile-8.x | 2 ++ src/xcp_ng_dev/files/Dockerfile-9.x | 2 ++ src/xcp_ng_dev/files/init-container.sh | 7 +++++++ 4 files changed, 14 insertions(+) diff --git a/src/xcp_ng_dev/cli.py b/src/xcp_ng_dev/cli.py index 642d543..2765d27 100755 --- a/src/xcp_ng_dev/cli.py +++ b/src/xcp_ng_dev/cli.py @@ -54,6 +54,7 @@ def add_common_args(parser): group.add_argument('--disablerepo', help='disable repositories. Same syntax as yum\'s --disablerepo parameter. ' 'If both --enablerepo and --disablerepo are set, --disablerepo will be applied first') + group.add_argument('-U', '--disable-upstream-repos', action='store_true', help='disable the upstream repositories') group.add_argument('--no-update', action='store_true', help='do not run "yum update" on container start, use it as it was at build time') @@ -170,6 +171,8 @@ def container(args): if args.env: for env in args.env: docker_args += ["-e", env] + if args.disable_upstream_repos: + docker_args += ["-e", "DISABLE_UPSTREAM_REPOS=true"] if args.enablerepo: docker_args += ["-e", "ENABLEREPO=%s" % args.enablerepo] if args.disablerepo: diff --git a/src/xcp_ng_dev/files/Dockerfile-8.x b/src/xcp_ng_dev/files/Dockerfile-8.x index b6e404c..c9dcc2e 100644 --- a/src/xcp_ng_dev/files/Dockerfile-8.x +++ b/src/xcp_ng_dev/files/Dockerfile-8.x @@ -10,6 +10,8 @@ ARG CENTOS_VERSION COPY files/CentOS-Vault.repo.in /etc/yum.repos.d/CentOS-Vault-7.5.repo RUN sed -i -e "s/@CENTOS_VERSION@/${CENTOS_VERSION}/g" /etc/yum.repos.d/CentOS-Vault-7.5.repo +ENV UPSTREAM_REPOS="C${CENTOS_VERSION}-base C${CENTOS_VERSION}-updates C${CENTOS_VERSION}-extras" + # Add our repositories # Repository file depends on the target version of XCP-ng, and is pre-processed by build.sh ARG XCP_NG_BRANCH=8.3 diff --git a/src/xcp_ng_dev/files/Dockerfile-9.x b/src/xcp_ng_dev/files/Dockerfile-9.x index be318d0..b1bb75d 100644 --- a/src/xcp_ng_dev/files/Dockerfile-9.x +++ b/src/xcp_ng_dev/files/Dockerfile-9.x @@ -41,6 +41,8 @@ RUN dnf update -y \ # clean package cache to avoid download errors && yum clean all +ENV UPSTREAM_REPOS="appstream baseos crb epel extras alma10-devel" + # enable repositories commonly required to build RUN dnf config-manager --enable crb diff --git a/src/xcp_ng_dev/files/init-container.sh b/src/xcp_ng_dev/files/init-container.sh index 27f8ef0..3637dcc 100755 --- a/src/xcp_ng_dev/files/init-container.sh +++ b/src/xcp_ng_dev/files/init-container.sh @@ -46,6 +46,13 @@ case "$OS_RELEASE" in *) echo >&2 "ERROR: unknown release, cannot know package manager"; exit 1 ;; esac +# disable upstream repositories if needed +if [ "$DISABLE_UPSTREAM_REPOS" == "true" ]; then + for repo in $UPSTREAM_REPOS; do + sudo $CFGMGR --disable "$repo" + done +fi + # disable repositories if needed if [ -n "$DISABLEREPO" ]; then sudo $CFGMGR --disable "$DISABLEREPO"