2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 17:46:38 +00:00

[go-xcat] Get rid of yum-config-manager, it make things easier if package yum-utils is not installed

This commit is contained in:
GONG Jie 2016-06-23 18:06:19 +08:00
parent 34abeed36c
commit e64d09c9b9

View File

@ -533,7 +533,7 @@ function download_file()
# $2 repo id
function add_repo_by_file_yum()
{
type yum-config-manager >/dev/null 2>&1 || return 255
[[ -d /etc/yum.repos.d ]] || return 255
local repo_file="$1"
local repo_id="$2"
[[ -f "${repo_file}" ]]
@ -544,13 +544,11 @@ function add_repo_by_file_yum()
exit_if_bad "$?" "empty repo id"
[[ "${repo_id}" =~ ^[a-zA-Z][0-9a-zA-Z-]*$ ]]
exit_if_bad "$?" "${repo_id} illegal character in repo id"
local tmp_repo_file="${TMP_DIR}/${repo_id}.repo"
remove_repo_yum "${repo_id}"
{
echo "[${repo_id}]"
grep -v '^\[' "${repo_file}"
} >"${tmp_repo_file}"
remove_repo_yum "${repo_id}"
yum-config-manager "--add-repo=${tmp_repo_file}" >/dev/null 2>&1
} >"/etc/yum.repos.d/${repo_id}.repo"
}
# $1 repo file
@ -806,11 +804,13 @@ function add_repo_by_url()
# $1 repo id
function remove_repo_yum()
{
[[ -d "/etc/yum.repos.d" ]] || return 255
type yum >/dev/null 2>&1 || return 255
local repo_id="$1"
[[ -f "/etc/yum.repos.d/${repo_id}.repo" ]] &&
rm -f "/etc/yum.repos.d/${repo_id}.repo" &&
yum clean metadata >/dev/null 2>&1
# This deleting method is not good enough. Since there could be more
# than one repostory definitions in a single repo file.
# This is a quick and dirty method.
rm -f $(grep -l "^\[${repo_id}\]$" "/etc/yum.repos.d/"*".repo")
yum clean metadata >/dev/null 2>&1
}
# $1 repo id
@ -839,8 +839,7 @@ function remove_repo()
# can be "2.10", "2.11", "2.12", "latest" or "devel"
function add_xcat_core_repo_yum_or_zypper()
{
type yum-config-manager >/dev/null 2>&1 ||
type zypper >/dev/null 2>&1 || return 255
type yum >/dev/null 2>&1 || type zypper >/dev/null 2>&1 || return 255
local url="$1"
local ver="$2"
local tmp=""
@ -897,8 +896,7 @@ function add_xcat_core_repo()
function add_xcat_dep_repo_yum_or_zypper()
{
type yum-config-manager >/dev/null 2>&1 ||
type zypper >/dev/null 2>&1 || return 255
type yum >/dev/null 2>&1 || type zypper >/dev/null 2>&1 || return 255
local url="$1"
local tmp=""
local install_path="${GO_XCAT_DEFAULT_INSTALL_PATH}"