-
-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(Containerfile): More bulletproof config-manager setopt (#2199)
* chore(Containerfile): More bulletproof config-manager setopt * chore(Containerfile): Add missing negativo disabling
- Loading branch information
Showing
3 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |