blob: 177be7eab3fd01ee198ade895600f497f5933727 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/usr/bin/python -b
# Copyright 2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import os
import sys
from portage.util import apply_recursive_permissions
# Change back to original cwd _after_ all imports (bug #469338).
os.chdir(os.environ["__PORTAGE_HELPER_CWD"])
def main(files):
if sys.hexversion >= 0x3000000:
# We can't trust that the filesystem encoding (locale dependent)
# correctly matches the arguments, so use surrogateescape to
# pass through the original argv bytes for Python 3.
fs_encoding = sys.getfilesystemencoding()
files = [x.encode(fs_encoding, 'surrogateescape') for x in files]
for filename in files:
# Emulate 'chmod -fR a+rX,u+w,g-w,o-w' with minimal chmod calls.
apply_recursive_permissions(filename, filemode=0o644,
filemask=0o022, dirmode=0o755, dirmask=0o022)
return os.EX_OK
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
|