blob: 20b203fd7b106a234d869aa0da7bc74219c1efb9 [file] [log] [blame]
Jan Kundráta4fbff22019-03-01 11:03:21 +01001#!/bin/bash
2
3set -eux -o pipefail
4shopt -s failglob
5
6ZUUL_JOB_NAME=$(jq < ~/zuul-env.json -r '.job')
Jan Kundrát699cd9c2020-05-13 21:24:07 +02007ZUUL_PROJECT_SRC_DIR=$HOME/$(jq < ~/zuul-env.json -r '.projects["cesnet-gerrit-czechlight/CzechLight/br2-external"].src_dir')
8ZUUL_PROJECT_SHORT_NAME=$(jq < ~/zuul-env.json -r '.projects["cesnet-gerrit-czechlight/CzechLight/br2-external"].short_name')
Jan Kundrát11a48c62019-03-08 14:44:53 +01009CI_PARALLEL_JOBS=$(awk -vcpu=$(getconf _NPROCESSORS_ONLN) 'BEGIN{printf "%.0f", cpu*1.3+1}')
Jan Kundráta4fbff22019-03-01 11:03:21 +010010
11BUILD_DIR=~/build
12mkdir ${BUILD_DIR}
13cd ${BUILD_DIR}
14
Jan Kundrát699cd9c2020-05-13 21:24:07 +020015# Dependencies are normally specified via the cla-sysrepo.git repo
Jan Kundráta4fbff22019-03-01 11:03:21 +010016${ZUUL_PROJECT_SRC_DIR}/dev-setup-git.sh
17
Jan Kundrát699cd9c2020-05-13 21:24:07 +020018if [[ $(jq < ~/zuul-env.json -r '.project.name') != 'CzechLight/br2-external' ]]; then
Jan Kundrátd45c1042020-05-14 15:06:42 +020019 TRIGGERED_VIA_DEP=1
20else
21 TRIGGERED_VIA_DEP=0
22fi
23BR2_EXTERNAL_COMMIT=$(git --git-dir ${ZUUL_PROJECT_SRC_DIR}/.git rev-parse HEAD)
24
25# If we're being triggered via a change against another repo, use speculatively merged stuff from Zuul, not our submodules
26if [[ ${TRIGGERED_VIA_DEP} == 1 ]]; then
Jan Kundrát699cd9c2020-05-13 21:24:07 +020027 # C++ dependencies can be provided either via cla-sysrepo, or via netconf-cli.
28 # Whatever is the latest change in the queue wins.
29 USE_DEPENDENCIES_VIA=$(jq < ~/zuul-env.json -r '[.items[]? | select(.project.name == "CzechLight/cla-sysrepo" or .project.name == "CzechLight/netconf-cli")][-1]?.project.src_dir + ""')
30 if [[ ! -z "${USE_DEPENDENCIES_VIA}" ]]; then
31 sed -i "s|${ZUUL_PROJECT_SRC_DIR}/submodules/cla-sysrepo/submodules/dependencies/|${HOME}/${USE_DEPENDENCIES_VIA}/submodules/dependencies/|g" local.mk
32 # Our Zuul playbook only prepares submodules within CzechLight/br2-external, not submodules of other projects
33 pushd ${HOME}/${USE_DEPENDENCIES_VIA}
34 # ...and before we check out, make sure that relative URLs work, i.e,. no file:///dev/null
35 git config remote.origin.url $(pwd)
36 git submodule update --init --recursive
37 git config remote.origin.url file:///dev/null
38 popd
39 fi
40
41 for PROJECT in cla-sysrepo netconf-cli gammarus; do
42 # If there's a change for ${PROJECT} queued ahead, ensure it gets used.
43 # This means that if our submodules still pin, say, `cla-sysrepo` to some ancient version and we're testing a `netconf-cli` change,
44 # then we will keep using that ancient `cla-sysrepo`. Hopefully this reduces the number of false alerts.
45 DEPSRCDIR=$(jq < ~/zuul-env.json -r "[.items[]? | select(.project.name == \"CzechLight/${PROJECT}\")][-1]?.project.src_dir + \"\"")
46 if [[ ! -z "${DEPSRCDIR}" ]]; then
47 sed -i "s|${ZUUL_PROJECT_SRC_DIR}/submodules/${PROJECT}|${HOME}/${DEPSRCDIR}|g" local.mk
48 fi
49 done
50fi
51
Jan Kundráta4fbff22019-03-01 11:03:21 +010052if [[ "${ZUUL_JOB_NAME}" =~ clearfog ]]; then
53 make czechlight_clearfog_defconfig
Jan Kundrát6100cf92019-12-05 16:01:33 +010054elif [[ "${ZUUL_JOB_NAME}" =~ beagleboneblack ]]; then
55 make czechlight_beaglebone_defconfig
Jan Kundráta4fbff22019-03-01 11:03:21 +010056else
57 echo "Unrecognized job name, cannot determine defconfig target"
58 exit 1
59fi
60
Jan Kundrátf5a026c2019-06-06 17:01:35 +020061echo BR2_PRIMARY_SITE=\"https://object-store.cloud.muni.cz/swift/v1/ci-artifacts-public/mirror/buildroot\" >> .config
Jan Kundrát11a48c62019-03-08 14:44:53 +010062make source -j${CI_PARALLEL_JOBS} --output-sync=target
Jan Kundráta4fbff22019-03-01 11:03:21 +010063
Jan Kundrát623bf872019-10-23 18:37:36 +020064make -j${CI_PARALLEL_JOBS} --output-sync=target rootfs-czechlight-rauc
Jan Kundráta4fbff22019-03-01 11:03:21 +010065mv images/update.raucb ~/zuul-output/artifacts/
66
67if [[ "${ZUUL_JOB_NAME}" =~ clearfog ]]; then
Jan Kundrátd45c1042020-05-14 15:06:42 +020068 if [[ ${TRIGGERED_VIA_DEP} != 1 ]]; then
69 mv images/u-boot-spl.kwb ~/zuul-output/artifacts/
70
71 # store a cached tarball as an artifact
72 ARTIFACT=br2-work-dir-${BR2_EXTERNAL_COMMIT}.tar.zst
73 # everything but local.mk which we might have adjusted in job prologue, so let's not overwrite that
74 tar --totals -c \
75 --exclude='images/rootfs.*' \
76 --exclude='images/sdcard.*' \
77 --exclude='images/usb-flash.*' \
78 .br* \
79 build \
80 .config \
81 host \
82 images \
83 Makefile \
84 per-package \
85 target \
86 | zstd -T0 > ~/zuul-output/artifacts/${ARTIFACT}
87 fi
Jan Kundráta4fbff22019-03-01 11:03:21 +010088fi
89
90# TODO: USB image as well? (`fallocate -d` to make it sparse)
91# TODO: make legal-info