1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/installer/dozip.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,42 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +# This script creates a zip file, but will also strip any binaries 1.9 +# it finds before adding them to the zip. 1.10 + 1.11 +from mozpack.files import FileFinder 1.12 +from mozpack.copier import Jarrer 1.13 +from mozpack.errors import errors 1.14 + 1.15 +import argparse 1.16 +import buildconfig 1.17 +import mozpack.path as mozpath 1.18 +import os 1.19 +import sys 1.20 +import tempfile 1.21 + 1.22 +def main(args): 1.23 + parser = argparse.ArgumentParser() 1.24 + parser.add_argument("--base-dir", 1.25 + default=os.path.join(buildconfig.topobjdir, 1.26 + "dist", "bin"), 1.27 + help="Store paths relative to this directory") 1.28 + parser.add_argument("zip", help="Path to zip file to write") 1.29 + parser.add_argument("input", nargs="+", 1.30 + help="Path to files to add to zip") 1.31 + args = parser.parse_args(args) 1.32 + 1.33 + jarrer = Jarrer(optimize=False) 1.34 + 1.35 + with errors.accumulate(): 1.36 + finder = FileFinder(args.base_dir) 1.37 + for i in args.input: 1.38 + path = mozpath.relpath(i, args.base_dir) 1.39 + for p, f in finder.find(path): 1.40 + jarrer.add(p, f) 1.41 + jarrer.copy(args.zip) 1.42 + 1.43 + 1.44 +if __name__ == '__main__': 1.45 + main(sys.argv[1:])