Skip to content

Commit

Permalink
chore: Update salt installation repository
Browse files Browse the repository at this point in the history
SaltProject packages have been migrated from repo.saltproject.io to packages.broadcom.com repository.

https://saltproject.io/blog/salt-project-package-repo-migration-and-guidance/

This commit closes Salt Project needs to migrate the Salt package repository #273
  • Loading branch information
cdalvaro committed Oct 30, 2024
1 parent 28710b9 commit c2c4174
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ jobs:
- name: Install and configure salt-minion
run: |
# Install salt-minion from salt repos
curl -o bootstrap-salt.sh -L https://bootstrap.saltproject.io/bootstrap-salt.sh
salt_bootstrap_url="https://github.com/saltstack/salt-bootstrap/releases/latest/download/bootstrap-salt.sh"
curl -o bootstrap-salt.sh -L "${salt_bootstrap_url}"
sudo sh bootstrap-salt.sh -dXP stable
sudo systemctl stop salt-minion
sudo systemctl disable salt-minion
Expand Down
53 changes: 26 additions & 27 deletions assets/build/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

set -o errexit
set -o pipefail
set -o nounset

DEBUG="${DEBUG:-false}"
ECHO_DEBUG="${ECHO_DEBUG:-false}"

#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: log_debug
Expand All @@ -26,26 +30,24 @@ function log_info() {
# DESCRIPTION: Echo warning information to stdout.
#----------------------------------------------------------------------------------------------------------------------
function log_warn() {
(>&2 echo "[WARN] - $*")
(echo >&2 "[WARN] - $*")
}

#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: log_error
# DESCRIPTION: Echo errors to stderr.
#----------------------------------------------------------------------------------------------------------------------
function log_error()
{
(>&2 echo "[ERROR] - $*")
function log_error() {
(echo >&2 "[ERROR] - $*")
}

#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: exec_as_salt
# DESCRIPTION: Execute the pass command as the `SALT_USER` user.
#----------------------------------------------------------------------------------------------------------------------
function exec_as_salt()
{
function exec_as_salt() {
if [[ $(whoami) == "${SALT_USER}" ]]; then
$@
"$@"
else
sudo -HEu "${SALT_USER}" "$@"
fi
Expand All @@ -55,18 +57,16 @@ function exec_as_salt()
# NAME: is_arm64
# DESCRIPTION: Check whether the platform is ARM 64-bits or not.
#----------------------------------------------------------------------------------------------------------------------
function is_arm64()
{
function is_arm64() {
uname -m | grep -qE 'arm64|aarch64'
}

#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: install_pkgs
# DESCRIPTION: Install packages using apt-get install.
#----------------------------------------------------------------------------------------------------------------------
function install_pkgs()
{
apt-get install --no-install-recommends --yes $@
function install_pkgs() {
apt-get install --no-install-recommends --yes "$@"
}

#--- FUNCTION -------------------------------------------------------------------------------------------------------
Expand All @@ -76,15 +76,14 @@ function install_pkgs()
# 1: URL where the file is hosted.
# 2: Filename (with path) for the downloaded file.
#----------------------------------------------------------------------------------------------------------------------
function download()
{
function download() {
local URL="$1"
local FILE_NAME="$2"

local WGET_ARGS=(--quiet)

log_info "Downloading ${FILE_NAME} from ${URL} ..."
wget ${WGET_ARGS[@]} -O "${FILE_NAME}" "${URL}"
wget "${WGET_ARGS[@]}" -O "${FILE_NAME}" "${URL}"
if [[ -f "${FILE_NAME}" ]]; then
log_debug "Success!"
else
Expand All @@ -100,16 +99,16 @@ function download()
# 1: The file to check.
# 2: The expected SHA256 checksum.
#----------------------------------------------------------------------------------------------------------------------
function check_sha256()
{
function check_sha256() {
local FILE="${1}"
local SHA256="${2}"

log_info "Checking ${FILE} SHA256 hash ..."
if echo "${SHA256} ${FILE}" | shasum -a 256 -c --status -; then
log_debug "SHA256 hash for ${FILE} matches! (${SHA256})"
else
local HASH=$(shasum -a 256 "${FILE}" | awk '{print $1}')
local HASH=
HASH=$(shasum -a 256 "${FILE}" | awk '{print $1}')
log_error "SHA256 checksum mismatch for ${FILE}"
log_error "Expected: ${SHA256}"
log_error " Got: ${HASH}"
Expand All @@ -123,8 +122,7 @@ function check_sha256()
# ARGUMENTS:
# 1: The file to extract.
#----------------------------------------------------------------------------------------------------------------------
function extract()
{
function extract() {
local FILE="${1}"
log_info "Unpacking file: ${FILE}"
tar xzf "${FILE}" --strip-components 1
Expand All @@ -134,15 +132,16 @@ function extract()
# NAME: add_salt_repository
# DESCRIPTION: Add salt repository to packages sources.
#----------------------------------------------------------------------------------------------------------------------
function add_salt_repository()
{
function add_salt_repository() {
local arch=amd64
is_arm64 && arch=arm64
source /etc/os-release

local keyring_file="/etc/apt/keyrings/salt-archive-keyring.gpg"
local root_url="https://repo.saltproject.io/salt/py3/ubuntu/${VERSION_ID:?}/${arch}"
# Download public key
local keyring_file="/etc/apt/keyrings/salt-archive-keyring-2023.pgp"
local key_url="https://packages.broadcom.com/artifactory/api/security/keypair/SaltProjectKey/public"
download "${key_url}" "${keyring_file}"

download "${root_url}/SALT-PROJECT-GPG-PUBKEY-2023.gpg" "${keyring_file}"
echo "deb [signed-by=${keyring_file} arch=${arch}] ${root_url}/minor/${SALT_VERSION} ${VERSION_CODENAME:?} main" > /etc/apt/sources.list.d/salt.list
# Create apt repo target configuration
local target_url="https://packages.broadcom.com/artifactory/saltproject-deb/"
echo "deb [signed-by=${keyring_file} arch=${arch}] ${target_url} stable main" >/etc/apt/sources.list.d/salt.list
}
9 changes: 7 additions & 2 deletions assets/build/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

set -o errexit
set -o pipefail
set -o nounset

export DEBIAN_FRONTEND=noninteractive

# shellcheck source=assets/build/functions.sh
FUNCTIONS_FILE="${SALT_BUILD_DIR}/functions.sh"
# shellcheck source=assets/build/functions.sh
source "${FUNCTIONS_FILE}"

log_info "Installing required packages and build dependencies ..."
Expand Down Expand Up @@ -49,7 +50,11 @@ EOF

# Install salt packages
log_info "Installing salt packages ..."
install_pkgs salt-master="${SALT_VERSION}" salt-minion="${SALT_VERSION}" salt-api="${SALT_VERSION}"
install_pkgs \
salt-common="${SALT_VERSION}" \
salt-master="${SALT_VERSION}" \
salt-minion="${SALT_VERSION}" \
salt-api="${SALT_VERSION}"

# Install python packages
log_info "Installing python packages ..."
Expand Down

0 comments on commit c2c4174

Please sign in to comment.