# HG changeset patch # User Tom Rodriguez # Date 1394160220 28800 # Node ID 9d8aaa3200a3bca3e35a2f66443965be5f302131 # Parent 43a80ad2730a5dc45119600a7c99cd25c397d776 make mx respect umask when making jar files diff -r 43a80ad2730a -r 9d8aaa3200a3 mxtool/mx.py --- a/mxtool/mx.py Thu Mar 06 18:41:48 2014 -0800 +++ b/mxtool/mx.py Thu Mar 06 18:43:40 2014 -0800 @@ -2067,6 +2067,8 @@ shutil.rmtree(services) # Atomic on Unix shutil.move(tmp, d.path) + # Correct the permissions on the temporary file which is created with restrictive permissions + os.chmod(d.path, 0o666 & ~currentUmask) archives.append(d.path) # print time.time(), 'move:', tmp, '->', d.path d.notify_updated() @@ -2092,6 +2094,8 @@ # Atomic on Unix jarFile = join(p.dir, p.name + '.jar') shutil.move(tmp, jarFile) + # Correct the permissions on the temporary file which is created with restrictive permissions + os.chmod(jarFile, 0o666 & ~currentUmask) archives.append(jarFile) finally: if exists(tmp): @@ -2839,6 +2843,8 @@ os.close(fd) # Atomic on Unix shutil.move(tmp, zipPath) + # Correct the permissions on the temporary file which is created with restrictive permissions + os.chmod(zipPath, 0o666 & ~currentUmask) finally: if exists(tmp): os.remove(tmp) @@ -4039,8 +4045,14 @@ version = VersionSpec("1.0") +currentUmask = None + if __name__ == '__main__': # rename this module as 'mx' so it is not imported twice by the commands.py modules sys.modules['mx'] = sys.modules.pop('__main__') + # Capture the current umask since there's no way to query it without mutating it. + currentUmask = os.umask(0) + os.umask(currentUmask) + main()