##// END OF EJS Templates
contrib: add execute bit for fixpax.py
timeless -
r27495:58eb1c5b default
parent child Browse files
Show More
@@ -1,60 +1,61 b''
1 #!/usr/bin/env python
1 # fixpax - fix ownership in bdist_mpkg output
2 # fixpax - fix ownership in bdist_mpkg output
2 #
3 #
3 # Copyright 2015 Matt Mackall <mpm@selenic.com>
4 # Copyright 2015 Matt Mackall <mpm@selenic.com>
4 #
5 #
5 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
6 # MIT license (http://opensource.org/licenses/MIT)
7 # MIT license (http://opensource.org/licenses/MIT)
7
8
8 """Set file ownership to 0 in an Archive.pax.gz.
9 """Set file ownership to 0 in an Archive.pax.gz.
9 Suitable for fixing files bdist_mpkg output:
10 Suitable for fixing files bdist_mpkg output:
10 *.mpkg/Contents/Packages/*.pkg/Contents/Archive.pax.gz
11 *.mpkg/Contents/Packages/*.pkg/Contents/Archive.pax.gz
11 """
12 """
12
13
13 import sys, os, gzip
14 import sys, os, gzip
14
15
15 def fixpax(iname, oname):
16 def fixpax(iname, oname):
16 i = gzip.GzipFile(iname)
17 i = gzip.GzipFile(iname)
17 o = gzip.GzipFile(oname, "w")
18 o = gzip.GzipFile(oname, "w")
18
19
19 while True:
20 while True:
20 magic = i.read(6)
21 magic = i.read(6)
21 dev = i.read(6)
22 dev = i.read(6)
22 ino = i.read(6)
23 ino = i.read(6)
23 mode = i.read(6)
24 mode = i.read(6)
24 i.read(6) # uid
25 i.read(6) # uid
25 i.read(6) # gid
26 i.read(6) # gid
26 nlink = i.read(6)
27 nlink = i.read(6)
27 rdev = i.read(6)
28 rdev = i.read(6)
28 mtime = i.read(11)
29 mtime = i.read(11)
29 namesize = i.read(6)
30 namesize = i.read(6)
30 filesize = i.read(11)
31 filesize = i.read(11)
31 name = i.read(int(namesize, 8))
32 name = i.read(int(namesize, 8))
32 data = i.read(int(filesize, 8))
33 data = i.read(int(filesize, 8))
33
34
34 o.write(magic)
35 o.write(magic)
35 o.write(dev)
36 o.write(dev)
36 o.write(ino)
37 o.write(ino)
37 o.write(mode)
38 o.write(mode)
38 o.write("000000")
39 o.write("000000")
39 o.write("000000")
40 o.write("000000")
40 o.write(nlink)
41 o.write(nlink)
41 o.write(rdev)
42 o.write(rdev)
42 o.write(mtime)
43 o.write(mtime)
43 o.write(namesize)
44 o.write(namesize)
44 o.write(filesize)
45 o.write(filesize)
45 o.write(name)
46 o.write(name)
46 o.write(data)
47 o.write(data)
47
48
48 if name.startswith("TRAILER!!!"):
49 if name.startswith("TRAILER!!!"):
49 o.write(i.read())
50 o.write(i.read())
50 break
51 break
51
52
52 o.close()
53 o.close()
53 i.close()
54 i.close()
54
55
55 if __name__ == '__main__':
56 if __name__ == '__main__':
56 for iname in sys.argv[1:]:
57 for iname in sys.argv[1:]:
57 print 'fixing file ownership in %s' % iname
58 print 'fixing file ownership in %s' % iname
58 oname = sys.argv[1] + '.tmp'
59 oname = sys.argv[1] + '.tmp'
59 fixpax(iname, oname)
60 fixpax(iname, oname)
60 os.rename(oname, iname)
61 os.rename(oname, iname)
General Comments 0
You need to be logged in to leave comments. Login now