comparison mxtool/mx.py @ 14103:9d8aaa3200a3

make mx respect umask when making jar files
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Thu, 06 Mar 2014 18:43:40 -0800
parents b167b1838029
children d2e4b81fd8f0
comparison
equal deleted inserted replaced
14102:43a80ad2730a 14103:9d8aaa3200a3
2065 zf.close() 2065 zf.close()
2066 os.close(fd) 2066 os.close(fd)
2067 shutil.rmtree(services) 2067 shutil.rmtree(services)
2068 # Atomic on Unix 2068 # Atomic on Unix
2069 shutil.move(tmp, d.path) 2069 shutil.move(tmp, d.path)
2070 # Correct the permissions on the temporary file which is created with restrictive permissions
2071 os.chmod(d.path, 0o666 & ~currentUmask)
2070 archives.append(d.path) 2072 archives.append(d.path)
2071 # print time.time(), 'move:', tmp, '->', d.path 2073 # print time.time(), 'move:', tmp, '->', d.path
2072 d.notify_updated() 2074 d.notify_updated()
2073 finally: 2075 finally:
2074 if exists(tmp): 2076 if exists(tmp):
2090 zf.close() 2092 zf.close()
2091 os.close(fd) 2093 os.close(fd)
2092 # Atomic on Unix 2094 # Atomic on Unix
2093 jarFile = join(p.dir, p.name + '.jar') 2095 jarFile = join(p.dir, p.name + '.jar')
2094 shutil.move(tmp, jarFile) 2096 shutil.move(tmp, jarFile)
2097 # Correct the permissions on the temporary file which is created with restrictive permissions
2098 os.chmod(jarFile, 0o666 & ~currentUmask)
2095 archives.append(jarFile) 2099 archives.append(jarFile)
2096 finally: 2100 finally:
2097 if exists(tmp): 2101 if exists(tmp):
2098 os.remove(tmp) 2102 os.remove(tmp)
2099 return archives 2103 return archives
2837 zf.write(f, arcname) 2841 zf.write(f, arcname)
2838 zf.close() 2842 zf.close()
2839 os.close(fd) 2843 os.close(fd)
2840 # Atomic on Unix 2844 # Atomic on Unix
2841 shutil.move(tmp, zipPath) 2845 shutil.move(tmp, zipPath)
2846 # Correct the permissions on the temporary file which is created with restrictive permissions
2847 os.chmod(zipPath, 0o666 & ~currentUmask)
2842 finally: 2848 finally:
2843 if exists(tmp): 2849 if exists(tmp):
2844 os.remove(tmp) 2850 os.remove(tmp)
2845 2851
2846 def _isAnnotationProcessorDependency(p): 2852 def _isAnnotationProcessorDependency(p):
4037 # no need to show the stack trace when the user presses CTRL-C 4043 # no need to show the stack trace when the user presses CTRL-C
4038 abort(1) 4044 abort(1)
4039 4045
4040 version = VersionSpec("1.0") 4046 version = VersionSpec("1.0")
4041 4047
4048 currentUmask = None
4049
4042 if __name__ == '__main__': 4050 if __name__ == '__main__':
4043 # rename this module as 'mx' so it is not imported twice by the commands.py modules 4051 # rename this module as 'mx' so it is not imported twice by the commands.py modules
4044 sys.modules['mx'] = sys.modules.pop('__main__') 4052 sys.modules['mx'] = sys.modules.pop('__main__')
4045 4053
4054 # Capture the current umask since there's no way to query it without mutating it.
4055 currentUmask = os.umask(0)
4056 os.umask(currentUmask)
4057
4046 main() 4058 main()