diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-16 09:59:13 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-20 10:28:53 +0000 |
commit | 6c11fb357ec39bf087b8b632e2b1e375aef1b38b (patch) | |
tree | c8315530db18a8ee566521c39ab8a6af4f72bc03 /chromium/build/symlink.py | |
parent | 3ffaed019d0772e59d6cdb2d0d32fe4834c31f72 (diff) | |
download | qtwebengine-chromium-6c11fb357ec39bf087b8b632e2b1e375aef1b38b.tar.gz |
BASELINE: Update Chromium to 74.0.3729.159
Change-Id: I8d2497da544c275415aedd94dd25328d555de811
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/build/symlink.py')
-rwxr-xr-x | chromium/build/symlink.py | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/chromium/build/symlink.py b/chromium/build/symlink.py index 5a261dcad93..12942aa1706 100755 --- a/chromium/build/symlink.py +++ b/chromium/build/symlink.py @@ -3,25 +3,32 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -"""Make a symlink and optionally touch a file (to handle dependencies). - -Usage: - symlink.py [options] sources... target - -A sym link to source is created at target. If multiple sources are specfied, -then target is assumed to be a directory, and will contain all the links to +description = """ +Make a symlink and optionally touch a file (to handle dependencies). +""" +usage = "%prog [options] source[ source ...] linkname" +epilog = """ +A sym link to source is created at linkname. If multiple sources are specfied, +then linkname is assumed to be a directory, and will contain all the links to the sources (basenames identical to their source). + +On Windows, this will use hard links (mklink /H) to avoid requiring elevation. +This means that if the original is deleted and replaced, the link will still +have the old contents. This is not expected to interfere with the Chromium +build. """ import errno import optparse import os.path import shutil +import subprocess import sys def Main(argv): - parser = optparse.OptionParser() + parser = optparse.OptionParser(usage=usage, description=description, + epilog=epilog) parser.add_option('-f', '--force', action='store_true') parser.add_option('--touch') @@ -36,10 +43,23 @@ def Main(argv): if len(sources) == 1 and not os.path.isdir(target): t = target t = os.path.expanduser(t) - if os.path.realpath(t) == s: + if os.path.realpath(t) == os.path.realpath(s): continue try: - os.symlink(s, t) + # N.B. Python 2.x does not have os.symlink for Windows. + # Python 3 has os.symlink for Windows, but requires either the admin- + # granted privilege SeCreateSymbolicLinkPrivilege or, as of Windows 10 + # 1703, that Developer Mode be enabled. Hard links and junctions do not + # require any extra privileges to create. + if os.name == 'nt': + # mklink does not tolerate /-delimited path names. + t = t.replace('/', '\\') + s = s.replace('/', '\\') + # N.B. This tool only handles file hardlinks, not directory junctions. + subprocess.check_output(['cmd.exe', '/c', 'mklink', '/H', t, s], + stderr=subprocess.STDOUT) + else: + os.symlink(s, t) except OSError, e: if e.errno == errno.EEXIST and options.force: if os.path.isdir(t): @@ -49,6 +69,18 @@ def Main(argv): os.symlink(s, t) else: raise + except subprocess.CalledProcessError, e: + # Since subprocess.check_output does not return an easily checked error + # number, in the 'force' case always assume it is 'file already exists' + # and retry. + if options.force: + if os.path.isdir(t): + shutil.rmtree(t, ignore_errors=True) + else: + os.remove(t) + subprocess.check_output(e.cmd, stderr=subprocess.STDOUT) + else: + raise if options.touch: |