[PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 34, 35

2024-02-28 Thread Collin Funk
Two more simple patches. The first deals with the @ALLOCA@
substitution for libtests.a. The second just bumps the Autoconf
requirement to 2.64.

CollinFrom 6a59d2ca97f111c5ca7dd564c5d92f62a5e196d7 Mon Sep 17 00:00:00 2001
From: Collin Funk 
Date: Wed, 28 Feb 2024 21:17:49 -0800
Subject: [PATCH 2/3] gnulib-tool.py: Follow gnulib-tool changes, part 34.

Follow gnulib-tool change
2017-05-15  Bruno Haible  
gnulib-tool: Fix generated code when libtests contains module 'alloca'.

* pygnulib/GLEmiter.py (GLEmiter.tests_Makefile_am): Use @ALLOCA@ for
libtests.a instead of @LTALLOCA@.
---
 ChangeLog|  9 +
 gnulib-tool.py.TODO  | 11 ---
 pygnulib/GLEmiter.py |  4 ++--
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a77eb99cec..a5cc9fd23b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-02-28  Collin Funk  
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 34.
+	Follow gnulib-tool change
+	2017-05-15  Bruno Haible  
+	gnulib-tool: Fix generated code when libtests contains module 'alloca'.
+	* pygnulib/GLEmiter.py (GLEmiter.tests_Makefile_am): Use @ALLOCA@ for
+	libtests.a instead of @LTALLOCA@.
+
 2024-02-28  Collin Funk  
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 33.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index 42cccaf71e..cd1274a7be 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -819,17 +819,6 @@ Date:   Sat May 20 13:24:37 2017 +0200
 
 
 
-commit 0414a24cf57f1569b0b4f2a0f22898a0943dfc14
-Author: Bruno Haible 
-Date:   Mon May 15 23:13:57 2017 +0200
-
-gnulib-tool: Fix generated code when libtests contains module 'alloca'.
-
-* gnulib-tool (func_emit_tests_Makefile_am): For libtests.a, use
-@ALLOCA@, not @LTALLOCA@.
-
-
-
 commit f30205c5d59bab2c035165158e7d5d65b07b8363
 Author: Mathieu Lirzin 
 Date:   Tue Mar 14 12:19:40 2017 +0100
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 260478e5da..dcabc3523c 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -993,8 +993,8 @@ AC_DEFUN([%V1%_LIBSOURCES], [
   include_guard_prefix)
 # Check if module is 'alloca'.
 if libtests and str(module) == 'alloca':
-snippet += 'libtests_a_LIBADD += @%sALLOCA@\n' % perhapsLT
-snippet += 'libtests_a_DEPENDENCIES += @%sALLOCA@\n' % perhapsLT
+snippet += 'libtests_a_LIBADD += @ALLOCA@\n'
+snippet += 'libtests_a_DEPENDENCIES += @ALLOCA@\n'
 
 # Skip the contents if it's entirely empty.
 if not snippet.isspace():
-- 
2.39.2

From d5aa0cfe26093327d339f763cee18a8e96023310 Mon Sep 17 00:00:00 2001
From: Collin Funk 
Date: Wed, 28 Feb 2024 22:15:04 -0800
Subject: [PATCH 3/3] gnulib-tool.py: Follow gnulib-tool changes, part 35.

Follow gnulib-tool change
2023-05-28  Bruno Haible  
warnings, manywarnings: Assume autoconf >= 2.64.

* pygnulib/GLConfig.py (GLConfig.default, GLConfig.getAutoconfVersion)
(GLConfig.setAutoconfVersion, resetAutoconfVersion): Set required
Autoconf version to 2.64.
* pygnulib/GLError.py (GLError.__init__, GLError.__repr__): Likewise.
* pygnulib/GLImport.py (GLImport.__init__): Likewise.
* pygnulib/constants.py (DEFAULT_AUTOCONF_MINVERSION): Likewise.
* pygnulib/main.py: Likewise.
---
 ChangeLog | 14 ++
 gnulib-tool.py.TODO   | 26 --
 pygnulib/GLConfig.py  | 10 +-
 pygnulib/GLError.py   |  4 ++--
 pygnulib/GLImport.py  |  2 +-
 pygnulib/constants.py |  4 ++--
 pygnulib/main.py  |  2 +-
 7 files changed, 25 insertions(+), 37 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a5cc9fd23b..a97282488d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-02-28  Collin Funk  
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 35.
+	Follow gnulib-tool change
+	2023-05-28  Bruno Haible  
+	warnings, manywarnings: Assume autoconf >= 2.64.
+	* pygnulib/GLConfig.py (GLConfig.default, GLConfig.getAutoconfVersion)
+	(GLConfig.setAutoconfVersion, resetAutoconfVersion): Set required
+	Autoconf version to 2.64.
+	* pygnulib/GLError.py (GLError.__init__, GLError.__repr__): Likewise.
+	* pygnulib/GLImport.py (GLImport.__init__): Likewise.
+	* pygnulib/constants.py (DEFAULT_AUTOCONF_MINVERSION): Likewise.
+	* pygnulib/main.py: Likewise.
+
 2024-02-28  Collin Funk  
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 34.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index cd1274a7be..d942119be0 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -620,32 +620,6 @@ Date:   Sun Dec 27 01:21:22 2020 +0100
 
 
 
-commit 15ce5a630b02af7c7104650dfb18e443b4111564

[PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 33.

2024-02-28 Thread Collin Funk
This patch explains the random tests/ directory that gnulib-tool.py
makes with the Emacs script. I've tried to make this patch match the
shell code. I was a bit confused by missing print statements in the
Python version's transitive_closure_separately but it seems that is
handled in GLImport.prepare() instead.

Also, I've noticed that some functions check if a type(var) == list.
To avoid problems I've returned an empty list instead of None. I've
used the Emacs script and it doesn't create the tests/ with a few
snippet headers anymore.

CollinFrom 73eca650d24767b412f1c82d0fe0815c0d2e51fc Mon Sep 17 00:00:00 2001
From: Collin Funk 
Date: Wed, 28 Feb 2024 19:05:16 -0800
Subject: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 33.

Follow gnulib-tool change
2017-03-14  Bruno Haible  
gnulib-tool: Don't produce a tests directory with only snippet .h files.

* pygnulib/GLModuleSystem.py
(GLModuleTable.transitive_closure_separately): Don't create a test
directory if all test related modules have applicability 'all'.
---
 ChangeLog  | 10 ++
 gnulib-tool.py.TODO| 12 
 pygnulib/GLModuleSystem.py | 11 ++-
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 398d1d5cda..a77eb99cec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-02-28  Collin Funk  
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 33.
+	Follow gnulib-tool change
+	2017-03-14  Bruno Haible  
+	gnulib-tool: Don't produce a tests directory with only snippet .h files.
+	* pygnulib/GLModuleSystem.py
+	(GLModuleTable.transitive_closure_separately): Don't create a test
+	directory if all test related modules have applicability 'all'.
+
 2024-02-28  Collin Funk  
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 32.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index 905793e0c7..42cccaf71e 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -830,18 +830,6 @@ Date:   Mon May 15 23:13:57 2017 +0200
 
 
 
-commit 363135016c25696d7a173094715e7f3f2dda3596
-Author: Bruno Haible 
-Date:   Wed Mar 15 23:24:03 2017 +0100
-
-gnulib-tool: Don't produce a tests directory with only snippet .h files.
-
-* gnulib-tool (func_modules_transitive_closure_separately): If
-testsrelated_modules ends up with no "real" modules, aside from
-modules with applicability 'all', set it to empty.
-
-
-
 commit f30205c5d59bab2c035165158e7d5d65b07b8363
 Author: Mathieu Lirzin 
 Date:   Tue Mar 14 12:19:40 2017 +0100
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 787614d38c..675d33de32 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -989,7 +989,16 @@ class GLModuleTable(object):
 #   + [ m
 #   for m in main_modules
 #   if m.getApplicability() != 'main' ]
-tests_modules = sorted(set(tests_modules))
+tests_modules = sorted(list(set(tests_modules)))
+# If testsrelated_modules consists only of modules with applicability 'all',
+# set it to empty (because such modules are only helper modules for other modules).
+have_nontrivial_testsrelated_modules = False
+for module in tests_modules:
+if module.getApplicability() != 'all':
+have_nontrivial_testsrelated_modules = True
+break
+if not have_nontrivial_testsrelated_modules:
+tests_modules = []
 result = tuple([main_modules, tests_modules])
 return result
 
-- 
2.39.2



Re: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 32.

2024-02-28 Thread Bruno Haible
Thanks! Applied.






[PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 32.

2024-02-28 Thread Collin Funk
Trying to fix some of the easy TODO items first. I've noticed that the
referenced commit in the TODO file had ftruncate in the excluded
modules list. I've not added it back since that seems to be intended
[1].

[1] 
https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=5c51e14ad89c9210536aab61836111962b68fb4f

CollinFrom 6b0a5a3203f5ef97a92b82756ee61d81103600e5 Mon Sep 17 00:00:00 2001
From: Collin Funk 
Date: Wed, 28 Feb 2024 16:35:36 -0800
Subject: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 32.

Follow gnulib-tool change
2018-10-22  Bruno Haible  
Fix failure of 'gnulib-tool --create-testdir' with all modules.

* pygnulib/GLTestDir.py (GLTestDir.execute): Exclude the 'timevar'
module from --create-testdir with all modules. Update comment.
---
 ChangeLog |  9 +
 gnulib-tool.py.TODO   | 10 --
 pygnulib/GLTestDir.py | 11 ++-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 02d22de00f..398d1d5cda 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-02-28  Collin Funk  
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 32.
+	Follow gnulib-tool change
+	2018-10-22  Bruno Haible  
+	Fix failure of 'gnulib-tool --create-testdir' with all modules.
+	* pygnulib/GLTestDir.py (GLTestDir.execute): Exclude the 'timevar'
+	module from --create-testdir with all modules. Update comment.
+
 2024-02-28  Collin Funk  
 
 	gnulib-tool.py: Emit year range on file copyright notices.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index 5f4a134edf..905793e0c7 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -729,16 +729,6 @@ Date:   Tue Oct 23 00:06:46 2018 +0200
 
 
 
-commit 98993f9d1b2ed03007be9dbcdc6bd9fe2d49777b
-Author: Bruno Haible 
-Date:   Mon Oct 22 20:32:41 2018 +0200
-
-Fix failure of 'gnulib-tool --create-testdir' with all modules.
-
-* gnulib-tool (func_create_testdir): Exclude 'timevar' module.
-
-
-
 commit 8b1d4a63e34f3893036d82f39c5680e845de5ddf
 Author: Bruno Haible 
 Date:   Mon Sep 3 21:19:16 2018 +0200
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index bc0b153304..a7fd806d4f 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -159,14 +159,15 @@ class GLTestDir(object):
 if len(specified_modules) == 0:
 # All modules together.
 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
-# Except non-recursive-gnulib-prefix-hack, which represents a
-# nonstandard way of using Automake.
-# Except mountlist, which aborts the configuration on mingw.
-# Except lib-ignore, which leads to link errors when Sun C++ is used.
+# Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
+# way of using Automake.
+# Except timevar, which lacks the required file timevar.def.
+# Except mountlist, which aborts the configuration on mingw. FIXME.
+# Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
 specified_modules = self.modulesystem.list()
 specified_modules = [module
  for module in specified_modules
- if module not in ['config-h', 'non-recursive-gnulib-prefix-hack',
+ if module not in ['config-h', 'non-recursive-gnulib-prefix-hack', 'timevar',
'mountlist', 'lib-ignore']]
 
 # Canonicalize the list of specified modules.
-- 
2.39.2



Re: Can we have gnulib-tool.py emit the same copyright header?

2024-02-28 Thread Bruno Haible
Collin Funk wrote:
> Attached it with the typo fixed.

Thanks! Applied.

Bruno






Re: Can we have gnulib-tool.py emit the same copyright header?

2024-02-28 Thread Collin Funk
On 2/28/24 1:30 PM, Bruno Haible wrote:
> Looks good, except for a typo or spelling mistake. [1]

I'm not the greatest at spelling apparently. Attached it with the typo fixed.

CollinFrom c21617ca4561f48225543378d0d4e24ac700877b Mon Sep 17 00:00:00 2001
From: Collin Funk 
Date: Wed, 28 Feb 2024 13:12:05 -0800
Subject: [PATCH] gnulib-tool.py: Emit year range on file copyright notices.

* pygnulib/GLInfo.py (GLInfo.copyright_range): New function. Return a
copyright string with a year range.
* pygnulib/GLEmiter.py (GLEmiter.copyright_notice): Use the new function
for file copyright headers.
---
 ChangeLog| 8 
 pygnulib/GLEmiter.py | 2 +-
 pygnulib/GLInfo.py   | 4 
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 8cfe498940..02d22de00f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-02-28  Collin Funk  
+
+	gnulib-tool.py: Emit year range on file copyright notices.
+	* pygnulib/GLInfo.py (GLInfo.copyright_range): New function. Return a
+	copyright string with a year range.
+	* pygnulib/GLEmiter.py (GLEmiter.copyright_notice): Use the new function
+	for file copyright headers.
+
 2024-02-28  Collin Funk  
 
 	gnulib-tool.py: Make module sorting more similar to gnulib-tool.
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index d8cc085f59..260478e5da 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -73,7 +73,7 @@ class GLEmiter(object):
 '''GLEmiter.copyright_notice() -> str
 
 Emit a header for a generated file.'''
-emit = "# %s" % self.info.copyright()
+emit = '# %s' % self.info.copyright_range()
 emit += """
 #
 # This file is free software; you can redistribute it and/or modify
diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py
index a0a70270a9..08edb9b383 100644
--- a/pygnulib/GLInfo.py
+++ b/pygnulib/GLInfo.py
@@ -125,6 +125,10 @@ class GLInfo(object):
 result = re.compile(' .*').sub('', first_changelog_line)
 return result
 
+def copyright_range(self):
+'''Returns a formatted copyright string showing a year range.'''
+return f'Copyright (C) {constants.__copyright__}'
+
 def usage(self):
 '''Show help message.'''
 result = '''\
-- 
2.39.2



Re: Can we have gnulib-tool.py emit the same copyright header?

2024-02-28 Thread Bruno Haible
Hi Collin,

> > I'm committing these three patches, that fix the version output also in the
> > presence of
> > 
> > [log]
> > date = relative
> 
> Nice. I wasn't aware of this option.

Neither was I. I searched through all possible git config variables whether any
could affect the "git log" output in a relevant way. Hope I didn't miss any.

> How does this patch look for fixing the copyright headers? I could
> have just used constants.__copyright__ in GLEmiter, but I thought it
> was best to put in GLInfo just in case it is needed elsewhere later.

Looks good, except for a typo or spelling mistake. [1]

Bruno

[1] https://en.wiktionary.org/wiki/formated






Re: Can we have gnulib-tool.py emit the same copyright header?

2024-02-28 Thread Collin Funk
On 2/28/24 3:00 AM, Bruno Haible wrote:
> I'm committing these three patches, that fix the version output also in the
> presence of
> 
> [log]
>   date = relative

Nice. I wasn't aware of this option. Your fixes give me the correct
date and time now.

How does this patch look for fixing the copyright headers? I could
have just used constants.__copyright__ in GLEmiter, but I thought it
was best to put in GLInfo just in case it is needed elsewhere later.

CollinFrom 67a69b85467f1641f5e8741a22c929cdf8268cd8 Mon Sep 17 00:00:00 2001
From: Collin Funk 
Date: Wed, 28 Feb 2024 13:12:05 -0800
Subject: [PATCH] gnulib-tool.py: Emit year range on file copyright notices.

* pygnulib/GLInfo.py (GLInfo.copyright_range): New function. Return a
copyright string with a year range.
* pygnulib/GLEmiter.py (GLEmiter.copyright_notice): Use the new function
for file copyright headers.
---
 ChangeLog| 8 
 pygnulib/GLEmiter.py | 2 +-
 pygnulib/GLInfo.py   | 4 
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 8cfe498940..02d22de00f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-02-28  Collin Funk  
+
+	gnulib-tool.py: Emit year range on file copyright notices.
+	* pygnulib/GLInfo.py (GLInfo.copyright_range): New function. Return a
+	copyright string with a year range.
+	* pygnulib/GLEmiter.py (GLEmiter.copyright_notice): Use the new function
+	for file copyright headers.
+
 2024-02-28  Collin Funk  
 
 	gnulib-tool.py: Make module sorting more similar to gnulib-tool.
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index d8cc085f59..260478e5da 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -73,7 +73,7 @@ class GLEmiter(object):
 '''GLEmiter.copyright_notice() -> str
 
 Emit a header for a generated file.'''
-emit = "# %s" % self.info.copyright()
+emit = '# %s' % self.info.copyright_range()
 emit += """
 #
 # This file is free software; you can redistribute it and/or modify
diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py
index a0a70270a9..1934fde103 100644
--- a/pygnulib/GLInfo.py
+++ b/pygnulib/GLInfo.py
@@ -125,6 +125,10 @@ class GLInfo(object):
 result = re.compile(' .*').sub('', first_changelog_line)
 return result
 
+def copyright_range(self):
+'''Returns a formated copyright string showing a year range.'''
+return f'Copyright (C) {constants.__copyright__}'
+
 def usage(self):
 '''Show help message.'''
 result = '''\
-- 
2.39.2



Re: sort dynamic linking overhead

2024-02-28 Thread Pádraig Brady

On 27/02/2024 21:36, Bruno Haible wrote:

Pádraig Brady wrote:

Does this work for all the various names of libcrypto in various distros?

Debian 12   libcrypto.so.3
Ubuntu 22.04libcrypto.so.1.1 libcrypto.so.3
Slackware 15libcrypto.so.1.1
openSUSE 15.5   libcrypto.so.1.1
CentOS Stream 9 libcrypto.so.3
Guix 1.4libcrypto.so.1.1
Alpine 3.19 libcrypto.so.3
FreeBSD 14.0libcrypto.so.38
NetBSD 9.3  libcrypto.so.14
OpenBSD 7.4 libcrypto.so.52.0



I only tested with libcrypto.so.3, but it should match all of the above.
It matches libcrypto.so.[.0-9]*


Here are my testing results (with the LIB_DL fix):

* On some machines, I had to install the packages with the 
   header files first:

   - Debian 12:
 # apt install libssl-dev
   - openSUSE 15.5:
 YaST software > install libopenssl-3-devel
   - Slackware 15:
 Download and unpack the openssl-1.1.1w binary packages
   - Alpine Linux 3.19:
 # apk add openssl openssl-dev

* On some platforms, the configure test gave

  checking whether openssl is GPL compatible... no

   due to the  header files being absent:

 - Guix 1.4
 - macOS 12.5
 - Cygwin 2.9.0

* On some platforms, the configure test gave

  checking whether openssl is GPL compatible... no

   because the openssl version is not >= 3.

 - Slackware 15 (has libcrypto.so.1.1)
 - NetBSD 9.3 (has libcrypto.so.14)
 - OpenBSD 7.4 (has libcrypto.so.52.0)
 - Solaris 11.4 (has libcrypto.so.1.0.0)

* On these platforms, the configure test gave

  checking whether openssl is GPL compatible... yes

   and LIBCRYPTO_SONAME got defined.

 - Debian 12
 - Ubuntu 22.04
 - openSUSE 15.5
 - CentOS Stream 9
 - Alpine Linux 3.19
 - FreeBSD 14.0
 - Android

   The value of LIBCRYPTO_SONAME is
 "libcrypto.so.30" on Android,
 "libcrypto.so.3" on the other platforms.


Thanks for all the testing / info.

FTR some platforms may deem openssl < 3 as GPL compat,
and they can `configure --with-openssl=auto`,
in which case this optimization would be enabled.

thanks!
Pádraig




Re: gnulib-tool.py: Follow gnulib-tool changes, part 28.

2024-02-28 Thread Bruno Haible
Collin Funk wrote:
> I've also removed the sorted() calls in actioncmd. The sorting in
> __init__ works correctly so gnulib-tool and gnulib-tool.py output the
> same actioncmd (at least with Emacs' merge-gnulib).

Thanks for following up on this. The patch looks good. Applied.

Bruno






Re: gnulib-tool.py: Follow gnulib-tool changes, part 28.

2024-02-28 Thread Collin Funk
On 2/26/24 12:51 PM, Bruno Haible wrote:
> Well, GLConfig applies to all modes (not just 'import', but also
> 'create-testdir' etc.). Since on the bash side, you found that the
> sorting is specifically in the func_import(), the right place to do it
> is in GLImport.py, not GLConfig.py.

I think that this patch should be correct. The sorting of modules is
done only for mode == 'import' in GLImport.__init__. Looking at the
path from main, this would make the sorting happen right before
performing the transitive closure, like gnulib-tool.

Also this comment from gnulib-tool:
# In 'import' mode, the new set of specified modules overrides the cached
# set of modules. Ignore the cached settings.

So we only care about self.config.getModules().

I've also removed the sorted() calls in actioncmd. The sorting in
__init__ works correctly so gnulib-tool and gnulib-tool.py output the
same actioncmd (at least with Emac's merge-gnulib). Let me know if I
missed anything.

CollinFrom 3a7cbd5c95b2d24341865bf101fe8b1a93f83737 Mon Sep 17 00:00:00 2001
From: Collin Funk 
Date: Wed, 28 Feb 2024 03:33:15 -0800
Subject: [PATCH] gnulib-tool.py: Make module sorting more similar to
 gnulib-tool.

* pygnulib/GLImport.py (GLImport.__init__): Sort modules when mode is
'import'.
(GLImport.actioncmd): Don't sort modules while creating actioncmd. Use
preferred quoting style.
---
 ChangeLog| 8 
 pygnulib/GLImport.py | 8 +---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 330727e02e..8cfe498940 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-02-28  Collin Funk  
+
+	gnulib-tool.py: Make module sorting more similar to gnulib-tool.
+	* pygnulib/GLImport.py (GLImport.__init__): Sort modules when mode is
+	'import'.
+	(GLImport.actioncmd): Don't sort modules while creating actioncmd. Use
+	preferred quoting style.
+
 2024-02-28  Bruno Haible  
 
 	gnulib-tool: Make --version output independent of git's configuration.
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index 0f0f463add..fca2333ec5 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -221,7 +221,9 @@ class GLImport(object):
   for localdir in self.cache['localpath'] ]
 self.config.setLocalPath(localpath)
 
-if self.mode != MODES['import']:
+if self.mode == MODES['import']:
+self.config.setModules(sorted(self.config.getModules()))
+else:
 if self.cache['m4base'] and (self.config['m4base'] != self.cache['m4base']):
 raise GLError(5, m4base)
 
@@ -438,9 +440,9 @@ class GLImport(object):
 elif vc_files == False:
 actioncmd += ' \\\n#  --no-vc-files'
 if len(avoids) > 0:
-actioncmd += ''.join([f" \\\n#  --avoid={x}" for x in sorted(avoids)])
+actioncmd += ''.join([f' \\\n#  --avoid={x}' for x in avoids])
 if len(modules) > 0:
-actioncmd += ''.join([f" \\\n#  {x}" for x in sorted(modules)])
+actioncmd += ''.join([f' \\\n#  {x}' for x in modules])
 return actioncmd
 
 def relative_to_destdir(self, dir):
-- 
2.39.2



Re: Can we have gnulib-tool.py emit the same copyright header?

2024-02-28 Thread Bruno Haible
Collin Funk wrote:
> > git log -n 1 ChangeLog | grep ^Date:
> 
> Ah, I see what is happening.
> 
> [collin@debian gnulib]$ git log -n 1
> commit 431d6a7615245e6b32d95b4b27aab5d3af65ad2b (HEAD -> master, 
> origin/master, origin/HEAD)
> Author: Bruno Haible 
> AuthorDate: Wed Feb 28 00:33:49 2024 +0100
> Commit: Bruno Haible 
> CommitDate: Wed Feb 28 00:33:49 2024 +0100
> 
> isnan: Fix compilation error in C++ mode on OpenBSD 7.5-beta.
> 
> Reported by Christian Weisgerber  in
> .
> 
> * lib/math.in.h (GNULIB_NAMESPACE_LACKS_ISNAN): Define on all platforms
> with clang ≥ 14.
> 
> So the grep ^Date fails. I don't remember changing this but in my git
> config it is caused by this [1]:
> 
> [format]
>   pretty = fuller

OK, so we need to make this piece of code more robust against various
git configurations.

> The regular gnulib-tool gives me this:
> 
> [collin@debian gnulib]$ gnulib-tool --version
> gnulib-tool (GNU gnulib 2024-02-28 00:00:00) 0.1.7153-431d6

Here, the git configuration fooled gnulib-tool too. $date ended up
being empty, and GNU date interprets the empty strings as "today at 00:00:00".
Which was unintended, but it's a decent fallback behaviour worth porting to
the Python code.

> It seems that the 'git command-name --pretty=medium' existed before
> git version 1.

Good. Thanks for the investigation.

I'm committing these three patches, that fix the version output also in the
presence of

[log]
date = relative
[format]
pretty = fuller


2024-02-28  Bruno Haible  

gnulib-tool: Make --version output independent of git's configuration.
Reported by Collin Funk  in
.
* pygnulib/GLInfo.py (GLInfo.date): Pass --format and --date options, to
override the user's git configuration.
* gnulib-tool (func_version): Likewise. Also pass options '-n 1', to
speed up the operation.

2024-02-28  Bruno Haible  

gnulib-tool.py: Avoid exception when 'git log' output is unexpected.
* pygnulib/GLInfo.py (GLInfo.date): When the 'git log' output does not
contain a line with the expected 'Date:' pattern, pass the empty string
to GNU date.

2024-02-28  Bruno Haible  

gnulib-tool: Avoid references to functions that get defined later.
* gnulib-tool (func_fatal_error, func_warning, func_readlink): Move
before func_gnulib_dir.

>From 584ef464a310638f94a79e9b4710fde41c884e7d Mon Sep 17 00:00:00 2001
From: Bruno Haible 
Date: Wed, 28 Feb 2024 11:23:17 +0100
Subject: [PATCH 1/3] gnulib-tool: Avoid references to functions that get
 defined later.

* gnulib-tool (func_fatal_error, func_warning, func_readlink): Move
before func_gnulib_dir.
---
 ChangeLog   |  6 +
 gnulib-tool | 70 ++---
 2 files changed, 41 insertions(+), 35 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index af3af3707e..af0835269f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-02-28  Bruno Haible  
+
+	gnulib-tool: Avoid references to functions that get defined later.
+	* gnulib-tool (func_fatal_error, func_warning, func_readlink): Move
+	before func_gnulib_dir.
+
 2024-02-27  Bruno Haible  
 
 	isnan: Fix compilation error in C++ mode on OpenBSD 7.5-beta.
diff --git a/gnulib-tool b/gnulib-tool
index 029a8cf377..2e10abcfcc 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -421,6 +421,41 @@ func_exit ()
   (exit $1); exit $1
 }
 
+# func_fatal_error message
+# outputs to stderr a fatal error message, and terminates the program.
+# Input:
+# - progname name of this program
+func_fatal_error ()
+{
+  echo "$progname: *** $1" 1>&2
+  echo "$progname: *** Stop." 1>&2
+  func_exit 1
+}
+
+# func_warning message
+# Outputs to stderr a warning message,
+func_warning ()
+{
+  echo "gnulib-tool: warning: $1" 1>&2
+}
+
+# func_readlink SYMLINK
+# outputs the target of the given symlink.
+if (type readlink) > /dev/null 2>&1; then
+  func_readlink ()
+  {
+# Use the readlink program from GNU coreutils.
+readlink "$1"
+  }
+else
+  func_readlink ()
+  {
+# Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
+# would do the wrong thing if the link target contains " -> ".
+LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
+  }
+fi
+
 # func_gnulib_dir
 # locates the directory where the gnulib repository lives
 # Input:
@@ -672,41 +707,6 @@ else
   fast_func_remove_suffix=false
 fi
 
-# func_fatal_error message
-# outputs to stderr a fatal error message, and terminates the program.
-# Input:
-# - progname name of this program
-func_fatal_error ()
-{
-  echo "$progname: *** $1" 1>&2
-  echo "$progname: *** Stop." 1>&2
-  func_exit 1
-}
-
-# func_warning message
-# Outputs to stderr a warning message,
-func_warning ()