summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Kim Højgaard-Hansen <kimrhh@gmail.com> 2017-05-05 22:47:00 +0200
committerAvatar Kim Højgaard-Hansen <kimrhh@gmail.com> 2017-05-05 22:47:00 +0200
commite888f62f8f1cd1ce33b222c9c5045085be8044f7 (patch)
tree77c911e9760358723f6b872443b3c5cf2944280d
parentacff3bb0e7748dfd79799d2b974598976381bf84 (diff)
downloadinfra-scripts-e888f62f8f1cd1ce33b222c9c5045085be8044f7.tar.gz
infra-scripts-e888f62f8f1cd1ce33b222c9c5045085be8044f7.tar.xz
Initial add of script to be used for Gitlab-CI
The scripts are ported from the use of Jenkins
-rw-r--r--continuous-integration/gitlab/buildtest60
-rw-r--r--continuous-integration/gitlab/handle_confirmations27
2 files changed, 87 insertions, 0 deletions
diff --git a/continuous-integration/gitlab/buildtest b/continuous-integration/gitlab/buildtest
new file mode 100644
index 0000000..8ff0fa9
--- /dev/null
+++ b/continuous-integration/gitlab/buildtest
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+TMPFILE=$(mktemp -uq)
+
+rm -Rf /tmp/ciwork
+mkdir /tmp/ciwork
+pushd /tmp/ciwork
+
+echo "Repository URL: ${CI_REPOSITORY_URL}"
+echo "Branch: ${CI_COMMIT_REF_NAME}"
+echo "Commit hash: ${CI_COMMIT_SHA}"
+
+git clone ${CI_REPOSITORY_URL} ${REPO}
+pushd ${REPO}
+git checkout ${CI_COMMIT_REF_NAME}
+
+PKG=$(git diff-tree --no-commit-id --name-only -r ${CI_COMMIT_SHA} | grep -v "^$" | awk -F/ '$1~/packages/{print $2"/"$3}' | sort -u | xargs)
+if [[ -z ${PKG} ]]; then
+ echo "No package to build. No exlib recognised. Don't know what to do. Exiting."
+ exit 0
+fi
+
+popd
+popd
+
+cave sync
+cave sync ${REPO} -s local -r ${CI_COMMIT_SHA}
+
+rc=$?
+if [[ ${rc} -gt 0 ]]; then
+ echo "Sync failed!"
+ exit ${rc}
+fi
+
+cave resolve ${PKG} --display-resolution-program "cave print-resolution-required-confirmations" > ${TMPFILE}
+ARGS=$(handle_confirmations < ${TMPFILE})
+if [[ "${ARGS}" == *unknown\ confirmation:* ]]; then
+ echo "***** I FAILED! ***********************************************"
+ cat ${TMPFILE}
+ echo "*************** COMMITTING SUICIDE NOW! ***********************"
+ exit 1
+fi
+
+echo "ARGS: ${ARGS}"
+
+echo "**************************************************************"
+cave resolve -zx --skip-phase test --change-phases-for \!targets ${PKG} ${ARGS}
+
+rc=$?
+if [[ ${rc} -gt 0 ]]; then
+ echo "Build failed!"
+else
+ echo "**************************************************************"
+ echo "Dependencies I believe to have found (excluding system):"
+ /usr/local/bin/mscan2.rb -i system ${PKG/::*} 2>&1
+ echo "**************************************************************"
+fi
+
+exit ${rc}
+
diff --git a/continuous-integration/gitlab/handle_confirmations b/continuous-integration/gitlab/handle_confirmations
new file mode 100644
index 0000000..e73a228
--- /dev/null
+++ b/continuous-integration/gitlab/handle_confirmations
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+parse_options() {
+ local options=() suboptions=()
+ for o ; do
+ if [[ $o == *:* ]]; then
+ suboptions+=( ${o%:*}: ${o#*:} )
+ else
+ options+=( $o )
+ fi
+ done
+ echo "${options[@]}" "${suboptions[@]}"
+}
+
+while read id cause options; do
+ case $cause in
+ break) echo --uninstalls-may-break ${id%::*} ;;
+ changed_choices) echo ${id%::*} $(parse_options $options) >> /etc/paludis/options.conf ;;
+ downgrade) echo --permit-downgrade ${id%::*} ;;
+ masked) echo ${id%::*} >> /etc/paludis/package_unmask.conf ;;
+ not_best) echo --permit-old-version ${id%::*} ;;
+ remove_system_package) echo --uninstalls-may-break system ;;
+ uninstall) echo --permit-uninstall ${id%::*} ;;
+ *) echo "unknown confirmation: $cause" >&2 ;;
+ esac
+done
+