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