diff options
author | Laurent Bonnans <laurent.bonnans@here.com> | 2019-07-04 15:35:44 +0200 |
---|---|---|
committer | Laurent Bonnans <laurent.bonnans@here.com> | 2019-07-16 16:25:55 +0200 |
commit | 9eebc8d15a297d68fc35dd4d77fcb945d2f395b2 (patch) | |
tree | 3539b2bdf61192e63c498b5c0bebce578198005a /scripts | |
parent | 5a23aa71c2bd5cfe23207553d04b54c5bdca49b4 (diff) | |
download | meta-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.bitbake | 12 | ||||
-rw-r--r-- | scripts/ci/Dockerfile.checkout | 9 | ||||
-rwxr-xr-x | scripts/ci/build.sh | 3 | ||||
-rwxr-xr-x | scripts/ci/checkout-oe.sh | 47 | ||||
-rwxr-xr-x | scripts/ci/configure.sh | 20 | ||||
-rwxr-xr-x | scripts/ci/oe-selftest.sh | 5 | ||||
-rwxr-xr-x | scripts/envsetup.sh | 2 |
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 @@ | |||
1 | FROM debian:stable | 1 | FROM debian:stretch |
2 | LABEL Description="Image for bitbaking" | 2 | LABEL Description="Image for bitbaking" |
3 | 3 | ||
4 | RUN 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 | 4 | RUN 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 |
5 | RUN 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 | 5 | RUN 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 |
6 | RUN apt-get update -q && apt-get install -qy \ | 6 | RUN 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 | ||
34 | ARG uid=1000 | 34 | ARG uid=4321 |
35 | ARG gid=1000 | 35 | ARG gid=4321 |
36 | RUN groupadd -g $gid bitbake | 36 | RUN groupadd -g $gid bitbake |
37 | RUN useradd -m -u $uid -g $gid bitbake | 37 | RUN 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 | |||
40 | ENV LC_ALL="en_US.UTF-8" | 40 | ENV LC_ALL="en_US.UTF-8" |
41 | ENV LANG="en_US.UTF-8" | 41 | ENV LANG="en_US.UTF-8" |
42 | ENV LANGUAGE="en_US.UTF-8" | 42 | ENV LANGUAGE="en_US.UTF-8" |
43 | |||
44 | USER "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 @@ | |||
1 | FROM debian:stretch-slim | ||
2 | LABEL Description="Image for checking out updater-repo" | ||
3 | |||
4 | RUN 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 | ||
5 | RUN 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 | ||
6 | RUN 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 | ( |
13 | set +euo pipefail | 13 | set +euo pipefail |
14 | set +x | 14 | set +x |
15 | METADIR=$(realpath "$TEST_REPO_DIR") | ||
16 | export 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 | ||
19 | set -x | ||
17 | bitbake "${IMAGE_NAME}" | 20 | bitbake "${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 | |||
3 | set -euo pipefail | ||
4 | |||
5 | set -x | ||
6 | |||
7 | REMOTE_SOURCE=${REMOTE_SOURCE:-https://github.com/advancedtelematic} | ||
8 | MANIFEST=${MANIFEST:-master} | ||
9 | CURRENT_PROJECT=${CURRENT_PROJECT:-meta-updater} | ||
10 | |||
11 | #CURRENT_REV=$(git rev-parse HEAD) | ||
12 | LOCAL_REPO=$PWD | ||
13 | |||
14 | mkdir -p updater-repo | ||
15 | |||
16 | cd updater-repo | ||
17 | |||
18 | repo init -m "${MANIFEST}.xml" -u "$REMOTE_SOURCE/updater-repo" | ||
19 | |||
20 | git -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 | ||
26 | MANIFEST_FILE=".repo/manifests/${MANIFEST}.xml" | ||
27 | xmlstarlet 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 | ||
36 | sed -i 's#name="advancedtelematic/#name="#g' "$MANIFEST_FILE" | ||
37 | |||
38 | repo manifest | ||
39 | |||
40 | repo forall -c 'git reset --hard ; git clean -fdx' | ||
41 | |||
42 | repo sync -d --force-sync | ||
43 | |||
44 | rm -f "$CURRENT_PROJECT" | ||
45 | ln -s "$LOCAL_REPO" "$CURRENT_PROJECT" | ||
46 | |||
47 | repo 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} | |||
8 | TEST_REPO_DIR=${TEST_REPO_DIR:-updater-repo} | 8 | TEST_REPO_DIR=${TEST_REPO_DIR:-updater-repo} |
9 | TEST_BITBAKE_COMMON_DIR=${TEST_BITBAKE_COMMON_DIR:-} | 9 | TEST_BITBAKE_COMMON_DIR=${TEST_BITBAKE_COMMON_DIR:-} |
10 | 10 | ||
11 | TEST_AKTUALIZR_DIR=${TEST_AKTUALIZR_DIR:-.} | 11 | TEST_AKTUALIZR_REMOTE=${TEST_AKTUALIZR_REMOTE:-} |
12 | TEST_AKTUALIZR_BRANCH=${TEST_AKTUALIZR_BRANCH:-master} | 12 | if [ -n "$TEST_AKTUALIZR_REMOTE" ]; then |
13 | TEST_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")} | ||
16 | fi | ||
17 | |||
14 | TEST_AKTUALIZR_CREDENTIALS=${TEST_AKTUALIZR_CREDENTIALS:-} | 18 | TEST_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 | |||
21 | set +euo pipefail | 25 | set +euo pipefail |
22 | set +x | 26 | set +x |
23 | echo ">> Running envsetup.sh" | 27 | echo ">> Running envsetup.sh" |
28 | METADIR=$(realpath "$TEST_REPO_DIR") | ||
29 | export 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" | |||
31 | echo ">> Set common bitbake config options" | 37 | echo ">> Set common bitbake config options" |
32 | cat << EOF > "$SITE_CONF" | 38 | cat << EOF > "$SITE_CONF" |
33 | SANITY_TESTED_DISTROS = "" | 39 | SANITY_TESTED_DISTROS = "" |
34 | SSTATE_MIRRORS ?= "file://.* https://bitbake-cache.atsgarage.com/PATH;downloadfilename=PATH" | ||
35 | IMAGE_FEATURES += "ssh-server-openssh" | 40 | IMAGE_FEATURES += "ssh-server-openssh" |
36 | 41 | ||
37 | EOF | 42 | EOF |
38 | 43 | ||
39 | echo ">> Set aktualizr branch in bitbake's config" | 44 | if [ -n "$TEST_AKTUALIZR_REMOTE" ]; then |
40 | cat << EOF >> "$SITE_CONF" | 45 | echo ">> Set aktualizr branch in bitbake's config" |
46 | cat << EOF >> "$SITE_CONF" | ||
41 | SRCREV_pn-aktualizr = "$TEST_AKTUALIZR_REV" | 47 | SRCREV_pn-aktualizr = "$TEST_AKTUALIZR_REV" |
42 | SRCREV_pn-aktualizr-native = "\${SRCREV_pn-aktualizr}" | 48 | SRCREV_pn-aktualizr-native = "\${SRCREV_pn-aktualizr}" |
43 | BRANCH_pn-aktualizr = "$TEST_AKTUALIZR_BRANCH" | 49 | BRANCH_pn-aktualizr = "$TEST_AKTUALIZR_BRANCH" |
44 | BRANCH_pn-aktualizr-native = "\${BRANCH_pn-aktualizr}" | 50 | BRANCH_pn-aktualizr-native = "\${BRANCH_pn-aktualizr}" |
45 | |||
46 | EOF | 51 | EOF |
52 | fi | ||
47 | 53 | ||
48 | if [[ -n $TEST_AKTUALIZR_CREDENTIALS ]]; then | 54 | if [[ -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 | ( |
13 | set +euo pipefail | 13 | set +euo pipefail |
14 | set +x | 14 | set +x |
15 | METADIR=$(realpath "$TEST_REPO_DIR") | ||
16 | export 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 | ||
17 | oe-selftest -r updater | 19 | set -x |
20 | oe-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 |
22 | fi | 22 | fi |
23 | 23 | ||
24 | METADIR="${SOURCEDIR}/../.." | 24 | METADIR=${METADIR:-${SOURCEDIR}/../..} |
25 | 25 | ||
26 | if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then | 26 | if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then |
27 | source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" | 27 | source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" |