Commit b4eda037 authored by Luca Giambonini's avatar Luca Giambonini

[skip-ci] implemented repository build detection

default settings:
core and lib32 build against testing
desktop and gtk build against stable

to build against an other repository add the repository name in the commend included in the brackets [] for instance:
"[testing] commit message"

the deploy server is always testing or staging, uploading to stable directly is not permitted
parent f51e0687
Pipeline #66 skipped
......@@ -10,8 +10,7 @@ if [ -z "$UPLOAD_LIST" ]; then
_log success "Done nothing to upload!"
else
# rsync upload
_do upload_files
_do upload_files $(get_repository)
# akbm to add to the repository
_do update_remote_db
......
......@@ -10,7 +10,7 @@ _do sh -c "echo 'LC_MESSAGES=C' >> '/etc/locale.conf'"
# create a local makepkg settings
_log command "Setting up makepkg.conf..."
_do echo "source /etc/makepkg.conf
echo "source /etc/makepkg.conf
#-- Make Flags: change this for DistCC/SMP systems
MAKEFLAGS=\"-j$(($(nproc)+1))\"
......@@ -23,5 +23,11 @@ _log command "Patching makepkg..."
_do wget https://code.chakralinux.org/tools/chakrabuildsystem/raw/master/chakra/bin/makepkg
_do cp makepkg /usr/bin/makepkg
# force to use the default chakra rsync
# sed -i '1s/^/<added text> /' file
# determine the the repository where we should build against (stable|testing|staging)
repo_name=$(get_repository)
_log command "Enabling [$repo_name] pacman.conf..."
_do wget "https://code.chakralinux.org/tools/chakrabuildsystem/raw/master/conf/$repo_name.conf"
_do cp $repo_name.conf /etc/pacman.conf
# resync database and update with latest changes
_do pacman -Syyu --noconfirm
......@@ -34,6 +34,17 @@ function _unlock_repo() {
_do_akbm ssh $SSH_USER@$DEPLOY_SERVER -p $SSH_PORT "akbm --repo-name $DEPLOY_REPO --arch x86_64 --unlock"
}
function _set_deploy_repo() {
if [[ "$1" == "stable" ]]; then
# convert stable to the real repository name
# DEPLOY_REPO=$CI_PROJECT_NAME
# force uploading to testing
DEPLOY_REPO="testing"
else
DEPLOY_REPO=$1
fi
}
# checks whether $1 contains a globbing pattern
# returns: '$1' or '*$1*'
function _glob() {
......@@ -70,6 +81,7 @@ function _upload_files() {
}
function upload_files() {
_do _set_deploy_repo $1
_log build_step "Start uploading to $DEPLOY_REPO the following packages: ${UPLOAD_LIST[@]}"
_do _lock_repo
_do_deploy _upload_files "${UPLOAD_LIST[@]}"
......@@ -87,7 +99,7 @@ function update_remote_db() {
_do _unlock_repo
}
_ensure-var "DEPLOY_REPO"
#_ensure-var "DEPLOY_REPO"
_ensure-var "DEPLOY_SERVER"
_ensure-var "SSH_USER"
_ensure-var "SSH_PORT"
......@@ -165,6 +165,40 @@ function sort_packages_by_dependency() {
PACKAGES=("${sorted_packages[@]}")
}
# determine the repository to build against
function get_repository() {
# save the current branch as the default repository
local current_repo=$CI_COMMIT_REF_NAME
if [ "$current_repo" == "master" ]; then
current_repo="stable"
fi
# verify if a manual override is present in the git comment
GIT_COMMIT_MESSAGE=$(git rev-list --format=%B --max-count=1 HEAD)
# extract the text between brackets, ex. [stable], [testing]
tokens=$(echo $GIT_COMMIT_MESSAGE | cut -d "[" -f2 | cut -d "]" -f1)
for token in $tokens;
do
case "$token" in
"stable")
current_repo="stable"
;;
"testing")
current_repo="testing"
;;
"staging" | "unstable")
current_repo="staging"
;;
*)
;;
esac
done
echo "$current_repo"
}
# Build all packages defined in array variable PACKAGES
# builds all $PACKAGES in the given order
function build_packages() {
......
......@@ -85,7 +85,6 @@ sign_pkgs:
deploy_repo:
stage: deploy
variables:
DEPLOY_REPO: "$DEPLOY_REPO"
DEPLOY_SERVER: "$DEPLOY_SERVER"
SSH_USER: "$SSH_USER"
SSH_PORT: "$SSH_PORT"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment