]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
gnulib-tool.py: Fix write failure due to bad sourcebase.
authorCollin Funk <collin.funk1@gmail.com>
Thu, 14 Mar 2024 02:21:44 +0000 (19:21 -0700)
committerBruno Haible <bruno@clisp.org>
Thu, 14 Mar 2024 14:34:29 +0000 (15:34 +0100)
* pygnulib/constants.py (cleaner): Only call strip() on string objects.
* pygnulib/main.py (main): Fix parsing of AMLOCAL_AMFLAGS from
Makefile.am. Add some comments from gnulib-tool.

ChangeLog
pygnulib/constants.py
pygnulib/main.py

index ace9a034f398e9d5b95b447c7a9ac7aa108f08aa..c77a884984861a1a06f28c7e2297cd23ce34d9d1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-03-14  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Fix write failure due to bad sourcebase.
+       * pygnulib/constants.py (cleaner): Only call strip() on string objects.
+       * pygnulib/main.py (main): Fix parsing of AMLOCAL_AMFLAGS from
+       Makefile.am. Add some comments from gnulib-tool.
+
 2024-03-13  Bruno Haible  <bruno@clisp.org>
 
        sig2str tests: Refactor.
index 918faa8cc056d996867da0d796b1b1f21e36e562..a3bf8cd1d43fb285f1297ce133589252cb765ca3 100644 (file)
@@ -249,6 +249,7 @@ def cleaner(sequence):
         sequence = [ True if value == 'true' else value
                      for value in sequence ]
         sequence = [ value.strip()
+                     if type(value) is str else value
                      for value in sequence ]
     return sequence
 
index 7f710a207910cbed7b8d84463099394741573c01..b145675f781e3ad6fcc21edd845e1656deb9c0ec 100644 (file)
@@ -858,7 +858,10 @@ def main():
 
         else:  # if mode != MODE['--import']
             if m4base:
+                # Apply func_import to a particular gnulib directory.
+                # Any number of additional modules can be given.
                 if not isfile(joinpath(destdir, m4base, 'gnulib-cache.m4')):
+                    # First use of gnulib in the given m4base.
                     if not sourcebase:
                         sourcebase = 'lib'
                     if not docbase:
@@ -877,8 +880,13 @@ def main():
                 filetable, transformers = importer.prepare()
                 importer.execute(filetable, transformers)
             else:  # if not m4base
-                m4dirs = list()
-                dirisnext = bool()
+                # Apply func_import to all gnulib directories.
+                # To get this list of directories, look at Makefile.am. (Not at
+                # configure, because it may be omitted from version control. Also,
+                # don't run "find $destdir -name gnulib-cache.m4", as it might be
+                # too expensive.)
+                m4dirs = []
+                dirisnext = False
                 filepath = joinpath(destdir, 'Makefile.am')
                 if isfile(filepath):
                     with codecs.open(filepath, 'rb', 'UTF-8') as file:
@@ -888,14 +896,18 @@ def main():
                     aclocal_amflags = data.split()
                     for aclocal_amflag in aclocal_amflags:
                         if dirisnext:
+                            # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
                             if not isabs(aclocal_amflag):
-                                m4dirs += [aclocal_amflag]
+                                if isfile(joinpath(destdir, joinpath(aclocal_amflag, 'gnulib-cache.m4'))):
+                                    m4dirs += [aclocal_amflag]
+                            dirisnext = False
                         else:  # if not dirisnext
                             if aclocal_amflag == '-I':
                                 dirisnext = True
                             else:  # if aclocal_amflag != '-I'
                                 dirisnext = False
                 else:  # if not isfile(filepath)
+                    # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
                     filepath = joinpath(destdir, 'aclocal.m4')
                     if isfile(filepath):
                         pattern = re.compile(r'm4_include\(\[(.*?)\]\)')
@@ -929,6 +941,8 @@ def main():
                     filetable, transformers = importer.prepare()
                     importer.execute(filetable, transformers)
                 elif len(m4dirs) == 1:
+                    # There's only one use of gnulib here. Assume the user means it.
+                    # Any number of additional modules can be given.
                     m4base = m4dirs[-1]
                     config.setM4Base(m4base)
                     # Perform GLImport actions.
@@ -936,6 +950,7 @@ def main():
                     filetable, transformers = importer.prepare()
                     importer.execute(filetable, transformers)
                 else:  # if len(m4dirs) > 1
+                    # No further arguments. Guess the user wants to update all of them.
                     for m4base in m4dirs:
                         config.setM4Base(m4base)
                         # Perform GLImport actions.