forked from EFForg/https-everywhere
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_xpi.py
More file actions
35 lines (26 loc) · 855 Bytes
/
create_xpi.py
File metadata and controls
35 lines (26 loc) · 855 Bytes
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
31
32
33
34
35
#!/usr/bin/env python
# Uses the Python zip implementation to create deterministic XPI's
# Author: Yan Zhu, yan@mit.edu
"""
Usage: python create_xpi.py -x <exclusions> -n <name of zipped file> <directory>
"""
import zipfile_deterministic as zipfile
import sys
import glob
import getopt
opts, args = getopt.getopt(sys.argv[1:], 'x:n:')
exclusions = []
for o, v in opts:
if o == "-x":
exclusionsFile = v
with open(exclusionsFile) as f:
for line in f:
exclusions.extend(glob.glob(line.strip()))
exclusions = map(lambda x: './'+x, exclusions)
elif o == "-n":
xpiName = v
compress = zipfile.ZIP_DEFLATED
xpiFile = zipfile.ZipFile(xpiName, mode='w', compression=compress)
directory = args[0]
xpiFile.write_from_directory(directory, exclusions, compress_type=compress)
xpiFile.close()