Chirayu Desai | 4663fc7 | 2022-01-18 03:24:02 +0530 | [diff] [blame] | 1 | #!/bin/bash |
Chirayu Desai | cc931dc | 2022-07-08 19:43:32 +0530 | [diff] [blame] | 2 | |
| 3 | # SPDX-FileCopyrightText: 2022 The Calyx Institute |
| 4 | # |
| 5 | # SPDX-License-Identifier: Apache-2.0 |
| 6 | |
Chirayu Desai | 4663fc7 | 2022-01-18 03:24:02 +0530 | [diff] [blame] | 7 | # |
| 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 |
| 19 | set -euo pipefail |
Chirayu Desai | e58c297 | 2022-06-28 18:49:03 +0530 | [diff] [blame] | 20 | |
Chirayu Desai | 4663fc7 | 2022-01-18 03:24:02 +0530 | [diff] [blame] | 21 | |
| 22 | ### TRAPS ### |
| 23 | |
| 24 | # trap signals for clean exit |
Chirayu Desai | 4663fc7 | 2022-01-18 03:24:02 +0530 | [diff] [blame] | 25 | trap 'error_m interrupted!' SIGINT |
| 26 | |
| 27 | ### CONSTANTS ### |
| 28 | readonly script_path="$(cd "$(dirname "$0")";pwd -P)" |
Jis G Jacob | 4c84cfa | 2024-02-09 11:20:03 -0500 | [diff] [blame] | 29 | readonly vars_path="${script_path}/../../../vendor/bliss/vars" |
Michael Bestas | 73c1f73 | 2022-01-13 18:30:44 +0200 | [diff] [blame] | 30 | readonly top="${script_path}/../../.." |
Chirayu Desai | 4663fc7 | 2022-01-18 03:24:02 +0530 | [diff] [blame] | 31 | |
Chirayu Desai | dd101d6 | 2022-03-01 23:38:44 +0530 | [diff] [blame] | 32 | source "${vars_path}/pixels" |
Chirayu Desai | aa56f05 | 2023-03-21 04:56:19 +0530 | [diff] [blame] | 33 | source "${vars_path}/common" |
Chirayu Desai | 4663fc7 | 2022-01-18 03:24:02 +0530 | [diff] [blame] | 34 | |
| 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 |
| 45 | error_m() { |
| 46 | echo "ERROR: ${1:-'failed.'}" 1>&2 |
| 47 | return "${2:-1}" |
| 48 | } |
| 49 | |
| 50 | # print help message. |
| 51 | help_message() { |
| 52 | echo "${help_message:-'No help available.'}" |
| 53 | } |
| 54 | |
| 55 | main() { |
Chirayu Desai | 4663fc7 | 2022-01-18 03:24:02 +0530 | [diff] [blame] | 56 | if [[ $# -ne 0 ]]; then |
| 57 | local ds="${@}" |
| 58 | else |
| 59 | local ds="${devices[@]}" |
| 60 | fi |
| 61 | |
Nolen Johnson | 019d327 | 2022-07-12 11:41:16 -0400 | [diff] [blame] | 62 | # Update the makefiles |
Chirayu Desai | 4663fc7 | 2022-01-18 03:24:02 +0530 | [diff] [blame] | 63 | for d in ${ds}; do |
| 64 | ( |
| 65 | local dv="${vars_path}/${d}" |
| 66 | source "${dv}" |
Jis G Jacob | 4c84cfa | 2024-02-09 11:20:03 -0500 | [diff] [blame] | 67 | local mk="$(ls ${top}/device/google/*/bliss_${d}.mk)" |
Chirayu Desai | aa56f05 | 2023-03-21 04:56:19 +0530 | [diff] [blame] | 68 | 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 Desai | 4663fc7 | 2022-01-18 03:24:02 +0530 | [diff] [blame] | 72 | ) |
| 73 | done |
Nolen Johnson | 019d327 | 2022-07-12 11:41:16 -0400 | [diff] [blame] | 74 | |
| 75 | # Commit the changes |
| 76 | for d in ${ds}; do |
| 77 | ( |
| 78 | local dv="${vars_path}/${d}" |
| 79 | source "${dv}" |
Jis G Jacob | 4c84cfa | 2024-02-09 11:20:03 -0500 | [diff] [blame] | 80 | local dir="$(ls ${top}/device/google/*/bliss_${d}.mk | sed s#/bliss_${d}.mk##)" |
Michael Bestas | 9572481 | 2022-08-26 22:46:25 +0300 | [diff] [blame] | 81 | cd "${dir}" |
Nolen Johnson | 019d327 | 2022-07-12 11:41:16 -0400 | [diff] [blame] | 82 | if [[ -n "$(git status --porcelain)" ]]; then |
| 83 | git commit -a -m "Update fingerprint/build description from ${build_id}" |
| 84 | fi |
| 85 | ) |
| 86 | done |
Chirayu Desai | 4663fc7 | 2022-01-18 03:24:02 +0530 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | ### RUN PROGRAM ### |
| 90 | |
| 91 | main "${@}" |
| 92 | |
| 93 | |
| 94 | ## |