toolkit/mozapps/installer/dozip.py

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:a1100b03eaf2
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 # This script creates a zip file, but will also strip any binaries
6 # it finds before adding them to the zip.
7
8 from mozpack.files import FileFinder
9 from mozpack.copier import Jarrer
10 from mozpack.errors import errors
11
12 import argparse
13 import buildconfig
14 import mozpack.path as mozpath
15 import os
16 import sys
17 import tempfile
18
19 def main(args):
20 parser = argparse.ArgumentParser()
21 parser.add_argument("--base-dir",
22 default=os.path.join(buildconfig.topobjdir,
23 "dist", "bin"),
24 help="Store paths relative to this directory")
25 parser.add_argument("zip", help="Path to zip file to write")
26 parser.add_argument("input", nargs="+",
27 help="Path to files to add to zip")
28 args = parser.parse_args(args)
29
30 jarrer = Jarrer(optimize=False)
31
32 with errors.accumulate():
33 finder = FileFinder(args.base_dir)
34 for i in args.input:
35 path = mozpath.relpath(i, args.base_dir)
36 for p, f in finder.find(path):
37 jarrer.add(p, f)
38 jarrer.copy(args.zip)
39
40
41 if __name__ == '__main__':
42 main(sys.argv[1:])

mercurial