autogen.sh: Reconstruct version from ChangeLog files (for CI)

When repos are forked on GitLab tags aren't copied (0 Tags) thus making
git-version-gen producing incorrect version ("UNKNOWN") which in turn
causes CI build failures (not helpful for people trying to make Merge
Requests). To workaround this issue reconstruct version from ChangeLogs
files (handy updated on every release). If git describe is not working
and we are not in dist package - take version from the top-most
ChangeLog file.

Example of error messages:

  ../libtool: line 1168: UNKNOWN + : syntax error: operand expected (error token is "+ ")

  In file included from net.c:83:
  net.c: In function 'connect_dev':
  <command-line>: error: 'UNKNOWN' undeclared (first use in this function)
  ../include/sane/sane.h:31:21: note: in definition of macro 'SANE_VERSION_CODE'
     31 |   (  (((SANE_Word) (major) &   0xff) << 24) \
	|                     ^~~~~
  net.c:485:41: note: in expansion of macro 'V_MAJOR'
    485 |   req.version_code = SANE_VERSION_CODE (V_MAJOR, V_MINOR,
	|                                         ^~~~~~~
merge-requests/569/head
Alex Belkin 2023-11-07 23:25:44 +03:00
rodzic 5bf66ca4e5
commit 02a417721f
1 zmienionych plików z 14 dodań i 0 usunięć

Wyświetl plik

@ -2,6 +2,20 @@
test -n "$srcdir" || srcdir=`dirname "$0"`
test -n "$srcdir" || srcdir=.
# When repos are forked on GitLab tags aren't copied thus making
# git-version-gen producing incorrect version ("UNKNOWN") which in turn causes
# CI build failures. To workaround this reconstruct version from ChangeLogs
# files (handy updated on every release). If git describe is not working and we
# are not in dist package - take version from the top-most ChangeLog file.
if [ ! -e .tarball-version ] &&
! git describe >/dev/null 2>&1; then
ls ChangeLogs \
| sort -Vr \
| grep -m1 -P -o '(?<=ChangeLog-).*' > .tarball-version
read v < .tarball-version
echo >&2 "Package version reconstructed from ChangeLog: $v"
fi
patchdir="$srcdir/patches"
# Suppress warnings about obsolete macros if still needed (#122)