mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 18:48:13 -07:00
mkversion.sh
: now regenerates version_pm3.c (and consequently the binaries) only when needed
and add --force to forcibly regenerate version_pm3.c and small fixes: * document mkversion.sh usage * remove call to mkversion.sh in client/experimental_lib/CMakeLists.txt on release * remove call to old `mkversion.pl` in bootrom/Makefile * just in case, mkversion.sh takes care of atomic write of the file
This commit is contained in:
parent
9dfc39dbbf
commit
cb72897b17
8 changed files with 61 additions and 15 deletions
|
@ -1,5 +1,13 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$1" = "" ]; then
|
||||
echo "To report a short string about the current version:"
|
||||
echo " $0 --short"
|
||||
echo "To regenerate version_pm3.c if needed:"
|
||||
echo " $0 [--force] [--undecided] path/to/version_pm3.c"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Output a version_pm3.c file that includes information about the current build
|
||||
# From mkversion.pl
|
||||
# pure sh POSIX as now even on Windows we use WSL or ProxSpace with sh available
|
||||
|
@ -13,6 +21,27 @@ if [ "$1" = "--short" ]; then
|
|||
SHORT=true
|
||||
shift
|
||||
fi
|
||||
FORCE=false
|
||||
if [ "$1" = "--force" ]; then
|
||||
FORCE=true
|
||||
shift
|
||||
fi
|
||||
UNDECIDED=false
|
||||
if [ "$1" = "--undecided" ]; then
|
||||
UNDECIDED=true
|
||||
shift
|
||||
fi
|
||||
VERSIONSRC="$1"
|
||||
|
||||
if ! $SHORT && [ "$VERSIONSRC" = "" ]; then
|
||||
echo "Error: $0 is missing its destination filename"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if $SHORT && [ "$VERSIONSRC" != "" ]; then
|
||||
echo "Error: can't output a short string and generate file at the same time"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if you are making your own fork, change this line to reflect your fork-name
|
||||
fullgitinfo="Iceman"
|
||||
|
@ -27,7 +56,7 @@ if [ "$commandGIT" != "" ]; then
|
|||
# now avoiding the "fatal: No names found, cannot describe anything." error by fallbacking to abbrev hash in such case
|
||||
gitversion=$(git describe --dirty --always)
|
||||
gitbranch=$(git rev-parse --abbrev-ref HEAD)
|
||||
if [ "$1" != "--undecided" ]; then
|
||||
if $UNDECIDED; then
|
||||
if [ "$gitversion" != "${gitversion%-dirty}" ]; then
|
||||
clean=0
|
||||
else
|
||||
|
@ -68,7 +97,21 @@ sha=$(
|
|||
if [ "$sha" = "" ]; then
|
||||
sha="no sha256"
|
||||
fi
|
||||
cat <<EOF
|
||||
|
||||
REDO=true
|
||||
if ! $FORCE && [ -f "$VERSIONSRC" ]; then
|
||||
# version src file exists, check if it needs to be updated
|
||||
# file parser quite fragile, be careful if you edit VERSIONSRC template below...
|
||||
oldclean=$(sed '13s/.*\([0-9]\+\).*/\1/;13!d' "$VERSIONSRC")
|
||||
oldfullgitinfo=$(sed '14s/.*"\([^"]*\)".*/\1/;14!d' "$VERSIONSRC")
|
||||
oldsha=$(sed '16s/.*"\([^"]*\)".*/\1/;16!d' "$VERSIONSRC")
|
||||
if [ "$oldclean" = "$clean" ] && [ "$oldfullgitinfo" = "$fullgitinfo" ] && [ "$oldsha" = "$sha" ]; then
|
||||
REDO=false
|
||||
fi
|
||||
fi
|
||||
if $REDO; then
|
||||
# use a tmp file to avoid concurrent call to mkversion to parse a half-written file.
|
||||
cat > "${VERSIONSRC}.tmp" <<EOF
|
||||
#include "common.h"
|
||||
/* Generated file, do not edit */
|
||||
#ifndef ON_DEVICE
|
||||
|
@ -87,3 +130,5 @@ const struct version_information_t SECTVERSINFO g_version_information = {
|
|||
"$sha"
|
||||
};
|
||||
EOF
|
||||
mv "${VERSIONSRC}.tmp" "${VERSIONSRC}"
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue