From f2e530efc5ebff2a0592d44cd01bccab198c920c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 26 Apr 2024 20:09:11 +0200 Subject: [PATCH] repositories --- cd.sh | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/cd.sh b/cd.sh index 06e975e..a640fe2 100644 --- a/cd.sh +++ b/cd.sh @@ -3,8 +3,9 @@ CD_DNS_SERVERS=( '9.9.9.9' ) +CD_REPOSITORIES_GROUP='rwx.work' +CD_REPOSITORIES_PARENT='rwx' CD_REPOSITORY_NAME='cd' -CD_REPOSITORY_PATH='rwx.work' CD_DNS_FILE='/etc/resolv.conf' case "${CD_OS_NAME}" in @@ -24,12 +25,12 @@ case "${CD_OS_NAME}" in exit 1 ;; esac -[ "${CI_SERVER_URL}" ] && CD_REPOSITORY_URL="${CI_SERVER_URL}" -[ "${GITHUB_SERVER_URL}" ] && CD_REPOSITORY_URL="${GITHUB_SERVER_URL}" -if [ "${CD_REPOSITORY_URL}" ] ; then - CD_REPOSITORY_URL+="/${CD_REPOSITORY_PATH}/${CD_REPOSITORY_NAME}" +[ "${CI_SERVER_URL}" ] && CD_REPOSITORIES_URL="${CI_SERVER_URL}" +[ "${GITHUB_SERVER_URL}" ] && CD_REPOSITORIES_URL="${GITHUB_SERVER_URL}" +if [ "${CD_REPOSITORIES_URL}" ] ; then + CD_REPOSITORIES_URL+="/${CD_REPOSITORIES_GROUP}" else - echo '_REPOSITORY_URL' + echo 'CD_REPOSITORIES_URL' exit 3 fi CD_STEP=0 @@ -182,11 +183,24 @@ function cd_clean_packages_cache { } function cd_install { -local directory +local repository +local root +local target cd_step "${FUNCNAME}" - directory="$(mktemp --directory)" || exit - git clone "${CD_REPOSITORY_URL}" "${directory}" || exit - # TODO copy + case "${CD_OS_NAME}" in + 'debian') target='/usr/lib/python3/dist-packages' || exit ;; + *) exit 1 ;; + esac + root="$(mktemp --directory)" || exit + for repository in \ + "${CD_REPOSITORIES_PARENT}" \ + "${CD_REPOSITORY_NAME}" \ + ; do + git clone \ + "${CD_REPOSITORIES_URL}/${repository}" "{root}/${repository}" || exit + cp --recursive --verbose "${root}/${repository}" "${target}" + # TODO commands + done } function cd_bootstrap {