bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] gnulib-tool.py: Fix "Creating directory" output.


From: Collin Funk
Subject: [PATCH] gnulib-tool.py: Fix "Creating directory" output.
Date: Sun, 24 Mar 2024 19:02:53 -0700
User-agent: Mozilla Thunderbird

This patch fixes this test failure:

./test-hello-c-gnulib-nonrecursive-1.out tmp1016386-out differ: byte 2612, line 
147
--- ./test-hello-c-gnulib-nonrecursive-1.out    2024-03-24 03:30:48.391074752 
-0700
+++ tmp1016386-out      2024-03-24 18:33:30.855703830 -0700
@@ -144,9 +144,9 @@
   m4/wchar_t.m4
   m4/wint_t.m4
   m4/zzgnulib.m4
-Creating directory ./lib
-Creating directory ./gnulib-m4
-Creating directory ./build-aux
+Creating directory build-aux
+Creating directory gnulib-m4
+Creating directory lib

This is because joinpath performs path normalization. Using
os.path.join seems like the best solution for this:

import os.path
from pathlib import Path
print(os.path.join('.', 'abc'))
./abc
print(str(Path('.', 'abc')))
abc

The second change is reordering the directories. In gnulib-tool.py we
sort all of them. However gnulib-tool.sh only sorts the new file
directories:

  # Create directories.
  { echo "$sourcebase"
    echo "$m4base"
    if test -n "$pobase"; then
      echo "$pobase"
    fi
    docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
    if test -n "$docfiles"; then
      echo "$docbase"
    fi
    if $gentests; then
      echo "$testsbase"
    fi
    echo "$auxdir"
    for f in $files; do echo $f; done \
      | sed -e "$sed_rewrite_new_files" \
      | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
      | LC_ALL=C sort -u
  } > "$tmp"/dirs

To match this we can reorder gnulib-tool.py and use the dictionary
trick I mentioned here to remove duplicates from a list while
preserving order:

https://lists.gnu.org/archive/html/bug-gnulib/2024-03/msg00011.html

diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index e8c8231886..c516491067 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -1060,7 +1060,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         gentests = len(testsfiles) > 0
 
         # Create all necessary directories.
-        dirs = list()
+        dirs = [sourcebase, m4base]
         if pobase:
             dirs += [pobase]
         if [ file
@@ -1069,11 +1069,11 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
             dirs += [docbase]
         if gentests:
             dirs += [testsbase]
-        dirs += [sourcebase, m4base, auxdir]
-        dirs += [ os.path.dirname(pair[0])
-                  for pair in filetable['new'] ]
-        dirs = sorted(set([ joinpath(destdir, d)
-                            for d in dirs ]))
+        dirs += [auxdir]
+        dirs += sorted(list(dict.fromkeys([ os.path.dirname(pair[0])
+                                            for pair in filetable['new'] ])))
+        dirs = [ os.path.join(destdir, d)
+                 for d in dirs ]
         for directory in dirs:
             if not isdir(directory):
                 print('Creating directory %s' % directory)

Collin

Attachment: 0001-gnulib-tool.py-Fix-Creating-directory-output.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]