import logging import optparse import sys import distutils.version from wizard import command, deploy, git, shell, util def main(argv, baton): usage = """usage: %prog configure [ARGS] Takes an already cloned working copy and configures the application, running any installer scripts and creating configuration files. Options change depending on what application is being configured in the current working directory. This is a plumbing command, normal users should use `%prog install`.""" # XXX: squick squick squick if argv and argv[0][0] != '-': if '--help' not in argv and '-h' not in argv: argv.append('--help') if '--help' in argv or '-h' in argv: # Do a "fake parse" in order to get out the application name parser = optparse.OptionParser(usage, add_help_option=False) parser.add_option("--help", "-h", action="store_true") options, args = parser.parse_args(argv) try: application = args[0] except IndexError: parser.error("Use 'wizard configure --help APP' to see APP-specific options.") version = None # not relevant else: tag = git.describe() application, _, version = tag.partition('-') app = deploy.applications()[application] handler = app.install_handler parser = command.WizardOptionParser(usage) handler.push(parser) options, args = parser.parse_all(argv) handler.handle(options) app.install(distutils.version.LooseVersion(version), options) sh = shell.Shell() message = "Autoinstall configuration of %s locker.\n\n%s" % (util.get_dir_owner(), util.get_git_footer()) util.set_git_env() try: message += "\nConfigured-by: " + util.get_operator_git() except util.NoOperatorInfo: pass sh.call("git", "commit", "--allow-empty", "-a", "-m", message)