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