Skip to content

Commit

Permalink
src/scripts/dnf.py: allow using --nobest and use it for osbuild-ci-c10s
Browse files Browse the repository at this point in the history
The c10s container contains newer packages than the ones that are
available in the repositories. Therefore we are running into a situation
when DNF would need to downgrade some packages, in order to install the
requested package set. This fails, unless the --nobest options is passed
to DNF.

Extend the dnf.py script and osbuild-ci.Dockerfile, to allow using the
--nobest option if needed. Use the option for the c10s osbuild-ci
container.

Signed-off-by: Tomáš Hozza <[email protected]>
  • Loading branch information
thozza committed Nov 12, 2024
1 parent 24085fc commit 4dc62f0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 2 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ target "osbuild-ci-c10s-latest" {
args = {
// DNF package list needs no changes so it is inherited
OSB_FROM = "quay.io/centos/centos:stream10-development",
// Allow DNF to downgrade some packages in the container, otherwise it will fail
OSB_DNF_NOBEST = 1,
}
tags = concat(
mirror("osbuild-ci-c10s", "latest", "", OSB_UNIQUEID),
Expand Down
5 changes: 3 additions & 2 deletions src/images/osbuild-ci.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ COPY src src
ARG OSB_DNF_PACKAGES=""
ARG OSB_DNF_GROUPS=""
ARG OSB_PIP_PACKAGES=""
ARG OSB_DNF_ALLOW_ERASING=""
RUN ./src/scripts/dnf.sh "${OSB_DNF_PACKAGES}" "${OSB_DNF_GROUPS}" ${OSB_DNF_ALLOW_ERASING}
ARG OSB_DNF_ALLOW_ERASING="0"
ARG OSB_DNF_NOBEST="0"
RUN ./src/scripts/dnf.sh "${OSB_DNF_PACKAGES}" "${OSB_DNF_GROUPS}" "${OSB_DNF_ALLOW_ERASING}" "${OSB_DNF_NOBEST}"
RUN ./src/scripts/pip.sh "${OSB_PIP_PACKAGES}"
COPY src/scripts/osbuild-ci.sh .

Expand Down
23 changes: 16 additions & 7 deletions src/scripts/dnf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,24 @@ if (( $# > 1 )) ; then
IFS=',' read -r -a OSB_GROUPS <<< "$2"
IFS=$OSB_IFS
fi
if (( $# > 2 )) ; then
if [[ ! $3 =~ ^[01]$ ]] ; then
echo >&2 "ERROR: invalid value for the third argument '$3'"
echo >&2 " only 0 or 1 are allowed"
exit 1
fi
if (( $# > 2 )) && [[ $3 =~ ^[01]$ ]] ; then
echo >&2 "ERROR: invalid value for the third argument '$3'"
echo >&2 " only 0 or 1 are allowed"
exit 1
fi
if (( $# > 3 )) && [[ ! $4 =~ ^[01]$ ]] ; then
echo >&2 "ERROR: invalid value for the fourth argument '$4'"
echo >&2 " only 0 or 1 are allowed"
exit 1
fi
if (( $# > 3 )) ; then

if (( $# > 4 )) ; then
echo >&2 "ERROR: invalid number of arguments"
exit 1
fi

ALLOW_ERASING=${3:-0}
NOBEST=${4:-0}

#
# Clean all caches so we force a metadata refresh. Then make sure to update
Expand All @@ -62,6 +67,10 @@ if [[ "$ALLOW_ERASING" == 1 ]] ; then
EXTRA_ARGS+=" --allowerasing"
fi

if [[ "$NOBEST" == 1 ]] ; then
EXTRA_ARGS+=" --nobest"
fi

DNF_VERSION=$(rpm -q --whatprovides dnf --qf "%{VERSION}\n")
POSITIONAL_OPS_DELIMITER="--"
# We can't use -- with DNF5 until https://github.com/rpm-software-management/dnf5/issues/1848 is fixed.
Expand Down

0 comments on commit 4dc62f0

Please sign in to comment.