rusefi/firmware/gen_signature.sh

48 lines
1.7 KiB
Bash
Raw Normal View History

#!/bin/bash
2020-07-05 19:39:55 -07:00
# file gen_signature.sh
# fail fast
set -e
SHORT_BOARD_NAME=${1:-$SHORT_BOARD_NAME}
2024-09-07 18:32:39 -07:00
SCRIPT_NAME=$(basename "$0")
cd $(dirname "$0")
2020-07-05 19:39:55 -07:00
SIGNATURE_FILE_NAME=${META_OUTPUT_ROOT_FOLDER}tunerstudio/generated/signature_${SHORT_BOARD_NAME}.txt
echo "Generating signature for ${SHORT_BOARD_NAME} file $SIGNATURE_FILE_NAME"
TEMP_FILE="${SIGNATURE_FILE_NAME}.temp"
# generate a unique signature
date=`TZ=Europe/London date +"%Y.%m.%d"`
echo "! Generated by gen_signature.sh" > ${TEMP_FILE}
echo "! SIGNATURE_HASH is a built-in variable generated by config_definition-all.jar" >> ${TEMP_FILE}
# 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-09-07 18:32:39 -07:00
echo "! ${SCRIPT_NAME} Using env variable branch [$branchname]" | tee >> ${TEMP_FILE}
2023-12-01 19:19:46 -08:00
else
2024-09-07 18:32:39 -07:00
echo "! ${SCRIPT_NAME} Current branch is: $branchname" | tee >> ${TEMP_FILE}
2023-12-01 19:19:46 -08:00
fi
if [ -z "${signature_white_label}" ]; then
signature_white_label=rusEFI
2024-06-05 18:22:01 -07:00
fi
2024-03-18 07:37:41 -07:00
echo "#define TS_SIGNATURE \"${signature_white_label} $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-09-01 20:57:31 -07:00
# We redirect errors to /dev/null to suppress 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}
rm -f ${TEMP_FILE}
exit 0