[gjs] build: Handle case where $bindir/gjs symlink already exists
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] build: Handle case where $bindir/gjs symlink already exists
- Date: Mon, 28 Oct 2019 18:06:25 +0000 (UTC)
commit a646ef7686906b303362c7a499aac1aa70c48e85
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Oct 26 16:38:26 2019 -0700
build: Handle case where $bindir/gjs symlink already exists
Python's os.symlink() will fail if the symlink already exists, so when
installing GJS in a prefix where it was already installed. This was
previously avoided with the -f option to ln.
Instead, create a temporary link and atomically rename it over the
existing link.
Unreviewed, pushing to fix build.
build/symlink-gjs.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/build/symlink-gjs.py b/build/symlink-gjs.py
index 51465e31..365a3211 100644
--- a/build/symlink-gjs.py
+++ b/build/symlink-gjs.py
@@ -4,6 +4,7 @@ import os
import shutil
import subprocess
import sys
+import tempfile
assert(len(sys.argv) == 2)
@@ -20,4 +21,10 @@ if os.name == 'nt':
# which is not what we want. Instead, copy gjs-console.exe.
shutil.copyfile('gjs-console.exe', os.path.join(installed_bin_dir, 'gjs.exe'))
else:
- os.symlink('gjs-console', os.path.join(installed_bin_dir, 'gjs'))
+ try:
+ temp_link = tempfile.mktemp(dir=installed_bin_dir)
+ os.symlink('gjs-console', temp_link)
+ os.replace(temp_link, os.path.join(installed_bin_dir, 'gjs'))
+ finally:
+ if os.path.islink(temp_link):
+ os.remove(temp_link)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]