Introduce script to update any var
* To make the manual build id / kernel tag update slightly less manual Usage: update-any-var.sh build_id SQ3A.220705.003 oriole raven # For Pixel 6 Jul 2022 TODO: Full automation Change-Id: Iea350df2653c623b8f8476de4aec9cd1f7461c45
This commit is contained in:
committed by
Michael Bestas
parent
8225cf77aa
commit
ed56c837cd
73
pixel/update-any-var.sh
Executable file
73
pixel/update-any-var.sh
Executable file
@@ -0,0 +1,73 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# update-vars:
|
||||||
|
#
|
||||||
|
# Update Pixel device-specific variables by parsing Google's pages
|
||||||
|
#
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
|
||||||
|
### SET ###
|
||||||
|
|
||||||
|
# use bash strict mode
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
|
||||||
|
### TRAPS ###
|
||||||
|
|
||||||
|
# trap signals for clean exit
|
||||||
|
trap 'error_m interrupted!' SIGINT
|
||||||
|
|
||||||
|
### CONSTANTS ###
|
||||||
|
readonly script_path="$(cd "$(dirname "$0")";pwd -P)"
|
||||||
|
readonly vars_path="${script_path}/../../../vendor/lineage/vars"
|
||||||
|
|
||||||
|
source "${vars_path}/pixels"
|
||||||
|
|
||||||
|
## HELP MESSAGE (USAGE INFO)
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
### FUNCTIONS ###
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# error message
|
||||||
|
# ARG1: error message for STDERR
|
||||||
|
# ARG2: error status
|
||||||
|
error_m() {
|
||||||
|
echo "ERROR: ${1:-'failed.'}" 1>&2
|
||||||
|
return "${2:-1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# print help message.
|
||||||
|
help_message() {
|
||||||
|
echo "${help_message:-'No help available.'}"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local key="${1}"
|
||||||
|
local value="${2}"
|
||||||
|
shift; shift
|
||||||
|
if [[ $# -ne 0 ]]; then
|
||||||
|
local files="${@}"
|
||||||
|
else
|
||||||
|
local files="${devices[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for f in ${files}; do
|
||||||
|
(
|
||||||
|
local fv="${vars_path}/${f}"
|
||||||
|
source "${fv}"
|
||||||
|
sed -i "/ prev_${key}=/c\readonly prev_${key}=\"${!key}\"" "${fv}"
|
||||||
|
sed -i "/ ${key}=/c\readonly ${key}=\"$value\"" "${fv}"
|
||||||
|
)
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
### RUN PROGRAM ###
|
||||||
|
|
||||||
|
main "${@}"
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
Reference in New Issue
Block a user