##// END OF EJS Templates
setup: set mode 644 or 755 on installed files
Kyle Lippincott -
r22640:e88a634e default
parent child Browse files
Show More
@@ -63,7 +63,7 b' else:'
63 63 raise SystemExit(
64 64 "Couldn't import standard bz2 (incomplete Python install).")
65 65
66 import os, subprocess, time
66 import os, stat, subprocess, time
67 67 import re
68 68 import shutil
69 69 import tempfile
@@ -73,9 +73,10 b' from distutils.dist import Distribution'
73 73 from distutils.command.build import build
74 74 from distutils.command.build_ext import build_ext
75 75 from distutils.command.build_py import build_py
76 from distutils.command.install_lib import install_lib
76 77 from distutils.command.install_scripts import install_scripts
77 78 from distutils.spawn import spawn, find_executable
78 from distutils import cygwinccompiler
79 from distutils import cygwinccompiler, file_util
79 80 from distutils.errors import CCompilerError, DistutilsExecError
80 81 from distutils.sysconfig import get_python_inc, get_config_var
81 82 from distutils.version import StrictVersion
@@ -375,6 +376,39 b' class buildhgexe(build_ext):'
375 376 libraries=[],
376 377 output_dir=self.build_temp)
377 378
379 class hginstalllib(install_lib):
380 '''
381 This is a specialization of install_lib that replaces the copy_file used
382 there so that it supports setting the mode of files after copying them,
383 instead of just preserving the mode that the files originally had. If your
384 system has a umask of something like 027, preserving the permissions when
385 copying will lead to a broken install.
386
387 Note that just passing keep_permissions=False to copy_file would be
388 insufficient, as it might still be applying a umask.
389 '''
390
391 def run(self):
392 realcopyfile = file_util.copy_file
393 def copyfileandsetmode(*args, **kwargs):
394 src, dst = args[0], args[1]
395 dst, copied = realcopyfile(*args, **kwargs)
396 if copied:
397 st = os.stat(src)
398 # Persist executable bit (apply it to group and other if user
399 # has it)
400 if st[stat.ST_MODE] & stat.S_IXUSR:
401 setmode = 0755
402 else:
403 setmode = 0644
404 os.chmod(dst, (stat.S_IMODE(st[stat.ST_MODE]) & ~0777) |
405 setmode)
406 file_util.copy_file = copyfileandsetmode
407 try:
408 install_lib.run(self)
409 finally:
410 file_util.copy_file = realcopyfile
411
378 412 class hginstallscripts(install_scripts):
379 413 '''
380 414 This is a specialization of install_scripts that replaces the @LIBDIR@ with
@@ -426,6 +460,7 b" cmdclass = {'build': hgbuild,"
426 460 'build_ext': hgbuildext,
427 461 'build_py': hgbuildpy,
428 462 'build_hgextindex': buildhgextindex,
463 'install_lib': hginstalllib,
429 464 'install_scripts': hginstallscripts,
430 465 'build_hgexe': buildhgexe,
431 466 }
General Comments 0
You need to be logged in to leave comments. Login now