blob: e9421230251542487a8397975a6e87f997ea8b50 [file] [log] [blame]
Benjamin Copelandc78807d2019-04-02 08:54:42 +01001#!/bin/bash
2
3set -ex
4
Benjamin Copelandc78807d2019-04-02 08:54:42 +01005echo ""
6echo "########################################################################"
7echo " Gerrit Environment"
8env |grep '^GERRIT'
9echo "########################################################################"
10
Paul Sokolovskyb5dca4b2022-11-11 21:52:03 +030011# For dpkg-architecture call below
Paul Sokolovsky09455562022-11-12 11:35:36 +030012if ! type dpkg-architecture
13then
14 sudo apt-get -y -qq install --no-install-recommends dpkg-dev
Paul Sokolovsky429589e2022-11-12 11:43:14 +030015fi
Paul Sokolovskyb5dca4b2022-11-11 21:52:03 +030016
17if ! type aws
18then
19 sudo apt-get -y -qq update
20 sudo apt-get -y -qq install --no-install-recommends unzip
21 curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
Paul Sokolovsky0810ea22022-11-11 22:23:41 +030022 unzip -q awscliv2.zip
Paul Sokolovskyb5dca4b2022-11-11 21:52:03 +030023 sudo ./aws/install
24fi
25
Riku Voipiob8ffb562020-10-12 11:44:40 +030026rm -f ${WORKSPACE}/log
Benjamin Copelandc78807d2019-04-02 08:54:42 +010027cd dockerfiles/
28
Paul Sokolovskyb5dca4b2022-11-11 21:52:03 +030029aws configure list
30aws s3 cp --recursive s3://trustedfirmware-private/armclang/ .
31find .
32
33df -h
34
Benjamin Copelandc78807d2019-04-02 08:54:42 +010035git_previous_commit=$(git rev-parse HEAD~1)
36git_commit=$(git rev-parse HEAD)
37files=$(git diff --name-only ${git_previous_commit} ${git_commit})
38echo Changes in: ${files}
Riku Voipiob8ffb562020-10-12 11:44:40 +030039changed_dirs=$(dirname ${files}|sort -u)
Benjamin Copelandc78807d2019-04-02 08:54:42 +010040
41update_images=""
42for dir in ${changed_dirs}; do
43 # Find the closest directory with build.sh. This is, primarily,
44 # to handle changes to tcwg-base/tcwg-build/tcwg-builslave/* directories.
45 while [ ! -e ${dir}/build.sh -a ! -e ${dir}/.git ]; do
46 dir=$(dirname ${dir})
47 done
48 # Add this and all dependant images in the update.
49 dir_basename=$(basename ${dir})
50 case "${dir_basename}" in
51 "tcwg-"*)
52 # ${dir} is one of generic tcwg-base/* directories. Add dependent
53 # images to the list.
54 update_images="${update_images} $(dirname $(find . -path "*-${dir_basename}*/build.sh" | sed -e "s#^\./##g"))"
55 ;;
Riku Voipiob8ffb562020-10-12 11:44:40 +030056 ".")
57 continue
58 ;;
Benjamin Copelandc78807d2019-04-02 08:54:42 +010059 *)
60 update_images="${update_images} $(dirname $(find ${dir} -name build.sh))"
61 ;;
62 esac
63done
64update_images="$(echo "${update_images}" | tr " " "\n" | sort -u)"
65
66host_arch=$(dpkg-architecture -qDEB_HOST_ARCH)
67
68for image in ${update_images}; do
69 (
70 cd ${image}
71 image_arch=$(basename ${PWD} | cut -f2 -d '-')
72 skip="skip"
73 if [ -f gerrit-branches ]; then
74 # Build only from branches mentioned in gerrit-branches
75 if grep -q "^${GERRIT_BRANCH}\$" gerrit-branches; then
76 skip="no"
77 fi
78 elif [ x"${GERRIT_BRANCH}" = x"master" ]; then
79 # No gerrit-branch file, so build only from "master" branch.
80 skip="no"
81 fi
82 case "${skip}:${host_arch}:${image_arch}" in
83 "skip:"*)
84 echo "Skipping: don't need to build ${image} on branch ${GERRIT_BRANCH}"
85 ;;
86 "no:amd64:amd64"|"no:amd64:i386"|"no:arm64:arm64"|"no:armhf:armhf")
87 echo "=== Start build: ${image} ==="
Paul Sokolovsky9c6dc902022-01-17 22:55:27 +030088 bash -x ./build.sh || echo "=== FAIL: ${image} ===" >> ${WORKSPACE}/log
Benjamin Copelandc78807d2019-04-02 08:54:42 +010089 ;;
90 *)
91 echo "Skipping: can't build for ${image_arch} on ${host_arch}"
92 ;;
93 esac
Benjamin Copelandc78807d2019-04-02 08:54:42 +010094 )||echo $image failed >> ${WORKSPACE}/log
95done
96