make install_dependencies more reslient to weirdness in different spec files (#8012)

install_dependencies in the containerized_rpmbuild environment was initially done as a quick script to install multiple dependencies in spec files. This change makes it more robust to handle some cases it wouldn't handle.
This commit is contained in:
Tobias Brick 2024-02-27 16:39:20 -08:00 коммит произвёл GitHub
Родитель 0e84a68e0f
Коммит 64f06a650c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 27 добавлений и 6 удалений

Просмотреть файл

@ -146,15 +146,36 @@ get_pkg_dependency() {
# Install package dependencies listed as BuildRequires in spec
install_dependencies() {
local PKG=("$@")
if [ -z "$PKG" ]; then echo "Please provide pkg name"; return; fi
# Accept a single argument, which is a pattern to find spec files.
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <pkg_pattern>"
return 1
fi
local PKG="$1"
echo "-------- installing build dependencies ---------"
spec_file=$SPECS_DIR/$PKG/$PKG.spec
dep_list=$(grep "BuildRequires:" $spec_file | cut -d ':' -f 2)
for dependency in $dep_list
# Find all spec files for the package pattern given.
spec_file_pattern=$SPECS_DIR/$PKG/$PKG.spec
echo "using spec file pattern: '$spec_file_pattern'"
spec_files=($spec_file_pattern)
# Install dependencies for each spec file found, preserving tdnf error codes.
echo "found ${#spec_files[@]} spec files; installing dependencies for each spec file sequentially"
exit_code=0
for spec_file in "${spec_files[@]}"
do
tdnf install -y $dependency 2>&1
echo "installing dependencies for spec file: '$spec_file'"
# Get the list of dependencies from the spec file.
mapfile -t dep_list < <(rpmspec -q --buildrequires $spec_file)
# Install all the dependencies.
tdnf install -y "${dep_list[@]}" || exit_code=$?
done
return $exit_code
}
# use Mariner specific DEFINES