all: avoid GNU "which" from shell scripts
"which" is a separate package and may not be installed. Also, shell has a built-in command for the same purpose. Use that.
This commit is contained in:
@@ -40,10 +40,10 @@ variables:
|
||||
# these tags should be updated each time the list of packages is updated
|
||||
# changing these will force rebuilding the associated image
|
||||
# Note: these tags have no meaning and are not tied to a particular NM version
|
||||
FEDORA_TAG: '2020-11-17.0-5276eb5b0e3c'
|
||||
FEDORA_TAG: '2020-11-17.0-0a04bc0f5618'
|
||||
UBUNTU_TAG: '2020-11-17.0-89dd88de8047'
|
||||
DEBIAN_TAG: '2020-11-17.0-89dd88de8047'
|
||||
CENTOS_TAG: '2020-11-17.0-5276eb5b0e3c'
|
||||
CENTOS_TAG: '2020-11-17.0-0a04bc0f5618'
|
||||
|
||||
FEDORA_EXEC: 'bash .gitlab-ci/fedora-install.sh'
|
||||
UBUNTU_EXEC: 'bash .gitlab-ci/debian-install.sh'
|
||||
|
@@ -16,8 +16,8 @@ locale -a
|
||||
env
|
||||
meson --version
|
||||
|
||||
! which dpkg || dpkg -l
|
||||
! which yum || yum list installed
|
||||
! command -v dpkg &>/dev/null || dpkg -l
|
||||
! command -v yum &>/dev/null || yum list installed
|
||||
|
||||
# The formatting depends on the version of python black.
|
||||
# We have a dedicated test that checks our formatting, which
|
||||
|
@@ -28,13 +28,13 @@ fi
|
||||
|
||||
|
||||
NM_NO_EXTRA=1 NM_INSTALL="yum install -y" ./contrib/fedora/REQUIRED_PACKAGES
|
||||
yum install -y glibc-langpack-pl ccache clang which
|
||||
yum install -y glibc-langpack-pl ccache clang
|
||||
|
||||
# containers have "tsflags=nodocs" in /etc/dnf/dnf.conf. We need /usr/shared/gtk-doc/html
|
||||
# to generate proper documentation.
|
||||
yum reinstall -y --setopt='tsflags=' glib2-doc
|
||||
|
||||
if which dnf &>/dev/null; then
|
||||
if command -v dnf &>/dev/null; then
|
||||
dnf install -y python3-dnf-plugins-core
|
||||
dnf debuginfo-install -y glib2
|
||||
else
|
||||
|
@@ -12,7 +12,7 @@
|
||||
|
||||
set -xe
|
||||
|
||||
DNF="$( ( which dnf || dnf --version ) &>/dev/null && echo dnf || echo yum)"
|
||||
DNF="$(command -v dnf &>/dev/null && echo dnf || echo yum)"
|
||||
|
||||
install() {
|
||||
if [ "$NM_INSTALL" != "" ]; then
|
||||
|
@@ -255,10 +255,10 @@ ls -dla \
|
||||
2>/dev/null | sed 's/^/ /'
|
||||
LOG
|
||||
if [[ "$BUILDTYPE" == "SRPM" ]]; then
|
||||
LOG sudo $(which dnf &>/dev/null && echo dnf builddep || echo yum-builddep) $TEMP_LATEST/SRPMS/*.src.rpm
|
||||
LOG sudo $(command -v dnf &>/dev/null && echo dnf builddep || echo yum-builddep) $TEMP_LATEST/SRPMS/*.src.rpm
|
||||
LOG
|
||||
else
|
||||
LOG "sudo $(which dnf &>/dev/null && echo dnf || echo yum) install '$TEMP_LATEST/RPMS'/*/*.rpm"
|
||||
LOG "sudo $(command -v dnf &>/dev/null && echo dnf || echo yum) install '$TEMP_LATEST/RPMS'/*/*.rpm"
|
||||
LOG
|
||||
fi
|
||||
|
||||
|
@@ -36,7 +36,7 @@ _is_true() {
|
||||
}
|
||||
|
||||
USE_CCACHE=0
|
||||
if which ccache &>/dev/null; then
|
||||
if command -v ccache &>/dev/null; then
|
||||
USE_CCACHE=1
|
||||
export PATH="/usr/lib64/ccache:/usr/lib/ccache${PATH:+:${PATH}}"
|
||||
fi
|
||||
|
@@ -38,7 +38,7 @@ if ! podman container exists "$PODNAME" ; then
|
||||
-v "$DIR:/tmp/NetworkManager:Z" \
|
||||
-w /tmp/NetworkManager \
|
||||
fedora:33 \
|
||||
/bin/bash -c 'dnf upgrade -y && dnf install -y git which /usr/bin/clang-format && ./contrib/scripts/nm-code-format.sh -i'
|
||||
/bin/bash -c 'dnf upgrade -y && dnf install -y git /usr/bin/clang-format && ./contrib/scripts/nm-code-format.sh -i'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@@ -37,7 +37,7 @@ EXCLUDE=":(exclude)shared/systemd/src
|
||||
:(exclude)shared/c-stdaux
|
||||
:(exclude)shared/n-acd"
|
||||
|
||||
if ! which clang-format &> /dev/null; then
|
||||
if ! command -v clang-format &> /dev/null; then
|
||||
echo -n "Error: clang-format is not installed, "
|
||||
echo "on RHEL/Fedora/CentOS run 'dnf install clang-tools-extra'"
|
||||
exit 1
|
||||
|
@@ -207,7 +207,7 @@ fi
|
||||
|
||||
NMTST_DBUS_RUN_SESSION=()
|
||||
if _is_true "$NMTST_LAUNCH_DBUS"; then
|
||||
if ! which dbus-run-session &>/dev/null ; then
|
||||
if ! command -v dbus-run-session &>/dev/null ; then
|
||||
eval `dbus-launch --sh-syntax`
|
||||
trap "kill $DBUS_SESSION_BUS_PID" EXIT
|
||||
else
|
||||
@@ -249,7 +249,7 @@ if ! _is_true "$NMTST_USE_VALGRIND" 0; then
|
||||
fi
|
||||
|
||||
if [[ -z "${NMTST_VALGRIND}" ]]; then
|
||||
NMTST_VALGRIND=`which valgrind` || die "cannot find valgrind binary. Set \$NMTST_VALGRIND"
|
||||
NMTST_VALGRIND="$(command -v valgrind)" || die "cannot find valgrind binary. Set \$NMTST_VALGRIND"
|
||||
else
|
||||
test -e "${NMTST_VALGRIND}" || die "cannot find valgrind binary from NMTST_VALGRIND=\"${NMTST_VALGRIND}\""
|
||||
fi
|
||||
|
Reference in New Issue
Block a user