-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The install-rpms accepted two non-optional "options" that ended up being used the same way. There was some logic in that bash script that checked and processed those options, and as it's typical of bash code, it had a bug, where if the script was supplied with only one of the two "options", the value of non-existent $extra_rpms_file, because it was enclosed in double quotes, would be treated as an actual object (an empty string), thus making the following code: ``` for file in "$common_rpms_file" "$extra_rpms_file"; do (...) mapfile -t tmp_array < <(awk '!/^#/' "$file") ``` iterate over an empty "$file" blocking awk. Because the only thing that this script did was to install RPMs specified by text files, this patch changes it to do exactly that without any error-prone bash logic.
- Loading branch information
1 parent
786fab2
commit d7857bc
Showing
3 changed files
with
15 additions
and
67 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 |
---|---|---|
@@ -1,59 +1,8 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
dnf_install() { | ||
dnf --assumeyes --installroot=/dest --noplugins \ | ||
--config=/etc/dnf/dnf.conf \ | ||
--setopt=cachedir=/var/cache/dnf \ | ||
--setopt=reposdir=/etc/yum.repos.d \ | ||
--setopt=varsdir=/etc/dnf \ | ||
install "$@" | ||
} | ||
|
||
usage() { | ||
echo "Usage: $0 --common-rpms-file FILE --extra-rpms-file FILE" | ||
exit 1 | ||
} | ||
|
||
# Parse command-line options | ||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
--common-rpms-file) | ||
common_rpms_file="$2" | ||
shift 2 | ||
;; | ||
--extra-rpms-file) | ||
extra_rpms_file="$2" | ||
shift 2 | ||
;; | ||
*) | ||
usage | ||
;; | ||
esac | ||
done | ||
|
||
if [[ -z "$common_rpms_file" && -z "$extra_rpms_file" ]]; then | ||
echo "Error: At least one of the options must be specified." | ||
usage | ||
fi | ||
|
||
rpms=() | ||
for file in "$common_rpms_file" "$extra_rpms_file"; do | ||
if [[ -n "$file" && ! -f "$file" ]]; then | ||
echo "Error: File '$file' does not exist." | ||
exit 1 | ||
fi | ||
|
||
mapfile -t tmp_array < <(awk '!/^#/' "$file") | ||
rpms+=("${tmp_array[@]}") | ||
done | ||
|
||
if [[ ${#rpms[@]} -eq 0 ]]; then | ||
echo "Error: No RPMs specified" | ||
exit 1 | ||
fi | ||
|
||
dnf_install "${rpms[@]}" | ||
|
||
#!/usr/bin/env bash | ||
|
||
cat "$@" | xargs dnf --assumeyes --installroot=/dest --noplugins \ | ||
--config=/etc/dnf/dnf.conf \ | ||
--setopt=cachedir=/var/cache/dnf \ | ||
--setopt=reposdir=/etc/yum.repos.d \ | ||
--setopt=varsdir=/etc/dnf \ | ||
install |