blob: b390d3dcadbacb2134eb6cd484ac211545e5f3c9 [file] [log] [blame]
Chirayu Desai4663fc72022-01-18 03:24:02 +05301#!/bin/bash
Chirayu Desaicc931dc2022-07-08 19:43:32 +05302
3# SPDX-FileCopyrightText: 2022 The Calyx Institute
4#
5# SPDX-License-Identifier: Apache-2.0
6
Chirayu Desai4663fc72022-01-18 03:24:02 +05307#
8# build-desc-fingerprint:
9#
10# Update build.prop build description and fingerprint overrides to match stock
11#
12#
13##############################################################################
14
15
16### SET ###
17
18# use bash strict mode
19set -euo pipefail
Chirayu Desaie58c2972022-06-28 18:49:03 +053020
Chirayu Desai4663fc72022-01-18 03:24:02 +053021
22### TRAPS ###
23
24# trap signals for clean exit
Chirayu Desai4663fc72022-01-18 03:24:02 +053025trap 'error_m interrupted!' SIGINT
26
27### CONSTANTS ###
28readonly script_path="$(cd "$(dirname "$0")";pwd -P)"
Jis G Jacob4c84cfa2024-02-09 11:20:03 -050029readonly vars_path="${script_path}/../../../vendor/bliss/vars"
Michael Bestas73c1f732022-01-13 18:30:44 +020030readonly top="${script_path}/../../.."
Chirayu Desai4663fc72022-01-18 03:24:02 +053031
Chirayu Desaidd101d62022-03-01 23:38:44 +053032source "${vars_path}/pixels"
Chirayu Desaiaa56f052023-03-21 04:56:19 +053033source "${vars_path}/common"
Chirayu Desai4663fc72022-01-18 03:24:02 +053034
35## HELP MESSAGE (USAGE INFO)
36# TODO
37
38### FUNCTIONS ###
39
40
41
42# error message
43# ARG1: error message for STDERR
44# ARG2: error status
45error_m() {
46 echo "ERROR: ${1:-'failed.'}" 1>&2
47 return "${2:-1}"
48}
49
50# print help message.
51help_message() {
52 echo "${help_message:-'No help available.'}"
53}
54
55main() {
Chirayu Desai4663fc72022-01-18 03:24:02 +053056 if [[ $# -ne 0 ]]; then
57 local ds="${@}"
58 else
59 local ds="${devices[@]}"
60 fi
61
Nolen Johnson019d3272022-07-12 11:41:16 -040062 # Update the makefiles
Chirayu Desai4663fc72022-01-18 03:24:02 +053063 for d in ${ds}; do
64 (
65 local dv="${vars_path}/${d}"
66 source "${dv}"
Jis G Jacob4c84cfa2024-02-09 11:20:03 -050067 local mk="$(ls ${top}/device/google/*/bliss_${d}.mk)"
Chirayu Desaiaa56f052023-03-21 04:56:19 +053068 desc="${d}-user ${android_version} ${build_id} ${build_number} release-keys"
69 fingerprint="google/${d}/${d}:${android_version}/${build_id}/${build_number}:user/release-keys"
70 sed -i "/PRIVATE_BUILD_DESC/c\ PRIVATE_BUILD_DESC=\"${desc}\"" "${mk}"
71 sed -i "/BUILD_FINGERPRINT/c\BUILD_FINGERPRINT\ :=\ ${fingerprint}" "${mk}"
Chirayu Desai4663fc72022-01-18 03:24:02 +053072 )
73 done
Nolen Johnson019d3272022-07-12 11:41:16 -040074
75 # Commit the changes
76 for d in ${ds}; do
77 (
78 local dv="${vars_path}/${d}"
79 source "${dv}"
Jis G Jacob4c84cfa2024-02-09 11:20:03 -050080 local dir="$(ls ${top}/device/google/*/bliss_${d}.mk | sed s#/bliss_${d}.mk##)"
Michael Bestas95724812022-08-26 22:46:25 +030081 cd "${dir}"
Nolen Johnson019d3272022-07-12 11:41:16 -040082 if [[ -n "$(git status --porcelain)" ]]; then
83 git commit -a -m "Update fingerprint/build description from ${build_id}"
84 fi
85 )
86 done
Chirayu Desai4663fc72022-01-18 03:24:02 +053087}
88
89### RUN PROGRAM ###
90
91main "${@}"
92
93
94##