Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packaging: Use GRASS version for non-git builds #2636

Merged
merged 3 commits into from
Nov 12, 2022

Conversation

sebastic
Copy link
Contributor

@sebastic sebastic commented Nov 8, 2022

As reported in #2610, rebuilding the GRASS sources (from the release tarballs) with no changes break the gdal-grass plugins because the GIS_H_VERSION value changes.

Non-git builds use the current timestamp in GRASS_HEADERS_GIT_HASH which is also used for GRASS_HEADERS_DATE.

This PR uses GRASS_VERSION_NUMBER for GRASS_HEADERS_GIT_HASH as a better value for non-git builds, that value won't change for simple rebuilds of the source tree.

Value is used in version check which fails when the value changes.

Fixes: OSGeo#2610
@neteler neteler added bug Something isn't working backport_needed C Related code is in C labels Nov 8, 2022
@neteler neteler added this to the 8.3.0 milestone Nov 8, 2022
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming a release when not using Git sounds good to me.

@sebastic
Copy link
Contributor Author

sebastic commented Nov 8, 2022

Assuming a release when not using Git sounds good to me.

When git is available the commit hash and date are used:

# get git short hash + date of last change in GRASS headers
# (and anything else in include)
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)
if test "$GIT" != "no" ; then
   GRASS_VERSION_GIT=`$GIT rev-parse --short HEAD 2>/dev/null`
   if test -z "$GRASS_VERSION_GIT"; then
      GRASS_VERSION_GIT="exported"
   fi
   GRASS_HEADERS_GIT_HASH=`$GIT log -1 --pretty=format:"%h" -- "${SRCDIR}/include" 2>/dev/null`
   if test -z "$GRASS_HEADERS_GIT_HASH"; then
      GRASS_HEADERS_GIT_HASH=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'`
   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
   if test -z "$GRASS_HEADERS_GIT_DATE"; then
      GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'`
   fi
fi

@nilason
Copy link
Contributor

nilason commented Nov 9, 2022

You need to run autoconf269 to update the configure file.

@sebastic
Copy link
Contributor Author

sebastic commented Nov 9, 2022

Generated files should not be committed.

@nilason
Copy link
Contributor

nilason commented Nov 9, 2022

Generated files should not be committed.

The generated file has been there in 20 years, since version 5. As long as it is there, the two should be in sync, no?
That being said, there is no reason -- as I see it -- this (i.e. generated file being part of source) have to remain the case indefinitely...

@nilason
Copy link
Contributor

nilason commented Nov 9, 2022

If git as a program is available, but building is made from a non-git repo (e.g. release tarball), the GRASS_HEADERS_GIT_HASH will still be reset with date on L152:

grass/configure.ac

Lines 144 to 158 in 5184a91

AC_PATH_PROG(GIT, git, no)
if test "$GIT" != "no" ; then
GRASS_VERSION_GIT=`$GIT rev-parse --short HEAD 2>/dev/null`
if test -z "$GRASS_VERSION_GIT"; then
GRASS_VERSION_GIT="exported"
fi
GRASS_HEADERS_GIT_HASH=`$GIT log -1 --pretty=format:"%h" -- "${SRCDIR}/include" 2>/dev/null`
if test -z "$GRASS_HEADERS_GIT_HASH"; then
GRASS_HEADERS_GIT_HASH=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'`
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
if test -z "$GRASS_HEADERS_GIT_DATE"; then
GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'`
fi
fi

Now, the question is whether L152 should change to:

      GRASS_HEADERS_GIT_HASH="${GRASS_VERSION_NUMBER}"

too, as a fallback if test on L150 fails?

@sebastic
Copy link
Contributor Author

sebastic commented Nov 9, 2022

Since there is no --without git configure option, that might be good.

Copy link
Contributor

@nilason nilason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
@wenzeslaus Please go ahead and merge if you still approve after latest changes.
@sebastic Thanks !

@neteler neteler merged commit fe2a30d into OSGeo:main Nov 12, 2022
neteler pushed a commit to neteler/grass that referenced this pull request Nov 12, 2022
As reported in OSGeo#2610, rebuilding the GRASS sources (from the release tarballs) with no changes break the gdal-grass plugins because the `GIS_H_VERSION` value changes.

Non-git builds use the current timestamp in `GRASS_HEADERS_GIT_HASH` which is also used for `GRASS_HEADERS_DATE`.

This PR uses `GRASS_VERSION_NUMBER` for `GRASS_HEADERS_GIT_HASH` as a better value for non-git builds, that value won't change for simple rebuilds of the source tree.
@neteler neteler modified the milestones: 8.3.0, 8.2.1 Nov 12, 2022
@sebastic sebastic deleted the version-check branch November 12, 2022 12:19
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
As reported in OSGeo#2610, rebuilding the GRASS sources (from the release tarballs) with no changes break the gdal-grass plugins because the `GIS_H_VERSION` value changes.

Non-git builds use the current timestamp in `GRASS_HEADERS_GIT_HASH` which is also used for `GRASS_HEADERS_DATE`.

This PR uses `GRASS_VERSION_NUMBER` for `GRASS_HEADERS_GIT_HASH` as a better value for non-git builds, that value won't change for simple rebuilds of the source tree.
marisn pushed a commit to marisn/grass that referenced this pull request Jun 2, 2023
As reported in OSGeo#2610, rebuilding the GRASS sources (from the release tarballs) with no changes break the gdal-grass plugins because the `GIS_H_VERSION` value changes.

Non-git builds use the current timestamp in `GRASS_HEADERS_GIT_HASH` which is also used for `GRASS_HEADERS_DATE`.

This PR uses `GRASS_VERSION_NUMBER` for `GRASS_HEADERS_GIT_HASH` as a better value for non-git builds, that value won't change for simple rebuilds of the source tree.
@wenzeslaus wenzeslaus changed the title Use GRASS version for non-git builds. packaging: Use GRASS version for non-git builds Jun 6, 2023
neteler pushed a commit to nilason/grass that referenced this pull request Nov 7, 2023
As reported in OSGeo#2610, rebuilding the GRASS sources (from the release tarballs) with no changes break the gdal-grass plugins because the `GIS_H_VERSION` value changes.

Non-git builds use the current timestamp in `GRASS_HEADERS_GIT_HASH` which is also used for `GRASS_HEADERS_DATE`.

This PR uses `GRASS_VERSION_NUMBER` for `GRASS_HEADERS_GIT_HASH` as a better value for non-git builds, that value won't change for simple rebuilds of the source tree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working C Related code is in C
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants