From 870cc8d8d51c600d1b9faa0a2d6a5a9dba8b5354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Thu, 21 Nov 2013 12:31:23 -0300 Subject: Create bundler for OSX --- bundler/main.py | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 bundler/main.py (limited to 'bundler/main.py') diff --git a/bundler/main.py b/bundler/main.py new file mode 100644 index 0000000..2c1207e --- /dev/null +++ b/bundler/main.py @@ -0,0 +1,116 @@ +# TODO: +# - Check if inside a virtualenv, and warn before doing anything +# - Build everything that we are currently expecting as a binary +# - Create complete bundle changelog + +import argparse +import os +import tempfile + +from contextlib import contextmanager +from distutils import dir_util + +from actions import GitCloneAll, PythonSetupAll, CreateDirStructure +from actions import CollectAllDeps, CopyBinaries, PLister, SeededConfig +from actions import DarwinLauncher, CopyAssets, CopyMisc, FixDylibs +from actions import DmgIt, PycRemover + +from utils import IS_MAC + +sorted_repos = [ + "leap_assets", + "leap_pycommon", + "keymanager", + "soledad", + "leap_mail", + "bitmask_client", + "bitmask_launcher", + "thandy" +] + +@contextmanager +def new_build_dir(default=None): + bd = default + if bd is None: + bd = tempfile.mkdtemp(prefix="bundler-") + yield bd + # Only remove if created a temp dir + if default is None: + dir_util.remove_tree(bd) + +def main(): + parser = argparse.ArgumentParser(description='Bundle creation tool.') + parser.add_argument('--workon', help="") + parser.add_argument('--skip', nargs="*", default=[], help="") + parser.add_argument('--do', nargs="*", default=[], help="") + parser.add_argument('--paths-file', help="") + parser.add_argument('--binaries', help="") + parser.add_argument('--seeded-config', help="") + parser.add_argument('--nightly', action="store_true", help="") + + args = parser.parse_args() + + assert args.paths_file is not None, \ + "We need a paths file, otherwise you'll get " \ + "problems with distutils and site" + paths_file = os.path.realpath(args.paths_file) + + assert args.binaries is not None, \ + "We don't support building from source, so you'll need to " \ + "specify a binaries path" + binaries_path = os.path.realpath(args.binaries) + + seeded_config = None + if args.seeded_config is not None: + seeded_config = os.path.realpath(args.seeded_config) + + with new_build_dir(os.path.realpath(args.workon)) as bd: + print "Doing it all in", bd + + def init(t, bd=bd): + return t(bd, args.skip, args.do) + + gc = init(GitCloneAll) + gc.run(sorted_repos, args.nightly) + + ps = init(PythonSetupAll) + ps.run(sorted_repos) + + cd = init(CreateDirStructure, os.path.join(bd, "Bitmask")) + cd.run() + + dp = init(CollectAllDeps) + dp.run(paths_file) + + if binaries_path is not None: + cb = init(CopyBinaries) + cb.run(binaries_path) + + if seeded_config is not None: + sc = init(SeededConfig) + sc.run(seeded_config) + + if IS_MAC: + pl = init(PLister) + pl.run() + dl = init(DarwinLauncher) + dl.run() + ca = init(CopyAssets) + ca.run() + fd = init(FixDylibs) + fd.run() + + cm = init(CopyMisc) + cm.run() + + pyc = init(PycRemover) + pyc.run() + + if IS_MAC: + dm = init(DmgIt) + dm.run() + + # do manifest on windows + +if __name__ == "__main__": + main() -- cgit v1.2.3