mirror of
https://github.com/YunoHost/yunohost-ci.git
synced 2024-09-03 20:05:53 +02:00
commit
4676dca075
8 changed files with 157 additions and 147 deletions
|
@ -9,9 +9,16 @@ do
|
||||||
do
|
do
|
||||||
for snapshot in "before-install" "after-install"
|
for snapshot in "before-install" "after-install"
|
||||||
do
|
do
|
||||||
update_image $debian_version $ynh_version $snapshot
|
info "Updating container $PREFIX_IMAGE_NAME-$debian_version $ynh_version $snapshot"
|
||||||
|
update_container "$PREFIX_IMAGE_NAME-$debian_version" "$debian_version" "$ynh_version" "$snapshot"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
containers_to_remove=$(lxc list $PREFIX_IMAGE_NAME-$debian_version-r -c n -f csv)
|
||||||
|
if [ -n "$containers_to_remove" ]
|
||||||
|
then
|
||||||
|
# Remove old runner containers
|
||||||
|
lxc delete -f $(echo $containers_to_remove)
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
for debian_version in "bookworm"
|
for debian_version in "bookworm"
|
||||||
|
@ -20,7 +27,14 @@ do
|
||||||
do
|
do
|
||||||
for snapshot in "before-install" "after-install"
|
for snapshot in "before-install" "after-install"
|
||||||
do
|
do
|
||||||
update_image $debian_version $ynh_version $snapshot
|
info "Updating container $PREFIX_IMAGE_NAME-$debian_version $ynh_version $snapshot"
|
||||||
|
update_container "$PREFIX_IMAGE_NAME-$debian_version" "$debian_version" "$ynh_version" "$snapshot"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
containers_to_remove=$(lxc list $PREFIX_IMAGE_NAME-$debian_version-r -c n -f csv)
|
||||||
|
if [ -n "$containers_to_remove" ]
|
||||||
|
then
|
||||||
|
# Remove old runner containers
|
||||||
|
lxc delete -f $(echo $containers_to_remove)
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
2
ci_cron
2
ci_cron
|
@ -1,2 +1,2 @@
|
||||||
# Upgrade all continers
|
# Upgrade all continers
|
||||||
30 2 * * * root /bin/bash -c "/opt/yunohost-ci/auto_upgrade_container.sh >> /opt/yunohost-ci/upgrade.log 2>>/opt/yunohost-ci/upgrade-error.log"
|
30 2 * * * root PATH=/snap/bin/:$PATH /bin/bash -c "/opt/yunohost-ci/auto_upgrade_container.sh >> /opt/yunohost-ci/upgrade.log 2>>/opt/yunohost-ci/upgrade-error.log"
|
|
@ -4,6 +4,6 @@ current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
source $current_dir/prints.sh
|
source $current_dir/prints.sh
|
||||||
source $current_dir/variables.sh # Get variables from variables.
|
source $current_dir/variables.sh # Get variables from variables.
|
||||||
|
|
||||||
info "Deleting container $CONTAINER_ID"
|
info "Stopping container $CONTAINER_IMAGE"
|
||||||
|
|
||||||
lxc delete -f "$CONTAINER_ID"
|
lxc stop "$CONTAINER_IMAGE"
|
40
prepare.sh
40
prepare.sh
|
@ -10,32 +10,36 @@ set -eo pipefail
|
||||||
trap "exit $SYSTEM_FAILURE_EXIT_CODE" ERR
|
trap "exit $SYSTEM_FAILURE_EXIT_CODE" ERR
|
||||||
|
|
||||||
start_container () {
|
start_container () {
|
||||||
if lxc info "$CONTAINER_ID" >/dev/null 2>/dev/null ; then
|
if ! lxc info "$CONTAINER_IMAGE" >/dev/null 2>/dev/null ; then
|
||||||
warn 'Found old container, deleting'
|
warn 'Container not found, copying it from the prebuilt image'
|
||||||
lxc delete -f "$CONTAINER_ID"
|
if ! lxc info "$BASE_IMAGE" | grep -w "$CURRENT_VERSION-$SNAPSHOT_NAME" >/dev/null
|
||||||
|
then
|
||||||
|
error "$BASE_IMAGE not found, please rebuild with rebuild_all.sh"
|
||||||
|
# Inform GitLab Runner that this is a system failure, so it
|
||||||
|
# should be retried.
|
||||||
|
exit $SYSTEM_FAILURE_EXIT_CODE
|
||||||
|
fi
|
||||||
|
lxc copy "$BASE_IMAGE" "$CONTAINER_IMAGE"
|
||||||
|
fi
|
||||||
|
# Stop the container if it's running
|
||||||
|
if [ "$(lxc info $CONTAINER_IMAGE | grep Status | awk '{print tolower($2)}')" == "running" ]; then
|
||||||
|
lxc stop $CONTAINER_IMAGE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! lxc image info "$BASE_IMAGE-$SNAPSHOT_NAME" &>/dev/null
|
info "Debian version: $DEBIAN_VERSION, YunoHost version: $CURRENT_VERSION, Image used: $BASE_IMAGE, Snapshot: $SNAPSHOT_NAME"
|
||||||
then
|
|
||||||
error "$BASE_IMAGE-$SNAPSHOT_NAME not found, please rebuild with rebuild_all.sh"
|
|
||||||
# Inform GitLab Runner that this is a system failure, so it
|
|
||||||
# should be retried.
|
|
||||||
exit $SYSTEM_FAILURE_EXIT_CODE
|
|
||||||
fi
|
|
||||||
|
|
||||||
info "Debian version: $DEBIAN_VERSION, YunoHost version: $CURRENT_VERSION, Image used: $BASE_IMAGE-$SNAPSHOT_NAME"
|
restore_snapshot "$CONTAINER_IMAGE" "$CURRENT_VERSION" "$SNAPSHOT_NAME"
|
||||||
|
|
||||||
lxc launch "$BASE_IMAGE-$SNAPSHOT_NAME" "$CONTAINER_ID" -c security.nesting=true 2>/dev/null
|
# Unset the mac address to ensure the copy will get a new one and will be able to get new IP
|
||||||
|
lxc config unset "$CONTAINER_IMAGE" volatile.eth0.hwaddr 2> /dev/null
|
||||||
|
|
||||||
mkdir -p $current_dir/cache
|
lxc start $CONTAINER_IMAGE
|
||||||
chmod 777 $current_dir/cache
|
|
||||||
lxc config device add "$CONTAINER_ID" cache-folder disk path=/cache source="$current_dir/cache"
|
|
||||||
|
|
||||||
wait_container $CONTAINER_ID
|
wait_container $CONTAINER_IMAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
info "Starting $CONTAINER_ID"
|
info "Starting $CONTAINER_IMAGE"
|
||||||
|
|
||||||
start_container
|
start_container
|
||||||
|
|
||||||
info "$CONTAINER_ID started properly"
|
info "$CONTAINER_IMAGE started properly"
|
||||||
|
|
|
@ -5,13 +5,13 @@ source $current_dir/utils.sh # Get utils functions.
|
||||||
|
|
||||||
for debian_version in "bullseye"
|
for debian_version in "bullseye"
|
||||||
do
|
do
|
||||||
rebuild_base_containers $debian_version "stable" "amd64"
|
rebuild_base_containers "$PREFIX_IMAGE_NAME-$debian_version" "$debian_version" "stable" "amd64"
|
||||||
|
|
||||||
for ynh_version in "testing" "unstable"
|
for ynh_version in "testing" "unstable"
|
||||||
do
|
do
|
||||||
for snapshot in "before-install" "after-install"
|
for snapshot in "before-install" "after-install"
|
||||||
do
|
do
|
||||||
lxc launch "yunohost-$debian_version-stable-$snapshot" "yunohost-$debian_version-$ynh_version-$snapshot-tmp"
|
restore_snapshot "$PREFIX_IMAGE_NAME-$debian_version" "stable" "$snapshot"
|
||||||
|
|
||||||
if [[ "$ynh_version" == "testing" ]]
|
if [[ "$ynh_version" == "testing" ]]
|
||||||
then
|
then
|
||||||
|
@ -21,16 +21,14 @@ do
|
||||||
repo_version="testing unstable"
|
repo_version="testing unstable"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
lxc exec "yunohost-$debian_version-$ynh_version-$snapshot-tmp" -- /bin/bash -c "for FILE in \`ls /etc/apt/sources.list /etc/apt/sources.list.d/*\`;
|
lxc exec "$PREFIX_IMAGE_NAME-$debian_version" -- /bin/bash -c "for FILE in \`ls /etc/apt/sources.list /etc/apt/sources.list.d/*\`;
|
||||||
do
|
do
|
||||||
sed -i 's@^deb http://forge.yunohost.org.*@& $repo_version@' \$FILE
|
sed -i 's@^deb http://forge.yunohost.org.*@& $repo_version@' \$FILE
|
||||||
done"
|
done"
|
||||||
|
|
||||||
rotate_image "yunohost-$debian_version-$ynh_version-$snapshot-tmp" "yunohost-$debian_version-$ynh_version-$snapshot"
|
create_snapshot "$PREFIX_IMAGE_NAME-$debian_version" "$ynh_version" "$snapshot"
|
||||||
|
|
||||||
lxc delete -f "yunohost-$debian_version-$ynh_version-$snapshot-tmp"
|
update_container "$PREFIX_IMAGE_NAME-$debian_version" "$debian_version" "$ynh_version" "$snapshot"
|
||||||
|
|
||||||
update_image $debian_version $ynh_version $snapshot
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
@ -38,6 +36,6 @@ done
|
||||||
|
|
||||||
for debian_version in "bookworm"
|
for debian_version in "bookworm"
|
||||||
do
|
do
|
||||||
rebuild_base_containers $debian_version "unstable" "amd64"
|
rebuild_base_containers "$PREFIX_IMAGE_NAME-$debian_version" "$debian_version" "unstable" "amd64"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
2
run.sh
2
run.sh
|
@ -36,7 +36,7 @@ case ${2} in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
lxc exec "$CONTAINER_ID" /bin/bash < "${1}"
|
lxc exec "$CONTAINER_IMAGE" /bin/bash < "${1}"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
# Exit using the variable, to make the build as failure in GitLab
|
# Exit using the variable, to make the build as failure in GitLab
|
||||||
# CI.
|
# CI.
|
||||||
|
|
211
utils.sh
211
utils.sh
|
@ -4,27 +4,6 @@ current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
source $current_dir/prints.sh
|
source $current_dir/prints.sh
|
||||||
source $current_dir/variables.sh # Get variables from variables.
|
source $current_dir/variables.sh # Get variables from variables.
|
||||||
|
|
||||||
clean_containers()
|
|
||||||
{
|
|
||||||
local base_image_to_clean=$1
|
|
||||||
|
|
||||||
for image_to_delete in "$base_image_to_clean"{,"-tmp"}
|
|
||||||
do
|
|
||||||
if lxc info $image_to_delete &>/dev/null
|
|
||||||
then
|
|
||||||
lxc delete $image_to_delete --force
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
for image_to_delete in "$base_image_to_clean-"{"before-install","after-install"}
|
|
||||||
do
|
|
||||||
if lxc image info $image_to_delete &>/dev/null
|
|
||||||
then
|
|
||||||
lxc image delete $image_to_delete
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
wait_container()
|
wait_container()
|
||||||
{
|
{
|
||||||
restart_container()
|
restart_container()
|
||||||
|
@ -67,6 +46,11 @@ wait_container()
|
||||||
if [ "$j" == "10" ]; then
|
if [ "$j" == "10" ]; then
|
||||||
error 'Failed to access the internet'
|
error 'Failed to access the internet'
|
||||||
failstart=1
|
failstart=1
|
||||||
|
lxc exec "$1" -- /bin/bash -c "echo 'resolv-file=/etc/resolv.dnsmasq.conf' > /etc/dnsmasq.d/resolvconf"
|
||||||
|
lxc exec "$1" -- /bin/bash -c "echo 'nameserver 8.8.8.8' > /etc/resolv.dnsmasq.conf"
|
||||||
|
lxc exec "$1" -- /bin/bash -c "sed -i 's/#IGNORE/IGNORE/g' /etc/default/dnsmasq"
|
||||||
|
lxc exec "$1" -- /bin/bash -c "systemctl restart dnsmasq"
|
||||||
|
lxc exec "$1" -- /bin/bash -c "journalctl -u dnsmasq -n 100 --no-pager"
|
||||||
|
|
||||||
restart_container "$1"
|
restart_container "$1"
|
||||||
fi
|
fi
|
||||||
|
@ -108,158 +92,161 @@ wait_container()
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
rotate_image()
|
create_snapshot()
|
||||||
{
|
{
|
||||||
local instance_to_publish=$1
|
local instance_to_publish=$1
|
||||||
local alias_image=$2
|
local ynh_version=$2
|
||||||
|
local snapshot=$3
|
||||||
|
|
||||||
# Save the finger print to delete the old image later
|
# Create snapshot
|
||||||
local finger_print_to_delete=$(lxc image info "$alias_image" | grep Fingerprint | awk '{print $2}')
|
lxc snapshot "$instance_to_publish" "$ynh_version-$snapshot" --reuse
|
||||||
local should_restart=0
|
}
|
||||||
|
|
||||||
# If the container is running, stop it
|
restore_snapshot()
|
||||||
if [ "$(lxc info $instance_to_publish | grep Status | awk '{print tolower($2)}')" = "running" ]
|
{
|
||||||
then
|
local instance_to_publish=$1
|
||||||
should_restart=1
|
local ynh_version=$2
|
||||||
lxc stop "$instance_to_publish"
|
local snapshot=$3
|
||||||
fi
|
|
||||||
|
|
||||||
# Create image before install
|
lxc restore "$instance_to_publish" "$ynh_version-$snapshot"
|
||||||
lxc publish "$instance_to_publish" --alias "$alias_image"
|
|
||||||
# Remove old image
|
|
||||||
lxc image delete "$finger_print_to_delete"
|
|
||||||
|
|
||||||
if [ $should_restart = 1 ]
|
|
||||||
then
|
|
||||||
lxc start "$instance_to_publish"
|
|
||||||
wait_container "$instance_to_publish"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# These lines are used to extract the dependencies/recommendations from the debian/control file.
|
# These lines are used to extract the dependencies/recommendations from the debian/control file.
|
||||||
# /!\ There's a high risk of lamentable failure if we change the format of this file
|
# /!\ There's a high risk of lamentable failure if we change the format of this file
|
||||||
get_dependencies()
|
get_dependencies()
|
||||||
{
|
{
|
||||||
local debian_version=$1
|
local debian_version=$1
|
||||||
if [[ "$debian_version" == "bullseye" ]]
|
if [[ "$debian_version" == "bullseye" ]]
|
||||||
then
|
then
|
||||||
local branch="dev"
|
local branch="dev"
|
||||||
else
|
else
|
||||||
local branch="$debian_version"
|
local branch="$debian_version"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# To extract the dependencies, we want to retrieve the lines between "^Dependencies:" and the new line that doesn't start with a space (exclusively) . Then, we remove ",", then we remove the version specifiers "(>= X.Y)", then we add simple quotes to packages when there is a pipe (or) 'php-mysql|php-mysqlnd'.
|
# To extract the dependencies, we want to retrieve the lines between "^Dependencies:" and the new line that doesn't start with a space (exclusively) . Then, we remove ",", then we remove the version specifiers "(>= X.Y)", then we add simple quotes to packages when there is a pipe (or) 'php-mysql|php-mysqlnd'.
|
||||||
YUNOHOST_DEPENDENCIES=$(curl https://raw.githubusercontent.com/YunoHost/yunohost/$branch/debian/control 2> /dev/null | sed -n '/^Depends:/,/^\w/{//!p}' | sed -e "s/,//g" -e "s/[(][^)]*[)]//g" -e "s/ | \S\+//g" | grep -v moulinette | grep -v ssowat | tr "\n" " ")
|
YUNOHOST_DEPENDENCIES=$(curl https://raw.githubusercontent.com/YunoHost/yunohost/$branch/debian/control 2> /dev/null | sed -n '/^Depends:/,/^\w/{//!p}' | sed -e "s/,//g" -e "s/[(][^)]*[)]//g" -e "s/ | \S\+//g" | grep -v moulinette | grep -v ssowat | tr "\n" " ")
|
||||||
YUNOHOST_RECOMMENDS=$(curl https://raw.githubusercontent.com/YunoHost/yunohost/$branch/debian/control 2> /dev/null | sed -n '/^Recommends:/,/^\w/{//!p}' | sed -e "s/,//g" -e "s/[(][^)]*[)]//g" -e "s/ | \S\+//g" | tr "\n" " ")
|
YUNOHOST_RECOMMENDS=$(curl https://raw.githubusercontent.com/YunoHost/yunohost/$branch/debian/control 2> /dev/null | sed -n '/^Recommends:/,/^\w/{//!p}' | sed -e "s/,//g" -e "s/[(][^)]*[)]//g" -e "s/ | \S\+//g" | tr "\n" " ")
|
||||||
MOULINETTE_DEPENDENCIES=$(curl https://raw.githubusercontent.com/YunoHost/moulinette/$branch/debian/control 2> /dev/null | sed -n '/^Depends:/,/^\w/{//!p}' | sed -e "s/,//g" -e "s/[(][^)]*[)]//g" -e "s/ | \S\+//g" | tr "\n" " ")
|
MOULINETTE_DEPENDENCIES=$(curl https://raw.githubusercontent.com/YunoHost/moulinette/$branch/debian/control 2> /dev/null | sed -n '/^Depends:/,/^\w/{//!p}' | sed -e "s/,//g" -e "s/[(][^)]*[)]//g" -e "s/ | \S\+//g" | tr "\n" " ")
|
||||||
# Same as above, except that all dependencies are in the same line
|
# Same as above, except that all dependencies are in the same line
|
||||||
SSOWAT_DEPENDENCIES=$(curl https://raw.githubusercontent.com/YunoHost/ssowat/$branch/debian/control 2> /dev/null | grep '^Depends:' | sed 's/Depends://' | sed -e "s/,//g" -e "s/[(][^)]*[)]//g" -e "s/ | \S\+//g" | tr "\n" " ")
|
SSOWAT_DEPENDENCIES=$(curl https://raw.githubusercontent.com/YunoHost/ssowat/$branch/debian/control 2> /dev/null | grep '^Depends:' | sed 's/Depends://' | sed -e "s/,//g" -e "s/[(][^)]*[)]//g" -e "s/ | \S\+//g" | tr "\n" " ")
|
||||||
BUILD_DEPENDENCIES="git-buildpackage postfix python3-setuptools python3-pip devscripts"
|
BUILD_DEPENDENCIES="git-buildpackage postfix python3-setuptools python3-pip devscripts"
|
||||||
PIP3_PKG='mock pip pyOpenSSL pytest pytest-cov pytest-mock pytest-sugar requests-mock tox ansi2html black jinja2 types-ipaddress types-enum34 types-cryptography types-toml types-requests types-PyYAML types-pyOpenSSL types-mock "packaging<22"'
|
TESTS_DEPENDENCIES="git hub"
|
||||||
if [[ "$debian_version" == "bookworm" ]]
|
PIP3_PKG='mock pip pyOpenSSL pytest pytest-cov pytest-mock pytest-sugar requests-mock tox ansi2html black jinja2 types-ipaddress types-enum34 types-cryptography types-toml types-requests types-PyYAML types-pyOpenSSL types-mock "packaging<22"'
|
||||||
then
|
|
||||||
PIP3_PKG="$PIP3_PKG --break-system-packages"
|
if [[ "$debian_version" == "bookworm" ]]
|
||||||
fi
|
then
|
||||||
|
# We add php8.2-cli, mariadb-client and mariadb-server to the dependencies for test_app_resources
|
||||||
|
TESTS_DEPENDENCIES="$TESTS_DEPENDENCIES php8.2-cli mariadb-client mariadb-server"
|
||||||
|
PIP3_PKG="$PIP3_PKG --break-system-packages"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
rebuild_base_containers()
|
rebuild_base_containers()
|
||||||
{
|
{
|
||||||
local debian_version=$1
|
local image_to_rebuild=$1
|
||||||
local ynh_version=$2
|
local debian_version=$2
|
||||||
local arch=$3
|
local ynh_version=$3
|
||||||
local base_image_to_rebuild="yunohost-$debian_version-$ynh_version"
|
local arch=$4
|
||||||
|
|
||||||
lxc launch images:debian/$debian_version/$arch "$base_image_to_rebuild-tmp" -c security.nesting=true
|
if lxc info "$image_to_rebuild" &>/dev/null
|
||||||
|
then
|
||||||
|
lxc delete -f "$image_to_rebuild"
|
||||||
|
fi
|
||||||
|
|
||||||
wait_container "$base_image_to_rebuild-tmp"
|
lxc launch images:debian/$debian_version/$arch "$image_to_rebuild" -c security.nesting=true
|
||||||
|
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "apt-get update"
|
wait_container "$image_to_rebuild"
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "apt-get install --assume-yes wget curl"
|
|
||||||
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "apt-get update"
|
||||||
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "apt-get install --assume-yes wget curl"
|
||||||
# Install Git LFS, git comes pre installed with ubuntu image.
|
# Install Git LFS, git comes pre installed with ubuntu image.
|
||||||
# Disable this line because we don't need to add a new repo to have git-lfs
|
# Disable this line because we don't need to add a new repo to have git-lfs
|
||||||
#lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash"
|
#lxc exec "$image_to_rebuild" -- /bin/bash -c "curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | bash"
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "apt-get install --assume-yes git-lfs"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "apt-get install --assume-yes git-lfs"
|
||||||
# Install gitlab-runner binary since we need for cache/artifacts.
|
# Install gitlab-runner binary since we need for cache/artifacts.
|
||||||
if [[ $debian_version == "bullseye" ]]
|
if [[ $debian_version == "bullseye" ]]
|
||||||
then
|
then
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "wget https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_amd64.deb"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "wget https://gitlab-runner-downloads.s3.amazonaws.com/latest/deb/gitlab-runner_amd64.deb"
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "dpkg -i gitlab-runner_amd64.deb"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "dpkg -i gitlab-runner_amd64.deb"
|
||||||
else
|
else
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "curl -s https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | os=debian dist=$debian_version bash"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "curl -s https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | os=debian dist=$debian_version bash"
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "apt-get install --assume-yes gitlab-runner"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "apt-get install --assume-yes gitlab-runner"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
INSTALL_SCRIPT="https://raw.githubusercontent.com/YunoHost/install_script/main/$debian_version"
|
INSTALL_SCRIPT="https://raw.githubusercontent.com/YunoHost/install_script/main/$debian_version"
|
||||||
|
|
||||||
# Download the YunoHost install script
|
# Download the YunoHost install script
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "curl $INSTALL_SCRIPT > install.sh"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "curl $INSTALL_SCRIPT > install.sh"
|
||||||
|
|
||||||
# Patch the YunoHost install script
|
# Patch the YunoHost install script
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "sed -i -E 's/(step\s+install_yunohost_packages)/#\1/' install.sh"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "sed -i -E 's/(step\s+install_yunohost_packages)/#\1/' install.sh"
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "sed -i -E 's/(step\s+restart_services)/#\1/' install.sh"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "sed -i -E 's/(step\s+restart_services)/#\1/' install.sh"
|
||||||
|
|
||||||
# Run the YunoHost install script patched
|
# Run the YunoHost install script patched
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "cat install.sh | bash -s -- -a -d $ynh_version"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "cat install.sh | bash -s -- -a -d $ynh_version"
|
||||||
|
|
||||||
get_dependencies $debian_version
|
get_dependencies $debian_version
|
||||||
|
|
||||||
# Pre install dependencies
|
# Pre install dependencies
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "DEBIAN_FRONTEND=noninteractive SUDO_FORCE_REMOVE=yes apt-get --assume-yes install --assume-yes $YUNOHOST_DEPENDENCIES $YUNOHOST_RECOMMENDS $MOULINETTE_DEPENDENCIES $SSOWAT_DEPENDENCIES $BUILD_DEPENDENCIES"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "DEBIAN_FRONTEND=noninteractive SUDO_FORCE_REMOVE=yes apt-get --assume-yes install --assume-yes $YUNOHOST_DEPENDENCIES $YUNOHOST_RECOMMENDS $MOULINETTE_DEPENDENCIES $SSOWAT_DEPENDENCIES $BUILD_DEPENDENCIES $TESTS_DEPENDENCIES"
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "python3 -m pip install -U $PIP3_PKG"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "python3 -m pip install -U $PIP3_PKG"
|
||||||
|
|
||||||
# Disable apt-daily
|
# Disable apt-daily
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "systemctl -q stop apt-daily.timer"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q stop apt-daily.timer"
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "systemctl -q stop apt-daily-upgrade.timer"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q stop apt-daily-upgrade.timer"
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "systemctl -q stop apt-daily.service"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q stop apt-daily.service"
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "systemctl -q stop apt-daily-upgrade.service"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q stop apt-daily-upgrade.service"
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "systemctl -q disable apt-daily.timer"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q disable apt-daily.timer"
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "systemctl -q disable apt-daily-upgrade.timer"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q disable apt-daily-upgrade.timer"
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "systemctl -q disable apt-daily.service"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q disable apt-daily.service"
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "systemctl -q disable apt-daily-upgrade.service"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "systemctl -q disable apt-daily-upgrade.service"
|
||||||
|
|
||||||
rotate_image "$base_image_to_rebuild-tmp" "$base_image_to_rebuild-before-install"
|
|
||||||
|
mkdir -p $current_dir/cache
|
||||||
|
chmod 777 $current_dir/cache
|
||||||
|
lxc config device add "$image_to_rebuild" cache-folder disk path=/cache source="$current_dir/cache"
|
||||||
|
|
||||||
|
create_snapshot "$image_to_rebuild" "$ynh_version" "before-install"
|
||||||
|
|
||||||
# Install YunoHost
|
# Install YunoHost
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "curl $INSTALL_SCRIPT | bash -s -- -a -d $ynh_version"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "curl $INSTALL_SCRIPT | bash -s -- -a -d $ynh_version"
|
||||||
|
|
||||||
# Run postinstall
|
# Run postinstall
|
||||||
lxc exec "$base_image_to_rebuild-tmp" -- /bin/bash -c "yunohost tools postinstall -d domain.tld -u syssa -F 'Syssa Mine' -p the_password --ignore-dyndns --force-diskspace"
|
lxc exec "$image_to_rebuild" -- /bin/bash -c "yunohost tools postinstall -d domain.tld -u syssa -F 'Syssa Mine' -p the_password --ignore-dyndns --force-diskspace"
|
||||||
|
|
||||||
rotate_image "$base_image_to_rebuild-tmp" "$base_image_to_rebuild-after-install"
|
create_snapshot "$image_to_rebuild" "$ynh_version" "after-install"
|
||||||
|
|
||||||
lxc stop "$base_image_to_rebuild-tmp"
|
lxc stop "$image_to_rebuild"
|
||||||
|
|
||||||
lxc delete "$base_image_to_rebuild-tmp"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update_image() {
|
update_container() {
|
||||||
local debian_version=$1
|
local image_to_update=$1
|
||||||
local ynh_version=$2
|
local debian_version=$2
|
||||||
local snapshot=$3
|
local ynh_version=$3
|
||||||
local image_to_update="yunohost-$debian_version-$ynh_version-$snapshot"
|
local snapshot=$4
|
||||||
|
|
||||||
if ! lxc image info "$image_to_update" &>/dev/null
|
if ! lxc info "$image_to_update" &>/dev/null
|
||||||
then
|
then
|
||||||
error "Unable to upgrade image $image_to_update"
|
error "Unable to upgrade image $image_to_update"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start and run upgrade
|
# Start and run upgrade
|
||||||
lxc launch "$image_to_update" "$image_to_update-tmp" -c security.nesting=true
|
restore_snapshot "$image_to_update" "$ynh_version" "$snapshot"
|
||||||
|
|
||||||
wait_container "$image_to_update-tmp"
|
lxc start "$image_to_update" 2>&1 || true
|
||||||
|
|
||||||
lxc exec "$image_to_update-tmp" -- /bin/bash -c "apt-get update"
|
wait_container "$image_to_update"
|
||||||
lxc exec "$image_to_update-tmp" -- /bin/bash -c "apt-get upgrade --assume-yes"
|
|
||||||
|
lxc exec "$image_to_update" -- /bin/bash -c "apt-get update"
|
||||||
|
lxc exec "$image_to_update" -- /bin/bash -c "apt-get upgrade --assume-yes"
|
||||||
|
|
||||||
get_dependencies $debian_version
|
get_dependencies $debian_version
|
||||||
|
|
||||||
lxc exec "$image_to_update-tmp" -- /bin/bash -c "DEBIAN_FRONTEND=noninteractive SUDO_FORCE_REMOVE=yes apt-get --assume-yes -o Dpkg::Options::=\"--force-confold\" install --assume-yes $YUNOHOST_DEPENDENCIES $YUNOHOST_RECOMMENDS $MOULINETTE_DEPENDENCIES $SSOWAT_DEPENDENCIES $BUILD_DEPENDENCIES"
|
lxc exec "$image_to_update" -- /bin/bash -c "DEBIAN_FRONTEND=noninteractive SUDO_FORCE_REMOVE=yes apt-get --assume-yes -o Dpkg::Options::=\"--force-confold\" install --assume-yes $YUNOHOST_DEPENDENCIES $YUNOHOST_RECOMMENDS $MOULINETTE_DEPENDENCIES $SSOWAT_DEPENDENCIES $BUILD_DEPENDENCIES $TESTS_DEPENDENCIES"
|
||||||
lxc exec "$image_to_update-tmp" -- /bin/bash -c "python3 -m pip install -U $PIP3_PKG"
|
lxc exec "$image_to_update" -- /bin/bash -c "python3 -m pip install -U $PIP3_PKG"
|
||||||
|
|
||||||
rotate_image "$image_to_update-tmp" "$image_to_update"
|
create_snapshot "$image_to_update" "$ynh_version" "$snapshot"
|
||||||
|
|
||||||
lxc stop "$image_to_update-tmp"
|
lxc stop "$image_to_update"
|
||||||
|
|
||||||
lxc delete "$image_to_update-tmp"
|
|
||||||
}
|
}
|
||||||
|
|
13
variables.sh
13
variables.sh
|
@ -5,11 +5,15 @@ source $current_dir/prints.sh
|
||||||
|
|
||||||
# All Variables here: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#variables-reference, strating with CUSTOM_ENV_
|
# All Variables here: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#variables-reference, strating with CUSTOM_ENV_
|
||||||
|
|
||||||
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
|
ARCH="$(echo $CUSTOM_ENV_CI_RUNNER_EXECUTABLE_ARCH | cut -d'/' -f2)" # linux/amd64
|
||||||
DEFAULT_BRANCH="$CUSTOM_ENV_CI_DEFAULT_BRANCH"
|
DEFAULT_BRANCH="$CUSTOM_ENV_CI_DEFAULT_BRANCH"
|
||||||
|
|
||||||
CURRENT_BRANCH="$CUSTOM_ENV_CI_COMMIT_REF_NAME" # CUSTOM_ENV_CI_COMMIT_REF_NAME is the target branch of the MR
|
CURRENT_BRANCH="$CUSTOM_ENV_CI_COMMIT_REF_NAME" # CUSTOM_ENV_CI_COMMIT_REF_NAME is the target branch of the MR
|
||||||
|
if [ -z "$CURRENT_BRANCH" ]
|
||||||
|
then
|
||||||
|
CURRENT_BRANCH="dev"
|
||||||
|
fi
|
||||||
|
|
||||||
LAST_CHANGELOG_ENTRY=$(curl https://gitlab.com/yunohost/yunohost/-/raw/$CURRENT_BRANCH/debian/changelog --silent | head -n 1) # yunohost (4.2) unstable; urgency=low
|
LAST_CHANGELOG_ENTRY=$(curl https://gitlab.com/yunohost/yunohost/-/raw/$CURRENT_BRANCH/debian/changelog --silent | head -n 1) # yunohost (4.2) unstable; urgency=low
|
||||||
CURRENT_VERSION=$(echo $LAST_CHANGELOG_ENTRY | cut -d' ' -f3 | tr -d ';') # stable, testing, unstable
|
CURRENT_VERSION=$(echo $LAST_CHANGELOG_ENTRY | cut -d' ' -f3 | tr -d ';') # stable, testing, unstable
|
||||||
|
|
||||||
|
@ -28,5 +32,8 @@ fi
|
||||||
PROJECT_DIR="$CUSTOM_ENV_CI_PROJECT_DIR"
|
PROJECT_DIR="$CUSTOM_ENV_CI_PROJECT_DIR"
|
||||||
PROJECT_NAME="$CUSTOM_ENV_CI_PROJECT_NAME"
|
PROJECT_NAME="$CUSTOM_ENV_CI_PROJECT_NAME"
|
||||||
|
|
||||||
# For example yunohost-buster-unstable
|
PREFIX_IMAGE_NAME="ynh"
|
||||||
BASE_IMAGE="yunohost-$DEBIAN_VERSION-$CURRENT_VERSION"
|
# For example ynh-buster
|
||||||
|
BASE_IMAGE="$PREFIX_IMAGE_NAME-$DEBIAN_VERSION"
|
||||||
|
|
||||||
|
CONTAINER_IMAGE="$BASE_IMAGE-r-$CUSTOM_ENV_CI_RUNNER_ID-p-$CUSTOM_ENV_CI_PROJECT_ID-c-$CUSTOM_ENV_CI_CONCURRENT_PROJECT_ID"
|
Loading…
Reference in a new issue