def main(_): """Launch the appropriate builder.""" config_lib.CONFIG.AddContext( "ClientBuilder Context", "Context applied when we run the client builder script.") startup.ClientInit() # Use basic console output logging so we can see what is happening. logger = logging.getLogger() handler = logging.StreamHandler() handler.setLevel(logging.INFO) logger.handlers = [handler] context = flags.FLAGS.context context = SetContextFromArgs(context) signer = None if args.sign: if not args.templatedir: raise RuntimeError( "Signing must be performed on the host system since " "that's where the keys are. If you want signed " "binaries you need to build templates in the vagrant " "vms then pass the templatedir here to do the repack " "and sign operation on the host.") signer = GetSigner(context) if args.subparser_name == "build": template_path = None if flags.FLAGS.output: template_path = os.path.join( flags.FLAGS.output, config_lib.CONFIG.Get("PyInstaller.template_filename", context=context)) builder_obj = GetBuilder(context) builder_obj.MakeExecutableTemplate(output_file=template_path) elif args.subparser_name == "repack": Repack(context, signer=signer) elif args.subparser_name == "deploy": Deploy(context, signer=signer) elif args.subparser_name == "buildanddeploy": if args.platform == "windows": # Handle windows differently because we do 32, 64, and debug builds all at # once. BuildAndDeployWindows(signer=signer) else: BuildAndDeploy(context, signer=signer) elif args.subparser_name == "build_components": component.BuildComponents(output_dir=flags.FLAGS.output) elif args.subparser_name == "build_component": component.BuildComponent(flags.FLAGS.setup_file, output_dir=flags.FLAGS.output)
def main(_): """Launch the appropriate builder.""" if flags.FLAGS.subparser_name == "generate_client_config": # We don't need a full init to just build a config. GetClientConfig(flags.FLAGS.client_config_output) return # We deliberately use flags.FLAGS.context because client_startup.py pollutes # config_lib.CONFIG.context with the running system context. context = flags.FLAGS.context context.append("ClientBuilder Context") client_startup.ClientInit() # Use basic console output logging so we can see what is happening. logger = logging.getLogger() handler = logging.StreamHandler() handler.setLevel(logging.INFO) logger.handlers = [handler] if args.subparser_name == "build": TemplateBuilder().BuildTemplate(context=context, output=flags.FLAGS.output) elif args.subparser_name == "repack": if args.debug_build: context.append("DebugClientBuild Context") result_path = repacking.TemplateRepacker().RepackTemplate( args.template, args.output_dir, context=context, sign=args.sign, signed_template=args.signed_template) if not result_path: raise ErrorDuringRepacking(" ".join(sys.argv[:])) elif args.subparser_name == "repack_multiple": MultiTemplateRepacker().RepackTemplates( args.repack_configs, args.templates, args.output_dir, config=args.config, sign=args.sign, signed_template=args.signed_template) elif args.subparser_name == "build_components": component.BuildComponents(output_dir=flags.FLAGS.output) elif args.subparser_name == "build_component": component.BuildComponent(flags.FLAGS.setup_file, output_dir=flags.FLAGS.output) elif args.subparser_name == "sign_template": repacking.TemplateRepacker().SignTemplate(args.template, args.output_file, context=context) if not os.path.exists(args.output_file): raise RuntimeError("Signing failed: output not written")
def main(_): """Launch the appropriate builder.""" config_lib.CONFIG.AddContext( "ClientBuilder Context", "Context applied when we run the client builder script.") startup.ClientInit() # Make sure we have all the secondary configs since they may be set under the # ClientBuilder Context for secondconfig in config_lib.CONFIG["ConfigIncludes"]: config_lib.CONFIG.LoadSecondaryConfig(secondconfig) # Use basic console output logging so we can see what is happening. logger = logging.getLogger() handler = logging.StreamHandler() handler.setLevel(logging.INFO) logger.handlers = [handler] context = flags.FLAGS.context context = SetContextFromArgs(context) signer = None if args.sign: signer = GetSigner(context) if args.subparser_name == "build": builder_obj = GetBuilder(context) builder_obj.MakeExecutableTemplate() elif args.subparser_name == "repack": Repack(context, signer=signer) elif args.subparser_name == "deploy": Deploy(context, signer=signer) elif args.subparser_name == "buildanddeploy": if args.platform == "windows": # Handle windows differently because we do 32, 64, and debug builds all at # once. BuildAndDeployWindows(signer=signer) else: BuildAndDeploy(context, signer=signer) elif args.subparser_name == "build_components": component.BuildComponents(output_dir=flags.FLAGS.output) elif args.subparser_name == "build_component": component.BuildComponent(flags.FLAGS.setup_file, output_dir=flags.FLAGS.output)
def BuildAndRepack(context, signer=None, timestamp=None): """Run build and repack to create installers.""" # ISO 8601 date timestamp = timestamp or time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) # Output directory like: 2015-02-13T21:48:47-0800/linux_amd64_deb/ spec = "_".join((args.platform, args.arch, args.package_format)) output_dir = os.path.join( config_lib.CONFIG.Get("ClientBuilder.executables_dir", context=context), timestamp, spec) # If we weren't passed a template, build one if args.templatedir: template_path = TemplateInputFilename(context) else: component.BuildComponents(output_dir=output_dir) template_path = os.path.join( output_dir, config_lib.CONFIG.Get("PyInstaller.template_filename", context=context)) builder_obj = GetBuilder(context) builder_obj.MakeExecutableTemplate(output_file=template_path) # Get the list of contexts which we should be building. context_list = config_lib.CONFIG.Get("ClientBuilder.BuildTargets") logging.info("Building installers for: %s", context_list) repacked_list = [] for repackcontext in context_list: # Add the settings for this context for newcontext in repackcontext.split(","): context.append(newcontext) try: # If the ClientBuilder.target_platforms doesn't match our environment, # skip. if not config_lib.CONFIG.MatchBuildContext( args.platform, args.arch, args.package_format, context=context): continue # Make a nicer filename out of the context string. context_filename = repackcontext.replace("AllPlatforms Context,", "").replace(",", "_").replace( " ", "_") logging.info( "Repacking %s as %s with labels: %s", repackcontext, config_lib.CONFIG.Get("Client.name", context=context), config_lib.CONFIG.Get("Client.labels", context=context)) repacking.TemplateRepacker().RepackTemplate(template_path, os.path.join( output_dir, context_filename), signer=signer, context=context) repacked_list.append(context_filename) finally: # Remove the custom settings for the next repack for newcontext in repackcontext.split(","): context.remove(newcontext) logging.info("Complete, installers for %s are in %s", repacked_list, output_dir)