Use right debian version, arch, and link necessary projects.

This commit is contained in:
Kay0u 2020-03-19 23:55:07 +01:00
parent e785931656
commit 017b9604c3
No known key found for this signature in database
GPG key ID: 7FF262C033518333
4 changed files with 52 additions and 37 deletions

20
base.sh
View file

@ -1,30 +1,28 @@
#!/usr/bin/env bash
# /opt/lxd-executor/base.sh
#CUSTOM_ENV_CI_BUILD_REF_NAME=stretch-unstable
#CUSTOM_ENV_CI_BUILD_REF_SLUG=stretch-unstable
#CUSTOM_ENV_CI_DEFAULT_BRANCH=stretch-unstable
#CUSTOM_ENV_CI_JOB_NAME=build1
#CUSTOM_ENV_CI_COMMIT_REF_SLUG=stretch-unstable
#CUSTOM_ENV_CI_BUILD_STAGE=pre-postinstall
#CUSTOM_ENV_CI_JOB_STAGE=pre-postinstall
#CUSTOM_ENV_CI_BUILD_REF_NAME=stretch-unstable
#CUSTOM_ENV_CI_BUILD_NAME=build1
#CUSTOM_ENV_CI_PROJECT_TITLE=yunohost
#CUSTOM_ENV_CI_RUNNER_EXECUTABLE_ARCH=linux/amd64
#CUSTOM_ENV_CI_PROJECT_NAMESPACE=yunohost
#CUSTOM_ENV_CI_COMMIT_REF_NAME=stretch-unstable
#CUSTOM_ENV_CI_COMMIT_REF_SLUG=stretch-unstable
#CUSTOM_ENV_CI_PROJECT_NAME=yunohost
#CUSTOM_ENV_CI_PROJECT_DIR=/builds/yunohost/yunohost
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"
DEBIAN_VERSION="$CUSTOM_ENV_DEBIAN_VERSION"
DEBIAN_VERSION=$(echo $CUSTOM_ENV_CI_JOB_IMAGE | cut -d':' -f1)
if [ -z "$DEBIAN_VERSION" ]
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_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" ]
then
DEBIAN_VERSION="stretch"
echo "Use the default branch $DEFAULT_BRANCH"
DEBIAN_VERSION="$DEFAULT_BRANCH"
fi
SNAPSHOT_NAME=$(echo $CUSTOM_ENV_CI_JOB_IMAGE | cut -d':' -f2)
SNAPSHOT_NAME="$CUSTOM_ENV_CI_JOB_IMAGE"
if [ -z "$SNAPSHOT_NAME" ]
then
SNAPSHOT_NAME="after-postinstall"

View file

@ -1,7 +1,5 @@
#!/usr/bin/env bash
# /opt/lxd-executor/cleanup.sh
currentDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source ${currentDir}/base.sh # Get variables from base.

View file

@ -1,7 +1,5 @@
#!/usr/bin/env bash
# /opt/lxd-executor/prepare.sh
currentDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source ${currentDir}/base.sh # Get variables from base.
@ -12,7 +10,7 @@ trap "exit $SYSTEM_FAILURE_EXIT_CODE" ERR
clean_containers()
{
for image_to_delete in "yunohost-$DEBIAN_VERSION" "yunohost-$DEBIAN_VERSION-tmp"
for image_to_delete in "yunohost-$DEBIAN_VERSION"{,"-tmp"}
do
if lxc info $image_to_delete &>/dev/null
then
@ -20,7 +18,7 @@ clean_containers()
fi
done
for image_to_delete in "yunohost-$DEBIAN_VERSION-before-install" "yunohost-$DEBIAN_VERSION-before-postinstall" "yunohost-$DEBIAN_VERSION-after-postinstall"
for image_to_delete in "yunohost-$DEBIAN_VERSION-"{"before-install","before-postinstall","after-postinstall"}
do
if lxc image info $image_to_delete &>/dev/null
then
@ -53,7 +51,7 @@ rebuild_base_container()
{
clean_containers
lxc launch images:debian/$DEBIAN_VERSION/amd64 "yunohost-$DEBIAN_VERSION-tmp"
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"
# 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"

59
run.sh
View file

@ -1,7 +1,5 @@
#!/usr/bin/env bash
# /opt/lxd-executor/run.sh
currentDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source ${currentDir}/base.sh # Get variables from base.
@ -9,11 +7,28 @@ create_sym_link() {
local DEST=$1
local LINK=$2
# Remove current sources if not a symlink
[ -L "$LINK" ] || rm -rf $LINK
lxc exec "$CONTAINER_ID" -- sh -c "[ -L "$LINK" ] || rm -rf $LINK"
# Symlink from Git repository
lxc exec "$CONTAINER_ID" -- sh -c "ln -sfn $DEST $LINK"
}
link_moulinette_from_git() {
moulinette_dir="/tmp/ci_moulinette"
lxc exec "$CONTAINER_ID" -- sh -c "mkdir $moulinette_dir"
lxc exec "$CONTAINER_ID" -- sh -c "git clone https://github.com/YunoHost/moulinette -b $CURRENT_BRANCH $moulinette_dir"
create_sym_link "$moulinette_dir/locales" "/usr/share/moulinette/locale"
create_sym_link "$moulinette_dir/moulinette" "/usr/lib/python2.7/dist-packages/moulinette"
}
link_ssowat_from_git() {
ssowat_dir="/tmp/ci_ssowat"
lxc exec "$CONTAINER_ID" -- sh -c "mkdir $ssowat_dir"
lxc exec "$CONTAINER_ID" -- sh -c "git clone https://github.com/YunoHost/ssowat -b $CURRENT_BRANCH $ssowat_dir"
create_sym_link "$ssowat_dir" "/usr/share/ssowat"
}
case ${2} in
prepare_script)
;;
@ -27,31 +42,37 @@ case ${2} in
case $PROJECT_NAME in
yunohost)
# bin
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/bin/yunohost" "/usr/bin/yunohost"
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/bin/yunohost-api" "/usr/bin/yunohost-api"
create_sym_link "$PROJECT_DIR/bin/yunohost" "/usr/bin/yunohost"
create_sym_link "$PROJECT_DIR/bin/yunohost-api" "/usr/bin/yunohost-api"
# data
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/data/actionsmap/yunohost.yml" "/usr/share/moulinette/actionsmap/yunohost.yml"
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/data/hooks" "/usr/share/yunohost/hooks"
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/data/templates" "/usr/share/yunohost/templates"
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/data/helpers" "/usr/share/yunohost/helpers"
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/data/helpers.d" "/usr/share/yunohost/helpers.d"
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/data/other" "/usr/share/yunohost/yunohost-config/moulinette"
create_sym_link "$PROJECT_DIR/data/actionsmap/yunohost.yml" "/usr/share/moulinette/actionsmap/yunohost.yml"
create_sym_link "$PROJECT_DIR/data/hooks" "/usr/share/yunohost/hooks"
create_sym_link "$PROJECT_DIR/data/templates" "/usr/share/yunohost/templates"
create_sym_link "$PROJECT_DIR/data/helpers" "/usr/share/yunohost/helpers"
create_sym_link "$PROJECT_DIR/data/helpers.d" "/usr/share/yunohost/helpers.d"
create_sym_link "$PROJECT_DIR/data/other" "/usr/share/yunohost/yunohost-config/moulinette"
# debian
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/debian/conf/pam/mkhomedir" "/usr/share/pam-configs/mkhomedir"
create_sym_link "$PROJECT_DIR/debian/conf/pam/mkhomedir" "/usr/share/pam-configs/mkhomedir"
# lib
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/lib/metronome/modules/ldap.lib.lua" "/usr/lib/metronome/modules/ldap.lib.lua"
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/lib/metronome/modules/mod_auth_ldap2.lua" "/usr/lib/metronome/modules/mod_auth_ldap2.lua"
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/lib/metronome/modules/mod_legacyauth.lua" "/usr/lib/metronome/modules/mod_legacyauth.lua"
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/lib/metronome/modules/mod_storage_ldap.lua" "/usr/lib/metronome/modules/mod_storage_ldap.lua"
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/lib/metronome/modules/vcard.lib.lua" "/usr/lib/metronome/modules/vcard.lib.lua"
create_sym_link "$PROJECT_DIR/lib/metronome/modules/ldap.lib.lua" "/usr/lib/metronome/modules/ldap.lib.lua"
create_sym_link "$PROJECT_DIR/lib/metronome/modules/mod_auth_ldap2.lua" "/usr/lib/metronome/modules/mod_auth_ldap2.lua"
create_sym_link "$PROJECT_DIR/lib/metronome/modules/mod_legacyauth.lua" "/usr/lib/metronome/modules/mod_legacyauth.lua"
create_sym_link "$PROJECT_DIR/lib/metronome/modules/mod_storage_ldap.lua" "/usr/lib/metronome/modules/mod_storage_ldap.lua"
create_sym_link "$PROJECT_DIR/lib/metronome/modules/vcard.lib.lua" "/usr/lib/metronome/modules/vcard.lib.lua"
# src
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/src/yunohost" "/usr/lib/moulinette/yunohost"
create_sym_link "$PROJECT_DIR/src/yunohost" "/usr/lib/moulinette/yunohost"
# locales
create_sym_link "$CUSTOM_ENV_CI_PROJECT_DIR/locales" "/usr/lib/moulinette/yunohost/locales"
create_sym_link "$PROJECT_DIR/locales" "/usr/lib/moulinette/yunohost/locales"
# moulinette
link_moulinette_from_git
# ssowat
link_ssowat_from_git
;;
esac
;;