summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLaurent Bonnans <laurent.bonnans@here.com>2019-07-04 15:35:44 +0200
committerLaurent Bonnans <laurent.bonnans@here.com>2019-07-16 16:25:55 +0200
commit9eebc8d15a297d68fc35dd4d77fcb945d2f395b2 (patch)
tree3539b2bdf61192e63c498b5c0bebce578198005a /scripts
parent5a23aa71c2bd5cfe23207553d04b54c5bdca49b4 (diff)
downloadmeta-updater-9eebc8d15a297d68fc35dd4d77fcb945d2f395b2.tar.gz
Gitlab pipeline for building core-image-minimal
Including these points (initially as separate commits): * Try caching updater-repo in gitlab * Only patch aktualizr recipe in CI if needed * Run under user 4321 in bitbake docker image * Add ability to supply METADIR to envsetup.sh So that we can bypass the "relative path from the script" trick that doesn't work with symlinks. * Checkout the PR base branch * do not run on pushes * run on runners with "gitlab" tag * Print all revisions after repo checkout on CI * Pull CI image from the base branch instead of master * More robust checkout in CI * Only store updater-repo artifacts for one day * Use "stretch" instead of "stable" for Debian release in Dockerfile (in fact, stable just changed to buster) * Move UPDATER_REPO variable out of .gitlab-ci.yml To be defined in the project's settings * Make docker CI stage buildable on shared runners Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/ci/Dockerfile.bitbake12
-rw-r--r--scripts/ci/Dockerfile.checkout9
-rwxr-xr-xscripts/ci/build.sh3
-rwxr-xr-xscripts/ci/checkout-oe.sh47
-rwxr-xr-xscripts/ci/configure.sh20
-rwxr-xr-xscripts/ci/oe-selftest.sh5
-rwxr-xr-xscripts/envsetup.sh2
7 files changed, 84 insertions, 14 deletions
diff --git a/scripts/ci/Dockerfile.bitbake b/scripts/ci/Dockerfile.bitbake
index c91f94c..75bad14 100644
--- a/scripts/ci/Dockerfile.bitbake
+++ b/scripts/ci/Dockerfile.bitbake
@@ -1,8 +1,8 @@
1FROM debian:stable 1FROM debian:stretch
2LABEL Description="Image for bitbaking" 2LABEL Description="Image for bitbaking"
3 3
4RUN sed -i 's#deb http://deb.debian.org/debian stable main#deb http://deb.debian.org/debian stable main contrib#g' /etc/apt/sources.list 4RUN sed -i 's#deb http://deb.debian.org/debian stretch main#deb http://deb.debian.org/debian stretch main contrib#g' /etc/apt/sources.list
5RUN sed -i 's#deb http://deb.debian.org/debian stable-updates main#deb http://deb.debian.org/debian stable-updates main contrib#g' /etc/apt/sources.list 5RUN sed -i 's#deb http://deb.debian.org/debian stretch-updates main#deb http://deb.debian.org/debian stretch-updates main contrib#g' /etc/apt/sources.list
6RUN apt-get update -q && apt-get install -qy \ 6RUN apt-get update -q && apt-get install -qy \
7 build-essential \ 7 build-essential \
8 bzip2 \ 8 bzip2 \
@@ -31,8 +31,8 @@ RUN apt-get update -q && apt-get install -qy \
31 xterm \ 31 xterm \
32 xz-utils 32 xz-utils
33 33
34ARG uid=1000 34ARG uid=4321
35ARG gid=1000 35ARG gid=4321
36RUN groupadd -g $gid bitbake 36RUN groupadd -g $gid bitbake
37RUN useradd -m -u $uid -g $gid bitbake 37RUN useradd -m -u $uid -g $gid bitbake
38 38
@@ -40,3 +40,5 @@ RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
40ENV LC_ALL="en_US.UTF-8" 40ENV LC_ALL="en_US.UTF-8"
41ENV LANG="en_US.UTF-8" 41ENV LANG="en_US.UTF-8"
42ENV LANGUAGE="en_US.UTF-8" 42ENV LANGUAGE="en_US.UTF-8"
43
44USER "bitbake"
diff --git a/scripts/ci/Dockerfile.checkout b/scripts/ci/Dockerfile.checkout
new file mode 100644
index 0000000..efec234
--- /dev/null
+++ b/scripts/ci/Dockerfile.checkout
@@ -0,0 +1,9 @@
1FROM debian:stretch-slim
2LABEL Description="Image for checking out updater-repo"
3
4RUN sed -i 's#deb http://deb.debian.org/debian stretch main#deb http://deb.debian.org/debian stretch main contrib#g' /etc/apt/sources.list
5RUN sed -i 's#deb http://deb.debian.org/debian stretch-updates main#deb http://deb.debian.org/debian stretch-updates main contrib#g' /etc/apt/sources.list
6RUN apt-get update -q && apt-get install -qy \
7 git \
8 repo \
9 xmlstarlet
diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh
index 6235428..9fbae98 100755
--- a/scripts/ci/build.sh
+++ b/scripts/ci/build.sh
@@ -12,7 +12,10 @@ IMAGE_NAME=${1:-core-image-minimal}
12( 12(
13set +euo pipefail 13set +euo pipefail
14set +x 14set +x
15METADIR=$(realpath "$TEST_REPO_DIR")
16export METADIR
15. "${TEST_REPO_DIR}/meta-updater/scripts/envsetup.sh" "${TEST_MACHINE}" "${TEST_BUILD_DIR}" 17. "${TEST_REPO_DIR}/meta-updater/scripts/envsetup.sh" "${TEST_MACHINE}" "${TEST_BUILD_DIR}"
16 18
19set -x
17bitbake "${IMAGE_NAME}" 20bitbake "${IMAGE_NAME}"
18) 21)
diff --git a/scripts/ci/checkout-oe.sh b/scripts/ci/checkout-oe.sh
new file mode 100755
index 0000000..8744b2f
--- /dev/null
+++ b/scripts/ci/checkout-oe.sh
@@ -0,0 +1,47 @@
1#!/usr/bin/env bash
2
3set -euo pipefail
4
5set -x
6
7REMOTE_SOURCE=${REMOTE_SOURCE:-https://github.com/advancedtelematic}
8MANIFEST=${MANIFEST:-master}
9CURRENT_PROJECT=${CURRENT_PROJECT:-meta-updater}
10
11#CURRENT_REV=$(git rev-parse HEAD)
12LOCAL_REPO=$PWD
13
14mkdir -p updater-repo
15
16cd updater-repo
17
18repo init -m "${MANIFEST}.xml" -u "$REMOTE_SOURCE/updater-repo"
19
20git -C .repo/manifests reset --hard
21
22# patch manifest:
23# - add a new "ats" remote that points to "$REMOTE_SOURCE"
24# - change projects that contain "advancedtelematic" to use the ats remote
25# - remove the current project from the manifest
26MANIFEST_FILE=".repo/manifests/${MANIFEST}.xml"
27xmlstarlet ed --omit-decl -L \
28 -s "/manifest" -t elem -n "remote" -v "" \
29 -i "/manifest/remote[last()]" -t attr -n "name" -v "ats" \
30 -i "/manifest/remote[last()]" -t attr -n "fetch" -v "$REMOTE_SOURCE" \
31 -i "/manifest/project[contains(@name, 'advancedtelematic')]" -t attr -n "remote" -v "ats" \
32 -d "/manifest/project[@path=\"$CURRENT_PROJECT\"]" \
33 "$MANIFEST_FILE"
34
35# hack: sed on `advancedtelematic/` names, to remove this unwanted prefix
36sed -i 's#name="advancedtelematic/#name="#g' "$MANIFEST_FILE"
37
38repo manifest
39
40repo forall -c 'git reset --hard ; git clean -fdx'
41
42repo sync -d --force-sync
43
44rm -f "$CURRENT_PROJECT"
45ln -s "$LOCAL_REPO" "$CURRENT_PROJECT"
46
47repo manifest -r
diff --git a/scripts/ci/configure.sh b/scripts/ci/configure.sh
index 960a0cc..a8968da 100755
--- a/scripts/ci/configure.sh
+++ b/scripts/ci/configure.sh
@@ -8,9 +8,13 @@ TEST_BUILD_DIR=${TEST_BUILD_DIR:-build}
8TEST_REPO_DIR=${TEST_REPO_DIR:-updater-repo} 8TEST_REPO_DIR=${TEST_REPO_DIR:-updater-repo}
9TEST_BITBAKE_COMMON_DIR=${TEST_BITBAKE_COMMON_DIR:-} 9TEST_BITBAKE_COMMON_DIR=${TEST_BITBAKE_COMMON_DIR:-}
10 10
11TEST_AKTUALIZR_DIR=${TEST_AKTUALIZR_DIR:-.} 11TEST_AKTUALIZR_REMOTE=${TEST_AKTUALIZR_REMOTE:-}
12TEST_AKTUALIZR_BRANCH=${TEST_AKTUALIZR_BRANCH:-master} 12if [ -n "$TEST_AKTUALIZR_REMOTE" ]; then
13TEST_AKTUALIZR_REV=${TEST_AKTUALIZR_REV:-$(GIT_DIR="$TEST_AKTUALIZR_DIR/.git" git rev-parse "$TEST_AKTUALIZR_REMOTE/$TEST_AKTUALIZR_BRANCH")} 13 TEST_AKTUALIZR_DIR=${TEST_AKTUALIZR_DIR:-.}
14 TEST_AKTUALIZR_BRANCH=${TEST_AKTUALIZR_BRANCH:-master}
15 TEST_AKTUALIZR_REV=${TEST_AKTUALIZR_REV:-$(GIT_DIR="$TEST_AKTUALIZR_DIR/.git" git rev-parse "$TEST_AKTUALIZR_REMOTE/$TEST_AKTUALIZR_BRANCH")}
16fi
17
14TEST_AKTUALIZR_CREDENTIALS=${TEST_AKTUALIZR_CREDENTIALS:-} 18TEST_AKTUALIZR_CREDENTIALS=${TEST_AKTUALIZR_CREDENTIALS:-}
15 19
16# move existing conf directory to backup, before generating a new one 20# move existing conf directory to backup, before generating a new one
@@ -21,6 +25,8 @@ mv "$TEST_BUILD_DIR/conf" "$TEST_BUILD_DIR/conf.old" || true
21set +euo pipefail 25set +euo pipefail
22set +x 26set +x
23echo ">> Running envsetup.sh" 27echo ">> Running envsetup.sh"
28METADIR=$(realpath "$TEST_REPO_DIR")
29export METADIR
24. "$TEST_REPO_DIR/meta-updater/scripts/envsetup.sh" "$TEST_MACHINE" "$TEST_BUILD_DIR" 30. "$TEST_REPO_DIR/meta-updater/scripts/envsetup.sh" "$TEST_MACHINE" "$TEST_BUILD_DIR"
25) 31)
26 32
@@ -31,19 +37,19 @@ SITE_CONF="$TEST_BUILD_DIR/conf/site.conf"
31echo ">> Set common bitbake config options" 37echo ">> Set common bitbake config options"
32cat << EOF > "$SITE_CONF" 38cat << EOF > "$SITE_CONF"
33SANITY_TESTED_DISTROS = "" 39SANITY_TESTED_DISTROS = ""
34SSTATE_MIRRORS ?= "file://.* https://bitbake-cache.atsgarage.com/PATH;downloadfilename=PATH"
35IMAGE_FEATURES += "ssh-server-openssh" 40IMAGE_FEATURES += "ssh-server-openssh"
36 41
37EOF 42EOF
38 43
39echo ">> Set aktualizr branch in bitbake's config" 44if [ -n "$TEST_AKTUALIZR_REMOTE" ]; then
40cat << EOF >> "$SITE_CONF" 45 echo ">> Set aktualizr branch in bitbake's config"
46 cat << EOF >> "$SITE_CONF"
41SRCREV_pn-aktualizr = "$TEST_AKTUALIZR_REV" 47SRCREV_pn-aktualizr = "$TEST_AKTUALIZR_REV"
42SRCREV_pn-aktualizr-native = "\${SRCREV_pn-aktualizr}" 48SRCREV_pn-aktualizr-native = "\${SRCREV_pn-aktualizr}"
43BRANCH_pn-aktualizr = "$TEST_AKTUALIZR_BRANCH" 49BRANCH_pn-aktualizr = "$TEST_AKTUALIZR_BRANCH"
44BRANCH_pn-aktualizr-native = "\${BRANCH_pn-aktualizr}" 50BRANCH_pn-aktualizr-native = "\${BRANCH_pn-aktualizr}"
45
46EOF 51EOF
52fi
47 53
48if [[ -n $TEST_AKTUALIZR_CREDENTIALS ]]; then 54if [[ -n $TEST_AKTUALIZR_CREDENTIALS ]]; then
49 echo ">> Set aktualizr credentials" 55 echo ">> Set aktualizr credentials"
diff --git a/scripts/ci/oe-selftest.sh b/scripts/ci/oe-selftest.sh
index 3124cce..66b1fc9 100755
--- a/scripts/ci/oe-selftest.sh
+++ b/scripts/ci/oe-selftest.sh
@@ -12,7 +12,10 @@ TEST_REPO_DIR=${TEST_REPO_DIR:-updater-repo}
12( 12(
13set +euo pipefail 13set +euo pipefail
14set +x 14set +x
15METADIR=$(realpath "$TEST_REPO_DIR")
16export METADIR
15. "${TEST_REPO_DIR}/meta-updater/scripts/envsetup.sh" "${TEST_MACHINE}" "${TEST_BUILD_DIR}" 17. "${TEST_REPO_DIR}/meta-updater/scripts/envsetup.sh" "${TEST_MACHINE}" "${TEST_BUILD_DIR}"
16 18
17oe-selftest -r updater 19set -x
20oe-selftest -r "$@"
18) 21)
diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh
index 6103cf6..5827bc2 100755
--- a/scripts/envsetup.sh
+++ b/scripts/envsetup.sh
@@ -21,7 +21,7 @@ if [[ $SOURCED -ne 1 ]]; then
21 exit 1 21 exit 1
22fi 22fi
23 23
24METADIR="${SOURCEDIR}/../.." 24METADIR=${METADIR:-${SOURCEDIR}/../..}
25 25
26if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then 26if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then
27 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" 27 source "$METADIR/poky/oe-init-build-env" "$BUILDDIR"