2020-06-28 10:39:09 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-07-05 19:39:55 -07:00
|
|
|
# file gen_signature.sh
|
|
|
|
|
2024-02-27 06:02:11 -08:00
|
|
|
# fail fast
|
|
|
|
set -e
|
|
|
|
|
2024-02-07 15:28:56 -08:00
|
|
|
SHORT_BOARD_NAME=${1:-$SHORT_BOARD_NAME}
|
2020-06-28 10:39:09 -07:00
|
|
|
|
2024-02-07 15:28:56 -08:00
|
|
|
cd $(dirname "$0")
|
2020-07-05 19:39:55 -07:00
|
|
|
|
2024-01-30 04:53:27 -08:00
|
|
|
SIGNATURE_FILE_NAME=tunerstudio/generated/signature_${SHORT_BOARD_NAME}.txt
|
|
|
|
echo "Generating signature for ${SHORT_BOARD_NAME}"
|
2020-06-28 10:39:09 -07:00
|
|
|
|
2024-02-27 06:07:36 -08:00
|
|
|
TEMP_FILE="${SIGNATURE_FILE_NAME}.temp"
|
|
|
|
|
2020-06-28 10:39:09 -07:00
|
|
|
# generate a unique signature
|
2021-03-05 17:16:59 -08:00
|
|
|
date=`TZ=Europe/London date +"%Y.%m.%d"`
|
2024-02-27 06:07:36 -08:00
|
|
|
echo "! Generated by gen_signature.sh" > ${TEMP_FILE}
|
2020-06-28 10:39:09 -07:00
|
|
|
|
2024-02-27 06:07:36 -08:00
|
|
|
echo "! SIGNATURE_HASH is a built-in variable generated by config_definition-all.jar" >> ${TEMP_FILE}
|
2020-06-28 10:39:09 -07:00
|
|
|
|
2023-01-19 22:14:05 -08:00
|
|
|
# read the current git branch name
|
|
|
|
branchname=`git branch --show-current`
|
2023-12-01 19:19:46 -08:00
|
|
|
if [ "${branchname}" = "" ]; then
|
|
|
|
# custom board, empty value while executed within submodule
|
2024-05-31 15:00:45 -07:00
|
|
|
branchname=${AUTOMATION_REF}
|
2024-05-31 07:31:16 -07:00
|
|
|
echo "! Using env variable branch $branchname" >> ${TEMP_FILE}
|
2023-12-01 19:19:46 -08:00
|
|
|
else
|
2024-02-27 06:07:36 -08:00
|
|
|
echo "! Current branch is: $branchname" >> ${TEMP_FILE}
|
2023-12-01 19:19:46 -08:00
|
|
|
fi
|
2023-01-19 22:14:05 -08:00
|
|
|
|
2024-06-05 18:22:01 -07:00
|
|
|
if [ -z "${WHITELABEL}" ]; then
|
2024-03-18 07:37:41 -07:00
|
|
|
WHITELABEL=rusEFI
|
2024-06-05 18:22:01 -07:00
|
|
|
fi
|
2024-03-18 07:37:41 -07:00
|
|
|
|
|
|
|
echo "#define TS_SIGNATURE \"${WHITELABEL} $branchname.$date.${SHORT_BOARD_NAME}.@@SIGNATURE_HASH@@\"" >> ${TEMP_FILE}
|
2024-02-27 06:39:47 -08:00
|
|
|
|
2024-02-27 06:54:54 -08:00
|
|
|
# We will generate the signature in a temp file, then only use it if it has changed.
|
|
|
|
# This is to avoid updating the timestamp of the signature file, which would cause the configs to regenerate when they don't need to.
|
2024-02-27 06:39:47 -08:00
|
|
|
# cmp compares files to see if they are different. If they are different or if SIGNATURE_FILE_NAME doesn't exist, the mv command will run.
|
2024-02-27 06:54:54 -08:00
|
|
|
# We redirect errors to /dev/null to supress the error if SIGNATURE_FILE_NAME doesn't exist
|
2024-02-27 06:39:47 -08:00
|
|
|
cmp ${TEMP_FILE} ${SIGNATURE_FILE_NAME} 2>/dev/null || mv -f ${TEMP_FILE} ${SIGNATURE_FILE_NAME}
|
2024-02-27 06:07:36 -08:00
|
|
|
rm -f ${TEMP_FILE}
|
2020-07-02 09:33:31 -07:00
|
|
|
|
2020-06-28 10:39:09 -07:00
|
|
|
exit 0
|