Commit 355ee687 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-13946 Server RPMs have dependency on "which"

cleanup. use "command -v" instead of "which"
simplify some checks.
parent 2232784f
......@@ -168,11 +168,6 @@ IF(WITH_WSREP)
SETA(CPACK_RPM_server_PACKAGE_REQUIRES
"galera" "rsync" "lsof" "grep" "gawk" "iproute"
"coreutils" "findutils" "tar")
IF (RPM MATCHES "sles11")
SETA(CPACK_RPM_server_PACKAGE_REQUIRES "util-linux")
ELSE()
SETA(CPACK_RPM_server_PACKAGE_REQUIRES "which")
ENDIF()
ENDIF()
SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh)
......@@ -292,4 +287,3 @@ IF(compat53 AND compat101)
ENDIF()
ENDIF(RPM)
......@@ -17,25 +17,6 @@
# This script reports various configuration settings that may be needed
# when using the MariaDB client library.
which ()
{
IFS="${IFS= }"; save_ifs="$IFS"; IFS=':'
for file
do
for dir in $PATH
do
if test -f $dir/$file
then
echo "$dir/$file"
continue 2
fi
done
echo "which: no $file in ($PATH)"
exit 1
done
IFS="$save_ifs"
}
#
# If we can find the given directory relatively to where mysql_config is
# we should use this instead of the incompiled one.
......@@ -70,7 +51,7 @@ get_full_path ()
case $file in
/*) echo "$file";;
*/*) tmp=`pwd`/$file; echo $tmp | sed -e 's;/\./;/;' ;;
*) which $file ;;
*) command -v $file ;;
esac
}
......
......@@ -103,35 +103,6 @@ EOF
exit 1
}
my_which ()
{
save_ifs="${IFS-UNSET}"
IFS=:
ret=0
for file
do
for dir in $PATH
do
if [ -f "$dir/$file" ]
then
echo "$dir/$file"
continue 2
fi
done
ret=1 #signal an error
break
done
if [ "$save_ifs" = UNSET ]
then
unset IFS
else
IFS="$save_ifs"
fi
return $ret # Success
}
find_in_bin() {
if test -x "$MY_BASEDIR_VERSION/bin/$1"
then
......@@ -220,7 +191,8 @@ wsrep_pick_url() {
log_error "WSREP: 'wsrep_urls' is DEPRECATED! Use wsrep_cluster_address to specify multiple addresses instead."
if ! which nc >/dev/null; then
if ! command -v nc >/dev/null
then
log_error "ERROR: nc tool not found in PATH! Make sure you have it installed."
return 1
fi
......@@ -646,8 +618,7 @@ plugin_dir="${plugin_dir}${PLUGIN_VARIANT}"
# Ensure that 'logger' exists, if it's requested
if [ $want_syslog -eq 1 ]
then
my_which logger > /dev/null 2>&1
if [ $? -ne 0 ]
if ! command -v logger > /dev/null
then
log_error "--syslog requested, but no 'logger' program found. Please ensure that 'logger' is in your PATH, or do not specify the --syslog option to mysqld_safe."
exit 1
......@@ -878,7 +849,7 @@ fi
if @TARGET_LINUX@ && test $flush_caches -eq 1
then
# Locate sync, ensure it exists.
if ! my_which sync > /dev/null 2>&1
if ! command -v sync > /dev/null
then
log_error "sync command not found, required for --flush-caches"
exit 1
......@@ -890,7 +861,7 @@ then
fi
# Locate sysctl, ensure it exists.
if ! my_which sysctl > /dev/null 2>&1
if ! command -v sysctl > /dev/null
then
log_error "sysctl command not found, required for --flush-caches"
exit 1
......@@ -934,7 +905,7 @@ cmd="`mysqld_ld_preload_text`$NOHUP_NICENESS"
if @TARGET_LINUX@ && test $numa_interleave -eq 1
then
# Locate numactl, ensure it exists.
if ! my_which numactl > /dev/null 2>&1
if ! command -v numactl > /dev/null
then
log_error "numactl command not found, required for --numa-interleave"
exit 1
......
......@@ -144,13 +144,13 @@ CLIENT_DIR="$SCRIPTS_DIR/../client"
if [ -x "$CLIENT_DIR/mysql" ]; then
MYSQL_CLIENT="$CLIENT_DIR/mysql"
else
MYSQL_CLIENT=$(which mysql)
MYSQL_CLIENT=mysql
fi
if [ -x "$CLIENT_DIR/mysqldump" ]; then
MYSQLDUMP="$CLIENT_DIR/mysqldump"
else
MYSQLDUMP=$(which mysqldump)
MYSQLDUMP=mysqldump
fi
if [ -x "$SCRIPTS_DIR/my_print_defaults" ]; then
......@@ -158,7 +158,7 @@ if [ -x "$SCRIPTS_DIR/my_print_defaults" ]; then
elif [ -x "$EXTRA_DIR/my_print_defaults" ]; then
MY_PRINT_DEFAULTS="$EXTRA_DIR/my_print_defaults"
else
MY_PRINT_DEFAULTS=$(which my_print_defaults)
MY_PRINT_DEFAULTS=my_print_defaults
fi
readonly WSREP_SST_OPT_CONF="$WSREP_SST_OPT_DEFAULT $WSREP_SST_OPT_EXTRA_DEFAULT"
......@@ -226,10 +226,10 @@ wsrep_check_program()
{
local prog=$1
if ! which $prog >/dev/null
if ! command -v $prog >/dev/null
then
echo "'$prog' not found in PATH"
return 2 # no such file or directory
exit 2 # ENOENT no such file or directory
fi
}
......@@ -239,11 +239,9 @@ wsrep_check_programs()
while [ $# -gt 0 ]
do
wsrep_check_program $1 || ret=$?
wsrep_check_program $1
shift
done
return $ret
}
#
......
......@@ -77,7 +77,7 @@ sdecomp=""
# 5.6.21 PXC and later can't donate to an older joiner
sst_ver=1
if which pv &>/dev/null && pv --help | grep -q FORMAT;then
if pv --help 2>/dev/null | grep -q FORMAT;then
pvopts+=$pvformat
fi
pcmd="pv $pvopts"
......@@ -172,10 +172,7 @@ get_transfer()
fi
if [[ $tfmt == 'nc' ]];then
if [[ ! -x `which nc` ]];then
wsrep_log_error "nc(netcat) not found in path: $PATH"
exit 2
fi
wsrep_check_programs nc
wsrep_log_info "Using netcat as streamer"
if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
if nc -h 2>&1 | grep -q ncat;then
......@@ -188,11 +185,8 @@ get_transfer()
fi
else
tfmt='socat'
wsrep_check_programs socat
wsrep_log_info "Using socat as streamer"
if [[ ! -x `which socat` ]];then
wsrep_log_error "socat not found in path: $PATH"
exit 2
fi
if [[ $encrypt -eq 2 || $encrypt -eq 3 ]] && ! socat -V | grep -q "WITH_OPENSSL 1";then
wsrep_log_error "Encryption requested, but socat is not OpenSSL enabled (encrypt=$encrypt)"
......@@ -281,7 +275,7 @@ get_footprint()
adjust_progress()
{
if [[ ! -x `which pv` ]];then
if ! command -v pv >/dev/null;then
wsrep_log_error "pv not found in path: $PATH"
wsrep_log_error "Disabling all progress/rate-limiting"
pcmd=""
......@@ -571,7 +565,7 @@ recv_joiner()
pushd ${dir} 1>/dev/null
set +e
if [[ $tmt -gt 0 && -x `which timeout` ]];then
if [[ $tmt -gt 0 ]] && command -v timeout >/dev/null;then
if timeout --help | grep -q -- '-k';then
ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
else
......@@ -630,10 +624,7 @@ send_donor()
}
if [[ ! -x `which $INNOBACKUPEX_BIN` ]];then
wsrep_log_error "${INNOBACKUPEX_BIN} not in path: $PATH"
exit 2
fi
wsrep_check_programs "$INNOBACKUPEX_BIN"
rm -f "${MAGIC_FILE}"
......@@ -659,7 +650,7 @@ INNOEXTRA=""
if [[ $ssyslog -eq 1 ]];then
if [[ ! -x `which logger` ]];then
if ! command -v logger >/dev/null;then
wsrep_log_error "logger not in path: $PATH. Ignoring"
else
......@@ -943,7 +934,7 @@ then
wsrep_log_info "Compressed qpress files found"
if [[ ! -x `which qpress` ]];then
if ! command -v qpress >/dev/null;then
wsrep_log_error "qpress not found in path: $PATH"
exit 22
fi
......
......@@ -71,7 +71,7 @@ check_pid_and_port()
grep '[[:space:]]\+rsync[[:space:]]\+'"$rsync_pid" 2>/dev/null)"
;;
*)
if ! which lsof > /dev/null; then
if ! command -v lsof > /dev/null; then
wsrep_log_error "lsof tool not found in PATH! Make sure you have it installed."
exit 2 # ENOENT
fi
......@@ -102,10 +102,10 @@ check_pid_and_port()
is_local_ip()
{
local address="$1"
local get_addr_bin=`which ifconfig`
if [ -z "$get_addr_bin" ]
local get_addr_bin
if ! command -v ifconfig > /dev/null
then
get_addr_bin=`which ip`
get_addr_bin=ip
get_addr_bin="$get_addr_bin address show"
# Add an slash at the end, so we don't get false positive : 172.18.0.4 matches 172.18.0.41
# ip output format is "X.X.X.X/mask"
......@@ -113,6 +113,7 @@ is_local_ip()
else
# Add an space at the end, so we don't get false positive : 172.18.0.4 matches 172.18.0.41
# ifconfig output format is "X.X.X.X "
get_addr_bin=ifconfig
address="$address "
fi
......
......@@ -82,7 +82,7 @@ ssl_key=""
# 5.6.21 PXC and later can't donate to an older joiner
sst_ver=1
if which pv &>/dev/null && pv --help | grep -q FORMAT;then
if pv --help 2>/dev/null | grep -q FORMAT;then
pvopts+=$pvformat
fi
pcmd="pv $pvopts"
......@@ -258,10 +258,7 @@ get_transfer()
fi
if [[ $tfmt == 'nc' ]];then
if [[ ! -x `which nc` ]];then
wsrep_log_error "nc(netcat) not found in path: $PATH"
exit 2
fi
wsrep_check_programs nc
if [[ $encrypt -eq 2 || $encrypt -eq 3 || $encrypt -eq 4 ]]; then
wsrep_log_error "******** FATAL ERROR *********************** "
......@@ -285,10 +282,7 @@ get_transfer()
else
tfmt='socat'
wsrep_log_info "Using socat as streamer"
if [[ ! -x `which socat` ]];then
wsrep_log_error "socat not found in path: $PATH"
exit 2
fi
wsrep_check_programs socat
donor_extra=""
joiner_extra=""
......@@ -414,7 +408,7 @@ get_footprint()
adjust_progress()
{
if [[ ! -x `which pv` ]];then
if ! command -v pv >/dev/null;then
wsrep_log_error "pv not found in path: $PATH"
wsrep_log_error "Disabling all progress/rate-limiting"
pcmd=""
......@@ -705,7 +699,7 @@ recv_joiner()
pushd ${dir} 1>/dev/null
set +e
if [[ $tmt -gt 0 && -x `which timeout` ]];then
if [[ $tmt -gt 0 ]] && command -v timeout >/dev/null;then
if timeout --help | grep -q -- '-k';then
ltcmd="timeout -k $(( tmt+10 )) $tmt $tcmd"
else
......@@ -801,10 +795,7 @@ check_for_version()
}
if [[ ! -x `which $INNOBACKUPEX_BIN` ]];then
wsrep_log_error "innobackupex not in path: $PATH"
exit 2
fi
wsrep_check_programs "$INNOBACKUPEX_BIN"
# check the version, we require XB-2.4 to ensure that we can pass the
# datadir via the command-line option
......@@ -846,7 +837,7 @@ INNOEXTRA=""
if [[ $ssyslog -eq 1 ]];then
if [[ ! -x `which logger` ]];then
if ! command -v logger >/dev/null;then
wsrep_log_error "logger not in path: $PATH. Ignoring"
else
......@@ -1119,7 +1110,7 @@ then
wsrep_log_info "Compressed qpress files found"
if [[ ! -x `which qpress` ]];then
if ! command -v qpress >/dev/null;then
wsrep_log_error "qpress not found in path: $PATH"
exit 22
fi
......
......@@ -54,7 +54,7 @@ pvformat="-F '%N => Rate:%r Avg:%a Elapsed:%t %e Bytes: %b %p' "
pvopts="-f -i 10 -N $WSREP_SST_OPT_ROLE "
uextra=0
if which pv &>/dev/null && pv --help | grep -q FORMAT;then
if pv --help 2>/dev/null | grep -q FORMAT;then
pvopts+=$pvformat
fi
pcmd="pv $pvopts"
......@@ -143,10 +143,7 @@ get_transfer()
fi
if [[ $tfmt == 'nc' ]];then
if [[ ! -x `which nc` ]];then
wsrep_log_error "nc(netcat) not found in path: $PATH"
exit 2
fi
wsrep_check_programs nc
wsrep_log_info "Using netcat as streamer"
if [[ "$WSREP_SST_OPT_ROLE" == "joiner" ]];then
if nc -h 2>&1 | grep -q ncat;then
......@@ -159,11 +156,8 @@ get_transfer()
fi
else
tfmt='socat'
wsrep_check_programs socat
wsrep_log_info "Using socat as streamer"
if [[ ! -x `which socat` ]];then
wsrep_log_error "socat not found in path: $PATH"
exit 2
fi
if [[ $encrypt -eq 2 ]] && ! socat -V | grep -q OPENSSL;then
wsrep_log_info "NOTE: socat is not openssl enabled, falling back to plain transfer"
......@@ -409,10 +403,7 @@ check_extra()
fi
}
if [[ ! -x `which innobackupex` ]];then
wsrep_log_error "innobackupex not in path: $PATH"
exit 2
fi
wsrep_check_programs "innobackupex"
rm -f "${MAGIC_FILE}"
......@@ -645,7 +636,7 @@ then
wsrep_log_info "Compressed qpress files found"
if [[ ! -x `which qpress` ]];then
if ! command -v qpress >/dev/null;then
wsrep_log_error "qpress not found in path: $PATH"
exit 22
fi
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment