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