Two simple patches. This just makes it so that the library Makefile
is output after gnulib-comp.m4.

The second patch fixes an error that I noticed because of this
change. We have a loop like this:

for file in ['Makefile.in.in', 'remove-potcdate.sin']:
    tmpfile = self.assistant.tmpfilename(joinpath(pobase, file))

but the removal of the temporary file is done inside of the parent,
outside of the loop. Therefore only the second temporary file would be
deleted.

Collin
From 3d500b2a124193e73f32a6c40d9e39b248d2a0da Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Mon, 18 Mar 2024 19:58:37 -0700
Subject: [PATCH 3/4] gnulib-tool.py: Follow gnulib-tool changes, part 67.

Follow gnulib-tool change
2022-03-01  Paul Eggert  <egg...@cs.ucla.edu>
Create lib/Makefile.am after gnulib-comp.m4

* pygnulib/GLImport.py (GLImport.execute): Create library makefile after
creating gnulib-comp.m4.
---
 ChangeLog            |  9 +++++++
 gnulib-tool.py.TODO  | 12 ----------
 pygnulib/GLImport.py | 56 +++++++++++++++++++++++---------------------
 3 files changed, 38 insertions(+), 39 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 20fd33b97a..fada1a3be6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-03-18  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 67.
+	Follow gnulib-tool change
+	2022-03-01  Paul Eggert  <egg...@cs.ucla.edu>
+	Create lib/Makefile.am after gnulib-comp.m4
+	* pygnulib/GLImport.py (GLImport.execute): Create library makefile after
+	creating gnulib-comp.m4.
+
 2024-03-18  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 66.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index 819cca07e6..75a51fc6b8 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -61,18 +61,6 @@ Date:   Fri Jun 3 17:52:19 2022 -0700
 
 --------------------------------------------------------------------------------
 
-commit 8c4f4d7a3c28f88b64fce2fb1d0dc0e570d1a482
-Author: Paul Eggert <egg...@cs.ucla.edu>
-Date:   Tue Mar 1 10:01:22 2022 -0800
-
-    Create lib/Makefile.am after gnulib-comp.m4
-
-    * gnulib-tool (func_import): Create library makefile after
-    creating gnulib-comp.m4.  With --gnu-make, the latter depends on
-    the former.  See <https://bugs.gnu.org/32452#109>.
-
---------------------------------------------------------------------------------
-
 commit 30459fe101541698ec704acb224946d73676750e
 Author: Bruno Haible <br...@clisp.org>
 Date:   Thu Jun 8 15:09:31 2017 +0200
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index 937c8d42e2..84bd01ecf3 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -1184,33 +1184,6 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         self.makefiletable.editor('', 'ACLOCAL_AMFLAGS', m4base)
         self.makefiletable.parent(gentests, source_makefile_am, tests_makefile_am)
 
-        # Create library makefile.
-        basename = joinpath(sourcebase, source_makefile_am)
-        tmpfile = self.assistant.tmpfilename(basename)
-        emit, uses_subdirs = self.emitter.lib_Makefile_am(basename,
-                                                          self.moduletable['main'], self.moduletable, self.makefiletable,
-                                                          actioncmd, for_test)
-        if automake_subdir:
-            emit = sp.run([joinpath(DIRS['root'], 'build-aux/prefix-gnulib-mk'), '--from-gnulib-tool',
-                           f'--lib-name={libname}', f'--prefix={sourcebase}/'],
-                          input=emit, text=True, capture_output=True).stdout
-        with codecs.open(tmpfile, 'wb', 'UTF-8') as file:
-            file.write(emit)
-        filename, backup, flag = self.assistant.super_update(basename, tmpfile)
-        if flag == 1:
-            if not self.config['dryrun']:
-                print('Updating %s (backup in %s)' % (filename, backup))
-            else:  # if self.config['dryrun']
-                print('Update %s (backup in %s)' % (filename, backup))
-        elif flag == 2:
-            if not self.config['dryrun']:
-                print('Creating %s' % filename)
-            else:  # if self.config['dryrun']:
-                print('Create %s' % filename)
-            filetable['added'] += [filename]
-        if isfile(tmpfile):
-            os.remove(tmpfile)
-
         # Create po/ directory.
         filesystem = GLFileSystem(self.config)
         if pobase:
@@ -1365,6 +1338,35 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         if isfile(tmpfile):
             os.remove(tmpfile)
 
+        # Create library makefile.
+        # Do this after creating gnulib-comp.m4, because func_emit_lib_Makefile_am
+        # can run 'autoconf -t', which reads gnulib-comp.m4.
+        basename = joinpath(sourcebase, source_makefile_am)
+        tmpfile = self.assistant.tmpfilename(basename)
+        emit, uses_subdirs = self.emitter.lib_Makefile_am(basename,
+                                                          self.moduletable['main'], self.moduletable, self.makefiletable,
+                                                          actioncmd, for_test)
+        if automake_subdir:
+            emit = sp.run([joinpath(DIRS['root'], 'build-aux/prefix-gnulib-mk'), '--from-gnulib-tool',
+                           f'--lib-name={libname}', f'--prefix={sourcebase}/'],
+                          input=emit, text=True, capture_output=True).stdout
+        with codecs.open(tmpfile, 'wb', 'UTF-8') as file:
+            file.write(emit)
+        filename, backup, flag = self.assistant.super_update(basename, tmpfile)
+        if flag == 1:
+            if not self.config['dryrun']:
+                print('Updating %s (backup in %s)' % (filename, backup))
+            else:  # if self.config['dryrun']
+                print('Update %s (backup in %s)' % (filename, backup))
+        elif flag == 2:
+            if not self.config['dryrun']:
+                print('Creating %s' % filename)
+            else:  # if self.config['dryrun']:
+                print('Create %s' % filename)
+            filetable['added'] += [filename]
+        if isfile(tmpfile):
+            os.remove(tmpfile)
+
         # Create tests Makefile.
         if gentests:
             basename = joinpath(testsbase, tests_makefile_am)
-- 
2.44.0

From 702d7c951eefe2d48bb8eb587ca4b1a0b26a616c Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Mon, 18 Mar 2024 20:01:50 -0700
Subject: [PATCH 4/4] gnulib-tool.py: Make sure temporary files are removed.

* pygnulib/GLImport.py (GLImport.execute): Fix nesting of statement so
that both temporary files are removed.
---
 ChangeLog            | 6 ++++++
 pygnulib/GLImport.py | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fada1a3be6..58d7528e92 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-03-18  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Make sure temporary files are removed.
+	* pygnulib/GLImport.py (GLImport.execute): Fix nesting of statement so
+	that both temporary files are removed.
+
 2024-03-18  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 67.
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index 84bd01ecf3..0c268f6b47 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -1206,8 +1206,8 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
                     else:  # if self.config['dryrun']:
                         print('Create %s' % filename)
                     filetable['added'] += [filename]
-            if isfile(tmpfile):
-                os.remove(tmpfile)
+                if isfile(tmpfile):
+                    os.remove(tmpfile)
 
             # Create po makefile parameterization, part 1.
             basename = joinpath(pobase, 'Makevars')
-- 
2.44.0

Reply via email to