1#!/bin/bash
2
3# Copyright 2019 Google Inc. All rights reserved.
4
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8
9#     http://www.apache.org/licenses/LICENSE-2.0
10
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17set -e
18set -u
19
20source "${ANDROID_BUILD_TOP}/external/shflags/shflags"
21
22DEFINE_string kernel \
23  "" "Path to kernel repo checkout" "k"
24DEFINE_string uboot \
25  "" "Path to u-boot repo checkout" "u"
26
27FLAGS_HELP="USAGE: $0 [flags]"
28
29FLAGS "$@" || exit $?
30eval set -- "${FLAGS_ARGV}"
31
32if [ -z ${FLAGS_kernel} -o -z ${FLAGS_uboot} ]; then
33	flags_help
34	exit 1
35fi
36
37cd "${ANDROID_BUILD_TOP}/device/google/cuttlefish"
38Sha=`git rev-parse HEAD`
39cd - >/dev/null
40# cd "${FLAGS_uboot}/u-boot"
41cd "${ANDROID_BUILD_TOP}/device/google/cuttlefish_prebuilts"
42Sha="$Sha,`git rev-parse HEAD`"
43cd - >/dev/null
44if [ -d "${FLAGS_uboot}/external/arm-trusted-firmware/.git" ]; then
45    cd "${FLAGS_uboot}/external/arm-trusted-firmware"
46    Sha="$Sha,`git rev-parse HEAD`"
47    cd - >/dev/null
48else
49    Sha="$Sha,"'!TFA'
50fi
51if [ -d "${FLAGS_kernel}/common/.git" ]; then
52    cd "${FLAGS_kernel}/common"
53    Sha="$Sha,`git rev-parse HEAD`"
54    cd - >/dev/null
55else
56    Sha="$Sha,"'!kernelcommon'
57fi
58echo $Sha
59