diff options
author | Philip Chimento <philip@endlessm.com> | 2018-06-05 13:47:01 -0700 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-06-07 00:18:21 +0300 |
commit | d9efee01d0dc08f8e41ef1f0dd239113309135a1 (patch) | |
tree | f0162ada56df0a62caf5667800d7d3e651a4dd8e /mesonbuild/scripts/gettext.py | |
parent | 9b791881ed61e3c9c68599c231337ffc8f5769b0 (diff) | |
download | meson-d9efee01d0dc08f8e41ef1f0dd239113309135a1.zip meson-d9efee01d0dc08f8e41ef1f0dd239113309135a1.tar.gz meson-d9efee01d0dc08f8e41ef1f0dd239113309135a1.tar.bz2 |
gettext: Install .mo files atomically
Without this, building a module in a Flatpak app manifest that is a
newer version of a module already present in the Flatpak runtime will
fail. (The Flatpak file system is a bunch of hard links to readonly
files, which can be replaced but not written to.)
This instead creates a temporary file in the same directory as the
destination (to avoid cross-device renaming errors) and atomically
renames the temporary file to the destination, replacing it instead of
rewriting it as shutil.copyfile() would do.
Diffstat (limited to 'mesonbuild/scripts/gettext.py')
-rw-r--r-- | mesonbuild/scripts/gettext.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/mesonbuild/scripts/gettext.py b/mesonbuild/scripts/gettext.py index f308c5a..593247a 100644 --- a/mesonbuild/scripts/gettext.py +++ b/mesonbuild/scripts/gettext.py @@ -81,9 +81,11 @@ def do_install(src_sub, bld_sub, dest, pkgname, langs): srcfile = os.path.join(bld_sub, l + '.gmo') outfile = os.path.join(dest, l, 'LC_MESSAGES', pkgname + '.mo') + tempfile = outfile + '.tmp' os.makedirs(os.path.dirname(outfile), exist_ok=True) - shutil.copyfile(srcfile, outfile) - shutil.copystat(srcfile, outfile) + shutil.copyfile(srcfile, tempfile) + shutil.copystat(srcfile, tempfile) + os.replace(tempfile, outfile) print('Installing %s to %s' % (srcfile, outfile)) return 0 |