blob: f216fa3fc3329061ce3939c2c12329b3505425c1 [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
12sudo apt-get -y -qq install --no-install-recommends dpkg-dev
13
14if ! type aws
15then
16 sudo apt-get -y -qq update
17 sudo apt-get -y -qq install --no-install-recommends unzip
18 curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
Paul Sokolovsky0810ea22022-11-11 22:23:41 +030019 unzip -q awscliv2.zip
Paul Sokolovskyb5dca4b2022-11-11 21:52:03 +030020 sudo ./aws/install
21fi
22
Riku Voipiob8ffb562020-10-12 11:44:40 +030023rm -f ${WORKSPACE}/log
Benjamin Copelandc78807d2019-04-02 08:54:42 +010024cd dockerfiles/
25
Paul Sokolovskyb5dca4b2022-11-11 21:52:03 +030026aws configure list
27aws s3 cp --recursive s3://trustedfirmware-private/armclang/ .
28find .
29
30df -h
31
Benjamin Copelandc78807d2019-04-02 08:54:42 +010032git_previous_commit=$(git rev-parse HEAD~1)
33git_commit=$(git rev-parse HEAD)
34files=$(git diff --name-only ${git_previous_commit} ${git_commit})
35echo Changes in: ${files}
Riku Voipiob8ffb562020-10-12 11:44:40 +030036changed_dirs=$(dirname ${files}|sort -u)
Benjamin Copelandc78807d2019-04-02 08:54:42 +010037
38update_images=""
39for dir in ${changed_dirs}; do
40 # Find the closest directory with build.sh. This is, primarily,
41 # to handle changes to tcwg-base/tcwg-build/tcwg-builslave/* directories.
42 while [ ! -e ${dir}/build.sh -a ! -e ${dir}/.git ]; do
43 dir=$(dirname ${dir})
44 done
45 # Add this and all dependant images in the update.
46 dir_basename=$(basename ${dir})
47 case "${dir_basename}" in
48 "tcwg-"*)
49 # ${dir} is one of generic tcwg-base/* directories. Add dependent
50 # images to the list.
51 update_images="${update_images} $(dirname $(find . -path "*-${dir_basename}*/build.sh" | sed -e "s#^\./##g"))"
52 ;;
Riku Voipiob8ffb562020-10-12 11:44:40 +030053 ".")
54 continue
55 ;;
Benjamin Copelandc78807d2019-04-02 08:54:42 +010056 *)
57 update_images="${update_images} $(dirname $(find ${dir} -name build.sh))"
58 ;;
59 esac
60done
61update_images="$(echo "${update_images}" | tr " " "\n" | sort -u)"
62
63host_arch=$(dpkg-architecture -qDEB_HOST_ARCH)
64
65for image in ${update_images}; do
66 (
67 cd ${image}
68 image_arch=$(basename ${PWD} | cut -f2 -d '-')
69 skip="skip"
70 if [ -f gerrit-branches ]; then
71 # Build only from branches mentioned in gerrit-branches
72 if grep -q "^${GERRIT_BRANCH}\$" gerrit-branches; then
73 skip="no"
74 fi
75 elif [ x"${GERRIT_BRANCH}" = x"master" ]; then
76 # No gerrit-branch file, so build only from "master" branch.
77 skip="no"
78 fi
79 case "${skip}:${host_arch}:${image_arch}" in
80 "skip:"*)
81 echo "Skipping: don't need to build ${image} on branch ${GERRIT_BRANCH}"
82 ;;
83 "no:amd64:amd64"|"no:amd64:i386"|"no:arm64:arm64"|"no:armhf:armhf")
84 echo "=== Start build: ${image} ==="
Paul Sokolovsky9c6dc902022-01-17 22:55:27 +030085 bash -x ./build.sh || echo "=== FAIL: ${image} ===" >> ${WORKSPACE}/log
Benjamin Copelandc78807d2019-04-02 08:54:42 +010086 ;;
87 *)
88 echo "Skipping: can't build for ${image_arch} on ${host_arch}"
89 ;;
90 esac
Benjamin Copelandc78807d2019-04-02 08:54:42 +010091 )||echo $image failed >> ${WORKSPACE}/log
92done
93