Commit caf5eea6 authored by Markus Frosch's avatar Markus Frosch
Browse files

rpm: Move extra repository handling to functions and startup

parent 0589a62c
Pipeline #4199 passed with stage
in 27 seconds
......@@ -183,6 +183,46 @@ preconfigure_ccache() {
PATH="${CCACHE_LINKS}:${PATH}"
}
setup_extra_repository() {
local extra_name=icinga-build-extra
local extra_repository="${ICINGA_BUILD_EXTRA_REPOSITORY}"
echo "[ Update extra repository ]"
if [ -n "${ICINGA_BUILD_EXTRA_REPOSITORY_BASE}" ]; then
extra_repository="${ICINGA_BUILD_EXTRA_REPOSITORY_BASE}/${extra_repository}"
fi # base
case "$ICINGA_BUILD_OS" in
opensuse*|sles)
if [ -n "${ICINGA_BUILD_EXTRA_REPOSITORY_USERNAME}" ]; then
echo "Creating /etc/zypp/credentials.d/${extra_name}"
extra_repository="${extra_repository}?credentials=${extra_name}"
(
echo "username=${ICINGA_BUILD_EXTRA_REPOSITORY_USERNAME}"
echo "password=${ICINGA_BUILD_EXTRA_REPOSITORY_PASSWORD}"
) | sudo bash -c "cat >'/etc/zypp/credentials.d/${extra_name}'"
fi
(
set -ex
sudo zypper --non-interactive removerepo "${extra_name}" || true
sudo zypper --non-interactive addrepo --priority 50 --refresh "${extra_repository}" "${extra_name}"
)
;;
*)
# TODO: implement
echo "Other OS than SUSE are not yet implemented!" >&2
#exit 1
;;
esac # ICINGA_BUILD_OS
}
prepare_system_config() {
if [ -n "${ICINGA_BUILD_EXTRA_REPOSITORY}" ]; then
setup_extra_repository
fi
}
: "${ICINGA_BUILD_PROJECT:="$(detect_project)"}"
: "${ICINGA_BUILD_OS:="$(detect_os)"}"
: "${ICINGA_BUILD_DIST:="$(detect_dist)"}"
......@@ -196,6 +236,7 @@ preconfigure_ccache() {
[ -n "${ICINGA_NO_ENV}" ] || print_build_env
require_var ICINGA_BUILD_PROJECT ICINGA_BUILD_OS ICINGA_BUILD_DIST ICINGA_BUILD_ARCH ICINGA_BUILD_TYPE
prepare_system_config
export_build_env
export LANG=C
......
......@@ -12,39 +12,6 @@ if [ "$(echo "${source_rpm}" | wc -l)" -gt 1 ]; then
exit 1
fi
if [ -n "${ICINGA_BUILD_EXTRA_REPOSITORY}" ]; then
echo "[ Update extra repository ]"
extra_repository="${ICINGA_BUILD_EXTRA_REPOSITORY}"
if [ -n "${ICINGA_BUILD_EXTRA_REPOSITORY_BASE}" ]; then
extra_repository="${ICINGA_BUILD_EXTRA_REPOSITORY_BASE}/${extra_repository}"
fi # base
extra_name=icinga-build-extra
case "$ICINGA_BUILD_OS" in
opensuse*|sles)
if [ -n "${ICINGA_BUILD_EXTRA_REPOSITORY_USERNAME}" ]; then
echo "Creating /etc/zypp/credentials.d/${extra_name}"
extra_repository="${extra_repository}?credentials=${extra_name}"
(
echo "username=${ICINGA_BUILD_EXTRA_REPOSITORY_USERNAME}"
echo "password=${ICINGA_BUILD_EXTRA_REPOSITORY_PASSWORD}"
) | sudo bash -c "cat >'/etc/zypp/credentials.d/${extra_name}'"
fi
(
set -ex
sudo zypper --non-interactive removerepo "${extra_name}" || true
sudo zypper --non-interactive addrepo --priority 50 --refresh "${extra_repository}" "${extra_name}"
)
;;
*)
# TODO: implement
echo "Other OS than SUSE are not yet implemented!" >&2
#exit 1
;;
esac # ICINGA_BUILD_OS
fi # ICINGA_BUILD_EXTRA_REPOSITORY
echo "[ Update package cache ]"
case "$ICINGA_BUILD_OS" in
opensuse*|sles)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment