Skip to content

Commit

Permalink
Reimplement repoquery in a more generic way
Browse files Browse the repository at this point in the history
This approach is based on rpmdist-repoquery where a certain directory
structure is used to track repositories. That is then selected, together
with a releasever.

Our own repositories are made generic by using DNF_VAR_$var, which makes
branching easier.

It also uses true modularity. For that it hacks together a temporary
installroot and uses fakeroot to pretend to be root, because dnf insists
you need to be root to enable a module. Due to only using real DNF, we
can rely on the modulary metadata and dependency resolution to select
the correct modules. Again, reducing duplication.

A major motivation for this is the upcoming CentOS Stream 8 EOL where
the repositories will be archived. This new repository structure allows
easy switching to another Enterprise Linux for repoclosure checks.

This needs a different approach in how we configure repoclosure in obal
and the wrapper scripts should probably live in another repository as
well. Another excercise is the EL7 repoclosure check.
  • Loading branch information
ekohl committed May 31, 2024
1 parent 819e816 commit 486bb75
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 162 deletions.
1 change: 1 addition & 0 deletions distros/centos-stream-legacy/centos-stream-legacy.repo
1 change: 1 addition & 0 deletions distros/centos-stream-legacy/foreman-staging.repo
1 change: 1 addition & 0 deletions distros/centos-stream-legacy/puppet.repo
33 changes: 33 additions & 0 deletions distros/centos-stream/foreman-staging.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[foreman-$foremanver-staging]
name=Foreman $foremanver staging EL$releasever
baseurl=https://stagingyum.theforeman.org/foreman/$foremanver/el$releasever/$basearch/
module_hotfixes=1
enable=0
gpgcheck=0

[foreman-plugins-$foremanver-staging]
name=Foreman Plugins $foremanver staging EL$releasever
baseurl=https://stagingyum.theforeman.org/plugins/$foremanver/el$releasever/$basearch/
module_hotfixes=1
enable=0
gpgcheck=0

[foreman-client-$foremanver-staging]
name=Foreman Client $foremanver staging EL$releasever
baseurl=https://stagingyum.theforeman.org/client/$foremanver/el$releasever/$basearch/
enable=0
gpgcheck=0

[katello-$katellover-staging]
name=Katello $katellover staging EL$releasever
baseurl=https://stagingyum.theforeman.org/katello/$katellover/el$releasever/$basearch/
module_hotfixes=1
enable=0
gpgcheck=0

[candlepin-$candlepinver-staging]
name=Candlepin $candlepinver staging EL$releasever
baseurl=https://stagingyum.theforeman.org/candlepin/$candlepinver/el$releasever/$basearch/
module_hotfixes=1
enable=0
gpgcheck=0
6 changes: 6 additions & 0 deletions distros/centos-stream/puppet.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[puppet$puppetver]
name=Puppet $puppetver Repository el $releasever - $basearch
baseurl=http://yum.puppet.com/puppet$puppetver/el/$releasever/$basearch
gpgkey=https://yum.puppet.com/RPM-GPG-KEY-puppet-20250406
enabled=0
gpgcheck=1
12 changes: 12 additions & 0 deletions distros/dnf.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[main]
keepcache=1
debuglevel=2
reposdir=/dev/null
logdir=/tmp/log/dnf
retries=20
obsoletes=1
gpgcheck=0
best=1
install_weak_deps=0
metadata_expire=6h
mdpolicy=group:primary
47 changes: 47 additions & 0 deletions dnfwrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/bash

# Script to configure across different RPM-based distributions
# Based on rpmdistro-repoquery
# License: MIT
# See LICENSE for license information

if (( $# < 2 )); then
echo "Usage: $0 <distro> <releasever> [<options> ...]"
exit 1
fi
repos=$1
releasever=$2
module_platform=""
repos_loc=$(dirname "$1")
# if config is a path to an directory, use it
# otherwise use the system installation
if [ -d "${repos}" ]; then
repos_loc=$(dirname "$1")
repos=$(basename "$1")
elif [[ "${repos}" =~ "/" ]]; then
echo "ERROR: specified repos path does not exist"
exit 1
else
repos_loc=/usr/share/rpmdistro-repoquery/distros
fi

if [[ "${repos}" =~ "centos" ]]; then
module_platform="--setopt=module_platform_id=platform:el${2}"
fi

if [[ "${repos}" =~ "mageia" ]]; then
DNF_VAR_distarch=$(rpm --eval "%{_target_cpu}")
export DNF_VAR_distarch
fi

if [[ "${repos}" =~ "sle-bci" ]]; then
arr=(${releasever//./ })
if [ "${#arr[@]}" -gt "1" ]; then
DNF_VAR_releaseversp="${arr[0]}-SP${arr[1]}"
else
DNF_VAR_releaseversp="${arr[0]}"
fi
export DNF_VAR_releaseversp
fi

dnf --config="${repos_loc}/dnf.conf" --setopt=reposdir="${repos_loc}/${repos}" --releasever="${releasever}" ${module_platform} --nogpgcheck "${@:3}"
30 changes: 30 additions & 0 deletions repoclosure
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

DNF_VAR_foremanver=nightly
DNF_VAR_katellover=nightly
DNF_VAR_candlepinver=nightly
DNF_VAR_puppetver=7

export DNF_VAR_foremanver DNF_VAR_katellover DNF_VAR_candlepinver DNF_VAR_puppetver

repoclosure() {
local distro releasever module
distro=./distros/$1
releasever=$2
module=$3

if [[ -n $module ]] ; then
# DNF needs root to enable modules
INSTALLROOT=$(mktemp -d)

fakeroot ./dnfwrapper "$distro" "$releasever" module enable "$module" -y --installroot "$INSTALLROOT"
fakeroot ./dnfwrapper "$distro" "$releasever" repoclosure --installroot "$INSTALLROOT" "${@:4}"

rm -rf "$INSTALLROOT"
else
./dnfwrapper "$distro" "$releasever" repoclosure "${@:4}"
fi
}

repoclosure centos-stream 9 "" --check foreman-${DNF_VAR_foremanver}-staging --enablerepo puppet7
repoclosure centos-stream-legacy 8 foreman-devel:el8 --check foreman-${DNF_VAR_foremanver}-staging --enablerepo puppet7
162 changes: 0 additions & 162 deletions repoclosure/yum.conf

This file was deleted.

0 comments on commit 486bb75

Please sign in to comment.