[MDEV-13946] Server RPMs have dependency on "which" Created: 2017-09-28  Updated: 2018-02-13  Resolved: 2017-10-10

Status: Closed
Project: MariaDB Server
Component/s: Packaging, Platform SUSE, wsrep
Affects Version/s: 10.1.28, 10.2.9
Fix Version/s: 10.1.29, 10.2.10, 10.3.5

Type: Bug Priority: Blocker
Reporter: Kolbe Kegel (Inactive) Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None
Environment:

RPM-based Linux distributions.


Issue Links:
Blocks
Problem/Incident
is caused by MDEV-10954 MariaDB Galera: wsrep_sst_common: lin... Closed
Sprint: 10.2.10

 Description   

Our Server RPMs have a dependency on "which" if they're build with wsrep support:

cmake/cpack_rpm.cmake:170:

IF(WITH_WSREP)
SETA(CPACK_RPM_server_PACKAGE_REQUIRES
  "galera" "rsync" "lsof" "grep" "gawk" "iproute"
  "coreutils" "findutils" "tar" "which")
ENDIF()

This breaks installations on SLES11, because SLES11 does not have any package that provides the "which" capability. (The which(1) tool itself is included in some other package.) It's also worth noting that many Docker containers and other very lightweight environments may not include which(1), either.

This is because which(1) is used in a large number of galera shell scripts (as well as other shell scripts):

server $ grep -r -c which scripts/
scripts/.wsrep_sst_mariabackup.sh.swp:2
scripts/CMakeLists.txt:0
scripts/comp_sql.c:1
scripts/convert-debug-for-diff.sh:0
scripts/dheadgen.pl:0
scripts/fill_help_tables.sql:90
scripts/galera_new_cluster.sh:0
scripts/galera_recovery.sh:0
scripts/make_win_bin_dist:0
scripts/maria_add_gis_sp.sql.in:0
scripts/mariadb-service-convert:0
scripts/msql2mysql.sh:0
scripts/mysql_config.pl.in:3
scripts/mysql_config.sh:3
scripts/mysql_convert_table_format.sh:0
scripts/mysql_find_rows.sh:0
scripts/mysql_fix_extensions.sh:0
scripts/mysql_install_db.pl.in:6
scripts/mysql_install_db.sh:6
scripts/mysql_performance_tables.sql:0
scripts/mysql_secure_installation.pl.in:0
scripts/mysql_secure_installation.sh:2
scripts/mysql_setpermission.sh:11
scripts/mysql_system_tables.sql:2
scripts/mysql_system_tables_data.sql:1
scripts/mysql_system_tables_fix.sql:0
scripts/mysql_test_data_timezone.sql:0
scripts/mysql_to_mariadb.sql:0
scripts/mysqlaccess.conf:0
scripts/mysqlaccess.sh:31
scripts/mysqld_multi.sh:10
scripts/mysqld_safe.sh:12
scripts/mysqldumpslow.sh:0
scripts/mysqlhotcopy.sh:7
scripts/mytop.sh:17
scripts/wsrep_sst_common.sh:4
scripts/wsrep_sst_mariabackup.sh:8
scripts/wsrep_sst_mysqldump.sh:0
scripts/wsrep_sst_rsync.sh:3
scripts/wsrep_sst_xtrabackup-v2.sh:8
scripts/wsrep_sst_xtrabackup.sh:5

For example:

scripts/wsrep_sst_xtrabackup.sh:        if [[ ! -x `which nc` ]];then
scripts/wsrep_sst_xtrabackup.sh:        if [[ ! -x `which socat` ]];then
scripts/wsrep_sst_xtrabackup.sh:if [[ ! -x `which innobackupex` ]];then
scripts/wsrep_sst_xtrabackup.sh:            if [[ ! -x `which qpress` ]];then

This is a very poor way to perform this kind of check. It unnecessarily requires an external tool, which makes it fragile and error-prone. The POSIX way to perform this same check would be to do, for example,

if ! command -v nc  >/dev/null;then

.

This change should be made across all shell scripts shipped by MariaDB Server, and the dependency on which(1) should be removed.



 Comments   
Comment by Kolbe Kegel (Inactive) [ 2017-09-28 ]

Here's a brute-force way to solve the SLES11-specific part of this problem:

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")
  ELSE()
    SETA(CPACK_RPM_server_PACKAGE_REQUIRES "which")
  ENDIF()
ENDIF()

Comment by Sergei Golubchik [ 2017-10-09 ]

I'll use your "brute-force" fix as above.

$ command -v ls
alias ls='ls --color=auto'

and I am not sure whether we could ignore that.

Comment by Kolbe Kegel (Inactive) [ 2017-10-10 ]

serg, alias expansion is disabled by default in non-interactive shell sessions, such as a script. ("Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt")

Comment by Sergei Golubchik [ 2017-10-10 ]

Indeed. Then I'll remove which in 10.2 or 10.3, as a cleanup

Generated at Thu Feb 08 08:09:38 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.