Compare commits
6 commits
88f75d8830
...
1e4ad2125e
Author | SHA1 | Date | |
---|---|---|---|
1e4ad2125e | |||
6aeec40503 | |||
bc5bca4ede | |||
fc5b997288 | |||
f990897cad | |||
3f121920fc |
3 changed files with 740 additions and 720 deletions
3
.editorconfig
Normal file
3
.editorconfig
Normal file
|
@ -0,0 +1,3 @@
|
|||
[*.sh]
|
||||
indent_size = 4
|
||||
indent_style = space
|
121
spcd.sh
121
spcd.sh
|
@ -28,11 +28,12 @@ spcd_main() {
|
|||
spcd_set_https_verification_on
|
||||
spcd_update_packages_catalog
|
||||
spcd_upgrade_packages
|
||||
spcd_install_dos2unix
|
||||
spcd_install_git
|
||||
spcd_install_python
|
||||
spcd_install_python_modules
|
||||
# TODO move to Python
|
||||
spcd_install_packages
|
||||
spcd_install_python_modules
|
||||
spcd_write_python_module
|
||||
spcd_switch_to_python
|
||||
}
|
||||
|
@ -206,10 +207,12 @@ ${SPCD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")"
|
|||
# universal
|
||||
SPCD_DNS_FILE="/etc/resolv.conf"
|
||||
SPCD_PKG_CA="ca-certificates"
|
||||
SPCD_PKG_DOS2UNIX="dos2unix"
|
||||
SPCD_PKG_GIT="git"
|
||||
SPCD_PYTHON_ALIAS="python3"
|
||||
spcd_split
|
||||
spcd_echo "SPCD_DNS_FILE" "SPCD_PKG_CA" "SPCD_PKG_GIT" "SPCD_PYTHON_ALIAS"
|
||||
spcd_echo "SPCD_DNS_FILE" \
|
||||
"SPCD_PKG_CA" "SPCD_PKG_DOS2UNIX" "SPCD_PKG_GIT" "SPCD_PYTHON_ALIAS"
|
||||
# set ca command & root
|
||||
case "${SPCD_OS_ID}" in
|
||||
"${SPCD_OS_ALMA}" | "${SPCD_OS_FEDORA}" | "${SPCD_OS_ROCKY}")
|
||||
|
@ -587,6 +590,11 @@ spcd_upgrade_packages() {
|
|||
${SPCD_PM_UPGRADE} || exit
|
||||
}
|
||||
|
||||
spcd_install_dos2unix() {
|
||||
spcd_step "Install dos2unix"
|
||||
spcd_install_package "${SPCD_PKG_DOS2UNIX}"
|
||||
}
|
||||
|
||||
spcd_install_git() {
|
||||
spcd_step "Install Git"
|
||||
spcd_install_package "${SPCD_PKG_GIT}"
|
||||
|
@ -599,11 +607,55 @@ spcd_install_python() {
|
|||
spcd_ln_python "${SPCD_PYTHON_COMMAND}"
|
||||
}
|
||||
|
||||
spcd_install_python_modules() {
|
||||
spcd_step "Install Python modules"
|
||||
spcd_ipm__root="$(mktemp --directory)" || exit
|
||||
spcd_ipm__target="${SPCD_PYTHON_VENV_PACKAGES}"
|
||||
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_ipm__target}"
|
||||
cp --recursive "${spcd_ipm__path}" "${spcd_ipm__target}" ||
|
||||
exit
|
||||
# check matching of file and variable
|
||||
spcd_ipm__script="${spcd_ipm__root}/${spcd_ipm__name}/spcd.sh"
|
||||
if [ -f "${spcd_ipm__script}" ]; then
|
||||
spcd_split
|
||||
spcd_ipm__check="${spcd_ipm__root}/check.sha512sum"
|
||||
sha512sum "${spcd_ipm__script}" >"${spcd_ipm__check}"
|
||||
printf "%s" "${SPCD}" >"${spcd_ipm__script}"
|
||||
ls -l "${spcd_ipm__script}"
|
||||
dos2unix "${spcd_ipm__script}"
|
||||
ls -l "${spcd_ipm__script}"
|
||||
sha512sum -c "${spcd_ipm__check}" || spcd_error_ci "SPCD"
|
||||
fi
|
||||
done
|
||||
spcd_split
|
||||
spcd_ls "${spcd_ipm__target}"
|
||||
spcd_split
|
||||
spcd_rm "${spcd_ipm__root}"
|
||||
}
|
||||
|
||||
# TODO move to Python
|
||||
spcd_install_packages() {
|
||||
# dos2unix
|
||||
spcd_step "Install dos2unix"
|
||||
spcd_install_package "dos2unix"
|
||||
# epel
|
||||
spcd_step "Install EPEL"
|
||||
case "${SPCD_OS_ID}" in
|
||||
|
@ -672,63 +724,8 @@ index-url = ${SPCD_URL_PYTHON}
|
|||
spcd_split
|
||||
"${SPCD_PYTHON_ALIAS}" -m "venv" "${SPCD_PYTHON_VENV}"
|
||||
spcd_split
|
||||
. "${SPCD_PYTHON_VENV}/bin/activate"
|
||||
spcd_split
|
||||
pip install --upgrade "pip"
|
||||
spcd_split
|
||||
pip install \
|
||||
"mypy" \
|
||||
"pelican" \
|
||||
"pytest" \
|
||||
"ruff" \
|
||||
"sphinx" "sphinx-rtd-theme"
|
||||
}
|
||||
|
||||
spcd_install_python_modules() {
|
||||
spcd_step "Install Python modules"
|
||||
spcd_ipm__root="$(mktemp --directory)" || exit
|
||||
spcd_ipm__target="${SPCD_PYTHON_VENV_PACKAGES}"
|
||||
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_ipm__target}"
|
||||
cp --recursive "${spcd_ipm__path}" "${spcd_ipm__target}" ||
|
||||
exit
|
||||
# check matching of file and variable
|
||||
spcd_ipm__script="${spcd_ipm__root}/${spcd_ipm__name}/spcd.sh"
|
||||
if [ -f "${spcd_ipm__script}" ]; then
|
||||
spcd_split
|
||||
spcd_ipm__check="${spcd_ipm__root}/check.sha512sum"
|
||||
sha512sum "${spcd_ipm__script}" >"${spcd_ipm__check}"
|
||||
printf "%s" "${SPCD}" >"${spcd_ipm__script}"
|
||||
ls -l "${spcd_ipm__script}"
|
||||
dos2unix "${spcd_ipm__script}"
|
||||
ls -l "${spcd_ipm__script}"
|
||||
sha512sum -c "${spcd_ipm__check}" || spcd_error_ci "SPCD"
|
||||
fi
|
||||
done
|
||||
spcd_split
|
||||
spcd_ls "${spcd_ipm__target}"
|
||||
spcd_split
|
||||
spcd_rm "${spcd_ipm__root}"
|
||||
export PATH="${SPCD_PYTHON_VENV_BINARIES}:${PATH}"
|
||||
export VIRTUAL_ENV="${SPCD_PYTHON_VENV}"
|
||||
}
|
||||
|
||||
spcd_write_python_module() {
|
||||
|
|
|
@ -53,6 +53,25 @@ def install_commands(path: str) -> None:
|
|||
(user / f"{COMMANDS_PREFIX}{command}").symlink_to(path)
|
||||
|
||||
|
||||
def install_python_packages() -> None:
|
||||
step("Install Python packages")
|
||||
log.info("pip")
|
||||
run("pip", "install", "--upgrade", "pip")
|
||||
split()
|
||||
packages = [
|
||||
"mypy",
|
||||
"pelican",
|
||||
"pytest",
|
||||
"ruff",
|
||||
"sphinx",
|
||||
"sphinx-rtd-theme",
|
||||
"twine",
|
||||
]
|
||||
for package in packages:
|
||||
log.info(package)
|
||||
run("pip", "install", *packages)
|
||||
|
||||
|
||||
def list_environment_variables() -> None:
|
||||
step("List environment variables")
|
||||
for variable, value in sorted(projects.environment.items()):
|
||||
|
@ -73,6 +92,7 @@ def main(main: str) -> None:
|
|||
clone_project_branch()
|
||||
set_ssh()
|
||||
install_commands(main)
|
||||
install_python_packages()
|
||||
else:
|
||||
function = getattr(cmd, name.replace("-", "_"))
|
||||
function(*arguments)
|
||||
|
|
Loading…
Reference in a new issue