aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2019-01-14 14:20:20 +0100
committerPeter Wu <peter@lekensteyn.nl>2019-01-14 19:01:27 +0000
commit60e32b6eb35f4ac5a7ced5b76a19d3d80e6e8e2d (patch)
treeef2f15911add432b615cdef0b2ea31a69ce85824
parente5f7f15b1f43f02e07e550596a6ccd47c5291a6f (diff)
RPM: remove dependency on the which utility
It is not necessary to know the full path to a program. Instead use the 'type' shell builtin (part of POSIX) to detect availability. Change-Id: Id68b298625d389a1f7843f52f56312bf81d97b80 Reviewed-on: https://code.wireshark.org/review/31540 Reviewed-by: Peter Wu <peter@lekensteyn.nl>
-rw-r--r--.gitlab-ci.yml4
-rw-r--r--packaging/rpm/wireshark.spec.in4
-rwxr-xr-xtools/rpm-setup.sh14
3 files changed, 11 insertions, 11 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 70a1195b7f..6efbb9bc5b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -76,7 +76,6 @@ rpm-centos-7:
image: centos:7
script:
- yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- - yum install -y which
- tools/rpm-setup.sh --install-optional -y
- mkdir build
- cd build
@@ -86,7 +85,7 @@ rpm-centos-7:
rpm-opensuse-42.3:
image: opensuse:42.3
script:
- - zypper --non-interactive install which update-desktop-files
+ - zypper --non-interactive install update-desktop-files
- tools/rpm-setup.sh --install-optional ruby
- gem install asciidoctor
- mkdir build
@@ -98,7 +97,6 @@ rpm-fedora-28:
image: fedora:28
script:
- dnf upgrade -y
- - dnf install -y which
- tools/rpm-setup.sh --install-optional -y
- mkdir build
- cd build
diff --git a/packaging/rpm/wireshark.spec.in b/packaging/rpm/wireshark.spec.in
index a9c391fb4d..8704c31c21 100644
--- a/packaging/rpm/wireshark.spec.in
+++ b/packaging/rpm/wireshark.spec.in
@@ -293,7 +293,7 @@ cmake3 \
%if %{with ninja}
# Older RPM-based distributions used ninja-build in order to prevent a collision with
# the Ninja IRC client: https://bugzilla.redhat.com/show_bug.cgi?id=1166135
-NINJA=$(which ninja || which ninja-build)
+NINJA=$(type ninja >/dev/null 2>&1 && echo ninja || echo ninja-build)
$NINJA
%else
# Suggestion: put this in your ~/.rpmmacros (without the hash sign, of course):
@@ -307,7 +307,7 @@ rm -rf $RPM_BUILD_ROOT
cd build
%endif
%if %{with ninja}
-NINJA=$(which ninja || which ninja-build)
+NINJA=$(type ninja >/dev/null 2>&1 && echo ninja || echo ninja-build)
DESTDIR=$RPM_BUILD_ROOT $NINJA install
%if %{with guides}
DESTDIR=$RPM_BUILD_ROOT $NINJA install_guides
diff --git a/tools/rpm-setup.sh b/tools/rpm-setup.sh
index f29093535b..359621e860 100755
--- a/tools/rpm-setup.sh
+++ b/tools/rpm-setup.sh
@@ -71,9 +71,11 @@ ADDITIONAL_LIST="libnl3-devel \
rpm-build"
# Guess which package manager we will use
-PM=`which zypper 2> /dev/null ||
-which dnf 2> /dev/null ||
-which yum 2> /dev/null`
+for PM in zypper dnf yum ''; do
+ if type "$PM" >/dev/null 2>&1; then
+ break
+ fi
+done
if [ -z $PM ]
then
@@ -82,14 +84,14 @@ then
fi
case $PM in
- */zypper)
+ zypper)
PM_OPT="--non-interactive"
PM_SEARCH="search -x --provides"
;;
- */dnf)
+ dnf)
PM_SEARCH="info"
;;
- */yum)
+ yum)
PM_SEARCH="info"
;;
esac