rusefi/firmware/gen_signature.sh

43 lines
1.5 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}
cd $(dirname "$0")
2020-07-05 19:39:55 -07:00
SIGNATURE_FILE_NAME=tunerstudio/generated/signature_${SHORT_BOARD_NAME}.txt
echo "Generating signature for ${SHORT_BOARD_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
branchname="default"
echo "! Using default branch $branchname" >> ${TEMP_FILE}
2023-12-01 19:19:46 -08:00
else
echo "! Current branch is: $branchname" >> ${TEMP_FILE}
2023-12-01 19:19:46 -08:00
fi
echo "#define TS_SIGNATURE \"rusEFI $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}
rm -f ${TEMP_FILE}
exit 0