Skip to content

Commit

Permalink
chore(Containerfile): More bulletproof config-manager setopt (#2199)
Browse files Browse the repository at this point in the history
* chore(Containerfile): More bulletproof config-manager setopt

* chore(Containerfile): Add missing negativo disabling
  • Loading branch information
Zeglius authored Jan 28, 2025
1 parent 17de2f1 commit 0215fe4
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ RUN --mount=type=cache,dst=/var/cache/libdnf5 \
dnf5 -y config-manager addrepo --from-repofile=https://negativo17.org/repos/fedora-rar.repo && \
dnf5 -y config-manager setopt "*bazzite*".priority=1 && \
dnf5 -y config-manager setopt "*terra*".priority=2 && \
dnf5 -y config-manager setopt $(printf '%s.priority=3 %s.exclude="mesa-*" ' $(/ctx/dnf5-search "*negativo*")) && \
eval "$(/ctx/dnf5-setopt setopt '*negativo17*' priority=3 exclude='mesa-*')" && \
dnf5 -y config-manager setopt "*rpmfusion*".priority=4 "*rpmfusion*".exclude="mesa-*" && \
dnf5 -y config-manager setopt "*fedora*".exclude="mesa-* kernel-core-* kernel-modules-* kernel-uki-virt-*" && \
/ctx/cleanup
Expand Down Expand Up @@ -519,7 +519,7 @@ RUN --mount=type=cache,dst=/var/cache/libdnf5 \
dnf5 config-manager setopt "*tailscale*".enabled=0 && \
dnf5 config-manager setopt "*charm*".enabled=0 && \
sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/negativo17-fedora-multimedia.repo && \
dnf5 -y config-manager setopt "*negativo*".enabled=0 && \
eval "$(/ctx/dnf5-setopt setopt '*negativo17*' enabled=0)" && \
sed -i 's#/var/lib/selinux#/etc/selinux#g' /usr/lib/python3.*/site-packages/setroubleshoot/util.py && \
mkdir -p /etc/flatpak/remotes.d && \
curl -Lo /etc/flatpak/remotes.d/flathub.flatpakrepo https://dl.flathub.org/repo/flathub.flatpakrepo && \
Expand Down
2 changes: 1 addition & 1 deletion build_files/dnf5-search
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Retrieve a list of repos ids by name or id
set -euo pipefail

dnf5 repo info --all --json "$1" | jq -r '.[].id'
dnf5 repo info --all --json "$@" | jq -r '.[].id'
72 changes: 72 additions & 0 deletions build_files/dnf5-setopt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/bash
set -euo pipefail

die() {
local frame=0
while caller $frame >&2; do
((++frame))
done
echo >&2 "${*:-Something went wrong}"
echo >&1 ":"
exit 0
}
trap 'die' ERR

_usage() {
local -i status=${1:-0}
printf >&2 'Usage: eval "%s <setopt|unsetopt> <repo_name|repo_id> <option>=<value>)"\n' "$(basename "$0")"
return $status
}

while getopts "h" opt; do
case $opt in
h)
_usage 0
exit
;;
*) ;;
esac
done

cmd="dnf5 config-manager"
action=$1
shift

case $action in
setopt | unsetopt) cmd+=" $action" ;;
*)
die "ERROR: Only setopt|unsetopt are allowed as first param"
;;
esac

_repos_raw="$(
cd "$(dirname "$0")"
# shellcheck disable=SC2086
./dnf5-search ${1//,/ }
)"
if [[ -z $_repos_raw ]]; then
die "No repo found matching '$1'"
fi
shift

repos=()
mapfile -t repos <<<"$_repos_raw"

options=()
while (($#)); do
[[ -n ${_v:=${1##.}} ]] && options+=("$_v")
shift
done
unset -v _v

if [[ ${#options[@]} -eq 0 ]]; then
die "No options were providied"
fi

for repo in "${repos[@]}"; do
for opt in "${options[@]}"; do
cmd+=" $repo.$opt"
done
done

echo "$cmd"

0 comments on commit 0215fe4

Please sign in to comment.