bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Collin Funk <collin.funk1@gmail.com>
To: bug-gnulib@gnu.org
Subject: gnulib-tool.py: Use auxdir as given by AC_CONFIG_AUX_DIR.
Date: Sat, 6 Apr 2024 06:19:40 -0700	[thread overview]
Message-ID: <2ac42381-ccc3-495f-a1fc-ffcc5549fef5@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2606 bytes --]

It seems that gettext catches a lot of issues with gnulib-tool.py...

The first patch addresses this:

diff -ru /home/collin/.local/src/gettext/gettext-runtime/gnulib-m4/gnulib-cache.m4 /home/collin/.local/src/glpyVCpuH3/gettext-runtime/gnulib-m4/gnulib-cache.m4
--- /home/collin/.local/src/gettext/gettext-runtime/gnulib-m4/gnulib-cache.m4	2024-04-06 05:23:27.471667282 -0700
+++ /home/collin/.local/src/glpyVCpuH3/gettext-runtime/gnulib-m4/gnulib-cache.m4	2024-04-06 06:06:28.102539887 -0700
@@ -34,7 +34,7 @@
 #  --m4-base=gnulib-m4 \
 #  --doc-base=doc \
 #  --tests-base=tests \
-#  --aux-dir=../build-aux \
+#  --aux-dir=build-aux \
 #  --no-conditional-dependencies \
 #  --no-libtool \
 #  --macro-prefix=gl \
Only in /home/collin/.local/src/glpyVCpuH3/gettext-runtime/gnulib-m4: gnulib-cache.m4~
diff -ru /home/collin/.local/src/gettext/gettext-runtime/gnulib-m4/gnulib-comp.m4 /home/collin/.local/src/glpyVCpuH3/gettext-runtime/gnulib-m4/gnulib-comp.m4
--- /home/collin/.local/src/gettext/gettext-runtime/gnulib-m4/gnulib-comp.m4	2024-04-06 05:23:29.262666548 -0700
+++ /home/collin/.local/src/glpyVCpuH3/gettext-runtime/gnulib-m4/gnulib-comp.m4	2024-04-06 06:06:28.103539887 -0700
@@ -387,7 +387,7 @@
   gl_CONDITIONAL([GL_COND_OBJ_CLOSE], [test $REPLACE_CLOSE = 1])
   gl_UNISTD_MODULE_INDICATOR([close])
   AC_REQUIRE([gt_CSHARPCOMP])
-  AC_CONFIG_FILES([csharpcomp.sh:../build-aux/csharpcomp.sh.in])
+  AC_CONFIG_FILES([csharpcomp.sh:build-aux/csharpcomp.sh.in])

This is because gnulib-tool.py gets the auxdir from AC_CONFIG_AUX_DIR
with destdir. This seems to be incorrect based on the section of code
in gnulib-tool.sh starting at line 7275:

    if test -z "$auxdir"; then
      auxdir="$guessed_auxdir"
    fi

The second patch addresses this:

diff -ru /home/collin/.local/src/gettext/gettext-runtime/gnulib-lib/Makefile.am /home/collin/.local/src/glpyaGkFPQ/gettext-runtime/gnulib-lib/Makefile.am
--- /home/collin/.local/src/gettext/gettext-runtime/gnulib-lib/Makefile.am	2024-04-06 05:23:34.728664307 -0700
+++ /home/collin/.local/src/glpyaGkFPQ/gettext-runtime/gnulib-lib/Makefile.am	2024-04-06 06:13:24.432322731 -0700
@@ -379,7 +379,7 @@
 ## begin gnulib module csharpcomp-script
 
 
-EXTRA_DIST += $(top_srcdir)/../build-aux/csharpcomp.sh.in
+EXTRA_DIST += build-aux/csharpcomp.sh.in

Since joinpath() uses os.path.norm(), it will see '$(top_srcdir)/..'
and delete both path components. This is incorrect.

I've just wrapped that variable with os.path.join() for now which will
prevent it from being deleted. That function is starting to become
pretty annoying though. :(

Collin

[-- Attachment #2: 0002-gnulib-tool.py-Use-auxdir-as-given-by-AC_CONFIG_AUX_.patch --]
[-- Type: text/x-patch, Size: 2005 bytes --]

From f6015a5f2416c2e077fc85b94e474a4921f59f04 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Sat, 6 Apr 2024 05:57:51 -0700
Subject: [PATCH 2/3] gnulib-tool.py: Use auxdir as given by AC_CONFIG_AUX_DIR.

* pygnulib/GLImport.py (GLImport.__init__): Don't modify the path given
by AC_CONFIG_AUX_DIR by prefixing it with destdir. Use a more strict
regular expression instead of cleaner().
---
 ChangeLog            | 7 +++++++
 pygnulib/GLImport.py | 7 +++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index feed5699f7..9e94583721 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-04-06  Collin Funk  <collin.funk1@gmail.com>
+
+	gnulib-tool.py: Use auxdir as given by AC_CONFIG_AUX_DIR.
+	* pygnulib/GLImport.py (GLImport.__init__): Don't modify the path given
+	by AC_CONFIG_AUX_DIR by prefixing it with destdir. Use a more strict
+	regular expression instead of cleaner().
+
 2024-04-06  Collin Funk  <collin.funk1@gmail.com>
 
 	gnulib-tool.py: Locate configure.ac correctly when --dir is given.
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index ee238a1615..2776f2c964 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -93,11 +93,10 @@ class GLImport:
         self.cache.setAuxDir('.')
         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)
+        pattern = re.compile(r'^AC_CONFIG_AUX_DIR\([\[ ]*([^\]"\$`\\\)]+).*?$', re.MULTILINE)
+        match = pattern.search(data)
         if match:
-            result = cleaner(match)[0]
-            self.cache.setAuxDir(joinpath(self.config['destdir'], result))
+            self.cache.setAuxDir(match.group(1))
         pattern = re.compile(r'A[CM]_PROG_LIBTOOL', re.M)
         guessed_libtool = bool(pattern.findall(data))
         if self.config['auxdir'] == '':
-- 
2.44.0


[-- Attachment #3: 0003-gnulib-tool.py-Don-t-allow-path-normalization-to-del.patch --]
[-- Type: text/x-patch, Size: 1910 bytes --]

From d93e3cd4657a3fa9c05bee6b1249cf5d9d6fe3d4 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.funk1@gmail.com>
Date: Sat, 6 Apr 2024 06:04:52 -0700
Subject: [PATCH 3/3] gnulib-tool.py: Don't allow path normalization to delete
 a variable.

* pygnulib/GLModuleSystem.py
(GLModule.getAutomakeSnippet_Unconditional): Use os.path.join() on the
Makefile variable so it isn't deleted by a following '..' from
os.path.norm().
---
 ChangeLog                  | 8 ++++++++
 pygnulib/GLModuleSystem.py | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 9e94583721..2b633d174a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-04-06  Collin Funk  <collin.funk1@gmail.com>
+
+	gnulib-tool.py: Don't allow path normalization to delete a variable.
+	* pygnulib/GLModuleSystem.py
+	(GLModule.getAutomakeSnippet_Unconditional): Use os.path.join() on the
+	Makefile variable so it isn't deleted by a following '..' from
+	os.path.norm().
+
 2024-04-06  Collin Funk  <collin.funk1@gmail.com>
 
 	gnulib-tool.py: Use auxdir as given by AC_CONFIG_AUX_DIR.
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 98a21c4696..f8ff71383a 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -645,7 +645,7 @@ class GLModule:
                 buildaux_files = filter_filelist(constants.NL, all_files,
                                                  'build-aux/', '', 'build-aux/', '')
                 if buildaux_files != '':
-                    buildaux_files = [ joinpath('$(top_srcdir)', auxdir, filename)
+                    buildaux_files = [ os.path.join('$(top_srcdir)', joinpath(auxdir, filename))
                                        for filename in buildaux_files.split(constants.NL) ]
                     result += 'EXTRA_DIST += %s' % ' '.join(buildaux_files)
                     result += '\n\n'
-- 
2.44.0


             reply	other threads:[~2024-04-06 13:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-06 13:19 Collin Funk [this message]
2024-04-06 16:37 ` gnulib-tool.py: Use auxdir as given by AC_CONFIG_AUX_DIR Bruno Haible
2024-04-06 21:23   ` Collin Funk
2024-04-06 23:31   ` gettext gnulib-tool test case failures Collin Funk
2024-04-07  0:54     ` Bruno Haible
2024-04-07  1:04       ` Collin Funk
2024-04-07 11:48 ` gnulib-tool.py: Use auxdir as given by AC_CONFIG_AUX_DIR Bruno Haible
2024-04-07 13:11   ` Collin Funk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ac42381-ccc3-495f-a1fc-ffcc5549fef5@gmail.com \
    --to=collin.funk1@gmail.com \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).