def __setup_build_options(self): global PACKAGING_STEPS, DESTDIR_OPTION_HELP bog = optparse.OptionGroup(self.oparser, "Build options") add_option = bog.add_option add_option("-w", "--workdir", help="Specify working dir to output results [%default]" ) choices = [step.name for step in self.env.steps] help = "Target step you want to go to: %s [%%default]" % choices add_option("", "--stepto", choices=choices, help=help) add_option("", "--upto", dest="stepto", choices=choices, help="Same as --stepto option (kept for backward compatibility)." ) collectors = Collectors.map() # {collector_type: collector_class} choices = collectors.keys() help = "Input type: %s [%%default]" % ", ".join(choices) add_option("-I", "--input-type", choices=choices, help=help) drivers = Backends.map() # {backend_type: backend_class} choices = drivers.keys() help = "Packaging driver: %s [%%default]" % ", ".join(choices) add_option("", "--driver", choices=choices, help=help) add_option("", "--backend", dest="driver", choices=choices, help="Same as --driver option" ) add_option("", "--destdir", help=DESTDIR_OPTION_HELP) add_option("-P", "--template-path", **setup_template_path_option()) self.oparser.add_option_group(bog)
def main(argv=sys.argv): logging.basicConfig(format="%(asctime)s %(levelname)-7s %(message)s", datefmt="%H:%M:%S", # or "%Y-%m-%d %H:%M:%S", ) o = O.Options() (opts, args) = o.parse_args(argv[1:]) listfile = args[0] if args else opts.config ccls = Collectors.map().get(opts.input_type) collector = ccls(listfile, opts) fs = collector.collect() if not fs: raise RuntimeError("Failed to collect files from " + listfile) pkgdata = P.PkgData(opts, fs) bcls = Backends.map().get(opts.driver) backend = bcls(pkgdata) rc = backend.run() return rc
def init_pkgdata(args): """ Initialize PkgData instance passed to backend classes. see also pmaker/app.py """ o = O.Options() (opts, args) = o.parse_args(shlex.split(args)) listfile = args[0] if args else opts.config ccls = Collectors.map().get(opts.input_type) collector = ccls(listfile, opts) fs = collector.collect() assert fs, "Failed to collect files from " + listfile pkgdata = P.PkgData(opts, fs) return pkgdata