+2024-03-17 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Follow gnulib-tool changes, part 62.
+ Follow gnulib-tool change
+ 2020-02-22 Bruno Haible <bruno@clisp.org>
+ gnulib-tool: Ensure copied files are writable.
+ * pygnulib/constants.py (ensure_writable): New function. Make sure files
+ are writable.
+ (symlink_relative, hardlink): Use it.
+ * pygnulib/GLFileSystem.py (GLFileSystem.lookup)
+ (GLFileAssistant.add_or_update): Likewise.
+ * pygnulib/GLTestDir.py (GLTestDir.execute): Likewise.
+ * pygnulib/main.py (main): Likewise.
+
2024-03-17 Bruno Haible <bruno@clisp.org>
gnulib-tool: Add undocumented option --gnulib-dir.
--------------------------------------------------------------------------------
-commit baec1bac1602ba8534320c295e120f7b658400f4
-Author: Bruno Haible <bruno@clisp.org>
-Date: Sat Feb 22 15:15:01 2020 +0100
-
- gnulib-tool: Ensure copied files are writable.
-
- Reported by Benno Fünfstück <benno.fuenfstueck@gmail.com> in
- <https://lists.gnu.org/archive/html/bug-gnulib/2020-02/msg00101.html>.
-
- * gnulib-tool (func_ensure_writable): New function.
- (func_ln_s, func_hardlink, func_lookup_file, func_import,
- func_create_testdir, copy-file): Invoke it after copying a file.
-
---------------------------------------------------------------------------------
-
commit 30459fe101541698ec704acb224946d73676750e
Author: Bruno Haible <bruno@clisp.org>
Date: Thu Jun 8 15:09:31 2017 +0200
copyfile = constants.copyfile
movefile = constants.movefile
hardlink = constants.hardlink
+ensure_writable = constants.ensure_writable
link_if_changed = constants.link_if_changed
isdir = os.path.isdir
isfile = os.path.isfile
if isfile(tempFile):
os.remove(tempFile)
copyfile(lookedupFile, tempFile)
+ ensure_writable(tempFile)
for diff_in_localdir in reversed(lookedupPatches):
command = 'patch -s "%s" < "%s" >&2' % (tempFile, diff_in_localdir)
try: # Try to apply patch
sed_transform_testsrelated_lib_file = self.transformers.get('tests', '')
try: # Try to copy lookedup file to tmpfile
copyfile(lookedup, tmpfile)
+ ensure_writable(tmpfile)
except Exception as error:
raise GLError(15, lookedup)
# Don't process binary files with sed.
joinpath = constants.joinpath
relinverse = constants.relinverse
copyfile = constants.copyfile
+ensure_writable = constants.ensure_writable
movefile = constants.movefile
isdir = os.path.isdir
isfile = os.path.isfile
os.remove(destpath)
if flag:
copyfile(lookedup, destpath)
+ ensure_writable(destpath)
else: # if not flag
if self.filesystem.shouldLink(src, lookedup) == CopyAction.Symlink:
constants.link_relative(lookedup, destpath)
constants.hardlink(lookedup, destpath)
else:
copyfile(lookedup, destpath)
+ ensure_writable(destpath)
# Create $sourcebase/Makefile.am.
for_test = True
import re
import os
import sys
+import stat
import platform
import shutil
import tempfile
return os.path.normpath(os.path.join(dir1, dir2))
+def ensure_writable(dest: str) -> None:
+ '''Ensure that the file dest is writable.'''
+ # os.stat throws FileNotFoundError error but we assume it exists.
+ st = os.stat(dest)
+ if not (st.st_mode & stat.S_IWUSR):
+ os.chmod(dest, st.st_mode | stat.S_IWUSR)
+
+
def relinverse(dir):
'''Compute the inverse of dir. Namely, a relative pathname consisting only
of '..' components, such that dir/relinverse = '.'.
else:
cp_src = src
copyfile2(cp_src, dest)
+ ensure_writable(dest)
def as_link_value_at_dest(src, dest):
else:
cp_src = src
copyfile2(cp_src, dest)
+ ensure_writable(dest)
def filter_filelist(separator, filelist,
TESTS = constants.TESTS
joinpath = constants.joinpath
copyfile = constants.copyfile
+ensure_writable = constants.ensure_writable
isabs = os.path.isabs
isdir = os.path.isdir
isfile = os.path.isfile
assistant = classes.GLFileAssistant(config)
tmpfile = assistant.tmpfilename(destpath)
copyfile(lookedup, tmpfile)
+ ensure_writable(tmpfile)
assistant.setOriginal(srcpath)
assistant.config.setDestDir(destdir)
assistant.setRewritten(destpath)