Yesterday one of my patches included a tiny bug. In the Emacs source
directory:
$ env GNULIB_TOOL_IMPL=py ./admin/merge-gnulib
Copying file lib/gl_openssl.h
Traceback (most recent call last):
File "/home/collin/.local/src/emacs/../gnulib/pygnulib/main.py", line 1298,
in <module>
main()
File "/home/collin/.local/src/emacs/../gnulib/pygnulib/main.py", line 881, in
main
importer.execute(filetable, transformers)
File "/home/collin/.local/src/gnulib/pygnulib/GLImport.py", line 1130, in
execute
self.assistant.add_or_update(already_present)
File "/home/collin/.local/src/gnulib/pygnulib/GLFileSystem.py", line 398, in
add_or_update
os.remove(tmpfile)
FileNotFoundError: [Errno 2] No such file or directory: 'lib/gl_openssl.h.tmp'
It seems that this only occurs in packages with gnulib sources contained
in them. When the files are the same as what is currently in gnulib the
temporary file is not created. This should fix the issue:
diff --git a/pygnulib/GLFileSystem.py b/pygnulib/GLFileSystem.py
index 7c6c9a15ef..c199235e2e 100644
--- a/pygnulib/GLFileSystem.py
+++ b/pygnulib/GLFileSystem.py
@@ -395,7 +395,8 @@ class GLFileAssistant(object):
# frequently that developers don't put autogenerated files under
version control.
self.add(lookedup, tmpflag, tmpfile)
self.addFile(rewritten)
- os.remove(tmpfile)
+ if isfile(tmpfile):
+ os.remove(tmpfile)
The corresponding lines in gnulib-tool.sh use 'rm -f "$tmpfile"' to
silence warnings when files do not exist.
Collin
>From 2861a2b7295bca64b0560c59ffd8b8b959693c62 Mon Sep 17 00:00:00 2001
From: Collin Funk <[email protected]>
Date: Sat, 16 Mar 2024 20:43:00 -0700
Subject: [PATCH 3/3] gnulib-tool.py: Don't try to remove files that don't
exist.
* pygnulib/GLFileSystem.py (GLFileSystem.add_or_update): Check if the
temporary file exists before trying to remove it.
---
ChangeLog | 6 ++++++
pygnulib/GLFileSystem.py | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 926e8b20a2..be20514df2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-03-16 Collin Funk <[email protected]>
+
+ gnulib-tool.py: Don't try to remove files that don't exist.
+ * pygnulib/GLFileSystem.py (GLFileSystem.add_or_update): Check if the
+ temporary file exists before trying to remove it.
+
2024-03-16 Collin Funk <[email protected]>
gnulib-tool.py: Follow gnulib-tool changes, part 61.
diff --git a/pygnulib/GLFileSystem.py b/pygnulib/GLFileSystem.py
index 7c6c9a15ef..c199235e2e 100644
--- a/pygnulib/GLFileSystem.py
+++ b/pygnulib/GLFileSystem.py
@@ -395,7 +395,8 @@ class GLFileAssistant(object):
# frequently that developers don't put autogenerated files under version control.
self.add(lookedup, tmpflag, tmpfile)
self.addFile(rewritten)
- os.remove(tmpfile)
+ if isfile(tmpfile):
+ os.remove(tmpfile)
def super_update(self, basename, tmpfile):
'''GLFileAssistant.super_update(basename, tmpfile) -> tuple
--
2.44.0