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