Jan Kundrát | a4fbff2 | 2019-03-01 11:03:21 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -eux -o pipefail |
| 4 | shopt -s failglob |
| 5 | |
| 6 | ZUUL_JOB_NAME=$(jq < ~/zuul-env.json -r '.job') |
Jan Kundrát | 699cd9c | 2020-05-13 21:24:07 +0200 | [diff] [blame] | 7 | ZUUL_PROJECT_SRC_DIR=$HOME/$(jq < ~/zuul-env.json -r '.projects["cesnet-gerrit-czechlight/CzechLight/br2-external"].src_dir') |
| 8 | ZUUL_PROJECT_SHORT_NAME=$(jq < ~/zuul-env.json -r '.projects["cesnet-gerrit-czechlight/CzechLight/br2-external"].short_name') |
Jan Kundrát | 11a48c6 | 2019-03-08 14:44:53 +0100 | [diff] [blame] | 9 | CI_PARALLEL_JOBS=$(awk -vcpu=$(getconf _NPROCESSORS_ONLN) 'BEGIN{printf "%.0f", cpu*1.3+1}') |
Jan Kundrát | a4fbff2 | 2019-03-01 11:03:21 +0100 | [diff] [blame] | 10 | |
| 11 | BUILD_DIR=~/build |
| 12 | mkdir ${BUILD_DIR} |
| 13 | cd ${BUILD_DIR} |
| 14 | |
Jan Kundrát | 699cd9c | 2020-05-13 21:24:07 +0200 | [diff] [blame] | 15 | # Dependencies are normally specified via the cla-sysrepo.git repo |
Jan Kundrát | a4fbff2 | 2019-03-01 11:03:21 +0100 | [diff] [blame] | 16 | ${ZUUL_PROJECT_SRC_DIR}/dev-setup-git.sh |
| 17 | |
Jan Kundrát | 699cd9c | 2020-05-13 21:24:07 +0200 | [diff] [blame] | 18 | # If we're being triggered via a change against another repo, use speculatively merged stuff from Zuul, not our submodules |
| 19 | if [[ $(jq < ~/zuul-env.json -r '.project.name') != 'CzechLight/br2-external' ]]; then |
| 20 | # C++ dependencies can be provided either via cla-sysrepo, or via netconf-cli. |
| 21 | # Whatever is the latest change in the queue wins. |
| 22 | 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 + ""') |
| 23 | if [[ ! -z "${USE_DEPENDENCIES_VIA}" ]]; then |
| 24 | sed -i "s|${ZUUL_PROJECT_SRC_DIR}/submodules/cla-sysrepo/submodules/dependencies/|${HOME}/${USE_DEPENDENCIES_VIA}/submodules/dependencies/|g" local.mk |
| 25 | # Our Zuul playbook only prepares submodules within CzechLight/br2-external, not submodules of other projects |
| 26 | pushd ${HOME}/${USE_DEPENDENCIES_VIA} |
| 27 | # ...and before we check out, make sure that relative URLs work, i.e,. no file:///dev/null |
| 28 | git config remote.origin.url $(pwd) |
| 29 | git submodule update --init --recursive |
| 30 | git config remote.origin.url file:///dev/null |
| 31 | popd |
| 32 | fi |
| 33 | |
| 34 | for PROJECT in cla-sysrepo netconf-cli gammarus; do |
| 35 | # If there's a change for ${PROJECT} queued ahead, ensure it gets used. |
| 36 | # This means that if our submodules still pin, say, `cla-sysrepo` to some ancient version and we're testing a `netconf-cli` change, |
| 37 | # then we will keep using that ancient `cla-sysrepo`. Hopefully this reduces the number of false alerts. |
| 38 | DEPSRCDIR=$(jq < ~/zuul-env.json -r "[.items[]? | select(.project.name == \"CzechLight/${PROJECT}\")][-1]?.project.src_dir + \"\"") |
| 39 | if [[ ! -z "${DEPSRCDIR}" ]]; then |
| 40 | sed -i "s|${ZUUL_PROJECT_SRC_DIR}/submodules/${PROJECT}|${HOME}/${DEPSRCDIR}|g" local.mk |
| 41 | fi |
| 42 | done |
| 43 | fi |
| 44 | |
Jan Kundrát | a4fbff2 | 2019-03-01 11:03:21 +0100 | [diff] [blame] | 45 | if [[ "${ZUUL_JOB_NAME}" =~ clearfog ]]; then |
| 46 | make czechlight_clearfog_defconfig |
Jan Kundrát | 6100cf9 | 2019-12-05 16:01:33 +0100 | [diff] [blame] | 47 | elif [[ "${ZUUL_JOB_NAME}" =~ beagleboneblack ]]; then |
| 48 | make czechlight_beaglebone_defconfig |
Jan Kundrát | a4fbff2 | 2019-03-01 11:03:21 +0100 | [diff] [blame] | 49 | else |
| 50 | echo "Unrecognized job name, cannot determine defconfig target" |
| 51 | exit 1 |
| 52 | fi |
| 53 | |
Jan Kundrát | f5a026c | 2019-06-06 17:01:35 +0200 | [diff] [blame] | 54 | echo BR2_PRIMARY_SITE=\"https://object-store.cloud.muni.cz/swift/v1/ci-artifacts-public/mirror/buildroot\" >> .config |
Jan Kundrát | 11a48c6 | 2019-03-08 14:44:53 +0100 | [diff] [blame] | 55 | make source -j${CI_PARALLEL_JOBS} --output-sync=target |
Jan Kundrát | a4fbff2 | 2019-03-01 11:03:21 +0100 | [diff] [blame] | 56 | |
Jan Kundrát | 623bf87 | 2019-10-23 18:37:36 +0200 | [diff] [blame] | 57 | make -j${CI_PARALLEL_JOBS} --output-sync=target rootfs-czechlight-rauc |
Jan Kundrát | a4fbff2 | 2019-03-01 11:03:21 +0100 | [diff] [blame] | 58 | mv images/update.raucb ~/zuul-output/artifacts/ |
| 59 | |
| 60 | if [[ "${ZUUL_JOB_NAME}" =~ clearfog ]]; then |
| 61 | mv images/u-boot-spl.kwb ~/zuul-output/artifacts/ |
| 62 | fi |
| 63 | |
| 64 | # TODO: USB image as well? (`fallocate -d` to make it sparse) |
| 65 | # TODO: make legal-info |