From f0a440d151b615126d2d1dc5498e6c83fafd08b5 Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Sat, 17 Feb 2024 19:16:39 +0100 Subject: [PATCH 1/8] configure: enable read Git hash and date from file --- configure | 23 +++++++++++++++++++++++ configure.ac | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/configure b/configure index cedd9e3d5a4..75f6dc28ead 100755 --- a/configure +++ b/configure @@ -4939,6 +4939,7 @@ GRASS_BIN="${DSTDIR}/bin.${ARCH}" # Set GRASS_VERSION_* GRASS_VERSION_FILE=include/VERSION +GRASS_VERSION_GIT_FILE=include/VERSION_GIT GRASS_VERSION_MAJOR=`sed -n 1p "${GRASS_VERSION_FILE}"` GRASS_VERSION_MINOR=`sed -n 2p "${GRASS_VERSION_FILE}"` GRASS_VERSION_RELEASE=`sed -n 3p "${GRASS_VERSION_FILE}"` @@ -4996,6 +4997,25 @@ printf "%s\n" "no" >&6; } fi +as_ac_File=`printf "%s\n" "ac_cv_file_$GRASS_VERSION_GIT_FILE" | $as_tr_sh` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $GRASS_VERSION_GIT_FILE" >&5 +printf %s "checking for $GRASS_VERSION_GIT_FILE... " >&6; } + +test "$cross_compiling" = yes && + as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 +if test -r "$GRASS_VERSION_GIT_FILE"; then + eval "$as_ac_File=yes" +else + eval "$as_ac_File=no" +fi +eval ac_res=\$$as_ac_File + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_File"\" = x"yes" +then : + +fi + if test "$GIT" != "no" ; then GRASS_VERSION_GIT=`$GIT rev-parse --short HEAD 2>/dev/null` if test -z "$GRASS_VERSION_GIT"; then @@ -5009,6 +5029,9 @@ if test "$GIT" != "no" ; then if test -z "$GRASS_HEADERS_GIT_DATE"; then GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'` fi +elif test "$ac_cv_file_include_VERSION_GIT" == "yes"; then + GRASS_HEADERS_GIT_HASH=$(sed -n 1p "${GRASS_VERSION_GIT_FILE}") + GRASS_HEADERS_GIT_DATE=$(sed -n 2p "${GRASS_VERSION_GIT_FILE}") fi diff --git a/configure.ac b/configure.ac index 2900d2689dd..e405a699cc5 100644 --- a/configure.ac +++ b/configure.ac @@ -144,6 +144,7 @@ AC_SUBST(GRASS_BIN) # Set GRASS_VERSION_* GRASS_VERSION_FILE=include/VERSION +GRASS_VERSION_GIT_FILE=include/VERSION_GIT GRASS_VERSION_MAJOR=`sed -n 1p "${GRASS_VERSION_FILE}"` GRASS_VERSION_MINOR=`sed -n 2p "${GRASS_VERSION_FILE}"` GRASS_VERSION_RELEASE=`sed -n 3p "${GRASS_VERSION_FILE}"` @@ -160,6 +161,7 @@ GRASS_VERSION_GIT="exported" GRASS_HEADERS_GIT_HASH="${GRASS_VERSION_NUMBER}" GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'` AC_PATH_PROG(GIT, git, no) +AC_CHECK_FILE([$GRASS_VERSION_GIT_FILE]) if test "$GIT" != "no" ; then GRASS_VERSION_GIT=`$GIT rev-parse --short HEAD 2>/dev/null` if test -z "$GRASS_VERSION_GIT"; then @@ -173,6 +175,9 @@ if test "$GIT" != "no" ; then if test -z "$GRASS_HEADERS_GIT_DATE"; then GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'` fi +elif test "$ac_cv_file_include_VERSION_GIT" == "yes"; then + GRASS_HEADERS_GIT_HASH=$(sed -n 1p "${GRASS_VERSION_GIT_FILE}") + GRASS_HEADERS_GIT_DATE=$(sed -n 2p "${GRASS_VERSION_GIT_FILE}") fi AC_SUBST(GRASS_VERSION_FILE) From 279ccec089927b7cf0451c09ee5451cda67936a8 Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Sat, 17 Feb 2024 20:06:48 +0100 Subject: [PATCH 2/8] fix git conditional --- configure | 4 +++- configure.ac | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 75f6dc28ead..14da3087589 100755 --- a/configure +++ b/configure @@ -5029,7 +5029,9 @@ if test "$GIT" != "no" ; then if test -z "$GRASS_HEADERS_GIT_DATE"; then GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'` fi -elif test "$ac_cv_file_include_VERSION_GIT" == "yes"; then +fi +if test $GRASS_VERSION_GIT == "exported" && \ + test "$ac_cv_file_include_VERSION_GIT" == "yes"; then GRASS_HEADERS_GIT_HASH=$(sed -n 1p "${GRASS_VERSION_GIT_FILE}") GRASS_HEADERS_GIT_DATE=$(sed -n 2p "${GRASS_VERSION_GIT_FILE}") fi diff --git a/configure.ac b/configure.ac index e405a699cc5..763b9c53064 100644 --- a/configure.ac +++ b/configure.ac @@ -175,7 +175,9 @@ if test "$GIT" != "no" ; then if test -z "$GRASS_HEADERS_GIT_DATE"; then GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'` fi -elif test "$ac_cv_file_include_VERSION_GIT" == "yes"; then +fi +if test $GRASS_VERSION_GIT == "exported" && \ + test "$ac_cv_file_include_VERSION_GIT" == "yes"; then GRASS_HEADERS_GIT_HASH=$(sed -n 1p "${GRASS_VERSION_GIT_FILE}") GRASS_HEADERS_GIT_DATE=$(sed -n 2p "${GRASS_VERSION_GIT_FILE}") fi From 0c0ffa34c55b06b8a452354812aa716e75cb9d50 Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Sun, 18 Feb 2024 15:55:10 +0100 Subject: [PATCH 3/8] add git version file generation script --- utils/generate_version_git_file.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 utils/generate_version_git_file.sh diff --git a/utils/generate_version_git_file.sh b/utils/generate_version_git_file.sh new file mode 100755 index 00000000000..a2eb7439e3f --- /dev/null +++ b/utils/generate_version_git_file.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +set -eu + +this_script=$(basename "$0") +version_file=include/VERSION +version_git_file=include/VERSION_GIT + +if [ ! -f "$version_file" ]; then + echo "Error: execute ${this_script} from repository top level." + exit 1 +fi + +if ! (git log -1 >/dev/null); then + echo "Error: git not available." + exit 1 +fi + +grass_version_git=$(git rev-parse --short HEAD) +gitdate_utc_local=$(TZ=UTC0 git log -1 --date=iso-local --pretty=format:"%cd" -- include) +grass_headers_git_date=$(echo "$gitdate_utc_local" \ + | sed 's/ /T/' | sed 's/ //' | sed 's/\(..\)$/:\1/') + +cat << EOF > "$version_git_file" +$grass_version_git +$grass_headers_git_date + +EOF From cd0b746e7ef3ba8d492708d72ee57380144815aa Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Mon, 19 Feb 2024 21:24:31 +0100 Subject: [PATCH 4/8] add generated files to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index bc8ac301e89..ed39ba99dee 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,5 @@ test_keyvalue_result.txt # ignore paths generated by helper tools node_modules +include/VERSION_GIT +core_modules_with_last_commit.json From 833593f16c868359361fa7a81f0d5edfc41eb515 Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Mon, 19 Feb 2024 21:43:03 +0100 Subject: [PATCH 5/8] revert file needed for create_release_draft.yml --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index ed39ba99dee..9a44ace144b 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,3 @@ test_keyvalue_result.txt # ignore paths generated by helper tools node_modules include/VERSION_GIT -core_modules_with_last_commit.json From 4db5b549bdefb6eae9047f418f9582af4216a435 Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Tue, 20 Feb 2024 10:29:03 +0100 Subject: [PATCH 6/8] no empy line --- utils/generate_version_git_file.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/generate_version_git_file.sh b/utils/generate_version_git_file.sh index a2eb7439e3f..bd604b55112 100755 --- a/utils/generate_version_git_file.sh +++ b/utils/generate_version_git_file.sh @@ -24,5 +24,4 @@ grass_headers_git_date=$(echo "$gitdate_utc_local" \ cat << EOF > "$version_git_file" $grass_version_git $grass_headers_git_date - EOF From 8705ddba0af7695afa9e582727cfa32effaae66d Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Tue, 20 Feb 2024 11:13:12 +0100 Subject: [PATCH 7/8] set GRASS_VERSION_GIT --- configure | 1 + configure.ac | 1 + 2 files changed, 2 insertions(+) diff --git a/configure b/configure index 14da3087589..91fc445e04a 100755 --- a/configure +++ b/configure @@ -5033,6 +5033,7 @@ fi if test $GRASS_VERSION_GIT == "exported" && \ test "$ac_cv_file_include_VERSION_GIT" == "yes"; then GRASS_HEADERS_GIT_HASH=$(sed -n 1p "${GRASS_VERSION_GIT_FILE}") + GRASS_VERSION_GIT=$GRASS_HEADERS_GIT_HASH GRASS_HEADERS_GIT_DATE=$(sed -n 2p "${GRASS_VERSION_GIT_FILE}") fi diff --git a/configure.ac b/configure.ac index 763b9c53064..d5c64f3c27f 100644 --- a/configure.ac +++ b/configure.ac @@ -179,6 +179,7 @@ fi if test $GRASS_VERSION_GIT == "exported" && \ test "$ac_cv_file_include_VERSION_GIT" == "yes"; then GRASS_HEADERS_GIT_HASH=$(sed -n 1p "${GRASS_VERSION_GIT_FILE}") + GRASS_VERSION_GIT=$GRASS_HEADERS_GIT_HASH GRASS_HEADERS_GIT_DATE=$(sed -n 2p "${GRASS_VERSION_GIT_FILE}") fi From 1b4e18fc1a6876a4b5bc04db06a509212189fa2f Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Sat, 23 Mar 2024 18:39:54 +0100 Subject: [PATCH 8/8] let configure use the more broadly supported commands to get headers commit date --- configure | 7 ++++++- configure.ac | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 91fc445e04a..bc58bfe0df2 100755 --- a/configure +++ b/configure @@ -5016,6 +5016,8 @@ then : fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GRASS GIS headers commit date" >&5 +printf %s "checking for GRASS GIS headers commit date... " >&6; } if test "$GIT" != "no" ; then GRASS_VERSION_GIT=`$GIT rev-parse --short HEAD 2>/dev/null` if test -z "$GRASS_VERSION_GIT"; then @@ -5025,7 +5027,8 @@ if test "$GIT" != "no" ; then if test -z "$GRASS_HEADERS_GIT_HASH"; then GRASS_HEADERS_GIT_HASH="${GRASS_VERSION_NUMBER}" fi - GRASS_HEADERS_GIT_DATE=`date -d $($GIT log -1 --pretty=format:"%cI" -- "${SRCDIR}/include") -u +%FT%T%z | sed 's/\(..\)$/:\1/'` 2>/dev/null + gitdate_utc_local=$(TZ=UTC0 git log -1 --date=iso-local --pretty=format:"%cd" -- include) + GRASS_HEADERS_GIT_DATE=$(echo "$gitdate_utc_local" | sed 's/ /T/' | sed 's/ //' | sed 's/\(..\)$/:\1/') if test -z "$GRASS_HEADERS_GIT_DATE"; then GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'` fi @@ -5036,6 +5039,8 @@ if test $GRASS_VERSION_GIT == "exported" && \ GRASS_VERSION_GIT=$GRASS_HEADERS_GIT_HASH GRASS_HEADERS_GIT_DATE=$(sed -n 2p "${GRASS_VERSION_GIT_FILE}") fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $GRASS_HEADERS_GIT_DATE" >&5 +printf "%s\n" "$GRASS_HEADERS_GIT_DATE" >&6; } diff --git a/configure.ac b/configure.ac index d5c64f3c27f..57af5a5923a 100644 --- a/configure.ac +++ b/configure.ac @@ -162,6 +162,7 @@ GRASS_HEADERS_GIT_HASH="${GRASS_VERSION_NUMBER}" GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'` AC_PATH_PROG(GIT, git, no) AC_CHECK_FILE([$GRASS_VERSION_GIT_FILE]) +AC_MSG_CHECKING(for GRASS GIS headers commit date) if test "$GIT" != "no" ; then GRASS_VERSION_GIT=`$GIT rev-parse --short HEAD 2>/dev/null` if test -z "$GRASS_VERSION_GIT"; then @@ -171,7 +172,8 @@ if test "$GIT" != "no" ; then if test -z "$GRASS_HEADERS_GIT_HASH"; then GRASS_HEADERS_GIT_HASH="${GRASS_VERSION_NUMBER}" fi - GRASS_HEADERS_GIT_DATE=`date -d $($GIT log -1 --pretty=format:"%cI" -- "${SRCDIR}/include") -u +%FT%T%z | sed 's/\(..\)$/:\1/'` 2>/dev/null + gitdate_utc_local=$(TZ=UTC0 git log -1 --date=iso-local --pretty=format:"%cd" -- include) + GRASS_HEADERS_GIT_DATE=$(echo "$gitdate_utc_local" | sed 's/ /T/' | sed 's/ //' | sed 's/\(..\)$/:\1/') if test -z "$GRASS_HEADERS_GIT_DATE"; then GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'` fi @@ -182,6 +184,7 @@ if test $GRASS_VERSION_GIT == "exported" && \ GRASS_VERSION_GIT=$GRASS_HEADERS_GIT_HASH GRASS_HEADERS_GIT_DATE=$(sed -n 2p "${GRASS_VERSION_GIT_FILE}") fi +AC_MSG_RESULT($GRASS_HEADERS_GIT_DATE) AC_SUBST(GRASS_VERSION_FILE) AC_SUBST(GRASS_VERSION_MAJOR)