blob: 5c8f0663547d49c4014564270a27da173883fb86 [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 "########################################################################"
10
Paul Sokolovskyccdd8542022-11-11 17:53:32 +030011# For dpkg-architecture call below
12sudo apt-get -y -qq install --no-install-recommends dpkg-dev
13
Paul Sokolovsky8364b0d2022-11-11 12:35:21 +030014if ! 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"
19 unzip awscliv2.zip
20 sudo ./aws/install
21fi
22
Paul Sokolovskydedc4832022-01-17 23:26:30 +030023rm -f ${WORKSPACE}/log
24cd dockerfiles/
25
Paul Sokolovsky8364b0d2022-11-11 12:35:21 +030026aws configure list
Paul Sokolovsky1080e1d2022-11-11 20:49:12 +030027aws s3 cp --recursive s3://trustedfirmware-private/armclang/ .
Paul Sokolovsky2eae0672022-11-11 18:17:38 +030028find .
Paul Sokolovsky8364b0d2022-11-11 12:35:21 +030029
Paul Sokolovskyd63cfd92022-11-11 21:32:06 +030030df -h
31
Paul Sokolovskydedc4832022-01-17 23:26:30 +030032git_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}
36changed_dirs=$(dirname ${files}|sort -u)
37
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 ;;
53 ".")
54 continue
55 ;;
56 *)
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} ==="
85 bash -x ./build.sh || echo "=== FAIL: ${image} ===" >> ${WORKSPACE}/log
86 ;;
87 *)
88 echo "Skipping: can't build for ${image_arch} on ${host_arch}"
89 ;;
90 esac
91 )||echo $image failed >> ${WORKSPACE}/log
92done
93