Compare commits
No commits in common. "e5d17cd0f010a506b34dc2dcfbabd27336a2026a" and "49cfdb32f877285611dcb3a91179d36a5b9541fb" have entirely different histories.
e5d17cd0f0
...
49cfdb32f8
2 changed files with 88 additions and 81 deletions
159
cd.sh
159
cd.sh
|
@ -37,19 +37,27 @@ cd_main () {
|
||||||
# steps
|
# steps
|
||||||
|
|
||||||
cd_set_environment_variables () {
|
cd_set_environment_variables () {
|
||||||
|
local index
|
||||||
|
local text
|
||||||
cd_step "Set environment variables"
|
cd_step "Set environment variables"
|
||||||
#
|
#
|
||||||
[ "${CD_CA_1}" ] && CD_CA=true
|
index=1
|
||||||
|
eval "text=\"\${CD_CA_${index}}\""
|
||||||
|
while [ "${text}" ] ; do
|
||||||
|
CD_CA=${index}
|
||||||
|
index=$((index+1))
|
||||||
|
eval "text=\"\${CD_CA_${index}}\""
|
||||||
|
done
|
||||||
#
|
#
|
||||||
case "$(cd_grep_os ID)" in
|
case "$(cd_grep_os ID)" in
|
||||||
"almalinux")
|
|
||||||
CD_OS_ID="${CD_OS_ALMA}"
|
|
||||||
CD_OS_VERSION="$(cd_grep_os VERSION_ID)"
|
|
||||||
;;
|
|
||||||
"debian")
|
"debian")
|
||||||
CD_OS_ID="${CD_OS_DEBIAN}"
|
CD_OS_ID="${CD_OS_DEBIAN}"
|
||||||
CD_OS_VERSION="$(cd_grep_os VERSION_CODENAME)"
|
CD_OS_VERSION="$(cd_grep_os VERSION_CODENAME)"
|
||||||
;;
|
;;
|
||||||
|
"almalinux")
|
||||||
|
CD_OS_ID="${CD_OS_ALMA}"
|
||||||
|
CD_OS_VERSION="$(cd_grep_os VERSION_ID)"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
#
|
#
|
||||||
CD_CA_PACKAGE="ca-certificates"
|
CD_CA_PACKAGE="ca-certificates"
|
||||||
|
@ -57,6 +65,18 @@ cd_set_environment_variables () {
|
||||||
CD_GIT_PACKAGE="git"
|
CD_GIT_PACKAGE="git"
|
||||||
#
|
#
|
||||||
case "${CD_OS_ID}" in
|
case "${CD_OS_ID}" in
|
||||||
|
"${CD_OS_DEBIAN}")
|
||||||
|
CD_OS_REPO="${CD_DEFAULT_REPO_DEBIAN}"
|
||||||
|
[ "${CD_REPO_DEBIAN}" ] && CD_OS_REPO="${CD_REPO_DEBIAN}"
|
||||||
|
case "${CD_OS_VERSION}" in
|
||||||
|
"bookworm"|"bullseye") cd_nop ;;
|
||||||
|
*) cd_error_os "CD_OS_VERSION" ;;
|
||||||
|
esac
|
||||||
|
CD_CA_ROOT="/usr/local/share/ca-certificates"
|
||||||
|
CD_PYTHON_COMMAND="python3"
|
||||||
|
CD_PYTHON_PACKAGE="python3"
|
||||||
|
CD_PYTHON_PACKAGES="/usr/lib/python3/dist-packages"
|
||||||
|
;;
|
||||||
"${CD_OS_ALMA}")
|
"${CD_OS_ALMA}")
|
||||||
CD_OS_REPO="${CD_DEFAULT_REPO_ALMA}"
|
CD_OS_REPO="${CD_DEFAULT_REPO_ALMA}"
|
||||||
[ "${CD_REPO_ALMA}" ] && CD_OS_REPO="${CD_REPO_ALMA}"
|
[ "${CD_REPO_ALMA}" ] && CD_OS_REPO="${CD_REPO_ALMA}"
|
||||||
|
@ -65,55 +85,10 @@ cd_set_environment_variables () {
|
||||||
*) cd_error_os "CD_OS_VERSION" ;;
|
*) cd_error_os "CD_OS_VERSION" ;;
|
||||||
esac
|
esac
|
||||||
CD_CA_ROOT="/etc/pki/ca-trust/source/anchors"
|
CD_CA_ROOT="/etc/pki/ca-trust/source/anchors"
|
||||||
CD_CMD_CA="update-ca-trust"
|
|
||||||
CD_CMD_CLEAN="dnf clean all"
|
|
||||||
CD_CMD_UPDATE="dnf makecache"
|
|
||||||
CD_CMD_UPGRADE="dnf upgrade --assumeyes"
|
|
||||||
CD_PKG_PKG=""
|
|
||||||
CD_PM_CONF_PATH="/etc/dnf/dnf.conf"
|
|
||||||
CD_PM_CONF_TEXT="\
|
|
||||||
[main]
|
|
||||||
best=True
|
|
||||||
clean_requirements_on_remove=True
|
|
||||||
gpgcheck=1
|
|
||||||
installonly_limit=3
|
|
||||||
skip_if_unavailable=False
|
|
||||||
"
|
|
||||||
CD_PM_HTTPS_PATH="/etc/dnf/dnf.conf.d/https.conf"
|
|
||||||
CD_PM_HTTPS_TEXT="sslverify=False"
|
|
||||||
CD_PYTHON_COMMAND="python3.11"
|
CD_PYTHON_COMMAND="python3.11"
|
||||||
CD_PYTHON_PACKAGE="python3.11"
|
CD_PYTHON_PACKAGE="python3.11"
|
||||||
CD_PYTHON_PACKAGES="/usr/lib64/python3.11/site-packages"
|
CD_PYTHON_PACKAGES="/usr/lib64/python3.11/site-packages"
|
||||||
;;
|
;;
|
||||||
"${CD_OS_DEBIAN}")
|
|
||||||
export DEBIAN_FRONTEND="noninteractive"
|
|
||||||
#
|
|
||||||
CD_OS_REPO="${CD_DEFAULT_REPO_DEBIAN}"
|
|
||||||
[ "${CD_REPO_DEBIAN}" ] && CD_OS_REPO="${CD_REPO_DEBIAN}"
|
|
||||||
case "${CD_OS_VERSION}" in
|
|
||||||
"bookworm"|"bullseye") cd_nop ;;
|
|
||||||
*) cd_error_os "CD_OS_VERSION" ;;
|
|
||||||
esac
|
|
||||||
CD_CA_ROOT="/usr/local/share/ca-certificates"
|
|
||||||
CD_CMD_CA="update-ca-certificates"
|
|
||||||
CD_CMD_CLEAN="apt-get clean"
|
|
||||||
CD_CMD_UPDATE="apt-get update"
|
|
||||||
CD_CMD_UPGRADE="apt-get upgrade --assume-yes"
|
|
||||||
CD_PKG_PKG="apt-utils"
|
|
||||||
CD_PM_CONF_PATH="/etc/apt/apt.conf.d/apt.conf"
|
|
||||||
CD_PM_CONF_TEXT="\
|
|
||||||
Acquire::Check-Valid-Until True;
|
|
||||||
APT::Get::Show-Versions True;
|
|
||||||
APT::Install-Recommends False;
|
|
||||||
APT::Install-Suggests False;
|
|
||||||
Dir::Etc::SourceParts \"\";
|
|
||||||
"
|
|
||||||
CD_PM_HTTPS_PATH="/etc/apt/apt.conf.d/https"
|
|
||||||
CD_PM_HTTPS_TEXT="Acquire::https::Verify-Peer False;"
|
|
||||||
CD_PYTHON_COMMAND="python3"
|
|
||||||
CD_PYTHON_PACKAGE="python3"
|
|
||||||
CD_PYTHON_PACKAGES="/usr/lib/python3/dist-packages"
|
|
||||||
;;
|
|
||||||
*) cd_error_os "CD_OS_ID" ;;
|
*) cd_error_os "CD_OS_ID" ;;
|
||||||
esac
|
esac
|
||||||
# continuous integration platform
|
# continuous integration platform
|
||||||
|
@ -174,14 +149,6 @@ local expression
|
||||||
local file
|
local file
|
||||||
cd_step "Set packages repositories"
|
cd_step "Set packages repositories"
|
||||||
case "${CD_OS_ID}" in
|
case "${CD_OS_ID}" in
|
||||||
"${CD_OS_ALMA}")
|
|
||||||
file="/etc/yum.repos.d/almalinux.repo"
|
|
||||||
cd_sed "${file}" \
|
|
||||||
"|^mirrorlist|# mirrorlist|" \
|
|
||||||
"|${CD_DEFAULT_REPO_ALMA}|${CD_OS_REPO}|" \
|
|
||||||
"|^# baseurl|baseurl|"
|
|
||||||
cd_cat "${file}"
|
|
||||||
;;
|
|
||||||
"${CD_OS_DEBIAN}")
|
"${CD_OS_DEBIAN}")
|
||||||
cd_write "/etc/apt/sources.list" "\
|
cd_write "/etc/apt/sources.list" "\
|
||||||
deb ${CD_OS_REPO} ${CD_OS_VERSION} main
|
deb ${CD_OS_REPO} ${CD_OS_VERSION} main
|
||||||
|
@ -190,32 +157,66 @@ deb ${CD_OS_REPO} ${CD_OS_VERSION}-updates main
|
||||||
deb ${CD_OS_REPO}-security ${CD_OS_VERSION}-security main
|
deb ${CD_OS_REPO}-security ${CD_OS_VERSION}-security main
|
||||||
"
|
"
|
||||||
;;
|
;;
|
||||||
|
"${CD_OS_ALMA}")
|
||||||
|
file="/etc/yum.repos.d/almalinux.repo"
|
||||||
|
cd_sed "${file}" \
|
||||||
|
"|^mirrorlist|# mirrorlist|" \
|
||||||
|
"|${CD_DEFAULT_REPO_ALMA}|${CD_OS_REPO}|" \
|
||||||
|
"|^# baseurl|baseurl|"
|
||||||
|
cd_cat "${file}"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# agnostic steps
|
|
||||||
|
|
||||||
cd_set_packages_configuration () {
|
cd_set_packages_configuration () {
|
||||||
cd_step "Set packages configuration"
|
cd_step "Set packages configuration"
|
||||||
cd_write "${CD_PM_CONF_PATH}" "${CD_PM_CONF_TEXT}"
|
case "${CD_OS_ID}" in
|
||||||
|
"${CD_OS_DEBIAN}")
|
||||||
|
export DEBIAN_FRONTEND="noninteractive"
|
||||||
|
cd_write "/etc/apt/apt.conf.d/apt.conf" "\
|
||||||
|
Acquire::Check-Valid-Until True;
|
||||||
|
APT::Get::Show-Versions True;
|
||||||
|
APT::Install-Recommends False;
|
||||||
|
APT::Install-Suggests False;
|
||||||
|
Dir::Etc::SourceParts \"\";
|
||||||
|
"
|
||||||
|
;;
|
||||||
|
"${CD_OS_ALMA}") cd_mkdir "/etc/dnf/dnf.conf.d" ;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
cd_set_https_verification_off () {
|
cd_set_https_verification_off () {
|
||||||
if [ "${CD_CA}" -o "${CD_OS_ID}" = "${CD_OS_DEBIAN}" ] ; then
|
if [ "${CD_CA}" ] ; then
|
||||||
cd_step "Set HTTPS verification off"
|
cd_step "Set HTTPS verification off"
|
||||||
cd_mkdir "$(dirname "${CD_PM_HTTPS_PATH}")"
|
case "${CD_OS_ID}" in
|
||||||
cd_write "${CD_PM_HTTPS_PATH}" "${CD_PM_HTTPS_TEXT}"
|
"${CD_OS_DEBIAN}")
|
||||||
|
cd_write "/etc/apt/apt.conf.d/https" "\
|
||||||
|
Acquire::https::Verify-Peer False;
|
||||||
|
"
|
||||||
|
;;
|
||||||
|
"${CD_OS_ALMA}")
|
||||||
|
cd_write "/etc/dnf/dnf.conf.d/https.conf" "\
|
||||||
|
sslverify=False
|
||||||
|
"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cd_update_packages_catalog () {
|
cd_update_packages_catalog () {
|
||||||
cd_step "Update packages catalog"
|
cd_step "Update packages catalog"
|
||||||
${CD_CMD_UPDATE} || exit
|
case "${CD_OS_ID}" in
|
||||||
|
"${CD_OS_DEBIAN}") apt-get update || exit ;;
|
||||||
|
"${CD_OS_ALMA}") dnf makecache || exit ;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
cd_install_packages_tools () {
|
cd_install_packages_tools () {
|
||||||
cd_step "Install packages tools"
|
cd_step "Install packages tools"
|
||||||
cd_install_package "${CD_PKG_PKG}"
|
case "${CD_OS_ID}" in
|
||||||
|
"${CD_OS_DEBIAN}") cd_install_package "apt-utils" ;;
|
||||||
|
"${CD_OS_ALMA}") cd_nop ;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
cd_install_ca_certificates () {
|
cd_install_ca_certificates () {
|
||||||
|
@ -226,7 +227,7 @@ cd_install_ca_certificates () {
|
||||||
cd_write_ca_certificates () {
|
cd_write_ca_certificates () {
|
||||||
local index
|
local index
|
||||||
local text
|
local text
|
||||||
cd_step "Write CA certificates"
|
cd_step "Copy CA"
|
||||||
cd_mkdir "${CD_CA_ROOT}"
|
cd_mkdir "${CD_CA_ROOT}"
|
||||||
index=1
|
index=1
|
||||||
eval "text=\"\${CD_CA_${index}}\""
|
eval "text=\"\${CD_CA_${index}}\""
|
||||||
|
@ -238,20 +239,29 @@ local text
|
||||||
}
|
}
|
||||||
|
|
||||||
cd_update_ca_certificates () {
|
cd_update_ca_certificates () {
|
||||||
cd_step "Update CA certificates"
|
cd_step "Update CA"
|
||||||
${CD_CMD_CA} || exit
|
case "${CD_OS_ID}" in
|
||||||
|
"${CD_OS_DEBIAN}") update-ca-certificates || exit ;;
|
||||||
|
"${CD_OS_ALMA}") update-ca-trust || exit ;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
cd_set_https_verification_on () {
|
cd_set_https_verification_on () {
|
||||||
if [ "${CD_CA}" -o "${CD_OS_ID}" = "${CD_OS_DEBIAN}" ] ; then
|
if [ "${CD_CA}" ] ; then
|
||||||
cd_step "Set HTTPS verification on"
|
cd_step "Set HTTPS verification on"
|
||||||
cd_rm "${CD_PM_HTTPS_PATH}"
|
case "${CD_OS_ID}" in
|
||||||
|
"${CD_OS_DEBIAN}") cd_rm "/etc/apt/apt.conf.d/https" ;;
|
||||||
|
"${CD_OS_ALMA}") cd_rm "/etc/dnf/dnf.conf.d/https.conf" ;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cd_upgrade_packages () {
|
cd_upgrade_packages () {
|
||||||
cd_step "Upgrade packages"
|
cd_step "Upgrade packages"
|
||||||
${CD_CMD_UPGRADE} || exit
|
case "${CD_OS_ID}" in
|
||||||
|
"${CD_OS_DEBIAN}") apt-get upgrade --assume-yes || exit ;;
|
||||||
|
"${CD_OS_ALMA}") dnf upgrade --assumeyes || exit ;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
cd_install_git () {
|
cd_install_git () {
|
||||||
|
@ -266,7 +276,10 @@ cd_install_python () {
|
||||||
|
|
||||||
cd_clean_packages_cache () {
|
cd_clean_packages_cache () {
|
||||||
cd_step "Clean packages cache"
|
cd_step "Clean packages cache"
|
||||||
${CD_CMD_CLEAN} || exit
|
case "${CD_OS_ID}" in
|
||||||
|
"${CD_OS_DEBIAN}") apt-get clean || exit ;;
|
||||||
|
"${CD_OS_ALMA}") dnf clean all || exit ;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
cd_install_python_modules () {
|
cd_install_python_modules () {
|
||||||
|
|
10
readme.md
10
readme.md
|
@ -29,14 +29,8 @@ from various CA, CI, OCI / OS.
|
||||||
|
|
||||||
## Tasks
|
## Tasks
|
||||||
|
|
||||||
* write bats
|
|
||||||
|
|
||||||
* handle cloning credentials
|
|
||||||
* make steps more agnostic
|
|
||||||
* show CA certificates as text
|
|
||||||
* write Python bootstrap
|
|
||||||
|
|
||||||
* first list working directory
|
* first list working directory
|
||||||
|
* handle cloning credentials
|
||||||
* integrate project repository cloning
|
* integrate project repository cloning
|
||||||
* override repository and framework locations
|
* override repository and framework locations
|
||||||
* reduce operating system version to major
|
* write Python bootstrap
|
||||||
|
|
Loading…
Reference in a new issue