Skip to content

Commit

Permalink
Merge pull request #1906 from saltstack/3006_release_stable_install
Browse files Browse the repository at this point in the history
Update with 3006 stable installs
  • Loading branch information
garethgreenaway authored Apr 15, 2023
2 parents 84b4e2a + 2af0e6c commit 9fa32bd
Showing 1 changed file with 191 additions and 15 deletions.
206 changes: 191 additions & 15 deletions bootstrap-salt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -616,20 +616,32 @@ if [ "$ITYPE" = "git" ]; then
# If doing stable install, check if version specified
elif [ "$ITYPE" = "stable" ]; then
if [ "$#" -eq 0 ];then
STABLE_REV="latest"
ONEDIR_REV="latest"
_ONEDIR_REV="$1"
ITYPE="onedir"
else
if [ "$(echo "$1" | grep -E '^(latest|1\.6|1\.7|2014\.1|2014\.7|2015\.5|2015\.8|2016\.3|2016\.11|2017\.7|2018\.3|2019\.2|3000|3001|3002|3003|3004|3005)$')" != "" ]; then
if [ "$(echo "$1" | grep -E '^(nightly|latest|3006)$')" != "" ]; then
ONEDIR_REV="$1"
_ONEDIR_REV="$1"
ITYPE="onedir"
shift
elif [ "$(echo "$1" | grep -E '^(3003|3004|3005)$')" != "" ]; then
STABLE_REV="$1"
shift
elif [ "$(echo "$1" | grep -E '^(2[0-9]*\.[0-9]*\.[0-9]*|[3-9][0-9]{3}(\.[0-9]*)?)$')" != "" ]; then
elif [ "$(echo "$1" | grep -E '^([3-9][6-9]{3}(\.[0-9]*)?)')" != "" ]; then
ONEDIR_REV="minor/$1"
_ONEDIR_REV="$1"
ITYPE="onedir"
shift
elif [ "$(echo "$1" | grep -E '^([3-9][0-5]{3}(\.[0-9]*)?)$')" != "" ]; then
# Handle the 3xxx.0 version as 3xxx archive (pin to minor) and strip the fake ".0" suffix
STABLE_REV=$(echo "$1" | sed -E 's/^([3-9][0-9]{3})\.0$/\1/')
if [ "$(uname)" != "Darwin" ]; then
STABLE_REV="archive/$STABLE_REV"
fi
shift
else
echo "Unknown stable version: $1 (valid: 1.6, 1.7, 2014.1, 2014.7, 2015.5, 2015.8, 2016.3, 2016.11, 2017.7, 2018.3, 2019.2, 3000, 3001, 3002, 3003, 3004, 3005, latest, \$MAJOR.\$MINOR.\$PATCH until 2019.2, \$MAJOR or \$MAJOR.\$PATCH starting from 3000)"
echo "Unknown stable version: $1 (valid: 3003, 3004, 3005, 3006, latest)"
exit 1
fi
fi
Expand All @@ -638,7 +650,7 @@ elif [ "$ITYPE" = "onedir" ]; then
if [ "$#" -eq 0 ];then
ONEDIR_REV="latest"
else
if [ "$(echo "$1" | grep -E '^(nightly|latest|3005)$')" != "" ]; then
if [ "$(echo "$1" | grep -E '^(nightly|latest|3005|3006)$')" != "" ]; then
ONEDIR_REV="$1"
shift
elif [ "$(echo "$1" | grep -E '^(3005(\.[0-9]*)?)')" != "" ]; then
Expand All @@ -650,7 +662,7 @@ elif [ "$ITYPE" = "onedir" ]; then
ONEDIR_REV="minor/$1"
shift
else
echo "Unknown onedir version: $1 (valid: 3005, latest, nightly.)"
echo "Unknown onedir version: $1 (valid: 3005, 3006, latest, nightly.)"
exit 1
fi
fi
Expand Down Expand Up @@ -888,6 +900,18 @@ __fetch_verify() {
return 1
}

#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __check_url_exists
# DESCRIPTION: Checks if a URL exists
#----------------------------------------------------------------------------------------------------------------------
__check_url_exists() {
_URL="$1"
if curl --output /dev/null --silent --fail "${_URL}"; then
return 0
else
return 1
fi
}
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __gather_hardware_info
# DESCRIPTION: Discover hardware information
Expand Down Expand Up @@ -3078,8 +3102,11 @@ __install_saltstack_ubuntu_onedir_repository() {
fi
echo "$__REPO_ARCH_DEB $SALTSTACK_UBUNTU_URL $UBUNTU_CODENAME main" > /etc/apt/sources.list.d/salt.list

if [ "$(echo "${ONEDIR_REV}" | grep -E '(3004|3005|nightly)')" != "" ]; then
if [ "$(echo "${ONEDIR_REV}" | grep -E '(3004|3005)')" != "" ]; then
__apt_key_fetch "${SALTSTACK_UBUNTU_URL}salt-archive-keyring.gpg" || return 1
elif [ "$(echo "${ONEDIR_REV}" | grep -E '(latest|nightly)')" != "" ]; then
__apt_key_fetch "${SALTSTACK_UBUNTU_URL}salt-archive-keyring.gpg" || \
__apt_key_fetch "${SALTSTACK_UBUNTU_URL}SALT-PROJECT-GPG-PUBKEY-2023.gpg" || return 1
else
__apt_key_fetch "${SALTSTACK_UBUNTU_URL}SALT-PROJECT-GPG-PUBKEY-2023.gpg" || return 1
fi
Expand Down Expand Up @@ -3622,8 +3649,11 @@ __install_saltstack_debian_onedir_repository() {
fi
echo "$__REPO_ARCH_DEB $SALTSTACK_DEBIAN_URL $DEBIAN_CODENAME main" > "/etc/apt/sources.list.d/salt.list"

if [ "$(echo "${ONEDIR_REV}" | grep -E '(3004|3005|nightly)')" != "" ]; then
if [ "$(echo "${ONEDIR_REV}" | grep -E '(3004|3005)')" != "" ]; then
__apt_key_fetch "${SALTSTACK_DEBIAN_URL}salt-archive-keyring.gpg" || return 1
elif [ "$(echo "${ONEDIR_REV}" | grep -E '(latest|nightly)')" != "" ]; then
__apt_key_fetch "${SALTSTACK_DEBIAN_URL}salt-archive-keyring.gpg" || \
__apt_key_fetch "${SALTSTACK_DEBIAN_URL}SALT-PROJECT-GPG-PUBKEY-2023.gpg" || return 1
else
__apt_key_fetch "${SALTSTACK_DEBIAN_URL}SALT-PROJECT-GPG-PUBKEY-2023.gpg" || return 1
fi
Expand Down Expand Up @@ -4427,6 +4457,19 @@ install_fedora_check_services() {

return 0
}
install_fedora_onedir() {
STABLE_REV=$ONEDIR_REV
install_fedora_stable || return 1

return 0
}

install_fedora_onedir_post() {
STABLE_REV=$ONEDIR_REV
install_fedora_stable_post || return 1

return 0
}
#
# Ended Fedora Install Functions
#
Expand Down Expand Up @@ -4510,12 +4553,22 @@ __install_saltstack_rhel_onedir_repository() {
if [ "${ONEDIR_REV}" = "nightly" ] ; then
base_url="${HTTP_VAL}://${_REPO_URL}/${_ONEDIR_NIGHTLY_DIR}/${__PY_VERSION_REPO}/redhat/${DISTRO_MAJOR_VERSION}/\$basearch/"
fi
if [ "$(echo "${ONEDIR_REV}" | grep -E '(3004|3005|nightly)')" != "" ]; then
if [ "$(echo "${ONEDIR_REV}" | grep -E '(3004|3005)')" != "" ]; then
if [ "${DISTRO_MAJOR_VERSION}" -eq 9 ]; then
gpg_key="SALTSTACK-GPG-KEY2.pub"
else
gpg_key="SALTSTACK-GPG-KEY.pub"
fi
elif [ "$(echo "${ONEDIR_REV}" | grep -E '(latest|nightly)')" != "" ]; then
if __check_url_exists "${base_url}SALT-PROJECT-GPG-PUBKEY-2023.pub"; then
gpg_key="SALT-PROJECT-GPG-PUBKEY-2023.pub"
else
if [ "${DISTRO_MAJOR_VERSION}" -eq 9 ]; then
gpg_key="SALTSTACK-GPG-KEY2.pub"
else
gpg_key="SALTSTACK-GPG-KEY.pub"
fi
fi
else
gpg_key="SALT-PROJECT-GPG-PUBKEY-2023.pub"
fi
Expand Down Expand Up @@ -6303,11 +6356,17 @@ install_amazon_linux_ami_2_onedir_deps() {
base_url="$HTTP_VAL://${_REPO_URL}/${_ONEDIR_NIGHTLY_DIR}/${__PY_VERSION_REPO}/amazon/2/\$basearch/"
fi

if [ "$(echo "${ONEDIR_REV}" | grep -E '(3004|3005|nightly)')" != "" ]; then
if [ "$(echo "${ONEDIR_REV}" | grep -E '(3004|3005)')" != "" ]; then
gpg_key="${base_url}SALTSTACK-GPG-KEY.pub,${base_url}base/RPM-GPG-KEY-CentOS-7"
if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then
gpg_key="${base_url}SALTSTACK-GPG-KEY.pub"
fi
elif [ "$(echo "${ONEDIR_REV}" | grep -E '(latest|nightly)')" != "" ]; then
if __check_url_exists "${base_url}SALT-PROJECT-GPG-PUBKEY-2023.pub"; then
gpg_key="${base_url}SALT-PROJECT-GPG-PUBKEY-2023.pub"
else
gpg_key="${base_url}SALTSTACK-GPG-KEY.pub"
fi
else
gpg_key="${base_url}SALT-PROJECT-GPG-PUBKEY-2023.pub"
fi
Expand Down Expand Up @@ -6528,6 +6587,10 @@ install_arch_linux_git_deps() {
return 0
}

install_arch_linux_onedir_deps() {
install_arch_linux_stable_deps || return 1
}

install_arch_linux_stable() {
# Pacman does not resolve dependencies on outdated versions
# They always need to be updated
Expand Down Expand Up @@ -6680,6 +6743,18 @@ install_arch_check_services() {

return 0
}

install_arch_linux_onedir() {
install_arch_linux_stable || return 1

return 0
}

install_arch_linux_onedir_post() {
install_arch_linux_post || return 1

return 0
}
#
# Ended Arch Install Functions
#
Expand Down Expand Up @@ -6858,6 +6933,15 @@ install_freebsd_restart_daemons() {
service salt_$fname start
done
}

install_freebsd_onedir() {
#
# call install_freebsd_stable
#
install_freebsd_stable || return 1

return 0
}
#
# Ended FreeBSD Install Functions
#
Expand Down Expand Up @@ -6976,6 +7060,14 @@ install_openbsd_restart_daemons() {
return 0
}

install_openbsd_onedir() {
#
# Call install_openbsd_stable
#
install_openbsd_stable || return 1

return 0
}
#
# Ended OpenBSD Install Functions
#
Expand Down Expand Up @@ -7176,6 +7268,14 @@ install_smartos_restart_daemons() {

return 0
}
install_smartos_onedir() {
#
# call install_smartos_stable
#
install_smartos_stable || return 1

return 0
}
#
# Ended SmartOS Install Functions
#
Expand Down Expand Up @@ -7360,6 +7460,10 @@ install_opensuse_git_deps() {
return 0
}

install_opensuse_onedir_deps() {
install_opensuse_stable_deps || return 1
}

install_opensuse_stable() {
__PACKAGES=""

Expand Down Expand Up @@ -7392,6 +7496,10 @@ install_opensuse_git() {
return 0
}

install_opensuse_onedir() {
install_opensuse_stable || return 1
}

install_opensuse_stable_post() {
for fname in api master minion syndic; do
# Skip salt-api since the service should be opt-in and not necessarily started on boot
Expand Down Expand Up @@ -7461,6 +7569,10 @@ install_opensuse_git_post() {
return 0
}

install_opensuse_onedir_post() {
install_opensuse_stable_post || return 1
}

install_opensuse_restart_daemons() {
[ $_START_DAEMONS -eq $BS_FALSE ] && return

Expand Down Expand Up @@ -7966,11 +8078,6 @@ __gentoo_pre_dep() {
mkdir /etc/portage
fi

# Enable Python 3.6 target for pre Neon Salt release
if echo "${STABLE_REV}" | grep -q "2019" || [ "${ITYPE}" = "git" ] && [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then
EXTRA_PYTHON_TARGET=python3_6
fi

# Enable Python 3.7 target for Salt Neon using GIT
if [ "${ITYPE}" = "git" ] && [ "${GIT_REV}" = "v3000" ]; then
EXTRA_PYTHON_TARGET=python3_7
Expand Down Expand Up @@ -8116,6 +8223,11 @@ install_gentoo_git() {
return 0
}

install_gentoo_onedir() {
STABLE_REV=${ONEDIR_REV}
install_gentoo_stable || return 1
}

install_gentoo_post() {
for fname in api master minion syndic; do
# Skip salt-api since the service should be opt-in and not necessarily started on boot
Expand Down Expand Up @@ -8205,6 +8317,10 @@ _eof
return 0
}

install_gentoo_onedir_post() {
install_gentoo_post || return 1
}

install_gentoo_restart_daemons() {
[ $_START_DAEMONS -eq $BS_FALSE ] && return

Expand Down Expand Up @@ -8359,17 +8475,62 @@ __macosx_get_packagesite() {
SALTPKGCONFURL="https://${_REPO_URL}/osx/${PKG}"
}

__parse_repo_json_python() {

# Using latest, grab the right
# version from the repo.json
_JSON_LATEST_VERSION=$(python - <<-EOF
import json, urllib.request
url = "https://repo.saltproject.io/salt/py3/macos/repo.json"
response = urllib.request.urlopen(url)
data = json.loads(response.read())
version = data['latest'][list(data['latest'])[0]]['version']
print(version)
EOF
)
echo "${_JSON_LATEST_VERSION}"
}

__macosx_get_packagesite_onedir() {
DARWIN_ARCH="x86_64"

__PY_VERSION_REPO="py2"
if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then
__PY_VERSION_REPO="py3"
fi

if [ "$(echo "$_ONEDIR_REV" | grep -E '^(latest)$')" != "" ]; then
_ONEDIR_REV=$(__parse_repo_json_python)
fi
if [ "$(echo "$_ONEDIR_REV" | grep -E '^(3005)')" != "" ]; then
PKG="salt-${_ONEDIR_REV}-macos-${DARWIN_ARCH}.pkg"
else
PKG="salt-${_ONEDIR_REV}-${__PY_VERSION_REPO}-${DARWIN_ARCH}.pkg"
fi
SALTPKGCONFURL="https://${_REPO_URL}/${_ONEDIR_DIR}/${__PY_VERSION_REPO}/macos/${_ONEDIR_REV}/${PKG}"
}

# Using a separate conf step to head for idempotent install...
__configure_macosx_pkg_details() {
__macosx_get_packagesite || return 1
return 0
}

__configure_macosx_pkg_details_onedir() {
__macosx_get_packagesite_onedir || return 1
return 0
}

install_macosx_stable_deps() {
__configure_macosx_pkg_details || return 1
return 0
}

install_macosx_onedir_deps() {
__configure_macosx_pkg_details_onedir || return 1
return 0
}

install_macosx_git_deps() {
install_macosx_stable_deps || return 1

Expand Down Expand Up @@ -8416,6 +8577,16 @@ install_macosx_stable() {
return 0
}

install_macosx_onedir() {
install_macosx_onedir_deps || return 1

__fetch_url "/tmp/${PKG}" "${SALTPKGCONFURL}" || return 1

/usr/sbin/installer -pkg "/tmp/${PKG}" -target / || return 1

return 0
}

install_macosx_git() {

if [ -n "$_PY_EXE" ]; then
Expand Down Expand Up @@ -8453,6 +8624,11 @@ install_macosx_stable_post() {
return 0
}

install_macosx_onedir_post() {
install_macosx_stable_post || return 1
return 0
}

install_macosx_git_post() {
install_macosx_stable_post || return 1
return 0
Expand Down

0 comments on commit 9fa32bd

Please sign in to comment.