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