When using gnulib-tool.py this comment in gnulib-comp.m4 is different
(using Emacs merge-gnulib):

-# This macro should be invoked from ./configure.ac, in the section
+# This macro should be invoked from configure.ac, in the section

In gnulib-tool the $configure_ac is set to [1]:

   configure_ac="$destdir/configure.ac"

but gnulib-tool.py uses relativize which modifies the path. The
GLConfig.resetAutoconfFile is unused (based on a quick grep search)
and uses joinpath. This does path normalization so it also gives the
incorrect result.

This patch just changes GLConfig.setAutoconfFile to use os.path.join
which seems most similar and fixes the output.

I think that this may _still_ give the incorrect output in some
situations. This test program:

    import os
    print(os.path.join('.//', 'configure.ac'))

prints (on GNU/Linux and most likely anything but Windows):

    .//configure.ac

where gnulib-tool would give (assuming unsanitized input):

    .///configure.ac

Feel free to propose a better solution if you think of one. I'm not
too sure how $destdir is sanitized or if we assume it doesn't contain
path separators.

[1] https://git.savannah.gnu.org/cgit/gnulib.git/tree/gnulib-tool#n1597

Collin
From 0343d44ada1c1b0d50ad4b90efa10d596f03c5b0 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sun, 3 Mar 2024 16:00:57 -0800
Subject: [PATCH] gnulib-tool.py: Adjust construction of configure.ac path.

* pygnulib/GLConfig.py (GLConfig.setAutoconfFile): Join destdir and
configure.ac instead of using relativize.
---
 ChangeLog            | 6 ++++++
 pygnulib/GLConfig.py | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 098868de10..75925373ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-03-03  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Adjust construction of configure.ac path.
+	* pygnulib/GLConfig.py (GLConfig.setAutoconfFile): Join destdir and
+	configure.ac instead of using relativize.
+
 2024-03-03  Collin Funk  <collin.fu...@gmail.com>
             Bruno Haible  <br...@clisp.org>
 
diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index 4284c73ad9..1689e867b0 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -927,7 +927,7 @@ class GLConfig(object):
         if type(configure_ac) is str:
             if configure_ac:
                 self.table['configure_ac'] = \
-                    relpath(self.table['destdir'], configure_ac)
+                    os.path.join(self.table['destdir'], configure_ac)
         else:  # if type of configure_ac is not str
             raise TypeError('configure_ac must be a string, not %s'
                             % type(configure_ac).__name__)
-- 
2.44.0

Reply via email to