]> scripts.mit.edu Git - wizard.git/blob - wizard/command/prepare_config.py
Convert ad hoc shell calls to singleton instance; fix upgrade bug.
[wizard.git] / wizard / command / prepare_config.py
1 import sys
2 import os.path
3
4 from wizard import command, deploy, shell
5
6 def main(argv, baton):
7     options, args = parse_args(argv, baton)
8     wc = deploy.WorkingCopy(".")
9     wc.verify()
10     wc.verifyConfigured()
11     # worst case scenario protection
12     for file in wc.application.parametrized_files:
13         shell.call("git", "add", file)
14     shell.call("git", "commit", "--allow-empty", "-am", "Protection commit")
15     shell.call("git", "reset", "HEAD~")
16     wc.prepareConfig()
17
18 def parse_args(argv, baton):
19     usage = """usage: %prog prepare-config
20
21 During the preparation of an upgrade, changes to configuration files
22 must be taken into account.  Unfortunately, configuration files
23 are not commonly versioned, and are commonly autogenerated.  Running
24 this command will update all configuration files.
25
26 To be more specific, it replaces the specific values from the installation
27 back with generic values, which can be committed to the repository.  The final
28 working copy state has HEAD pointing to the -scripts version that the commit
29 was based off of, but with local changes that can be incorporated using
30 `git commit --amend -a`.  You should inspect the changes with `git diff`;
31 it is possible that the regular expressions in wizard.app.APPNAME are
32 now non-functional.
33
34 Wizard should be run in the environment installations are planned
35 to be deployed to, because installers can have subtle differences
36 in configuration files based on detected server configuration.
37 """
38     parser = command.WizardOptionParser(usage)
39     return parser.parse_all(argv)
40