diff --git a/base.sh b/base.sh index 800b889..330435d 100755 --- a/base.sh +++ b/base.sh @@ -16,6 +16,7 @@ CONTAINER_ID="runner-$CUSTOM_ENV_CI_RUNNER_ID-project-$CUSTOM_ENV_CI_PROJECT_ID-concurrent-$CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID-$CUSTOM_ENV_CI_JOB_ID" ARCH="$(echo $CUSTOM_ENV_CI_RUNNER_EXECUTABLE_ARCH | cut -d'/' -f2)" # linux/amd64 DEFAULT_BRANCH=$(echo $CUSTOM_ENV_CI_DEFAULT_BRANCH | cut -d'-' -f1) # stretch-unstable, buster-unstable... +CURRENT_VERSION=$(echo $CUSTOM_ENV_CI_DEFAULT_BRANCH | cut -d'-' -f2) # stretch-unstable, stretch-testing, stretch-stable... CURRENT_BRANCH="$CUSTOM_ENV_CI_COMMIT_REF_NAME" DEBIAN_VERSION=$(echo $CUSTOM_ENV_CI_COMMIT_REF_NAME | cut -d'-' -f1) # CUSTOM_ENV_CI_COMMIT_REF_NAME is the target branch of the MR: stretch-unstable, buster-unstable... if [ -z "$DEBIAN_VERSION" ] || [ "$DEBIAN_VERSION" != "stretch" ] && [ "$DEBIAN_VERSION" != "buster" ] diff --git a/prepare.sh b/prepare.sh index 95e0afe..5a41c4e 100755 --- a/prepare.sh +++ b/prepare.sh @@ -10,7 +10,7 @@ trap "exit $SYSTEM_FAILURE_EXIT_CODE" ERR clean_containers() { - for image_to_delete in "yunohost-$DEBIAN_VERSION"{,"-tmp"} + for image_to_delete in "yunohost-$DEBIAN_VERSION-"{"stable","testing","unstable"}""{,"-tmp"} do if lxc info $image_to_delete &>/dev/null then @@ -18,7 +18,7 @@ clean_containers() fi done - for image_to_delete in "yunohost-$DEBIAN_VERSION-"{"before-install","before-postinstall","after-postinstall"} + for image_to_delete in "yunohost-$DEBIAN_VERSION-"{"stable","testing","unstable"}"-"{"before-install","before-postinstall","after-postinstall"} do if lxc image info $image_to_delete &>/dev/null then @@ -51,38 +51,38 @@ rebuild_base_container() { clean_containers - lxc launch images:debian/$DEBIAN_VERSION/$ARCH "yunohost-$DEBIAN_VERSION-tmp" - lxc exec "yunohost-$DEBIAN_VERSION-tmp" -- /bin/bash -c "apt-get install curl -y" + lxc launch images:debian/$DEBIAN_VERSION/$ARCH "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" + lxc exec "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" -- /bin/bash -c "apt-get install curl -y" # Install Git LFS, git comes pre installed with ubuntu image. - lxc exec "yunohost-$DEBIAN_VERSION-tmp" -- /bin/bash -c "curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash" - lxc exec "yunohost-$DEBIAN_VERSION-tmp" -- /bin/bash -c "apt-get install git-lfs -y" + lxc exec "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" -- /bin/bash -c "curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash" + lxc exec "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" -- /bin/bash -c "apt-get install git-lfs -y" # Install gitlab-runner binary since we need for cache/artifacts. - lxc exec "yunohost-$DEBIAN_VERSION-tmp" -- /bin/bash -c "curl -s https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | bash" - lxc exec "yunohost-$DEBIAN_VERSION-tmp" -- /bin/bash -c "apt-get install gitlab-runner -y" - lxc stop "yunohost-$DEBIAN_VERSION-tmp" + lxc exec "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" -- /bin/bash -c "curl -s https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | bash" + lxc exec "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" -- /bin/bash -c "apt-get install gitlab-runner -y" + lxc stop "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" # Create image before install - lxc publish "yunohost-$DEBIAN_VERSION-tmp" --alias "yunohost-$DEBIAN_VERSION-before-install" - lxc start "yunohost-$DEBIAN_VERSION-tmp" - wait_container "yunohost-$DEBIAN_VERSION-tmp" + lxc publish "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" --alias "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-before-install" + lxc start "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" + wait_container "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" # Install yunohost - lxc exec "yunohost-$DEBIAN_VERSION-tmp" -- /bin/bash -c "curl https://install.yunohost.org | bash -s -- -a -d unstable" - lxc stop "yunohost-$DEBIAN_VERSION-tmp" + lxc exec "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" -- /bin/bash -c "curl https://install.yunohost.org | bash -s -- -a -d $CURRENT_VERSION" + lxc stop "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" # Create image before postinstall - lxc publish "yunohost-$DEBIAN_VERSION-tmp" --alias "yunohost-$DEBIAN_VERSION-before-postinstall" - lxc start "yunohost-$DEBIAN_VERSION-tmp" - wait_container "yunohost-$DEBIAN_VERSION-tmp" + lxc publish "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" --alias "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-before-postinstall" + lxc start "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" + wait_container "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" # Running post Install - lxc exec "yunohost-$DEBIAN_VERSION-tmp" -- /bin/bash -c "yunohost tools postinstall -d domain.tld -p the_password --ignore-dyndns" - lxc stop "yunohost-$DEBIAN_VERSION-tmp" + lxc exec "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" -- /bin/bash -c "yunohost tools postinstall -d domain.tld -p the_password --ignore-dyndns" + lxc stop "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" # Create image after postinstall - lxc publish "yunohost-$DEBIAN_VERSION-tmp" --alias "yunohost-$DEBIAN_VERSION-after-postinstall" + lxc publish "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" --alias "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-after-postinstall" - lxc delete "yunohost-$DEBIAN_VERSION-tmp" + lxc delete "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-tmp" } update_image() { @@ -111,14 +111,14 @@ start_container () { lxc delete -f "$CONTAINER_ID" fi - if ! lxc image info "yunohost-$DEBIAN_VERSION-$SNAPSHOT_NAME" &>/dev/null + if ! lxc image info "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-$SNAPSHOT_NAME" &>/dev/null then rebuild_base_container fi - update_image "yunohost-$DEBIAN_VERSION-$SNAPSHOT_NAME" + update_image "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-$SNAPSHOT_NAME" - lxc launch "yunohost-$DEBIAN_VERSION-$SNAPSHOT_NAME" "$CONTAINER_ID" 2>/dev/null + lxc launch "yunohost-$DEBIAN_VERSION-$CURRENT_VERSION-$SNAPSHOT_NAME" "$CONTAINER_ID" 2>/dev/null mkdir -p ${currentDir}/cache chmod 777 ${currentDir}/cache