Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osbuild-ci: explicitly install python3-dnf package #81

Merged
merged 5 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ python3-boto3
python3-botocore
python3-docutils
python3-devel
python3-dnf
python3-iniparse
python3-isort
python3-jsonschema
Expand Down Expand Up @@ -308,7 +309,7 @@ target "virtual-osbuild-ci-base" {
args = {
OSB_DNF_PACKAGES = join(",", split("\n", BASE_PACKAGES)),
OSB_DNF_GROUPS = join(",", [
"development tools",
"development-tools",
"rpm-development-tools",
]),
}
Expand Down Expand Up @@ -364,6 +365,10 @@ EOF
target "virtual-osbuild-ci-cXs" {
args = {
OSB_DNF_PACKAGES = join(",", setsubtract(split("\n", BASE_PACKAGES), split("\n", CENTOS_REMOVED_PACKAGES))),
OSB_DNF_GROUPS = join(",", [
"development tools",
"rpm-development-tools",
]),
OSB_PIP_PACKAGES = join(",", [
"autopep8",
"boto3",
Expand Down Expand Up @@ -405,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
2 changes: 1 addition & 1 deletion src/config/google-cloud-sdk.repo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el8-x86_64
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el9-$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=0
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
36 changes: 25 additions & 11 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,15 +67,25 @@ 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.
if [[ "${DNF_VERSION%%.*}" -ge 5 ]] ; then
POSITIONAL_OPS_DELIMITER=""
fi

if (( ${#OSB_PACKAGES[@]} )) ; then
dnf -y \
--nodocs \
--setopt=fastestmirror=True \
--setopt=install_weak_deps=False \
$EXTRA_ARGS \
install \
-- \
"${OSB_PACKAGES[@]}"
$POSITIONAL_OPS_DELIMITER "${OSB_PACKAGES[@]}"
fi

if (( ${#OSB_GROUPS[@]} )) ; then
Expand All @@ -80,8 +95,7 @@ if (( ${#OSB_GROUPS[@]} )) ; then
--setopt=install_weak_deps=False \
$EXTRA_ARGS \
group install \
-- \
"${OSB_GROUPS[@]}"
$POSITIONAL_OPS_DELIMITER "${OSB_GROUPS[@]}"
fi

#
Expand Down
Loading