toolkit/mozapps/installer/dozip.py

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

     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/.
     5 # This script creates a zip file, but will also strip any binaries
     6 # it finds before adding them to the zip.
     8 from mozpack.files import FileFinder
     9 from mozpack.copier import Jarrer
    10 from mozpack.errors import errors
    12 import argparse
    13 import buildconfig
    14 import mozpack.path as mozpath
    15 import os
    16 import sys
    17 import tempfile
    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)
    30     jarrer = Jarrer(optimize=False)
    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)
    41 if __name__ == '__main__':
    42     main(sys.argv[1:])

mercurial