Hi Bruno,
On 3/26/24 4:46 AM, Bruno Haible wrote:
> The original code looked out for multiple AC_PREREQ invocations and
> took the maximum. For example:
> AC_PREREQ([2.64])
> AC_PREREQ([2.69])
> AC_PREREQ([2.66])
> must be treated as if it were
> AC_PREREQ([2.69])
> The new code looks at the first AC_PREREQ invocation only.
Ah, I see. I didn't notice this for some reason. Is there a reason why
there might be multiple?
Usually when I used Autoconf I would just keep one at the top in sync
with whatever was in Debian GNU/Linux Stable at the time. Seemed to
work well for me. :)
> * The --automake-subdir/--automake-subdir-tests handling is specific
> to the 'import', 'add-import', 'remove-import', 'update' modes. It
> therefore belongs in GLImport.py. It does not belong in main.py.
I think that that I misunderstood this:
if case "$mode" in import | add-import | remove-import | update) true;; *)
false;; esac \
&& test -n "$destdir"; then
conditional and the if .. else indentation which lead to many of the
following issues. Sorry about that...
> The only problem that should be fixed is the determination of the file
> name of configure.ac/in, since that is currently duplicated code between
> main.py and GLImport.py.
How does this patch look?
An unintended side effect is that the './configure.ac' and
'configure.ac' disagreement in that gnulib-comp.m4 comment is also
fixed. The GLConfig.py change is not needed.
> A new test case is not needed. Test cases are needed, in general, for
> functionality that is
> - essential to many users, or
> - implemented in a complicated way, or
> - likely to be broken through future maintenance.
> The configure.in filename handling does not match either of these three
> criteria.
That makes sense. I agree that it is not likely to be broken.
Here is how I tested it in case you would like to confirm:
$ gnulib-tool.py --create-testdir --dir test-dir readme-release
$ cd test-dir
$ gnulib-tool.py --import readme-release
$ mv configure.ac configure.in
$ gnulib-tool.py --import readme-release
$ mv configure.in configure-missing.ac
$ gnulib-tool.py --import readme-release
/home/collin/.local/src/gnulib/gnulib-tool.py: *** cannot find configure.ac -
make sure you run gnulib-tool from within your package's directory
/home/collin/.local/src/gnulib/gnulib-tool.py: *** Stop.
Collin
From 5951d7c55eb31c7892349fc468d989d5fba8a422 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Tue, 26 Mar 2024 15:43:21 -0700
Subject: [PATCH] gnulib-tool.py: Allow the use of both configure.ac and
configure.in.
* pygnulib/GLImport.py (GLImport.__init__): Remove redundant checks for
configure.ac and configure.in.
* pygnulib/main.py (main): Check for configure.ac and configure.in
before reading it. Pass it to GLImport using the GLConfig object.
---
ChangeLog | 8 ++++++++
pygnulib/GLImport.py | 8 +-------
pygnulib/main.py | 13 ++++++++++++-
3 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 94fc26fb44..e70c0e9271 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-03-26 Collin Funk <collin.fu...@gmail.com>
+
+ gnulib-tool.py: Allow the use of both configure.ac and configure.in.
+ * pygnulib/GLImport.py (GLImport.__init__): Remove redundant checks for
+ configure.ac and configure.in.
+ * pygnulib/main.py (main): Check for configure.ac and configure.in
+ before reading it. Pass it to GLImport using the GLConfig object.
+
2024-03-26 Bruno Haible <br...@clisp.org>
gettime-res: Fix test failure on Solaris 11.4/SPARC.
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index 1a45776f4f..d7d820f8d1 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -89,13 +89,7 @@ class GLImport(object):
# Get cached auxdir and libtool from configure.ac/in.
self.cache.setAuxDir('.')
- path = joinpath(self.config['destdir'], 'configure.ac')
- if not isfile(path):
- path = joinpath(self.config['destdir'], 'configure.in')
- if not isfile(path):
- raise GLError(3, path)
- self.config.setAutoconfFile(path)
- with codecs.open(path, 'rb', 'UTF-8') as file:
+ with codecs.open(self.config.getAutoconfFile(), 'rb', 'UTF-8') as file:
data = file.read()
pattern = re.compile(r'^AC_CONFIG_AUX_DIR\((.*)\)$', re.M)
match = pattern.findall(data)
diff --git a/pygnulib/main.py b/pygnulib/main.py
index c83612d91f..204050facb 100644
--- a/pygnulib/main.py
+++ b/pygnulib/main.py
@@ -886,8 +886,19 @@ def main():
destdir = '.'
config.setDestDir(destdir)
+ # Prefer configure.ac but also look for configure.in.
+ if isfile(joinpath(destdir, 'configure.ac')):
+ configure_ac = joinpath(destdir, 'configure.ac')
+ elif isfile(joinpath(destdir, 'configure.in')):
+ configure_ac = joinpath(destdir, 'configure.in')
+ else:
+ raise classes.GLError(3, joinpath(destdir, 'configure.ac'))
+
+ # Save the Autoconf file path for the rest of the import.
+ config.setAutoconfFile(configure_ac)
+
# Analyze configure.ac.
- with open(joinpath(destdir, 'configure.ac'), 'r', encoding='utf-8') as file:
+ with open(configure_ac, 'r', encoding='utf-8') as file:
configure_ac_data = file.read()
guessed_m4dirs = []
--
2.44.0