From 80ba704a154b8cf1c83d4beb3a7638406173bc03 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Fri, 26 Aug 2016 16:52:06 +0800 Subject: [PATCH 1/4] [go-xcat] Fix github issue #1641, issue #1748 --- xCAT-server/share/xcat/tools/go-xcat | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 62b7ed9e6..794355cef 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -2,7 +2,7 @@ # # go-xcat - Install xCAT automatically. # -# Version 1.0.2 +# Version 1.0.3 # # Copyright (C) 2016 International Business Machines # Eclipse Public License, Version 1.0 (EPL-1.0) @@ -483,7 +483,8 @@ function check_repo_version_dnf() function check_repo_version_yum() { type yum >/dev/null 2>&1 || return 255 - check_exec_or_exit repoquery + check_executes repoquery + exit_if_bad "$?" "Install the 'yum-utils' package and rerun." local -a name=() local -a ver=() while read -r name ver @@ -588,12 +589,12 @@ function get_package_list_dnf() function get_package_list_yum() { type yum >/dev/null 2>&1 || return 255 - check_exec_or_exit repoquery + check_executes repoquery + exit_if_bad "$?" "Install the 'yum-utils' package and rerun." local repo_id="$1" [[ -z "${repo_id}" ]] && return 1 repoquery -qa "--repoid=${repo_id}" --qf "%{name}" 2>/dev/null } - # $1 repo id function get_package_list_zypper() { @@ -611,8 +612,13 @@ function get_package_list_apt() local repo_id="$1" [[ -z "${repo_id}" ]] && return 1 awk '/^Package: / { print $2 }' \ - <"/var/lib/apt/lists/"*"_${repo_id}_dists"*"_main_binary-"*"_Packages" \ + "/var/lib/apt/lists/"*"_${repo_id}_dists"*"_main_binary-"*"_Packages" \ 2>/dev/null + # This is a dirty hack, and use recursion. + # For the `devel' branch of the online repo for apt, it has the + # subdirectory name of `core-snap' instead of `xcat-core'. + [[ "$?" -ne "0" && "${repo_id}" = "xcat-core" ]] && + "${FUNCNAME}" "core-snap" } # $1 repo id @@ -1519,7 +1525,10 @@ case "${GO_XCAT_ACTION}" in esac fi ( - "${GO_XCAT_INSTALLER}" "${GO_XCAT_YES[@]}" 2>&1 1>&42 | + # Use `-y' here. Since the STDOUT is redirect to tee. + # `yum' does not display the prompt message properly when + # working with tee. + "${GO_XCAT_INSTALLER}" -y 2>&1 1>&42 | tee "${TMP_DIR}/${GO_XCAT_INSTALLER}.stderr" >&2 exit "${PIPESTATUS[0]}" ) 42>&1 | tee "${TMP_DIR}/${GO_XCAT_INSTALLER}.stdout" @@ -1557,8 +1566,6 @@ case "${GO_XCAT_ACTION}" in fi fi >"${TMP_DIR}/go-xcat.log.008" - list_xcat_packages | tee "${TMP_DIR}/go-xcat.log.099" - if [[ "${RET}" -ne "0" ]] then GO_XCAT_LOG="/tmp/go-xcat.log" @@ -1600,6 +1607,7 @@ case "${GO_XCAT_ACTION}" in xCAT has been updated! ====================== + Congratulations! EOF ;; esac From 22a16ed80351aa990a784f9f3b23d520534adaea Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Wed, 31 Aug 2016 13:46:43 +0800 Subject: [PATCH 2/4] [go-xcat] Another patch for github issue #1641 --- xCAT-server/share/xcat/tools/go-xcat | 53 +++++++++++----------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 794355cef..01419fa6c 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -2,7 +2,7 @@ # # go-xcat - Install xCAT automatically. # -# Version 1.0.3 +# Version 1.0.5 # # Copyright (C) 2016 International Business Machines # Eclipse Public License, Version 1.0 (EPL-1.0) @@ -136,14 +136,7 @@ GO_XCAT_DEFAULT_BASE_URL="http://xcat.org/files/xcat/repos" GO_XCAT_DEFAULT_INSTALL_PATH="/install/xcat" # The package list of xcat-core -GO_XCAT_CORE_PACKAGE_LIST=(perl-xCAT xCAT xCAT-SoftLayer xCAT-buildkit - xCAT-client xCAT-confluent xCAT-genesis-scripts-ppc64 - xCAT-genesis-scripts-x86_64 xCAT-server xCAT-test xCAT-vlan xCATsn) -# For Debian/Ubuntu, it will need a sight different package list -type dpkg >/dev/null 2>&1 && -GO_XCAT_CORE_PACKAGE_LIST=(perl-xcat xcat xcat-buildkit xcat-client - xcat-confluent xcat-genesis-scripts-amd64 xcat-genesis-scripts-ppc64 - xcat-server xcat-test xcat-vlan xcatsn) +GO_XCAT_CORE_PACKAGE_LIST=() GO_XCAT_DEP_PACKAGE_LIST=() # The package list of all the packages should be installed @@ -293,7 +286,7 @@ function internal_cleanup() # function custom_setup() { - check_exec_or_exit awk cat printf sort sleep tee + check_exec_or_exit awk cat comm printf sleep tee check_root_or_exit } @@ -1168,12 +1161,12 @@ function update_xcat() { local -i i=0 local ver="" + local -a xcat_core_package_list + xcat_core_package_list=($(get_package_list xcat-core)) + exit_if_bad "$?" "Fail to get package list from repository 'xcat-core'." local -a install_list=($( - for p in "${GO_XCAT_INSTALL_LIST[@]}" \ - $(get_package_list xcat-core) - do - echo "${p}" - done | sort -u + comm <(echo "${GO_XCAT_INSTALL_LIST[@]}") \ + <(echo "${xcat_core_package_list[@]}") )) for i in "${!install_list[@]}" do @@ -1186,14 +1179,10 @@ function update_xcat() function list_xcat_packages() { - GO_XCAT_CORE_PACKAGE_LIST=($( - for p in "${GO_XCAT_CORE_PACKAGE_LIST[@]}" \ - $(get_package_list xcat-core) - do - echo "${p}" - done | sort -u - )) + GO_XCAT_CORE_PACKAGE_LIST=($(get_package_list xcat-core)) + exit_if_bad "$?" "Fail to get package list from repository 'xcat-core'." GO_XCAT_DEP_PACKAGE_LIST=($(get_package_list xcat-dep)) + exit_if_bad "$?" "Fail to get package list from repository 'xcat-dep'." local -i cols="$(type tput >/dev/null 2>&1 && tput cols)" [[ "${cols}" -lt 80 ]] && cols=80 @@ -1484,9 +1473,9 @@ echo echo -n "Reading repositories " show_progress_meters ERR_MSG="$({ - if add_xcat_core_repo "${GO_XCAT_YES[@]}" "${GO_XCAT_CORE_URL}" "${GO_XCAT_VERSION}" + if add_xcat_core_repo -y "${GO_XCAT_CORE_URL}" "${GO_XCAT_VERSION}" then - if add_xcat_dep_repo "${GO_XCAT_YES[@]}" "${GO_XCAT_DEP_URL}" + if add_xcat_dep_repo -y "${GO_XCAT_DEP_URL}" then update_repo && exit 0 remove_repo "xcat-dep" @@ -1524,15 +1513,13 @@ case "${GO_XCAT_ACTION}" in exit 0 esac fi - ( - # Use `-y' here. Since the STDOUT is redirect to tee. - # `yum' does not display the prompt message properly when - # working with tee. - "${GO_XCAT_INSTALLER}" -y 2>&1 1>&42 | - tee "${TMP_DIR}/${GO_XCAT_INSTALLER}.stderr" >&2 - exit "${PIPESTATUS[0]}" - ) 42>&1 | tee "${TMP_DIR}/${GO_XCAT_INSTALLER}.stdout" - RET="${PIPESTATUS[0]}" + # Use `-y' here. Since the STDOUT is redirect to tee. + # `yum' does not display the prompt message properly when + # working with tee. + "${GO_XCAT_INSTALLER}" -y \ + > >(tee "${TMP_DIR}/${GO_XCAT_INSTALLER}.stdout") \ + 2> >(tee "${TMP_DIR}/${GO_XCAT_INSTALLER}.stderr" >&2) + RET="$?" { # Creating logs echo "-- 8< -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" From 0643166295fd9fd76c5f3dbaa8e58a5a04d7feb8 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Sun, 18 Sep 2016 22:27:24 +0800 Subject: [PATCH 3/4] [go-xcat] Handle command argument more flexible --- xCAT-server/share/xcat/tools/go-xcat | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 01419fa6c..6a642320d 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -1379,12 +1379,24 @@ do verbose_usage exit 0 ;; + "--xcat-core") + shift + GO_XCAT_CORE_URL="$1" + ;; "--xcat-core="*) GO_XCAT_CORE_URL="${1##--xcat-core=}" ;; + "--xcat-dep") + shift + GO_XCAT_DEP_URL="$1" + ;; "--xcat-dep="*) GO_XCAT_DEP_URL="${1##--xcat-dep=}" ;; + "--xcat-version") + shift + GO_XCAT_VERSION="$1" + ;; "--xcat-version="*) GO_XCAT_VERSION="${1##--xcat-version=}" ;; From 6ca356cfb7a155b44848caac997db037539c73f0 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Sun, 18 Sep 2016 23:25:18 +0800 Subject: [PATCH 4/4] [go-xcat] Change the output based on the comment of @geruvichmark --- xCAT-server/share/xcat/tools/go-xcat | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 6a642320d..de5f0d21c 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -1595,18 +1595,15 @@ case "${GO_XCAT_ACTION}" in commands to set environment variables into your PATH: for sh, - \`source /etc/profile.d/xcat.sh\` + \`source /etc/profile.d/xcat.sh' or csh, - \`source /etc/profile.d/xcat.csh\` + \`source /etc/profile.d/xcat.csh' EOF ;; "update") while read -r ; do echo "${REPLY}" ; done <<-EOF - xCAT has been updated! - ====================== - - Congratulations! + xCAT has been successfully updated! EOF ;; esac