build: Make autogen.sh --find-version work for nested packages

* autogen.sh: If package_subdir is set then look for .git in the root
of the package containing the nested package in package_subdir.
--

This makes it possible to use autogen.sh --find-version from
configure.ac files in nested packages.

GnuPG-bug-id: 7110
This commit is contained in:
Ingo Klöcker 2024-05-24 18:39:28 +02:00
parent 84affea627
commit f97245f628
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9

View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# autogen.sh # autogen.sh
# Copyright (C) 2003, 2014, 2017, 2018, 2022 g10 Code GmbH # Copyright (C) 2003, 2014, 2017, 2018, 2022, 2024 g10 Code GmbH
# #
# This file is free software; as a special exception the author gives # This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without # unlimited permission to copy and/or distribute it, with or without
@ -15,7 +15,7 @@
# configure it for the respective package. It is maintained as part of # configure it for the respective package. It is maintained as part of
# GnuPG and source copied by other packages. # GnuPG and source copied by other packages.
# #
# Version: 2023-03-15 # Version: 2024-05-24
configure_ac="configure.ac" configure_ac="configure.ac"
@ -72,6 +72,7 @@ FORCE=
SILENT= SILENT=
PRINT_HOST=no PRINT_HOST=no
PRINT_BUILD=no PRINT_BUILD=no
IS_GIT_CLONE=no
tmp=$(dirname "$0") tmp=$(dirname "$0")
tsdir=$(cd "${tmp}"; pwd) tsdir=$(cd "${tmp}"; pwd)
@ -134,6 +135,7 @@ die_p
# these variables are replaced by the actual system root. # these variables are replaced by the actual system root.
configure_opts= configure_opts=
extraoptions= extraoptions=
package_subdir=
# List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc # List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc
w32_toolprefixes= w32_toolprefixes=
w32_extraoptions= w32_extraoptions=
@ -214,6 +216,18 @@ if [ -f "$HOME/.gnupg-autogen.rc" ]; then
fi fi
# Find the .git directory (or file for work trees)
if [ -e .git ]; then
IS_GIT_CLONE=yes
elif [ -n "${package_subdir}" ]; then
# Look for .git in root of package containing the nested package
package_subdir=${package_subdir#/}
root_path=${tsdir%/${package_subdir}}
if [ -e "${root_path}/.git" ]; then
IS_GIT_CLONE=yes
fi
fi
# **** FIND VERSION **** # **** FIND VERSION ****
# This is a helper for the configure.ac M4 magic # This is a helper for the configure.ac M4 magic
# Called # Called
@ -243,7 +257,7 @@ if [ "$myhost" = "find-version" ]; then
fi fi
beta=no beta=no
if [ -e .git ]; then if [ $IS_GIT_CLONE = yes ]; then
ingit=yes ingit=yes
tmp=$(git describe --match "${matchstr1}" --long 2>/dev/null) tmp=$(git describe --match "${matchstr1}" --long 2>/dev/null)
if [ -n "$tmp" ]; then if [ -n "$tmp" ]; then