Compare commits
8 commits
a6d4cfc52c
...
9b24102fcb
Author | SHA1 | Date | |
---|---|---|---|
9b24102fcb | |||
60e4eeebb9 | |||
0052a11203 | |||
117902ff7c | |||
b9ee5bdc0e | |||
7f5b2be317 | |||
657e2cd59f | |||
e240fad832 |
25 changed files with 1036 additions and 1036 deletions
|
@ -4,16 +4,16 @@ jobs:
|
|||
container:
|
||||
image: almalinux:8
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
|
|
|
@ -4,16 +4,16 @@ jobs:
|
|||
container:
|
||||
image: almalinux:9
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
|
|
|
@ -4,16 +4,16 @@ jobs:
|
|||
container:
|
||||
image: alpine:3.18
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
|
|
|
@ -4,16 +4,16 @@ jobs:
|
|||
container:
|
||||
image: alpine:3.19
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
|
|
|
@ -4,16 +4,16 @@ jobs:
|
|||
container:
|
||||
image: archlinux:base-20231112.0.191179
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
|
|
|
@ -4,16 +4,16 @@ jobs:
|
|||
container:
|
||||
image: archlinux:base-20240101.0.204074
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
|
|
|
@ -4,17 +4,17 @@ jobs:
|
|||
container:
|
||||
image: debian:bookworm
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: pidd-synchronize
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
- run: spcd-synchronize
|
||||
|
|
|
@ -4,16 +4,16 @@ jobs:
|
|||
container:
|
||||
image: debian:bullseye
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
|
|
|
@ -4,16 +4,16 @@ jobs:
|
|||
container:
|
||||
image: fedora:39
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
|
|
|
@ -4,16 +4,16 @@ jobs:
|
|||
container:
|
||||
image: fedora:40
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
|
|
|
@ -4,16 +4,16 @@ jobs:
|
|||
container:
|
||||
image: rockylinux:8
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
|
|
|
@ -4,16 +4,16 @@ jobs:
|
|||
container:
|
||||
image: rockylinux:9
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
|
|
|
@ -4,16 +4,16 @@ jobs:
|
|||
container:
|
||||
image: ubuntu:jammy
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
|
|
|
@ -4,16 +4,16 @@ jobs:
|
|||
container:
|
||||
image: ubuntu:noble
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
${{vars.PIDD}}
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
${{vars.SPCD}}
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
|
|
22
.github/workflows/debian:bookworm.yaml
vendored
22
.github/workflows/debian:bookworm.yaml
vendored
|
@ -5,17 +5,17 @@ jobs:
|
|||
container:
|
||||
image: debian:bookworm
|
||||
steps:
|
||||
- name: pidd
|
||||
- name: spcd
|
||||
env:
|
||||
PIDD_GIT_MAIN: ${{vars.PIDD_GIT_MAIN}}
|
||||
PIDD_GIT_ROOT: ${{vars.PIDD_GIT_ROOT}}
|
||||
SPCD_GIT_MAIN: ${{vars.SPCD_GIT_MAIN}}
|
||||
SPCD_GIT_ROOT: ${{vars.SPCD_GIT_ROOT}}
|
||||
run: >
|
||||
echo '${{vars.PIDD}}' | tr -d '\r' | sh -s
|
||||
"${{secrets.PIDD_SSH_KEY}}"
|
||||
"${{vars.PIDD_SSH_HOSTS}}"
|
||||
echo '${{vars.SPCD}}' | tr -d '\r' | sh -s
|
||||
"${{secrets.SPCD_SSH_KEY}}"
|
||||
"${{vars.SPCD_SSH_HOSTS}}"
|
||||
|
||||
- run: pidd-list-environment
|
||||
- run: pidd-clone-branch
|
||||
- run: pidd-build-project
|
||||
- run: pidd-browse-workspace
|
||||
- run: pidd-synchronize
|
||||
- run: spcd-list-environment
|
||||
- run: spcd-clone-branch
|
||||
- run: spcd-build-project
|
||||
- run: spcd-browse-workspace
|
||||
- run: spcd-synchronize
|
||||
|
|
|
@ -2,11 +2,11 @@ image: debian:bookworm
|
|||
job:
|
||||
script:
|
||||
- >
|
||||
sh ${PIDD}
|
||||
${PIDD_SSH_KEY}
|
||||
${PIDD_SSH_HOSTS}
|
||||
sh ${SPCD}
|
||||
${SPCD_SSH_KEY}
|
||||
${SPCD_SSH_HOSTS}
|
||||
|
||||
- pidd-list-environment
|
||||
- pidd-clone-branch
|
||||
- pidd-build-project
|
||||
- pidd-browse-workspace
|
||||
- spcd-list-environment
|
||||
- spcd-clone-branch
|
||||
- spcd-build-project
|
||||
- spcd-browse-workspace
|
||||
|
|
837
pidd.sh
837
pidd.sh
|
@ -1,837 +0,0 @@
|
|||
#! /usr/bin/env sh
|
||||
|
||||
# defaults
|
||||
[ -n "${PIDD_DNS}" ] || PIDD_DNS="\
|
||||
9.9.9.9 \
|
||||
"
|
||||
[ -n "${PIDD_GIT_MAIN}" ] || PIDD_GIT_MAIN="pidd"
|
||||
[ -n "${PIDD_GIT_ROOT}" ] || PIDD_GIT_ROOT="rwx"
|
||||
|
||||
# main
|
||||
pidd_main() {
|
||||
pidd_list_environment_variables
|
||||
pidd_list_working_directory
|
||||
#
|
||||
pidd_set_environment_variables
|
||||
pidd_set_packages_repositories
|
||||
pidd_set_packages_configuration
|
||||
#
|
||||
pidd_set_https_verification_off
|
||||
pidd_set_dns_resolving
|
||||
pidd_update_packages_catalog
|
||||
pidd_install_packages_tools
|
||||
pidd_install_ca_certificates
|
||||
pidd_write_ca_certificates
|
||||
pidd_update_ca_certificates
|
||||
pidd_set_https_verification_on
|
||||
pidd_update_packages_catalog
|
||||
pidd_upgrade_packages
|
||||
pidd_install_git
|
||||
pidd_install_python
|
||||
# TODO move to Python
|
||||
pidd_install_rsync
|
||||
# TODO move to Python
|
||||
pidd_install_ssh
|
||||
pidd_clean_packages_cache
|
||||
pidd_install_python_modules
|
||||
pidd_write_python_module
|
||||
pidd_switch_to_python "${@}"
|
||||
}
|
||||
|
||||
# context
|
||||
|
||||
pidd_list_environment_variables() {
|
||||
pidd_step "List environment variables"
|
||||
for pidd_lev__name in $(printenv | cut -d = -f 1 | sort); do
|
||||
pidd_lev__text=""
|
||||
eval "pidd_lev__text=\"\${${pidd_lev__name}}\""
|
||||
echo "${pidd_lev__name}=${pidd_lev__text}"
|
||||
done
|
||||
}
|
||||
|
||||
pidd_list_working_directory() {
|
||||
pidd_step "List working directory"
|
||||
pidd_lwd__path="$(realpath .)"
|
||||
pidd_ls "${pidd_lwd__path}"
|
||||
}
|
||||
|
||||
# steps
|
||||
|
||||
pidd_set_environment_variables() {
|
||||
pidd_step "Set environment variables"
|
||||
# set path
|
||||
PIDD_PATH="$(realpath "${0}")"
|
||||
pidd_echo "PIDD_PATH"
|
||||
# set operating system id
|
||||
PIDD_OS_ID="$(pidd_grep_os ID)"
|
||||
case "${PIDD_OS_ID}" in
|
||||
"almalinux") PIDD_OS_ID="${PIDD_OS_ALMA}" ;;
|
||||
"alpine") PIDD_OS_ID="${PIDD_OS_ALPINE}" ;;
|
||||
"arch") PIDD_OS_ID="${PIDD_OS_ARCH}" ;;
|
||||
"debian") PIDD_OS_ID="${PIDD_OS_DEBIAN}" ;;
|
||||
"fedora") PIDD_OS_ID="${PIDD_OS_FEDORA}" ;;
|
||||
"rocky") PIDD_OS_ID="${PIDD_OS_ROCKY}" ;;
|
||||
"ubuntu") PIDD_OS_ID="${PIDD_OS_UBUNTU}" ;;
|
||||
*) pidd_error_os "PIDD_OS_ID" ;;
|
||||
esac
|
||||
# set operating system version
|
||||
case "${PIDD_OS_ID}" in
|
||||
"${PIDD_OS_ALMA}" | "${PIDD_OS_FEDORA}" | "${PIDD_OS_ROCKY}" | \
|
||||
"${PIDD_OS_ARCH}")
|
||||
PIDD_OS_VERSION=$(pidd_grep_os VERSION_ID |
|
||||
sed "s|^\([0-9]\+\)\..*|\1|")
|
||||
;;
|
||||
"${PIDD_OS_ALPINE}")
|
||||
PIDD_OS_VERSION=$(pidd_grep_os VERSION_ID |
|
||||
sed "s|^\([0-9]\+\.[0-9]\+\)\..*|\1|")
|
||||
;;
|
||||
"${PIDD_OS_DEBIAN}" | "${PIDD_OS_UBUNTU}")
|
||||
PIDD_OS_VERSION="$(pidd_grep_os VERSION_CODENAME)"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
# check operating system version
|
||||
case "${PIDD_OS_ID}" in
|
||||
"${PIDD_OS_ALMA}" | "${PIDD_OS_ROCKY}")
|
||||
case "${PIDD_OS_VERSION}" in
|
||||
"8" | "9") ;;
|
||||
*) pidd_error_os "PIDD_OS_VERSION" ;;
|
||||
esac
|
||||
;;
|
||||
"${PIDD_OS_ALPINE}")
|
||||
case "${PIDD_OS_VERSION}" in
|
||||
"3.18" | "3.19") ;;
|
||||
*) pidd_error_os "PIDD_OS_VERSION" ;;
|
||||
esac
|
||||
;;
|
||||
"${PIDD_OS_ARCH}")
|
||||
case "${PIDD_OS_VERSION}" in
|
||||
"20231112" | "20240101") ;;
|
||||
*) pidd_error_os "PIDD_OS_VERSION" ;;
|
||||
esac
|
||||
;;
|
||||
"${PIDD_OS_DEBIAN}")
|
||||
case "${PIDD_OS_VERSION}" in
|
||||
"bookworm" | "bullseye") ;;
|
||||
*) pidd_error_os "PIDD_OS_VERSION" ;;
|
||||
esac
|
||||
;;
|
||||
"${PIDD_OS_FEDORA}")
|
||||
case "${PIDD_OS_VERSION}" in
|
||||
"39" | "40") ;;
|
||||
*) pidd_error_os "PIDD_OS_VERSION" ;;
|
||||
esac
|
||||
;;
|
||||
"${PIDD_OS_UBUNTU}")
|
||||
case "${PIDD_OS_VERSION}" in
|
||||
"jammy" | "noble") ;;
|
||||
*) pidd_error_os "PIDD_OS_VERSION" ;;
|
||||
esac
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
pidd_split
|
||||
pidd_echo "PIDD_OS_ID" "PIDD_OS_VERSION"
|
||||
# universal
|
||||
PIDD_DNS_FILE="/etc/resolv.conf"
|
||||
PIDD_PKG_CA="ca-certificates"
|
||||
PIDD_PKG_GIT="git"
|
||||
# TODO move to Python
|
||||
PIDD_PKG_RSYNC="rsync"
|
||||
PIDD_PYTHON_ALIAS="python3"
|
||||
pidd_split
|
||||
pidd_echo "PIDD_DNS_FILE" "PIDD_PKG_CA" "PIDD_PKG_GIT" "PIDD_PYTHON_ALIAS"
|
||||
# set ca command & root
|
||||
case "${PIDD_OS_ID}" in
|
||||
"${PIDD_OS_ALMA}" | "${PIDD_OS_FEDORA}" | "${PIDD_OS_ROCKY}")
|
||||
PIDD_CA_ROOT="/etc/pki/ca-trust/source/anchors"
|
||||
PIDD_CMD_CA="update-ca-trust"
|
||||
;;
|
||||
"${PIDD_OS_ALPINE}")
|
||||
PIDD_CA_ROOT="/usr/local/share/ca-certificates"
|
||||
PIDD_CMD_CA="update-ca-certificates"
|
||||
;;
|
||||
"${PIDD_OS_ARCH}")
|
||||
PIDD_CA_ROOT="/etc/ca-certificates/trust-source/anchors"
|
||||
PIDD_CMD_CA="update-ca-trust"
|
||||
;;
|
||||
"${PIDD_OS_DEBIAN}" | "${PIDD_OS_UBUNTU}")
|
||||
PIDD_CA_ROOT="/usr/local/share/ca-certificates"
|
||||
PIDD_CMD_CA="update-ca-certificates"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
pidd_split
|
||||
pidd_echo "PIDD_CA_ROOT" "PIDD_CMD_CA"
|
||||
# set package manager
|
||||
case "${PIDD_OS_ID}" in
|
||||
"${PIDD_OS_ALPINE}")
|
||||
PIDD_PM="${PIDD_PM_APK}"
|
||||
;;
|
||||
"${PIDD_OS_DEBIAN}" | "${PIDD_OS_UBUNTU}")
|
||||
PIDD_PM="${PIDD_PM_APT}"
|
||||
;;
|
||||
"${PIDD_OS_ALMA}" | "${PIDD_OS_FEDORA}" | "${PIDD_OS_ROCKY}")
|
||||
PIDD_PM="${PIDD_PM_DNF}"
|
||||
;;
|
||||
"${PIDD_OS_ARCH}")
|
||||
PIDD_PM="${PIDD_PM_PACMAN}"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
pidd_split
|
||||
pidd_echo "PIDD_PM"
|
||||
case "${PIDD_PM}" in
|
||||
"${PIDD_PM_DNF}")
|
||||
PIDD_PM_CLEAN="dnf clean all"
|
||||
PIDD_PM_INSTALL="dnf install --assumeyes"
|
||||
PIDD_PM_QUERY="rpm --query"
|
||||
PIDD_PM_UPDATE="dnf makecache"
|
||||
PIDD_PM_UPGRADE="dnf upgrade --assumeyes"
|
||||
PIDD_PKG_PKG=""
|
||||
PIDD_PM_CONF_PATH="/etc/dnf/dnf.conf"
|
||||
PIDD_PM_CONF_TEXT="\
|
||||
[main]
|
||||
best=True
|
||||
clean_requirements_on_remove=True
|
||||
gpgcheck=1
|
||||
installonly_limit=3
|
||||
skip_if_unavailable=False
|
||||
"
|
||||
PIDD_PM_HTTPS_PATH="/etc/dnf/dnf.conf.d/https.conf"
|
||||
PIDD_PM_HTTPS_TEXT="\
|
||||
sslverify=False
|
||||
"
|
||||
;;
|
||||
"${PIDD_PM_APK}")
|
||||
PIDD_PM_CLEAN="apk cache purge"
|
||||
PIDD_PM_INSTALL="apk add"
|
||||
PIDD_PM_QUERY="apk info"
|
||||
PIDD_PM_UPDATE="apk update"
|
||||
PIDD_PM_UPGRADE="apk upgrade"
|
||||
PIDD_PKG_PKG=""
|
||||
PIDD_PM_CONF_PATH=""
|
||||
PIDD_PM_CONF_TEXT=""
|
||||
PIDD_PM_HTTPS_PATH="/etc/apk/repositories.d/https"
|
||||
PIDD_PM_HTTPS_TEXT="\
|
||||
--no-verify
|
||||
"
|
||||
;;
|
||||
"${PIDD_PM_PACMAN}")
|
||||
PIDD_PM_CLEAN="pacman --sync --clean --noconfirm"
|
||||
PIDD_PM_INSTALL="pacman --sync --noconfirm"
|
||||
PIDD_PM_QUERY="pacman --query"
|
||||
PIDD_PM_UPDATE="pacman --sync --refresh"
|
||||
PIDD_PM_UPGRADE="pacman --sync --sysupgrade --noconfirm"
|
||||
PIDD_PKG_PKG=""
|
||||
PIDD_PM_CONF_PATH=""
|
||||
PIDD_PM_CONF_TEXT=""
|
||||
PIDD_PM_HTTPS_PATH="/etc/pacman.d/https.conf"
|
||||
PIDD_PM_HTTPS_TEXT="\
|
||||
SSLVerify = No
|
||||
"
|
||||
;;
|
||||
"${PIDD_PM_APT}")
|
||||
PIDD_PM_CLEAN="apt-get clean"
|
||||
PIDD_PM_INSTALL="apt-get install --assume-yes"
|
||||
PIDD_PM_QUERY="dpkg-query --show"
|
||||
PIDD_PM_UPDATE="apt-get update"
|
||||
PIDD_PM_UPGRADE="apt-get upgrade --assume-yes"
|
||||
PIDD_PKG_PKG="apt-utils"
|
||||
PIDD_PM_CONF_PATH="/etc/apt/apt.conf.d/apt.conf"
|
||||
PIDD_PM_CONF_TEXT="\
|
||||
Acquire::Check-Valid-Until True;
|
||||
APT::Get::Show-Versions True;
|
||||
APT::Install-Recommends False;
|
||||
APT::Install-Suggests False;
|
||||
Dir::Etc::SourceParts \"\";
|
||||
"
|
||||
PIDD_PM_HTTPS_PATH="/etc/apt/apt.conf.d/https"
|
||||
PIDD_PM_HTTPS_TEXT="\
|
||||
Acquire::https::Verify-Peer False;
|
||||
"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
pidd_split
|
||||
pidd_echo "PIDD_PM_CLEAN" \
|
||||
"PIDD_PM_INSTALL" "PIDD_PM_QUERY" "PIDD_PM_UPDATE" "PIDD_PM_UPGRADE"
|
||||
pidd_split
|
||||
pidd_echo "PIDD_PKG_PKG" "PIDD_PM_CONF_PATH" "PIDD_PM_HTTPS_PATH"
|
||||
# specific
|
||||
case "${PIDD_OS_ID}" in
|
||||
"${PIDD_OS_ALMA}")
|
||||
PIDD_URL_DEFAULT="https://repo.almalinux.org/almalinux"
|
||||
;;
|
||||
"${PIDD_OS_ALPINE}")
|
||||
PIDD_URL_DEFAULT="https://dl-cdn.alpinelinux.org/alpine"
|
||||
;;
|
||||
"${PIDD_OS_ARCH}")
|
||||
PIDD_URL_DEFAULT="https://geo.mirror.pkgbuild.com"
|
||||
;;
|
||||
"${PIDD_OS_DEBIAN}")
|
||||
PIDD_URL_DEFAULT="http://deb.debian.org/debian"
|
||||
;;
|
||||
"${PIDD_OS_FEDORA}")
|
||||
PIDD_URL_DEFAULT="http://download.example/pub/fedora/linux/releases"
|
||||
;;
|
||||
"${PIDD_OS_ROCKY}")
|
||||
PIDD_URL_DEFAULT="http://dl.rockylinux.org/\$contentdir"
|
||||
;;
|
||||
"${PIDD_OS_UBUNTU}")
|
||||
PIDD_URL_DEFAULT="http://archive.ubuntu.com/ubuntu"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
PIDD_URL_CHOSEN="${PIDD_URL_DEFAULT}"
|
||||
case "${PIDD_OS_ID}" in
|
||||
"${PIDD_OS_ALMA}")
|
||||
[ -n "${PIDD_URL_ALMA}" ] && PIDD_URL_CHOSEN="${PIDD_URL_ALMA}"
|
||||
;;
|
||||
"${PIDD_OS_ALPINE}")
|
||||
[ -n "${PIDD_URL_ALPINE}" ] && PIDD_URL_CHOSEN="${PIDD_URL_ALPINE}"
|
||||
;;
|
||||
"${PIDD_OS_ARCH}")
|
||||
[ -n "${PIDD_URL_ARCH}" ] && PIDD_URL_CHOSEN="${PIDD_URL_ARCH}"
|
||||
;;
|
||||
"${PIDD_OS_DEBIAN}")
|
||||
[ -n "${PIDD_URL_DEBIAN}" ] && PIDD_URL_CHOSEN="${PIDD_URL_DEBIAN}" ||
|
||||
PIDD_URL_CHOSEN="https://deb.debian.org/debian"
|
||||
;;
|
||||
"${PIDD_OS_FEDORA}")
|
||||
[ -n "${PIDD_URL_FEDORA}" ] && PIDD_URL_CHOSEN="${PIDD_URL_FEDORA}" ||
|
||||
PIDD_URL_CHOSEN="https://rpmfind.net/linux/fedora/linux/releases"
|
||||
;;
|
||||
"${PIDD_OS_ROCKY}")
|
||||
[ -n "${PIDD_URL_ROCKY}" ] && PIDD_URL_CHOSEN="${PIDD_URL_ROCKY}" ||
|
||||
PIDD_URL_CHOSEN="https://dl.rockylinux.org/\$contentdir"
|
||||
;;
|
||||
"${PIDD_OS_UBUNTU}")
|
||||
[ -n "${PIDD_URL_UBUNTU}" ] && PIDD_URL_CHOSEN="${PIDD_URL_UBUNTU}" ||
|
||||
PIDD_URL_CHOSEN="https://ubuntu.mirrors.ovh.net/ubuntu"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
pidd_split
|
||||
pidd_echo "PIDD_URL_DEFAULT" "PIDD_URL_CHOSEN"
|
||||
# set python command & package
|
||||
case "${PIDD_OS_ID}" in
|
||||
"${PIDD_OS_ALMA}" | "${PIDD_OS_ROCKY}")
|
||||
PIDD_PYTHON_COMMAND="python3.11"
|
||||
PIDD_PYTHON_PACKAGE="python3.11"
|
||||
;;
|
||||
"${PIDD_OS_ALPINE}")
|
||||
PIDD_PYTHON_COMMAND="python3.11"
|
||||
PIDD_PYTHON_PACKAGE="python3"
|
||||
;;
|
||||
"${PIDD_OS_ARCH}")
|
||||
PIDD_PYTHON_COMMAND="python3.12"
|
||||
PIDD_PYTHON_PACKAGE="python"
|
||||
;;
|
||||
"${PIDD_OS_DEBIAN}")
|
||||
case "${PIDD_OS_VERSION}" in
|
||||
"bookworm") PIDD_PYTHON_COMMAND="python3.11" ;;
|
||||
"bullseye") PIDD_PYTHON_COMMAND="python3.9" ;;
|
||||
*) ;;
|
||||
esac
|
||||
PIDD_PYTHON_PACKAGE="python3"
|
||||
;;
|
||||
"${PIDD_OS_FEDORA}")
|
||||
PIDD_PYTHON_COMMAND="python3.12"
|
||||
PIDD_PYTHON_PACKAGE="python3"
|
||||
;;
|
||||
"${PIDD_OS_UBUNTU}")
|
||||
case "${PIDD_OS_VERSION}" in
|
||||
"noble") PIDD_PYTHON_COMMAND="python3.12" ;;
|
||||
"jammy") PIDD_PYTHON_COMMAND="python3.10" ;;
|
||||
*) ;;
|
||||
esac
|
||||
PIDD_PYTHON_PACKAGE="python3"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
# set python packages
|
||||
case "${PIDD_OS_ID}" in
|
||||
"${PIDD_OS_ALMA}" | "${PIDD_OS_FEDORA}" | "${PIDD_OS_ROCKY}")
|
||||
PIDD_PYTHON_PACKAGES="/usr/lib64/${PIDD_PYTHON_COMMAND}/site-packages"
|
||||
;;
|
||||
"${PIDD_OS_ALPINE}" | "${PIDD_OS_ARCH}")
|
||||
PIDD_PYTHON_PACKAGES="/usr/lib/${PIDD_PYTHON_COMMAND}/site-packages"
|
||||
;;
|
||||
"${PIDD_OS_DEBIAN}" | "${PIDD_OS_UBUNTU}")
|
||||
PIDD_PYTHON_PACKAGES="/usr/lib/${PIDD_PYTHON_ALIAS}/dist-packages"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
pidd_split
|
||||
pidd_echo "PIDD_PYTHON_COMMAND" "PIDD_PYTHON_PACKAGE" "PIDD_PYTHON_PACKAGES"
|
||||
# variables
|
||||
[ -n "${PIDD_CA_1}" ] && PIDD_CA=true
|
||||
# continuous integration platform
|
||||
if [ -n "${GITHUB_ACTIONS}" ]; then
|
||||
# github → gitea → forgejo
|
||||
if [ -n "${GITHUB_SERVER_URL}" ]; then
|
||||
PIDD_PROJECT_ROOT="$(dirname "${GITHUB_SERVER_URL}")//"
|
||||
[ -n "${GITHUB_TOKEN}" ] &&
|
||||
PIDD_PROJECT_ROOT="${PIDD_PROJECT_ROOT}${GITHUB_TOKEN}@"
|
||||
PIDD_PROJECT_ROOT="${PIDD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")"
|
||||
else
|
||||
pidd_error_ci "GITHUB_SERVER_URL"
|
||||
fi
|
||||
if [ -n "${GITHUB_REPOSITORY}" ]; then
|
||||
PIDD_PROJECT_PATH="$(dirname "${GITHUB_REPOSITORY}")"
|
||||
PIDD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
|
||||
else
|
||||
pidd_error_ci "GITHUB_REPOSITORY"
|
||||
fi
|
||||
if [ -n "${GITHUB_REF_NAME}" ]; then
|
||||
PIDD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
|
||||
else
|
||||
pidd_error_ci "GITHUB_REF_NAME"
|
||||
fi
|
||||
elif [ -n "${GITLAB_CI}" ]; then
|
||||
# gitlab
|
||||
if [ -n "${CI_SERVER_PROTOCOL}" ]; then
|
||||
if [ -n "${CI_REGISTRY_USER}" ]; then
|
||||
if [ -n "${CI_REGISTRY_PASSWORD}" ]; then
|
||||
if [ -n "${CI_SERVER_FQDN}" ]; then
|
||||
PIDD_PROJECT_ROOT="${CI_SERVER_PROTOCOL}\
|
||||
://${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}@${CI_SERVER_FQDN}"
|
||||
if [ -n "${CI_PROJECT_NAMESPACE}" ]; then
|
||||
PIDD_PROJECT_PATH="${CI_PROJECT_NAMESPACE}"
|
||||
if [ -n "${CI_PROJECT_NAME}" ]; then
|
||||
PIDD_PROJECT_NAME="${CI_PROJECT_NAME}"
|
||||
else
|
||||
pidd_error_ci "CI_PROJECT_NAME"
|
||||
fi
|
||||
else
|
||||
pidd_error_ci "CI_PROJECT_NAMESPACE"
|
||||
fi
|
||||
else
|
||||
pidd_error_ci "CI_SERVER_FQDN"
|
||||
fi
|
||||
else
|
||||
pidd_error_ci "CI_REGISTRY_PASSWORD"
|
||||
fi
|
||||
else
|
||||
pidd_error_ci "CI_REGISTRY_USER"
|
||||
fi
|
||||
else
|
||||
pidd_error_ci "CI_SERVER_PROTOCOL"
|
||||
fi
|
||||
if [ -n "${CI_COMMIT_BRANCH}" ]; then
|
||||
PIDD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
|
||||
else
|
||||
pidd_error_ci "CI_COMMIT_BRANCH"
|
||||
fi
|
||||
else
|
||||
# unsupported
|
||||
pidd_error_ci "ø"
|
||||
fi
|
||||
[ -n "${PIDD_PROJECT_ROOT}" ] || pidd_error_ci "PIDD_PROJECT_ROOT"
|
||||
[ -n "${PIDD_PROJECT_PATH}" ] || pidd_error_ci "PIDD_PROJECT_PATH"
|
||||
[ -n "${PIDD_PROJECT_NAME}" ] || pidd_error_ci "PIDD_PROJECT_NAME"
|
||||
[ -n "${PIDD_PROJECT_BRANCH}" ] || pidd_error_ci "PIDD_PROJECT_BRANCH"
|
||||
#
|
||||
pidd_split
|
||||
pidd_echo "PIDD_CA"
|
||||
pidd_split
|
||||
pidd_echo "PIDD_PROJECT_ROOT" \
|
||||
"PIDD_PROJECT_PATH" "PIDD_PROJECT_NAME" "PIDD_PROJECT_BRANCH"
|
||||
# TODO move to Python
|
||||
case "${PIDD_PM}" in
|
||||
"${PIDD_PM_APK}" | "${PIDD_PM_APT}") PIDD_PKG_SSH="openssh-client" ;;
|
||||
"${PIDD_PM_DNF}") PIDD_PKG_SSH="openssh-clients" ;;
|
||||
"${PIDD_PM_PACMAN}") PIDD_PKG_SSH="openssh" ;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
pidd_set_packages_repositories() {
|
||||
pidd_step "Set packages repositories"
|
||||
case "${PIDD_OS_ID}" in
|
||||
"${PIDD_OS_ALMA}")
|
||||
case "${PIDD_OS_VERSION}" in
|
||||
"8") pidd_spr__file="/etc/yum.repos.d/almalinux.repo" ;;
|
||||
"9") pidd_spr__file="/etc/yum.repos.d/almalinux-baseos.repo" ;;
|
||||
*) ;;
|
||||
esac
|
||||
pidd_sed "${pidd_spr__file}" \
|
||||
"|^mirrorlist|# mirrorlist|" \
|
||||
"|${PIDD_URL_DEFAULT}|${PIDD_URL_CHOSEN}|" \
|
||||
"|^# baseurl|baseurl|"
|
||||
;;
|
||||
"${PIDD_OS_ALPINE}")
|
||||
pidd_spr__file="/etc/apk/repositories"
|
||||
pidd_write "${pidd_spr__file}" "\
|
||||
${PIDD_URL_CHOSEN}/v${PIDD_OS_VERSION}/main
|
||||
${PIDD_URL_CHOSEN}/v${PIDD_OS_VERSION}/community
|
||||
"
|
||||
;;
|
||||
"${PIDD_OS_DEBIAN}")
|
||||
pidd_spr__file="/etc/apt/sources.list"
|
||||
pidd_write "${pidd_spr__file}" "\
|
||||
deb ${PIDD_URL_CHOSEN} ${PIDD_OS_VERSION} main
|
||||
deb ${PIDD_URL_CHOSEN} ${PIDD_OS_VERSION}-backports main
|
||||
deb ${PIDD_URL_CHOSEN} ${PIDD_OS_VERSION}-updates main
|
||||
deb ${PIDD_URL_CHOSEN}-security ${PIDD_OS_VERSION}-security main
|
||||
"
|
||||
;;
|
||||
"${PIDD_OS_ROCKY}")
|
||||
case "${PIDD_OS_VERSION}" in
|
||||
"8") pidd_spr__file="/etc/yum.repos.d/Rocky-BaseOS.repo" ;;
|
||||
"9") pidd_spr__file="/etc/yum.repos.d/rocky.repo" ;;
|
||||
*) ;;
|
||||
esac
|
||||
pidd_sed "${pidd_spr__file}" \
|
||||
"|^mirrorlist|# mirrorlist|" \
|
||||
"|${PIDD_URL_DEFAULT}|${PIDD_URL_CHOSEN}|" \
|
||||
"|^#baseurl|baseurl|"
|
||||
;;
|
||||
"${PIDD_OS_UBUNTU}")
|
||||
pidd_spr__file="/etc/apt/sources.list"
|
||||
pidd_write "${pidd_spr__file}" "\
|
||||
deb ${PIDD_URL_CHOSEN} ${PIDD_OS_VERSION} main
|
||||
deb ${PIDD_URL_CHOSEN} ${PIDD_OS_VERSION}-backports main
|
||||
deb ${PIDD_URL_CHOSEN} ${PIDD_OS_VERSION}-updates main
|
||||
deb ${PIDD_URL_CHOSEN} ${PIDD_OS_VERSION}-security main
|
||||
"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
pidd_set_packages_configuration() {
|
||||
pidd_step "Set packages configuration"
|
||||
pidd_write "${PIDD_PM_CONF_PATH}" "${PIDD_PM_CONF_TEXT}"
|
||||
case "${PIDD_OS_ID}" in
|
||||
"${PIDD_OS_DEBIAN}" | "${PIDD_OS_UBUNTU}")
|
||||
export DEBIAN_FRONTEND="noninteractive"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# agnostic steps
|
||||
|
||||
pidd_set_https_verification_off() {
|
||||
if [ -n "${PIDD_CA}" ] || [ "${PIDD_PM}" = "${PIDD_PM_APT}" ]; then
|
||||
pidd_step "Set HTTPS verification off"
|
||||
pidd_mkdir "$(dirname "${PIDD_PM_HTTPS_PATH}")"
|
||||
pidd_write "${PIDD_PM_HTTPS_PATH}" "${PIDD_PM_HTTPS_TEXT}"
|
||||
fi
|
||||
}
|
||||
|
||||
pidd_set_dns_resolving() {
|
||||
pidd_step "Set DNS resolving"
|
||||
for pidd_sdr__server in ${PIDD_DNS}; do
|
||||
pidd_sdr__text="${pidd_sdr__text}\
|
||||
nameserver ${pidd_sdr__server}
|
||||
"
|
||||
done
|
||||
pidd_write "${PIDD_DNS_FILE}" "${pidd_sdr__text}"
|
||||
}
|
||||
|
||||
pidd_update_packages_catalog() {
|
||||
pidd_step "Update packages catalog"
|
||||
${PIDD_PM_UPDATE} || exit
|
||||
}
|
||||
|
||||
pidd_install_packages_tools() {
|
||||
pidd_step "Install packages tools"
|
||||
pidd_install_package "${PIDD_PKG_PKG}"
|
||||
}
|
||||
|
||||
pidd_install_ca_certificates() {
|
||||
pidd_step "Install CA"
|
||||
pidd_install_package "${PIDD_PKG_CA}"
|
||||
}
|
||||
|
||||
pidd_write_ca_certificates() {
|
||||
pidd_step "Write CA certificates"
|
||||
pidd_mkdir "${PIDD_CA_ROOT}"
|
||||
pidd_wcc__index=1
|
||||
eval "pidd_wcc__text=\"\${PIDD_CA_${pidd_wcc__index}}\""
|
||||
while [ -n "${pidd_wcc__text}" ]; do
|
||||
pidd_wcc__path="${PIDD_CA_ROOT}/${pidd_wcc__index}.crt"
|
||||
pidd_split
|
||||
pidd_write "${pidd_wcc__path}" "${pidd_wcc__text}"
|
||||
pidd_openssl "${pidd_wcc__path}"
|
||||
pidd_wcc__index=$((pidd_wcc__index + 1))
|
||||
eval "pidd_wcc__text=\"\${PIDD_CA_${pidd_wcc__index}}\""
|
||||
done
|
||||
}
|
||||
|
||||
pidd_update_ca_certificates() {
|
||||
pidd_step "Update CA certificates"
|
||||
${PIDD_CMD_CA} || exit
|
||||
}
|
||||
|
||||
pidd_set_https_verification_on() {
|
||||
pidd_step "Set HTTPS verification on"
|
||||
pidd_rm "${PIDD_PM_HTTPS_PATH}"
|
||||
}
|
||||
|
||||
pidd_upgrade_packages() {
|
||||
pidd_step "Upgrade packages"
|
||||
${PIDD_PM_UPGRADE} || exit
|
||||
}
|
||||
|
||||
pidd_install_git() {
|
||||
pidd_step "Install Git"
|
||||
pidd_install_package "${PIDD_PKG_GIT}"
|
||||
}
|
||||
|
||||
pidd_install_python() {
|
||||
pidd_step "Install Python"
|
||||
pidd_install_package "${PIDD_PYTHON_PACKAGE}"
|
||||
pidd_split
|
||||
pidd_ln_python "${PIDD_PYTHON_COMMAND}"
|
||||
}
|
||||
|
||||
# TODO move to Python
|
||||
pidd_install_rsync() {
|
||||
pidd_step "Install Rsync"
|
||||
pidd_install_package "${PIDD_PKG_RSYNC}"
|
||||
}
|
||||
|
||||
# TODO move to Python
|
||||
pidd_install_ssh() {
|
||||
pidd_step "Install SSH"
|
||||
pidd_install_package "${PIDD_PKG_SSH}"
|
||||
}
|
||||
|
||||
pidd_clean_packages_cache() {
|
||||
pidd_step "Clean packages cache"
|
||||
${PIDD_PM_CLEAN} || exit
|
||||
}
|
||||
|
||||
pidd_install_python_modules() {
|
||||
pidd_step "Install Python modules"
|
||||
pidd_ipm__root="$(mktemp --directory)" || exit
|
||||
echo "→ ${pidd_ipm__root}"
|
||||
for pidd_ipm__repository in "${PIDD_GIT_MAIN}" "${PIDD_GIT_ROOT}"; do
|
||||
case "${pidd_ipm__repository}" in
|
||||
http*) pidd_ipm__url="${pidd_ipm__repository}" ;;
|
||||
/*) pidd_ipm__url="${PIDD_PROJECT_ROOT}${pidd_ipm__repository}" ;;
|
||||
*) pidd_ipm__url="\
|
||||
${PIDD_PROJECT_ROOT}/${PIDD_PROJECT_PATH}/${pidd_ipm__repository}" ;;
|
||||
esac
|
||||
pidd_ipm__name="$(basename "${pidd_ipm__url}")"
|
||||
pidd_split
|
||||
echo "\
|
||||
${pidd_ipm__url}
|
||||
↓"
|
||||
git clone \
|
||||
"${pidd_ipm__url}" \
|
||||
"${pidd_ipm__root}/${pidd_ipm__name}" ||
|
||||
exit
|
||||
pidd_ipm__path="${pidd_ipm__root}/${pidd_ipm__name}/${pidd_ipm__name}"
|
||||
echo "\
|
||||
${pidd_ipm__path}
|
||||
↓
|
||||
${PIDD_PYTHON_PACKAGES}"
|
||||
cp --recursive "${pidd_ipm__path}" "${PIDD_PYTHON_PACKAGES}" ||
|
||||
exit
|
||||
done
|
||||
pidd_split
|
||||
pidd_ls "${PIDD_PYTHON_PACKAGES}"
|
||||
pidd_split
|
||||
pidd_rm "${pidd_ipm__root}"
|
||||
}
|
||||
|
||||
pidd_write_python_module() {
|
||||
pidd_step "Write Python module"
|
||||
for pidd_wpm__variable in \
|
||||
OS_ID OS_VERSION \
|
||||
PROJECT_ROOT PROJECT_PATH PROJECT_NAME \
|
||||
OPEN DOWN VERT SPLT __UP SHUT; do
|
||||
pidd_wpm__value="$(pidd_echo "PIDD_${pidd_wpm__variable}")"
|
||||
pidd_wpm__text="${pidd_wpm__text}${pidd_wpm__value}
|
||||
"
|
||||
done
|
||||
pidd_write "${PIDD_PYTHON_PACKAGES}/env.py" "${pidd_wpm__text}
|
||||
PIDD_STEP = $((PIDD_STEP + 1))
|
||||
"
|
||||
}
|
||||
|
||||
pidd_switch_to_python() {
|
||||
pidd_step "Switch to Python"
|
||||
pidd_stp__name="$(basename "${PIDD_GIT_MAIN}")"
|
||||
echo "\
|
||||
${PIDD_PATH}
|
||||
↓
|
||||
${PIDD_PYTHON_PACKAGES}/${pidd_stp__name}"
|
||||
"${PIDD_PYTHON_ALIAS}" -m "${pidd_stp__name}" "${@}"
|
||||
}
|
||||
|
||||
# functions
|
||||
|
||||
pidd_cat() {
|
||||
pidd_cat__file="${1}"
|
||||
if [ -n "${pidd_cat__file}" ]; then
|
||||
pidd_open "${pidd_cat__file}"
|
||||
cat "${pidd_cat__file}" || exit
|
||||
pidd_shut "${pidd_cat__file}"
|
||||
fi
|
||||
}
|
||||
|
||||
pidd_echo() {
|
||||
if [ -n "${1}" ]; then
|
||||
for pidd_echo__name in "${@}"; do
|
||||
pidd_echo__text=""
|
||||
eval "pidd_echo__text=\"\${${pidd_echo__name}}\""
|
||||
echo "${pidd_echo__name} = \"${pidd_echo__text}\""
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
pidd_error_ci() {
|
||||
echo "× CI: ${*}"
|
||||
exit "${PIDD_ERROR_CI}"
|
||||
}
|
||||
|
||||
pidd_error_os() {
|
||||
pidd_error_os__variable="${1}"
|
||||
printf "× OS: "
|
||||
pidd_echo "${pidd_error_os__variable}"
|
||||
exit "${PIDD_ERROR_OS}"
|
||||
}
|
||||
|
||||
pidd_grep_os() {
|
||||
pidd_grep_os__variable="${1}"
|
||||
[ -n "${pidd_grep_os__variable}" ] &&
|
||||
grep "^${pidd_grep_os__variable}=" "/etc/os-release" |
|
||||
sed "s|^${pidd_grep_os__variable}=||" |
|
||||
sed "s|^\"\(.*\)\"$|\1|"
|
||||
}
|
||||
|
||||
pidd_install_package() {
|
||||
pidd_install_package__name="${1}"
|
||||
if [ -n "${pidd_install_package__name}" ]; then
|
||||
${PIDD_PM_INSTALL} "${pidd_install_package__name}" || exit
|
||||
fi
|
||||
}
|
||||
|
||||
pidd_ln_python() {
|
||||
pidd_ln_python__command="${1}"
|
||||
if [ -n "${pidd_ln_python__command}" ]; then
|
||||
echo "→ ${PIDD_PYTHON_ALIAS} → ${pidd_ln_python__command}"
|
||||
ln -f -s "${pidd_ln_python__command}" \
|
||||
"/usr/bin/${PIDD_PYTHON_ALIAS}" || exit
|
||||
fi
|
||||
}
|
||||
|
||||
pidd_ls() {
|
||||
pidd_ls__path="${1}"
|
||||
if [ -n "${pidd_ls__path}" ]; then
|
||||
pidd_open "${pidd_ls__path}"
|
||||
ls -a -l "${pidd_ls__path}" || exit
|
||||
pidd_shut "${pidd_ls__path}"
|
||||
fi
|
||||
}
|
||||
|
||||
pidd_mkdir() {
|
||||
pidd_mkdir__path="${1}"
|
||||
if [ -n "${pidd_mkdir__path}" ]; then
|
||||
echo "→ ${pidd_mkdir__path}"
|
||||
mkdir --parents "${pidd_mkdir__path}" || exit
|
||||
fi
|
||||
}
|
||||
|
||||
pidd_open() {
|
||||
echo "${PIDD_OPEN}${*}"
|
||||
}
|
||||
|
||||
pidd_openssl() {
|
||||
pidd_openssl__file="${1}"
|
||||
if [ -f "${pidd_openssl__file}" ]; then
|
||||
openssl x509 \
|
||||
-in "${pidd_openssl__file}" \
|
||||
-noout -text ||
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
pidd_rm() {
|
||||
pidd_rm__path="${1}"
|
||||
if [ -e "${pidd_rm__path}" ]; then
|
||||
echo "← ${pidd_rm__path}"
|
||||
rm -r "${pidd_rm__path}" || exit
|
||||
fi
|
||||
}
|
||||
|
||||
pidd_sed() {
|
||||
pidd_sed__file="${1}"
|
||||
shift
|
||||
if [ -f "${pidd_sed__file}" ]; then
|
||||
pidd_cat "${pidd_sed__file}"
|
||||
for pidd_sed__regex in "${@}"; do
|
||||
sed --in-place "s${pidd_sed__regex}g" "${pidd_sed__file}" &&
|
||||
pidd_cat "${pidd_sed__file}" || exit
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
pidd_shut() {
|
||||
echo "${PIDD_SHUT}${*}"
|
||||
}
|
||||
|
||||
pidd_split() {
|
||||
echo "${PIDD_SPLT}"
|
||||
}
|
||||
|
||||
pidd_step() {
|
||||
PIDD_STEP=$((PIDD_STEP + 1))
|
||||
echo "\
|
||||
${PIDD_DOWN}
|
||||
${PIDD_VERT} ${PIDD_STEP} ${*}
|
||||
${PIDD___UP}"
|
||||
}
|
||||
|
||||
pidd_write() {
|
||||
pidd_write__file="${1}"
|
||||
pidd_write__text="${2}"
|
||||
if [ -n "${pidd_write__file}" ]; then
|
||||
[ -f "${pidd_write__file}" ] && pidd_cat "${pidd_write__file}"
|
||||
echo "→ ${pidd_write__file}"
|
||||
printf "%s" "${pidd_write__text}" >"${pidd_write__file}" || exit
|
||||
pidd_cat "${pidd_write__file}"
|
||||
fi
|
||||
}
|
||||
|
||||
# constants
|
||||
|
||||
PIDD_BOX_DOWN="╭"
|
||||
PIDD_BOX_LEFT="╴"
|
||||
PIDD_BOX_RIGHT="╶"
|
||||
PIDD_BOX_UP="╰"
|
||||
PIDD_BOX_VERTICAL="│"
|
||||
|
||||
PIDD_ERROR_CI=2
|
||||
PIDD_ERROR_OS=1
|
||||
|
||||
PIDD_OS_ALMA="alma"
|
||||
PIDD_OS_ALPINE="alpine"
|
||||
PIDD_OS_ARCH="arch"
|
||||
PIDD_OS_DEBIAN="debian"
|
||||
PIDD_OS_FEDORA="fedora"
|
||||
PIDD_OS_ROCKY="rocky"
|
||||
PIDD_OS_UBUNTU="ubuntu"
|
||||
|
||||
PIDD_PM_APK="apk"
|
||||
PIDD_PM_APT="apt"
|
||||
PIDD_PM_DNF="dnf"
|
||||
PIDD_PM_PACMAN="pacman"
|
||||
|
||||
PIDD_HORIZONTAL="────╌╌╌╌┄┄┄┄┈┈┈┈"
|
||||
|
||||
PIDD_OPEN="${PIDD_BOX_DOWN}${PIDD_BOX_LEFT}"
|
||||
PIDD_DOWN="${PIDD_BOX_DOWN}${PIDD_HORIZONTAL}"
|
||||
PIDD_VERT="${PIDD_BOX_VERTICAL}"
|
||||
PIDD_SPLT="${PIDD_BOX_RIGHT}${PIDD_HORIZONTAL}"
|
||||
PIDD___UP="${PIDD_BOX_UP}${PIDD_HORIZONTAL}"
|
||||
PIDD_SHUT="${PIDD_BOX_UP}${PIDD_BOX_LEFT}"
|
||||
|
||||
# run
|
||||
pidd_main "${@}"
|
|
@ -15,11 +15,11 @@ classifiers = [
|
|||
"Operating System :: OS Independent",
|
||||
]
|
||||
dependencies = ["rwx"]
|
||||
description = "Python Integration, Delivery & Deployment"
|
||||
description = "Shell to Python Continuous Deployment"
|
||||
dynamic = ["version"]
|
||||
keywords = []
|
||||
license-files = { paths = ["license.md"] }
|
||||
name = "pidd"
|
||||
name = "spcd"
|
||||
readme = "readme.md"
|
||||
requires-python = ">= 3.10"
|
||||
|
||||
|
@ -29,7 +29,7 @@ requires-python = ">= 3.10"
|
|||
[project.urls]
|
||||
|
||||
[tool.hatch.version]
|
||||
path = "pidd/__init__.py"
|
||||
path = "spcd/__init__.py"
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 80
|
||||
|
|
28
readme.md
28
readme.md
|
@ -1,4 +1,4 @@
|
|||
# Python Integration, Delivery & Deployment
|
||||
# Shell to Python Continuous Deployment
|
||||
|
||||
Get a common set of Python CI & CD commands \
|
||||
from various contexts of CA, CI and OCI / OS.
|
||||
|
@ -41,19 +41,19 @@ from various contexts of CA, CI and OCI / OS.
|
|||
|
||||
| Variable | Description | Default |
|
||||
|:----------------|:------------------------|:--------------------------------|
|
||||
| PIDD_CA_n | Numbered CA certificate | |
|
||||
| PIDD_DNS | Space separated servers | 9.9.9.9 |
|
||||
| PIDD_GIT_MAIN | Main Git repository | pidd |
|
||||
| PIDD_GIT_ROOT | Root Git repository | rwx |
|
||||
| PIDD_SSH_HOSTS | domain.tld ssh-type pub | |
|
||||
| PIDD_SSH_KEY | SSH private key | |
|
||||
| PIDD_URL_ALMA | Alma repository URL | https://repo.almalinux.org |
|
||||
| PIDD_URL_ALPINE | Alpine repository URL | https://dl-cdn.alpinelinux.org |
|
||||
| PIDD_URL_ARCH | Arch repository URL | https://geo.mirror.pkgbuild.com |
|
||||
| PIDD_URL_DEBIAN | Debian repository URL | https://deb.debian.org |
|
||||
| PIDD_URL_FEDORA | Fedora repository URL | https://rpmfind.net |
|
||||
| PIDD_URL_ROCKY | Rocky repository URL | https://dl.rockylinux.org |
|
||||
| PIDD_URL_UBUNTU | Ubuntu repository URL | https://ubuntu.mirrors.ovh.net |
|
||||
| SPCD_CA_n | Numbered CA certificate | |
|
||||
| SPCD_DNS | Space separated servers | 9.9.9.9 |
|
||||
| SPCD_GIT_MAIN | Main Git repository | spcd |
|
||||
| SPCD_GIT_ROOT | Root Git repository | rwx |
|
||||
| SPCD_SSH_HOSTS | domain.tld ssh-type pub | |
|
||||
| SPCD_SSH_KEY | SSH private key | |
|
||||
| SPCD_URL_ALMA | Alma repository URL | https://repo.almalinux.org |
|
||||
| SPCD_URL_ALPINE | Alpine repository URL | https://dl-cdn.alpinelinux.org |
|
||||
| SPCD_URL_ARCH | Arch repository URL | https://geo.mirror.pkgbuild.com |
|
||||
| SPCD_URL_DEBIAN | Debian repository URL | https://deb.debian.org |
|
||||
| SPCD_URL_FEDORA | Fedora repository URL | https://rpmfind.net |
|
||||
| SPCD_URL_ROCKY | Rocky repository URL | https://dl.rockylinux.org |
|
||||
| SPCD_URL_UBUNTU | Ubuntu repository URL | https://ubuntu.mirrors.ovh.net |
|
||||
|
||||
## HTTPS & Python
|
||||
|
||||
|
|
837
spcd.sh
Normal file
837
spcd.sh
Normal file
|
@ -0,0 +1,837 @@
|
|||
#! /usr/bin/env sh
|
||||
|
||||
# defaults
|
||||
[ -n "${SPCD_DNS}" ] || SPCD_DNS="\
|
||||
9.9.9.9 \
|
||||
"
|
||||
[ -n "${SPCD_GIT_MAIN}" ] || SPCD_GIT_MAIN="spcd"
|
||||
[ -n "${SPCD_GIT_ROOT}" ] || SPCD_GIT_ROOT="rwx"
|
||||
|
||||
# main
|
||||
spcd_main() {
|
||||
spcd_list_environment_variables
|
||||
spcd_list_working_directory
|
||||
#
|
||||
spcd_set_environment_variables
|
||||
spcd_set_packages_repositories
|
||||
spcd_set_packages_configuration
|
||||
#
|
||||
spcd_set_https_verification_off
|
||||
spcd_set_dns_resolving
|
||||
spcd_update_packages_catalog
|
||||
spcd_install_packages_tools
|
||||
spcd_install_ca_certificates
|
||||
spcd_write_ca_certificates
|
||||
spcd_update_ca_certificates
|
||||
spcd_set_https_verification_on
|
||||
spcd_update_packages_catalog
|
||||
spcd_upgrade_packages
|
||||
spcd_install_git
|
||||
spcd_install_python
|
||||
# TODO move to Python
|
||||
spcd_install_rsync
|
||||
# TODO move to Python
|
||||
spcd_install_ssh
|
||||
spcd_clean_packages_cache
|
||||
spcd_install_python_modules
|
||||
spcd_write_python_module
|
||||
spcd_switch_to_python "${@}"
|
||||
}
|
||||
|
||||
# context
|
||||
|
||||
spcd_list_environment_variables() {
|
||||
spcd_step "List environment variables"
|
||||
for spcd_lev__name in $(printenv | cut -d = -f 1 | sort); do
|
||||
spcd_lev__text=""
|
||||
eval "spcd_lev__text=\"\${${spcd_lev__name}}\""
|
||||
echo "${spcd_lev__name}=${spcd_lev__text}"
|
||||
done
|
||||
}
|
||||
|
||||
spcd_list_working_directory() {
|
||||
spcd_step "List working directory"
|
||||
spcd_lwd__path="$(realpath .)"
|
||||
spcd_ls "${spcd_lwd__path}"
|
||||
}
|
||||
|
||||
# steps
|
||||
|
||||
spcd_set_environment_variables() {
|
||||
spcd_step "Set environment variables"
|
||||
# set path
|
||||
SPCD_PATH="$(realpath "${0}")"
|
||||
spcd_echo "SPCD_PATH"
|
||||
# set operating system id
|
||||
SPCD_OS_ID="$(spcd_grep_os ID)"
|
||||
case "${SPCD_OS_ID}" in
|
||||
"almalinux") SPCD_OS_ID="${SPCD_OS_ALMA}" ;;
|
||||
"alpine") SPCD_OS_ID="${SPCD_OS_ALPINE}" ;;
|
||||
"arch") SPCD_OS_ID="${SPCD_OS_ARCH}" ;;
|
||||
"debian") SPCD_OS_ID="${SPCD_OS_DEBIAN}" ;;
|
||||
"fedora") SPCD_OS_ID="${SPCD_OS_FEDORA}" ;;
|
||||
"rocky") SPCD_OS_ID="${SPCD_OS_ROCKY}" ;;
|
||||
"ubuntu") SPCD_OS_ID="${SPCD_OS_UBUNTU}" ;;
|
||||
*) spcd_error_os "SPCD_OS_ID" ;;
|
||||
esac
|
||||
# set operating system version
|
||||
case "${SPCD_OS_ID}" in
|
||||
"${SPCD_OS_ALMA}" | "${SPCD_OS_FEDORA}" | "${SPCD_OS_ROCKY}" | \
|
||||
"${SPCD_OS_ARCH}")
|
||||
SPCD_OS_VERSION=$(spcd_grep_os VERSION_ID |
|
||||
sed "s|^\([0-9]\+\)\..*|\1|")
|
||||
;;
|
||||
"${SPCD_OS_ALPINE}")
|
||||
SPCD_OS_VERSION=$(spcd_grep_os VERSION_ID |
|
||||
sed "s|^\([0-9]\+\.[0-9]\+\)\..*|\1|")
|
||||
;;
|
||||
"${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
|
||||
SPCD_OS_VERSION="$(spcd_grep_os VERSION_CODENAME)"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
# check operating system version
|
||||
case "${SPCD_OS_ID}" in
|
||||
"${SPCD_OS_ALMA}" | "${SPCD_OS_ROCKY}")
|
||||
case "${SPCD_OS_VERSION}" in
|
||||
"8" | "9") ;;
|
||||
*) spcd_error_os "SPCD_OS_VERSION" ;;
|
||||
esac
|
||||
;;
|
||||
"${SPCD_OS_ALPINE}")
|
||||
case "${SPCD_OS_VERSION}" in
|
||||
"3.18" | "3.19") ;;
|
||||
*) spcd_error_os "SPCD_OS_VERSION" ;;
|
||||
esac
|
||||
;;
|
||||
"${SPCD_OS_ARCH}")
|
||||
case "${SPCD_OS_VERSION}" in
|
||||
"20231112" | "20240101") ;;
|
||||
*) spcd_error_os "SPCD_OS_VERSION" ;;
|
||||
esac
|
||||
;;
|
||||
"${SPCD_OS_DEBIAN}")
|
||||
case "${SPCD_OS_VERSION}" in
|
||||
"bookworm" | "bullseye") ;;
|
||||
*) spcd_error_os "SPCD_OS_VERSION" ;;
|
||||
esac
|
||||
;;
|
||||
"${SPCD_OS_FEDORA}")
|
||||
case "${SPCD_OS_VERSION}" in
|
||||
"39" | "40") ;;
|
||||
*) spcd_error_os "SPCD_OS_VERSION" ;;
|
||||
esac
|
||||
;;
|
||||
"${SPCD_OS_UBUNTU}")
|
||||
case "${SPCD_OS_VERSION}" in
|
||||
"jammy" | "noble") ;;
|
||||
*) spcd_error_os "SPCD_OS_VERSION" ;;
|
||||
esac
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
spcd_split
|
||||
spcd_echo "SPCD_OS_ID" "SPCD_OS_VERSION"
|
||||
# universal
|
||||
SPCD_DNS_FILE="/etc/resolv.conf"
|
||||
SPCD_PKG_CA="ca-certificates"
|
||||
SPCD_PKG_GIT="git"
|
||||
# TODO move to Python
|
||||
SPCD_PKG_RSYNC="rsync"
|
||||
SPCD_PYTHON_ALIAS="python3"
|
||||
spcd_split
|
||||
spcd_echo "SPCD_DNS_FILE" "SPCD_PKG_CA" "SPCD_PKG_GIT" "SPCD_PYTHON_ALIAS"
|
||||
# set ca command & root
|
||||
case "${SPCD_OS_ID}" in
|
||||
"${SPCD_OS_ALMA}" | "${SPCD_OS_FEDORA}" | "${SPCD_OS_ROCKY}")
|
||||
SPCD_CA_ROOT="/etc/pki/ca-trust/source/anchors"
|
||||
SPCD_CMD_CA="update-ca-trust"
|
||||
;;
|
||||
"${SPCD_OS_ALPINE}")
|
||||
SPCD_CA_ROOT="/usr/local/share/ca-certificates"
|
||||
SPCD_CMD_CA="update-ca-certificates"
|
||||
;;
|
||||
"${SPCD_OS_ARCH}")
|
||||
SPCD_CA_ROOT="/etc/ca-certificates/trust-source/anchors"
|
||||
SPCD_CMD_CA="update-ca-trust"
|
||||
;;
|
||||
"${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
|
||||
SPCD_CA_ROOT="/usr/local/share/ca-certificates"
|
||||
SPCD_CMD_CA="update-ca-certificates"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
spcd_split
|
||||
spcd_echo "SPCD_CA_ROOT" "SPCD_CMD_CA"
|
||||
# set package manager
|
||||
case "${SPCD_OS_ID}" in
|
||||
"${SPCD_OS_ALPINE}")
|
||||
SPCD_PM="${SPCD_PM_APK}"
|
||||
;;
|
||||
"${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
|
||||
SPCD_PM="${SPCD_PM_APT}"
|
||||
;;
|
||||
"${SPCD_OS_ALMA}" | "${SPCD_OS_FEDORA}" | "${SPCD_OS_ROCKY}")
|
||||
SPCD_PM="${SPCD_PM_DNF}"
|
||||
;;
|
||||
"${SPCD_OS_ARCH}")
|
||||
SPCD_PM="${SPCD_PM_PACMAN}"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
spcd_split
|
||||
spcd_echo "SPCD_PM"
|
||||
case "${SPCD_PM}" in
|
||||
"${SPCD_PM_DNF}")
|
||||
SPCD_PM_CLEAN="dnf clean all"
|
||||
SPCD_PM_INSTALL="dnf install --assumeyes"
|
||||
SPCD_PM_QUERY="rpm --query"
|
||||
SPCD_PM_UPDATE="dnf makecache"
|
||||
SPCD_PM_UPGRADE="dnf upgrade --assumeyes"
|
||||
SPCD_PKG_PKG=""
|
||||
SPCD_PM_CONF_PATH="/etc/dnf/dnf.conf"
|
||||
SPCD_PM_CONF_TEXT="\
|
||||
[main]
|
||||
best=True
|
||||
clean_requirements_on_remove=True
|
||||
gpgcheck=1
|
||||
installonly_limit=3
|
||||
skip_if_unavailable=False
|
||||
"
|
||||
SPCD_PM_HTTPS_PATH="/etc/dnf/dnf.conf.d/https.conf"
|
||||
SPCD_PM_HTTPS_TEXT="\
|
||||
sslverify=False
|
||||
"
|
||||
;;
|
||||
"${SPCD_PM_APK}")
|
||||
SPCD_PM_CLEAN="apk cache purge"
|
||||
SPCD_PM_INSTALL="apk add"
|
||||
SPCD_PM_QUERY="apk info"
|
||||
SPCD_PM_UPDATE="apk update"
|
||||
SPCD_PM_UPGRADE="apk upgrade"
|
||||
SPCD_PKG_PKG=""
|
||||
SPCD_PM_CONF_PATH=""
|
||||
SPCD_PM_CONF_TEXT=""
|
||||
SPCD_PM_HTTPS_PATH="/etc/apk/repositories.d/https"
|
||||
SPCD_PM_HTTPS_TEXT="\
|
||||
--no-verify
|
||||
"
|
||||
;;
|
||||
"${SPCD_PM_PACMAN}")
|
||||
SPCD_PM_CLEAN="pacman --sync --clean --noconfirm"
|
||||
SPCD_PM_INSTALL="pacman --sync --noconfirm"
|
||||
SPCD_PM_QUERY="pacman --query"
|
||||
SPCD_PM_UPDATE="pacman --sync --refresh"
|
||||
SPCD_PM_UPGRADE="pacman --sync --sysupgrade --noconfirm"
|
||||
SPCD_PKG_PKG=""
|
||||
SPCD_PM_CONF_PATH=""
|
||||
SPCD_PM_CONF_TEXT=""
|
||||
SPCD_PM_HTTPS_PATH="/etc/pacman.d/https.conf"
|
||||
SPCD_PM_HTTPS_TEXT="\
|
||||
SSLVerify = No
|
||||
"
|
||||
;;
|
||||
"${SPCD_PM_APT}")
|
||||
SPCD_PM_CLEAN="apt-get clean"
|
||||
SPCD_PM_INSTALL="apt-get install --assume-yes"
|
||||
SPCD_PM_QUERY="dpkg-query --show"
|
||||
SPCD_PM_UPDATE="apt-get update"
|
||||
SPCD_PM_UPGRADE="apt-get upgrade --assume-yes"
|
||||
SPCD_PKG_PKG="apt-utils"
|
||||
SPCD_PM_CONF_PATH="/etc/apt/apt.conf.d/apt.conf"
|
||||
SPCD_PM_CONF_TEXT="\
|
||||
Acquire::Check-Valid-Until True;
|
||||
APT::Get::Show-Versions True;
|
||||
APT::Install-Recommends False;
|
||||
APT::Install-Suggests False;
|
||||
Dir::Etc::SourceParts \"\";
|
||||
"
|
||||
SPCD_PM_HTTPS_PATH="/etc/apt/apt.conf.d/https"
|
||||
SPCD_PM_HTTPS_TEXT="\
|
||||
Acquire::https::Verify-Peer False;
|
||||
"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
spcd_split
|
||||
spcd_echo "SPCD_PM_CLEAN" \
|
||||
"SPCD_PM_INSTALL" "SPCD_PM_QUERY" "SPCD_PM_UPDATE" "SPCD_PM_UPGRADE"
|
||||
spcd_split
|
||||
spcd_echo "SPCD_PKG_PKG" "SPCD_PM_CONF_PATH" "SPCD_PM_HTTPS_PATH"
|
||||
# specific
|
||||
case "${SPCD_OS_ID}" in
|
||||
"${SPCD_OS_ALMA}")
|
||||
SPCD_URL_DEFAULT="https://repo.almalinux.org/almalinux"
|
||||
;;
|
||||
"${SPCD_OS_ALPINE}")
|
||||
SPCD_URL_DEFAULT="https://dl-cdn.alpinelinux.org/alpine"
|
||||
;;
|
||||
"${SPCD_OS_ARCH}")
|
||||
SPCD_URL_DEFAULT="https://geo.mirror.pkgbuild.com"
|
||||
;;
|
||||
"${SPCD_OS_DEBIAN}")
|
||||
SPCD_URL_DEFAULT="http://deb.debian.org/debian"
|
||||
;;
|
||||
"${SPCD_OS_FEDORA}")
|
||||
SPCD_URL_DEFAULT="http://download.example/pub/fedora/linux/releases"
|
||||
;;
|
||||
"${SPCD_OS_ROCKY}")
|
||||
SPCD_URL_DEFAULT="http://dl.rockylinux.org/\$contentdir"
|
||||
;;
|
||||
"${SPCD_OS_UBUNTU}")
|
||||
SPCD_URL_DEFAULT="http://archive.ubuntu.com/ubuntu"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
SPCD_URL_CHOSEN="${SPCD_URL_DEFAULT}"
|
||||
case "${SPCD_OS_ID}" in
|
||||
"${SPCD_OS_ALMA}")
|
||||
[ -n "${SPCD_URL_ALMA}" ] && SPCD_URL_CHOSEN="${SPCD_URL_ALMA}"
|
||||
;;
|
||||
"${SPCD_OS_ALPINE}")
|
||||
[ -n "${SPCD_URL_ALPINE}" ] && SPCD_URL_CHOSEN="${SPCD_URL_ALPINE}"
|
||||
;;
|
||||
"${SPCD_OS_ARCH}")
|
||||
[ -n "${SPCD_URL_ARCH}" ] && SPCD_URL_CHOSEN="${SPCD_URL_ARCH}"
|
||||
;;
|
||||
"${SPCD_OS_DEBIAN}")
|
||||
[ -n "${SPCD_URL_DEBIAN}" ] && SPCD_URL_CHOSEN="${SPCD_URL_DEBIAN}" ||
|
||||
SPCD_URL_CHOSEN="https://deb.debian.org/debian"
|
||||
;;
|
||||
"${SPCD_OS_FEDORA}")
|
||||
[ -n "${SPCD_URL_FEDORA}" ] && SPCD_URL_CHOSEN="${SPCD_URL_FEDORA}" ||
|
||||
SPCD_URL_CHOSEN="https://rpmfind.net/linux/fedora/linux/releases"
|
||||
;;
|
||||
"${SPCD_OS_ROCKY}")
|
||||
[ -n "${SPCD_URL_ROCKY}" ] && SPCD_URL_CHOSEN="${SPCD_URL_ROCKY}" ||
|
||||
SPCD_URL_CHOSEN="https://dl.rockylinux.org/\$contentdir"
|
||||
;;
|
||||
"${SPCD_OS_UBUNTU}")
|
||||
[ -n "${SPCD_URL_UBUNTU}" ] && SPCD_URL_CHOSEN="${SPCD_URL_UBUNTU}" ||
|
||||
SPCD_URL_CHOSEN="https://ubuntu.mirrors.ovh.net/ubuntu"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
spcd_split
|
||||
spcd_echo "SPCD_URL_DEFAULT" "SPCD_URL_CHOSEN"
|
||||
# set python command & package
|
||||
case "${SPCD_OS_ID}" in
|
||||
"${SPCD_OS_ALMA}" | "${SPCD_OS_ROCKY}")
|
||||
SPCD_PYTHON_COMMAND="python3.11"
|
||||
SPCD_PYTHON_PACKAGE="python3.11"
|
||||
;;
|
||||
"${SPCD_OS_ALPINE}")
|
||||
SPCD_PYTHON_COMMAND="python3.11"
|
||||
SPCD_PYTHON_PACKAGE="python3"
|
||||
;;
|
||||
"${SPCD_OS_ARCH}")
|
||||
SPCD_PYTHON_COMMAND="python3.12"
|
||||
SPCD_PYTHON_PACKAGE="python"
|
||||
;;
|
||||
"${SPCD_OS_DEBIAN}")
|
||||
case "${SPCD_OS_VERSION}" in
|
||||
"bookworm") SPCD_PYTHON_COMMAND="python3.11" ;;
|
||||
"bullseye") SPCD_PYTHON_COMMAND="python3.9" ;;
|
||||
*) ;;
|
||||
esac
|
||||
SPCD_PYTHON_PACKAGE="python3"
|
||||
;;
|
||||
"${SPCD_OS_FEDORA}")
|
||||
SPCD_PYTHON_COMMAND="python3.12"
|
||||
SPCD_PYTHON_PACKAGE="python3"
|
||||
;;
|
||||
"${SPCD_OS_UBUNTU}")
|
||||
case "${SPCD_OS_VERSION}" in
|
||||
"noble") SPCD_PYTHON_COMMAND="python3.12" ;;
|
||||
"jammy") SPCD_PYTHON_COMMAND="python3.10" ;;
|
||||
*) ;;
|
||||
esac
|
||||
SPCD_PYTHON_PACKAGE="python3"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
# set python packages
|
||||
case "${SPCD_OS_ID}" in
|
||||
"${SPCD_OS_ALMA}" | "${SPCD_OS_FEDORA}" | "${SPCD_OS_ROCKY}")
|
||||
SPCD_PYTHON_PACKAGES="/usr/lib64/${SPCD_PYTHON_COMMAND}/site-packages"
|
||||
;;
|
||||
"${SPCD_OS_ALPINE}" | "${SPCD_OS_ARCH}")
|
||||
SPCD_PYTHON_PACKAGES="/usr/lib/${SPCD_PYTHON_COMMAND}/site-packages"
|
||||
;;
|
||||
"${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
|
||||
SPCD_PYTHON_PACKAGES="/usr/lib/${SPCD_PYTHON_ALIAS}/dist-packages"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
spcd_split
|
||||
spcd_echo "SPCD_PYTHON_COMMAND" "SPCD_PYTHON_PACKAGE" "SPCD_PYTHON_PACKAGES"
|
||||
# variables
|
||||
[ -n "${SPCD_CA_1}" ] && SPCD_CA=true
|
||||
# continuous integration platform
|
||||
if [ -n "${GITHUB_ACTIONS}" ]; then
|
||||
# github → gitea → forgejo
|
||||
if [ -n "${GITHUB_SERVER_URL}" ]; then
|
||||
SPCD_PROJECT_ROOT="$(dirname "${GITHUB_SERVER_URL}")//"
|
||||
[ -n "${GITHUB_TOKEN}" ] &&
|
||||
SPCD_PROJECT_ROOT="${SPCD_PROJECT_ROOT}${GITHUB_TOKEN}@"
|
||||
SPCD_PROJECT_ROOT="${SPCD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")"
|
||||
else
|
||||
spcd_error_ci "GITHUB_SERVER_URL"
|
||||
fi
|
||||
if [ -n "${GITHUB_REPOSITORY}" ]; then
|
||||
SPCD_PROJECT_PATH="$(dirname "${GITHUB_REPOSITORY}")"
|
||||
SPCD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
|
||||
else
|
||||
spcd_error_ci "GITHUB_REPOSITORY"
|
||||
fi
|
||||
if [ -n "${GITHUB_REF_NAME}" ]; then
|
||||
SPCD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
|
||||
else
|
||||
spcd_error_ci "GITHUB_REF_NAME"
|
||||
fi
|
||||
elif [ -n "${GITLAB_CI}" ]; then
|
||||
# gitlab
|
||||
if [ -n "${CI_SERVER_PROTOCOL}" ]; then
|
||||
if [ -n "${CI_REGISTRY_USER}" ]; then
|
||||
if [ -n "${CI_REGISTRY_PASSWORD}" ]; then
|
||||
if [ -n "${CI_SERVER_FQDN}" ]; then
|
||||
SPCD_PROJECT_ROOT="${CI_SERVER_PROTOCOL}\
|
||||
://${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}@${CI_SERVER_FQDN}"
|
||||
if [ -n "${CI_PROJECT_NAMESPACE}" ]; then
|
||||
SPCD_PROJECT_PATH="${CI_PROJECT_NAMESPACE}"
|
||||
if [ -n "${CI_PROJECT_NAME}" ]; then
|
||||
SPCD_PROJECT_NAME="${CI_PROJECT_NAME}"
|
||||
else
|
||||
spcd_error_ci "CI_PROJECT_NAME"
|
||||
fi
|
||||
else
|
||||
spcd_error_ci "CI_PROJECT_NAMESPACE"
|
||||
fi
|
||||
else
|
||||
spcd_error_ci "CI_SERVER_FQDN"
|
||||
fi
|
||||
else
|
||||
spcd_error_ci "CI_REGISTRY_PASSWORD"
|
||||
fi
|
||||
else
|
||||
spcd_error_ci "CI_REGISTRY_USER"
|
||||
fi
|
||||
else
|
||||
spcd_error_ci "CI_SERVER_PROTOCOL"
|
||||
fi
|
||||
if [ -n "${CI_COMMIT_BRANCH}" ]; then
|
||||
SPCD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
|
||||
else
|
||||
spcd_error_ci "CI_COMMIT_BRANCH"
|
||||
fi
|
||||
else
|
||||
# unsupported
|
||||
spcd_error_ci "ø"
|
||||
fi
|
||||
[ -n "${SPCD_PROJECT_ROOT}" ] || spcd_error_ci "SPCD_PROJECT_ROOT"
|
||||
[ -n "${SPCD_PROJECT_PATH}" ] || spcd_error_ci "SPCD_PROJECT_PATH"
|
||||
[ -n "${SPCD_PROJECT_NAME}" ] || spcd_error_ci "SPCD_PROJECT_NAME"
|
||||
[ -n "${SPCD_PROJECT_BRANCH}" ] || spcd_error_ci "SPCD_PROJECT_BRANCH"
|
||||
#
|
||||
spcd_split
|
||||
spcd_echo "SPCD_CA"
|
||||
spcd_split
|
||||
spcd_echo "SPCD_PROJECT_ROOT" \
|
||||
"SPCD_PROJECT_PATH" "SPCD_PROJECT_NAME" "SPCD_PROJECT_BRANCH"
|
||||
# TODO move to Python
|
||||
case "${SPCD_PM}" in
|
||||
"${SPCD_PM_APK}" | "${SPCD_PM_APT}") SPCD_PKG_SSH="openssh-client" ;;
|
||||
"${SPCD_PM_DNF}") SPCD_PKG_SSH="openssh-clients" ;;
|
||||
"${SPCD_PM_PACMAN}") SPCD_PKG_SSH="openssh" ;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
spcd_set_packages_repositories() {
|
||||
spcd_step "Set packages repositories"
|
||||
case "${SPCD_OS_ID}" in
|
||||
"${SPCD_OS_ALMA}")
|
||||
case "${SPCD_OS_VERSION}" in
|
||||
"8") spcd_spr__file="/etc/yum.repos.d/almalinux.repo" ;;
|
||||
"9") spcd_spr__file="/etc/yum.repos.d/almalinux-baseos.repo" ;;
|
||||
*) ;;
|
||||
esac
|
||||
spcd_sed "${spcd_spr__file}" \
|
||||
"|^mirrorlist|# mirrorlist|" \
|
||||
"|${SPCD_URL_DEFAULT}|${SPCD_URL_CHOSEN}|" \
|
||||
"|^# baseurl|baseurl|"
|
||||
;;
|
||||
"${SPCD_OS_ALPINE}")
|
||||
spcd_spr__file="/etc/apk/repositories"
|
||||
spcd_write "${spcd_spr__file}" "\
|
||||
${SPCD_URL_CHOSEN}/v${SPCD_OS_VERSION}/main
|
||||
${SPCD_URL_CHOSEN}/v${SPCD_OS_VERSION}/community
|
||||
"
|
||||
;;
|
||||
"${SPCD_OS_DEBIAN}")
|
||||
spcd_spr__file="/etc/apt/sources.list"
|
||||
spcd_write "${spcd_spr__file}" "\
|
||||
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION} main
|
||||
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-backports main
|
||||
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-updates main
|
||||
deb ${SPCD_URL_CHOSEN}-security ${SPCD_OS_VERSION}-security main
|
||||
"
|
||||
;;
|
||||
"${SPCD_OS_ROCKY}")
|
||||
case "${SPCD_OS_VERSION}" in
|
||||
"8") spcd_spr__file="/etc/yum.repos.d/Rocky-BaseOS.repo" ;;
|
||||
"9") spcd_spr__file="/etc/yum.repos.d/rocky.repo" ;;
|
||||
*) ;;
|
||||
esac
|
||||
spcd_sed "${spcd_spr__file}" \
|
||||
"|^mirrorlist|# mirrorlist|" \
|
||||
"|${SPCD_URL_DEFAULT}|${SPCD_URL_CHOSEN}|" \
|
||||
"|^#baseurl|baseurl|"
|
||||
;;
|
||||
"${SPCD_OS_UBUNTU}")
|
||||
spcd_spr__file="/etc/apt/sources.list"
|
||||
spcd_write "${spcd_spr__file}" "\
|
||||
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION} main
|
||||
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-backports main
|
||||
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-updates main
|
||||
deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-security main
|
||||
"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
spcd_set_packages_configuration() {
|
||||
spcd_step "Set packages configuration"
|
||||
spcd_write "${SPCD_PM_CONF_PATH}" "${SPCD_PM_CONF_TEXT}"
|
||||
case "${SPCD_OS_ID}" in
|
||||
"${SPCD_OS_DEBIAN}" | "${SPCD_OS_UBUNTU}")
|
||||
export DEBIAN_FRONTEND="noninteractive"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# agnostic steps
|
||||
|
||||
spcd_set_https_verification_off() {
|
||||
if [ -n "${SPCD_CA}" ] || [ "${SPCD_PM}" = "${SPCD_PM_APT}" ]; then
|
||||
spcd_step "Set HTTPS verification off"
|
||||
spcd_mkdir "$(dirname "${SPCD_PM_HTTPS_PATH}")"
|
||||
spcd_write "${SPCD_PM_HTTPS_PATH}" "${SPCD_PM_HTTPS_TEXT}"
|
||||
fi
|
||||
}
|
||||
|
||||
spcd_set_dns_resolving() {
|
||||
spcd_step "Set DNS resolving"
|
||||
for spcd_sdr__server in ${SPCD_DNS}; do
|
||||
spcd_sdr__text="${spcd_sdr__text}\
|
||||
nameserver ${spcd_sdr__server}
|
||||
"
|
||||
done
|
||||
spcd_write "${SPCD_DNS_FILE}" "${spcd_sdr__text}"
|
||||
}
|
||||
|
||||
spcd_update_packages_catalog() {
|
||||
spcd_step "Update packages catalog"
|
||||
${SPCD_PM_UPDATE} || exit
|
||||
}
|
||||
|
||||
spcd_install_packages_tools() {
|
||||
spcd_step "Install packages tools"
|
||||
spcd_install_package "${SPCD_PKG_PKG}"
|
||||
}
|
||||
|
||||
spcd_install_ca_certificates() {
|
||||
spcd_step "Install CA"
|
||||
spcd_install_package "${SPCD_PKG_CA}"
|
||||
}
|
||||
|
||||
spcd_write_ca_certificates() {
|
||||
spcd_step "Write CA certificates"
|
||||
spcd_mkdir "${SPCD_CA_ROOT}"
|
||||
spcd_wcc__index=1
|
||||
eval "spcd_wcc__text=\"\${SPCD_CA_${spcd_wcc__index}}\""
|
||||
while [ -n "${spcd_wcc__text}" ]; do
|
||||
spcd_wcc__path="${SPCD_CA_ROOT}/${spcd_wcc__index}.crt"
|
||||
spcd_split
|
||||
spcd_write "${spcd_wcc__path}" "${spcd_wcc__text}"
|
||||
spcd_openssl "${spcd_wcc__path}"
|
||||
spcd_wcc__index=$((spcd_wcc__index + 1))
|
||||
eval "spcd_wcc__text=\"\${SPCD_CA_${spcd_wcc__index}}\""
|
||||
done
|
||||
}
|
||||
|
||||
spcd_update_ca_certificates() {
|
||||
spcd_step "Update CA certificates"
|
||||
${SPCD_CMD_CA} || exit
|
||||
}
|
||||
|
||||
spcd_set_https_verification_on() {
|
||||
spcd_step "Set HTTPS verification on"
|
||||
spcd_rm "${SPCD_PM_HTTPS_PATH}"
|
||||
}
|
||||
|
||||
spcd_upgrade_packages() {
|
||||
spcd_step "Upgrade packages"
|
||||
${SPCD_PM_UPGRADE} || exit
|
||||
}
|
||||
|
||||
spcd_install_git() {
|
||||
spcd_step "Install Git"
|
||||
spcd_install_package "${SPCD_PKG_GIT}"
|
||||
}
|
||||
|
||||
spcd_install_python() {
|
||||
spcd_step "Install Python"
|
||||
spcd_install_package "${SPCD_PYTHON_PACKAGE}"
|
||||
spcd_split
|
||||
spcd_ln_python "${SPCD_PYTHON_COMMAND}"
|
||||
}
|
||||
|
||||
# TODO move to Python
|
||||
spcd_install_rsync() {
|
||||
spcd_step "Install Rsync"
|
||||
spcd_install_package "${SPCD_PKG_RSYNC}"
|
||||
}
|
||||
|
||||
# TODO move to Python
|
||||
spcd_install_ssh() {
|
||||
spcd_step "Install SSH"
|
||||
spcd_install_package "${SPCD_PKG_SSH}"
|
||||
}
|
||||
|
||||
spcd_clean_packages_cache() {
|
||||
spcd_step "Clean packages cache"
|
||||
${SPCD_PM_CLEAN} || exit
|
||||
}
|
||||
|
||||
spcd_install_python_modules() {
|
||||
spcd_step "Install Python modules"
|
||||
spcd_ipm__root="$(mktemp --directory)" || exit
|
||||
echo "→ ${spcd_ipm__root}"
|
||||
for spcd_ipm__repository in "${SPCD_GIT_MAIN}" "${SPCD_GIT_ROOT}"; do
|
||||
case "${spcd_ipm__repository}" in
|
||||
http*) spcd_ipm__url="${spcd_ipm__repository}" ;;
|
||||
/*) spcd_ipm__url="${SPCD_PROJECT_ROOT}${spcd_ipm__repository}" ;;
|
||||
*) spcd_ipm__url="\
|
||||
${SPCD_PROJECT_ROOT}/${SPCD_PROJECT_PATH}/${spcd_ipm__repository}" ;;
|
||||
esac
|
||||
spcd_ipm__name="$(basename "${spcd_ipm__url}")"
|
||||
spcd_split
|
||||
echo "\
|
||||
${spcd_ipm__url}
|
||||
↓"
|
||||
git clone \
|
||||
"${spcd_ipm__url}" \
|
||||
"${spcd_ipm__root}/${spcd_ipm__name}" ||
|
||||
exit
|
||||
spcd_ipm__path="${spcd_ipm__root}/${spcd_ipm__name}/${spcd_ipm__name}"
|
||||
echo "\
|
||||
${spcd_ipm__path}
|
||||
↓
|
||||
${SPCD_PYTHON_PACKAGES}"
|
||||
cp --recursive "${spcd_ipm__path}" "${SPCD_PYTHON_PACKAGES}" ||
|
||||
exit
|
||||
done
|
||||
spcd_split
|
||||
spcd_ls "${SPCD_PYTHON_PACKAGES}"
|
||||
spcd_split
|
||||
spcd_rm "${spcd_ipm__root}"
|
||||
}
|
||||
|
||||
spcd_write_python_module() {
|
||||
spcd_step "Write Python module"
|
||||
for spcd_wpm__variable in \
|
||||
OS_ID OS_VERSION \
|
||||
PROJECT_ROOT PROJECT_PATH PROJECT_NAME \
|
||||
OPEN DOWN VERT SPLT __UP SHUT; do
|
||||
spcd_wpm__value="$(spcd_echo "SPCD_${spcd_wpm__variable}")"
|
||||
spcd_wpm__text="${spcd_wpm__text}${spcd_wpm__value}
|
||||
"
|
||||
done
|
||||
spcd_write "${SPCD_PYTHON_PACKAGES}/env.py" "${spcd_wpm__text}
|
||||
SPCD_STEP = $((SPCD_STEP + 1))
|
||||
"
|
||||
}
|
||||
|
||||
spcd_switch_to_python() {
|
||||
spcd_step "Switch to Python"
|
||||
spcd_stp__name="$(basename "${SPCD_GIT_MAIN}")"
|
||||
echo "\
|
||||
${SPCD_PATH}
|
||||
↓
|
||||
${SPCD_PYTHON_PACKAGES}/${spcd_stp__name}"
|
||||
"${SPCD_PYTHON_ALIAS}" -m "${spcd_stp__name}" "${@}"
|
||||
}
|
||||
|
||||
# functions
|
||||
|
||||
spcd_cat() {
|
||||
spcd_cat__file="${1}"
|
||||
if [ -n "${spcd_cat__file}" ]; then
|
||||
spcd_open "${spcd_cat__file}"
|
||||
cat "${spcd_cat__file}" || exit
|
||||
spcd_shut "${spcd_cat__file}"
|
||||
fi
|
||||
}
|
||||
|
||||
spcd_echo() {
|
||||
if [ -n "${1}" ]; then
|
||||
for spcd_echo__name in "${@}"; do
|
||||
spcd_echo__text=""
|
||||
eval "spcd_echo__text=\"\${${spcd_echo__name}}\""
|
||||
echo "${spcd_echo__name} = \"${spcd_echo__text}\""
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
spcd_error_ci() {
|
||||
echo "× CI: ${*}"
|
||||
exit "${SPCD_ERROR_CI}"
|
||||
}
|
||||
|
||||
spcd_error_os() {
|
||||
spcd_error_os__variable="${1}"
|
||||
printf "× OS: "
|
||||
spcd_echo "${spcd_error_os__variable}"
|
||||
exit "${SPCD_ERROR_OS}"
|
||||
}
|
||||
|
||||
spcd_grep_os() {
|
||||
spcd_grep_os__variable="${1}"
|
||||
[ -n "${spcd_grep_os__variable}" ] &&
|
||||
grep "^${spcd_grep_os__variable}=" "/etc/os-release" |
|
||||
sed "s|^${spcd_grep_os__variable}=||" |
|
||||
sed "s|^\"\(.*\)\"$|\1|"
|
||||
}
|
||||
|
||||
spcd_install_package() {
|
||||
spcd_install_package__name="${1}"
|
||||
if [ -n "${spcd_install_package__name}" ]; then
|
||||
${SPCD_PM_INSTALL} "${spcd_install_package__name}" || exit
|
||||
fi
|
||||
}
|
||||
|
||||
spcd_ln_python() {
|
||||
spcd_ln_python__command="${1}"
|
||||
if [ -n "${spcd_ln_python__command}" ]; then
|
||||
echo "→ ${SPCD_PYTHON_ALIAS} → ${spcd_ln_python__command}"
|
||||
ln -f -s "${spcd_ln_python__command}" \
|
||||
"/usr/bin/${SPCD_PYTHON_ALIAS}" || exit
|
||||
fi
|
||||
}
|
||||
|
||||
spcd_ls() {
|
||||
spcd_ls__path="${1}"
|
||||
if [ -n "${spcd_ls__path}" ]; then
|
||||
spcd_open "${spcd_ls__path}"
|
||||
ls -a -l "${spcd_ls__path}" || exit
|
||||
spcd_shut "${spcd_ls__path}"
|
||||
fi
|
||||
}
|
||||
|
||||
spcd_mkdir() {
|
||||
spcd_mkdir__path="${1}"
|
||||
if [ -n "${spcd_mkdir__path}" ]; then
|
||||
echo "→ ${spcd_mkdir__path}"
|
||||
mkdir --parents "${spcd_mkdir__path}" || exit
|
||||
fi
|
||||
}
|
||||
|
||||
spcd_open() {
|
||||
echo "${SPCD_OPEN}${*}"
|
||||
}
|
||||
|
||||
spcd_openssl() {
|
||||
spcd_openssl__file="${1}"
|
||||
if [ -f "${spcd_openssl__file}" ]; then
|
||||
openssl x509 \
|
||||
-in "${spcd_openssl__file}" \
|
||||
-noout -text ||
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
spcd_rm() {
|
||||
spcd_rm__path="${1}"
|
||||
if [ -e "${spcd_rm__path}" ]; then
|
||||
echo "← ${spcd_rm__path}"
|
||||
rm -r "${spcd_rm__path}" || exit
|
||||
fi
|
||||
}
|
||||
|
||||
spcd_sed() {
|
||||
spcd_sed__file="${1}"
|
||||
shift
|
||||
if [ -f "${spcd_sed__file}" ]; then
|
||||
spcd_cat "${spcd_sed__file}"
|
||||
for spcd_sed__regex in "${@}"; do
|
||||
sed --in-place "s${spcd_sed__regex}g" "${spcd_sed__file}" &&
|
||||
spcd_cat "${spcd_sed__file}" || exit
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
spcd_shut() {
|
||||
echo "${SPCD_SHUT}${*}"
|
||||
}
|
||||
|
||||
spcd_split() {
|
||||
echo "${SPCD_SPLT}"
|
||||
}
|
||||
|
||||
spcd_step() {
|
||||
SPCD_STEP=$((SPCD_STEP + 1))
|
||||
echo "\
|
||||
${SPCD_DOWN}
|
||||
${SPCD_VERT} ${SPCD_STEP} ${*}
|
||||
${SPCD___UP}"
|
||||
}
|
||||
|
||||
spcd_write() {
|
||||
spcd_write__file="${1}"
|
||||
spcd_write__text="${2}"
|
||||
if [ -n "${spcd_write__file}" ]; then
|
||||
[ -f "${spcd_write__file}" ] && spcd_cat "${spcd_write__file}"
|
||||
echo "→ ${spcd_write__file}"
|
||||
printf "%s" "${spcd_write__text}" >"${spcd_write__file}" || exit
|
||||
spcd_cat "${spcd_write__file}"
|
||||
fi
|
||||
}
|
||||
|
||||
# constants
|
||||
|
||||
SPCD_BOX_DOWN="╭"
|
||||
SPCD_BOX_LEFT="╴"
|
||||
SPCD_BOX_RIGHT="╶"
|
||||
SPCD_BOX_UP="╰"
|
||||
SPCD_BOX_VERTICAL="│"
|
||||
|
||||
SPCD_ERROR_CI=2
|
||||
SPCD_ERROR_OS=1
|
||||
|
||||
SPCD_OS_ALMA="alma"
|
||||
SPCD_OS_ALPINE="alpine"
|
||||
SPCD_OS_ARCH="arch"
|
||||
SPCD_OS_DEBIAN="debian"
|
||||
SPCD_OS_FEDORA="fedora"
|
||||
SPCD_OS_ROCKY="rocky"
|
||||
SPCD_OS_UBUNTU="ubuntu"
|
||||
|
||||
SPCD_PM_APK="apk"
|
||||
SPCD_PM_APT="apt"
|
||||
SPCD_PM_DNF="dnf"
|
||||
SPCD_PM_PACMAN="pacman"
|
||||
|
||||
SPCD_HORIZONTAL="────╌╌╌╌┄┄┄┄┈┈┈┈"
|
||||
|
||||
SPCD_OPEN="${SPCD_BOX_DOWN}${SPCD_BOX_LEFT}"
|
||||
SPCD_DOWN="${SPCD_BOX_DOWN}${SPCD_HORIZONTAL}"
|
||||
SPCD_VERT="${SPCD_BOX_VERTICAL}"
|
||||
SPCD_SPLT="${SPCD_BOX_RIGHT}${SPCD_HORIZONTAL}"
|
||||
SPCD___UP="${SPCD_BOX_UP}${SPCD_HORIZONTAL}"
|
||||
SPCD_SHUT="${SPCD_BOX_UP}${SPCD_BOX_LEFT}"
|
||||
|
||||
# run
|
||||
spcd_main "${@}"
|
|
@ -10,12 +10,12 @@ import env
|
|||
from rwx import fs
|
||||
from rwx.log import stream as log
|
||||
|
||||
import pidd
|
||||
from pidd import cmd
|
||||
from pidd.project import Project
|
||||
from pidd.projects import Projects
|
||||
import spcd
|
||||
from spcd import cmd
|
||||
from spcd.project import Project
|
||||
from spcd.projects import Projects
|
||||
|
||||
COMMANDS_PREFIX = "pidd-"
|
||||
COMMANDS_PREFIX = "spcd-"
|
||||
|
||||
projects = Projects()
|
||||
project = Project(projects)
|
||||
|
@ -58,8 +58,8 @@ def main(main: str) -> None:
|
|||
path, *arguments = sys.argv
|
||||
name = Path(path).name
|
||||
if name == "__main__.py":
|
||||
pidd.set_ssh(*arguments)
|
||||
pidd.install_commands(main)
|
||||
spcd.set_ssh(*arguments)
|
||||
spcd.install_commands(main)
|
||||
else:
|
||||
function = getattr(cmd, name.replace("-", "_"))
|
||||
function(*arguments)
|
||||
|
@ -93,19 +93,19 @@ def set_ssh(*arguments: list[str]) -> None:
|
|||
|
||||
|
||||
def frame(text: str) -> None:
|
||||
log.info(f"{env.PIDD_OPEN}{text}")
|
||||
log.info(f"{env.SPCD_OPEN}{text}")
|
||||
|
||||
|
||||
def shut(text: str) -> None:
|
||||
log.info(f"{env.PIDD_SHUT}{text}")
|
||||
log.info(f"{env.SPCD_SHUT}{text}")
|
||||
|
||||
|
||||
def split() -> None:
|
||||
log.info(env.PIDD_SPLT)
|
||||
log.info(env.SPCD_SPLT)
|
||||
|
||||
|
||||
def step(text: str) -> None:
|
||||
env.PIDD_STEP += 1
|
||||
log.info(env.PIDD_DOWN)
|
||||
log.info(f"{env.PIDD_VERT} {env.PIDD_STEP} {text}")
|
||||
log.info(env.PIDD___UP)
|
||||
env.SPCD_STEP += 1
|
||||
log.info(env.SPCD_DOWN)
|
||||
log.info(f"{env.SPCD_VERT} {env.SPCD_STEP} {text}")
|
||||
log.info(env.SPCD___UP)
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
"""Entry point."""
|
||||
|
||||
import pidd
|
||||
import spcd
|
||||
|
||||
if __name__ == "__main__":
|
||||
pidd.main(__file__)
|
||||
spcd.main(__file__)
|
|
@ -4,14 +4,14 @@ from pathlib import Path
|
|||
from rwx import ps, split
|
||||
from rwx.log import log
|
||||
|
||||
from pidd import browse, project, projects
|
||||
from spcd import browse, project, projects
|
||||
|
||||
|
||||
def pidd_browse_workspace() -> None:
|
||||
def spcd_browse_workspace() -> None:
|
||||
browse(project.root)
|
||||
|
||||
|
||||
def pidd_build_project() -> None:
|
||||
def spcd_build_project() -> None:
|
||||
for extension in ["py", "sh"]:
|
||||
path = Path(project.root) / f"build.{extension}"
|
||||
if path.exists():
|
||||
|
@ -21,7 +21,7 @@ def pidd_build_project() -> None:
|
|||
pass
|
||||
|
||||
|
||||
def pidd_clone_branch() -> None:
|
||||
def spcd_clone_branch() -> None:
|
||||
log.info(projects)
|
||||
split()
|
||||
log.info(project)
|
||||
|
@ -41,12 +41,12 @@ def pidd_clone_branch() -> None:
|
|||
)
|
||||
|
||||
|
||||
def pidd_list_environment() -> None:
|
||||
def spcd_list_environment() -> None:
|
||||
for variable, value in sorted(projects.environment.items()):
|
||||
log.info(f"{variable} = {value}")
|
||||
|
||||
|
||||
def pidd_synchronize() -> None:
|
||||
def spcd_synchronize() -> None:
|
||||
host = "rwx.work"
|
||||
source = "out"
|
||||
user = "cd"
|
|
@ -7,7 +7,7 @@ from typing import TYPE_CHECKING
|
|||
from urllib.parse import urljoin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pidd.projects import Projects
|
||||
from spcd.projects import Projects
|
||||
|
||||
BRANCH = [
|
||||
"GITHUB_REF_NAME",
|
Loading…
Reference in a new issue