Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 69 lines (57 sloc) 1.781 kb
0663ba1 @cortesi Initial checkin.
authored
1 #!/usr/bin/env python
2 import os, shutil, subprocess
3 import cubictemp
4
5 def walkTree(path, exclude=()):
6 for root, dirs, files in os.walk(path):
7 for f in files:
8 relpath = os.path.join(root[len(path)+1:], f)
9 for patt in exclude:
10 if fnmatch.fnmatch(relpath, patt):
11 break
12 else:
13 yield relpath
14
15
16 config = dict()
17
18
19 templates = set([
20 "chrome.manifest",
21 ])
22
23
24 def main():
25 from optparse import OptionParser, OptionGroup
26 parser = OptionParser(
27 usage = "%prog [options] src dest",
28 version="%prog 0.1",
29 )
30 parser.add_option(
31 "-b", "--bin", action="store_true",
32 dest="bin", default=False,
33 help = "Installation binary."
34 )
35 options, args = parser.parse_args()
36 if len(args) != 2:
37 parser.error("Please specify source and destination.")
38 config["bin"] = options.bin
39
40 for i in walkTree(args[0]):
41 src = os.path.join(args[0], i)
42 d, _ = os.path.split(i)
43 dstdir = os.path.join(args[1], d)
44 dst = os.path.join(args[1], i)
45 try:
46 os.makedirs(dstdir)
47 except OSError:
48 pass
49 if i in templates:
50 temp = cubictemp.File(src, **config)
51 df = file(dst, "w")
52 df.write(str(temp))
53 df.close()
54 else:
55 shutil.copy(src, dst)
56
57 if options.bin:
58 #src = os.path.join(args[1], "chrome")
59 #pwd = os.getcwd()
60 #os.chdir(src)
61 #subprocess.call(["zip", "-q", "-r", "apphash.jar", "."])
62 #os.chdir(pwd)
63 xpipath = os.path.abspath(args[1]+".xpi")
64 os.chdir(args[1])
65 subprocess.call(["zip", "-q", "-r", xpipath, "."])
66
67
68 main()
Something went wrong with that request. Please try again.