Improve dnf tests inside build_rpm.sh
Fix bug failing to detect dnf in various locations
Add missing sudo to yum/dnf calls
Fix bug where pkg_manager may endup with a multi-line value
#!/bin/bash
set -euxo pipefail
-pkg_manager=`command -v dnf`
-if [ -z "$pkg_manager" ]; then
- pkg_manager=`command -v yum`
-fi
-
+# returned path can vary: /usr/bin/dnf /bin/dnf ...
+pkg_manager=`command -v dnf yum | head -n1`
echo "Package manager binary: $pkg_manager"
-if [ $pkg_manager == "/usr/bin/yum" ]; then
+if [ $pkg_manager == "*yum" ]; then
echo "[virt7-container-common-candidate]
name=virt7-container-common-candidate
baseurl=https://cbs.centos.org/repos/virt7-container-common-candidate/x86_64/os/
@@ -31,7 +28,7 @@ declare -a PKGS=(device-mapper-devel \
go-compilers-golang-compiler \
)
-if [ $pkg_manager == "/usr/bin/dnf" ]; then
+if [ $pkg_manager == "*dnf" ]; then
PKGS+=(python3-devel \
python3-varlink \
)
@@ -49,16 +46,16 @@ if [ -z "$extra_arg" ]; then
fi
echo ${PKGS[*]}
-$pkg_manager install -y ${PKGS[*]}
+sudo $pkg_manager install -y ${PKGS[*]}
make -f .copr/Makefile
rpmbuild --rebuild ${extra_arg:-""} podman-*.src.rpm
# Test to make sure the install of the binary works
-$pkg_manager -y install ~/rpmbuild/RPMS/x86_64/podman-*.x86_64.rpm
+sudo $pkg_manager -y install ~/rpmbuild/RPMS/x86_64/podman-*.x86_64.rpm
# If we built python/varlink packages, we should test their installs too
-if [ $pkg_manager == "/usr/bin/dnf" ]; then
- $pkg_manager -y install ~/rpmbuild/RPMS/noarch/python*
+if [ $pkg_manager == "*dnf" ]; then
+ sudo $pkg_manager -y install ~/rpmbuild/RPMS/noarch/python*
fi
