From 4cfd954e1e56900ee42adf8d815a39f089e6b879 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Mon, 8 Nov 2021 21:15:54 +0100 Subject: [PATCH] Remove dependency from 'which' utility Debian declared the 'which' utility as deprecated. Fixes #4319 --- repos/base/src/core/version.inc | 2 +- tool/builddir/build.mk | 6 +++--- tool/ports/mk/common.inc | 2 +- tool/run/run | 5 +---- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/repos/base/src/core/version.inc b/repos/base/src/core/version.inc index d7ca818776..a1b4cd51fe 100644 --- a/repos/base/src/core/version.inc +++ b/repos/base/src/core/version.inc @@ -3,7 +3,7 @@ # GENODE_ROOT_DIR = $(BASE_DIR)/../.. GENODE_VERSION := $(shell \ - which git > /dev/null \ + command -v git > /dev/null \ && git -C $(GENODE_ROOT_DIR) describe --dirty=" " 2> /dev/null \ && exit 0 \ || \ diff --git a/tool/builddir/build.mk b/tool/builddir/build.mk index 5544a74ad8..a991492f58 100644 --- a/tool/builddir/build.mk +++ b/tool/builddir/build.mk @@ -81,7 +81,7 @@ BASE_DIR := $(realpath $(shell echo $(BASE_DIR))) # standard shell is dash, which breaks colored output via its built-in echo # command. # -export SHELL := $(shell which bash) +export SHELL := $(shell sh -c "command -v bash") # # Discharge variables evaluated by ccache mechanism that may be inherited when @@ -137,7 +137,7 @@ endif # # Helper function to check if a needed tool is installed # -check_tool = $(if $(shell which $(1)),,$(error Need to have '$(1)' installed.)) +check_tool = $(if $(shell command -v $(1)),,$(error Need to have '$(1)' installed.)) # # Tool chain version check @@ -363,7 +363,7 @@ gen_deps_and_build_targets: $(CCACHED_CUSTOM_CC) $(CCACHED_CUSTOM_CXX) # create ccache symlinks at var/tool/ccache/ $(CCACHED_CUSTOM_CC) $(CCACHED_CUSTOM_CXX): $(VERBOSE_MK)mkdir -p $(dir $@) - $(VERBOSE_MK)ln -sf `which ccache` $@ + $(VERBOSE_MK)ln -sf `command -v ccache` $@ # supplement tool-chain directory to the search-path variable used by ccache ifneq ($(filter /%,$(CUSTOM_CXX)),) diff --git a/tool/ports/mk/common.inc b/tool/ports/mk/common.inc index 9c0a431b71..dd1c5e4179 100644 --- a/tool/ports/mk/common.inc +++ b/tool/ports/mk/common.inc @@ -31,4 +31,4 @@ MSG_GIT := $(MSG_PREFIX_TXT)git # # Utility to check if a tool is installed # -check_tool = $(if $(shell which $(1)),,$(error Need to have '$(1)' installed.)) +check_tool = $(if $(shell command -v $(1)),,$(error Need to have '$(1)' installed.)) diff --git a/tool/run/run b/tool/run/run index 0d4d3a9bf8..8b24bba6a6 100755 --- a/tool/run/run +++ b/tool/run/run @@ -533,11 +533,8 @@ proc have_spec {spec} { global specs; return [expr [lsearch $specs $spec] != -1] # Return true if specified program is installed # proc have_installed {program} { - if {[catch { exec which $program }] == 0} { return true; } - if {[catch { exec which "/sbin/$program" }] == 0} { return true; } - if {[catch { exec which "/usr/sbin/$program" }] == 0} { return true; } - if {[catch { exec which "/usr/local/bin/$program" }] == 0} { return true; } + if {[auto_execok "$program"] != ""} { return true; } return false; }