From e71accdc8dea5162faa395d7f493ade608662b44 Mon Sep 17 00:00:00 2001 From: "Shawn M." Date: Mon, 2 Sep 2024 14:01:26 -0700 Subject: [PATCH] Update genbuild.sh --- share/genbuild.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/share/genbuild.sh b/share/genbuild.sh index dfc730c7..fd36703f 100755 --- a/share/genbuild.sh +++ b/share/genbuild.sh @@ -1,10 +1,12 @@ #!/bin/sh -# Needs root + if [ $# -gt 0 ]; then FILE="$1" shift if [ -f "$FILE" ]; then INFO="$(head -n 1 "$FILE")" + else + INFO="" fi else echo "Usage: $0 " @@ -13,13 +15,16 @@ fi if [ -e "$(which git)" ]; then # clean 'dirty' status of touched files that haven't been modified - git diff >/dev/null 2>/dev/null + git diff >/dev/null 2>/dev/null # get a string like "v0.6.0-66-g59887e8-dirty" DESC="$(git describe --dirty 2>/dev/null)" # get a string like "2012-04-10 16:27:19 +0200" TIME="$(git log -n 1 --format="%ci")" +else + DESC="" + TIME="" fi if [ -n "$DESC" ]; then @@ -31,5 +36,7 @@ fi # only update build.h if necessary if [ "$INFO" != "$NEWINFO" ]; then echo "$NEWINFO" >"$FILE" - echo "#define BUILD_DATE \"$TIME\"" >>"$FILE" + if [ -n "$TIME" ]; then + echo "#define BUILD_DATE \"$TIME\"" >>"$FILE" + fi fi