The Coreutils test case fails because of this diff (in part at least):
--- ./test-coreutils-1.result/m4/gnulib-comp.m4 2024-03-25 19:19:30.371888468
-0700
+++ tmp116344-result/m4/gnulib-comp.m4 2024-03-25 20:17:01.642173500 -0700
@@ -42,6 +42,7 @@
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
AC_REQUIRE([gl_PROG_AR_RANLIB])
+ AC_REQUIRE([AM_PROG_CC_C_O])
# Code from module absolute-header:
# Code from module accept:
# Code from module accept-tests:
@@ -104,7 +105,6 @@
# Code from module btoc32-tests:
# Code from module btowc:
# Code from module btowc-tests:
- # Code from module buffer-lcm:
# Code from module builtin-expect:
# Code from module byteswap:
# Code from module byteswap-tests:
@@ -170,8 +170,6 @@
# Code from module chown:
# Code from module chown-tests:
# Code from module chownat:
- # Code from module cl-strtod:
- # Code from module cl-strtold:
I don't want to send 200 lines of diff, but these are all placed at
the end by gnulib-tool.py. This seems to be because gnulib-tool.sh
sorts by module name, but gnulib-tool.py sorts by file path.
Since gnulib-tool.py stores --local-dir modules relative to destdir
and non --local-dir modules as absolute paths (not sure if this is
*always* true) they are sorted differently.
For gnulib-tool.py:
/home/collin/modules/zzz < gl/modules/aaa
but for gnulib-tool.sh:
zzz > aaa
The solution to this would be to change GLModule.__lt__() to use the
module name instead of the file path [1]. I feel that, for
consistency, all of the comparison operators should be changed in that
case. This seems to be the intended behavior when I read the
"Extending Gnulib" section of the manual [2]. The module name is a
unique identifier and the process for choosing the actual module
description file is given by the --local-dir ordering, correct?
As a side effect of using the module name, calling this function
repeatedly is really slow:
def getName(self):
pattern = re.compile(joinpath('modules', '(.*)$'))
result = pattern.findall(self.path)[0]
return result
Before:
$ time env GNULIB_TOOL_IMPL=py ./test-all.sh
real 0m6.189s
user 0m3.326s
sys 0m2.936s
After:
$ time env GNULIB_TOOL_IMPL=py ./test-all.sh
real 0m23.791s
user 0m20.847s
sys 0m2.950s
But that is an easy fix. I just have to figure out how to write it so
that it isn't ugly. :)
[1] https://docs.python.org/3/howto/sorting.html#odds-and-ends
[2] https://www.gnu.org/software/gnulib/manual/gnulib.html#Extending-Gnulib
Collin
From 18d4b947255f910cd93b9aec4963d03231b15913 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Mon, 25 Mar 2024 21:33:29 -0700
Subject: [PATCH] gnulib-tool.py: Fix sorting of modules when --local-dir is
used.
* pygnulib/GLModuleSystem.py (GLModule.__eq__, GLModule.__ne__)
(GLModule.__ge__, GLModule.__gt__, GLModule.__hash__, GLModule.__le__)
(GLModule.__lt__): Use module names as identifiers instead of paths.
---
ChangeLog | 7 +++++++
pygnulib/GLModuleSystem.py | 14 +++++++-------
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d72b1ebb82..2ae1c7340e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-03-25 Collin Funk <collin.fu...@gmail.com>
+
+ gnulib-tool.py: Fix sorting of modules when --local-dir is used.
+ * pygnulib/GLModuleSystem.py (GLModule.__eq__, GLModule.__ne__)
+ (GLModule.__ge__, GLModule.__gt__, GLModule.__hash__, GLModule.__le__)
+ (GLModule.__lt__): Use module names as identifiers instead of paths.
+
2024-03-25 Collin Funk <collin.fu...@gmail.com>
gnulib-tool.py: Only process configure.ac once.
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index d2c83b2911..38379da3d3 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -231,7 +231,7 @@ class GLModule(object):
'''x.__eq__(y) <==> x==y'''
result = False
if type(module) is GLModule:
- if self.path == module.path:
+ if self.getName() == module.getName():
result = True
return result
@@ -239,7 +239,7 @@ class GLModule(object):
'''x.__ne__(y) <==> x!=y'''
result = False
if type(module) is GLModule:
- if self.path != module.path:
+ if self.getName() != module.getName():
result = True
return result
@@ -247,7 +247,7 @@ class GLModule(object):
'''x.__ge__(y) <==> x>=y'''
result = False
if type(module) is GLModule:
- if self.path >= module.path:
+ if self.getName() >= module.getName():
result = True
return result
@@ -255,20 +255,20 @@ class GLModule(object):
'''x.__gt__(y) <==> x>y'''
result = False
if type(module) is GLModule:
- if self.path > module.path:
+ if self.getName() > module.getName():
result = True
return result
def __hash__(self):
'''x.__hash__() <==> hash(x)'''
- result = hash(self.path) ^ hash(self.patched)
+ result = hash(self.getName()) ^ hash(self.patched)
return result
def __le__(self, module):
'''x.__le__(y) <==> x<=y'''
result = False
if type(module) is GLModule:
- if self.path <= module.path:
+ if self.getName() <= module.getName():
result = True
return result
@@ -276,7 +276,7 @@ class GLModule(object):
'''x.__lt__(y) <==> x<y'''
result = False
if type(module) is GLModule:
- if self.path < module.path:
+ if self.getName() < module.getName():
result = True
return result
--
2.44.0