X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/blobdiff_plain/7d857aba9c7d324084127f7ba4430b7607dd7824..8939cb421d77e7469160f38381cf2106974e5ba8:/wizard/app/mediawiki.py diff --git a/wizard/app/mediawiki.py b/wizard/app/mediawiki.py index 5c18b15..600eccd 100644 --- a/wizard/app/mediawiki.py +++ b/wizard/app/mediawiki.py @@ -1,11 +1,16 @@ import re +import distutils.version import os +import datetime +import logging +import shlex +import shutil -from wizard import app, deploy, install, util +from wizard import app, deploy, install, resolve, scripts, shell, util from wizard.app import php def make_filename_regex(var): - return 'LocalSettings.php', re.compile('^(\$' + app.expand_re(var) + r'''\s*=\s*)(.*)(;)$''', re.M) + return 'LocalSettings.php', re.compile('^(\$' + app.expand_re(var) + r'''\s*=\s*)(.*)(;)''', re.M) make_extractor = app.filename_regex_extractor(make_filename_regex) make_substitution = app.filename_regex_substitution(make_filename_regex) @@ -21,6 +26,101 @@ seed = { 'WIZARD_SECRETKEY': ('wgSecretKey', 'wgProxyKey'), } +resolutions = { +'LocalSettings.php': [ + (""" +<<<<<<< +***1*** +======= +## The URL base path to the directory containing the wiki; +## defaults for all runtime URL paths are based off of this. +## For more information on customizing the URLs please see: +## http://www.mediawiki.org/wiki/Manual:Short_URL +***2*** +$wgScriptExtension = ".php"; + +## UPO means: this is also a user preference option +>>>>>>> +""", [-1]), + (""" +<<<<<<< +***1*** +======= + +# MySQL specific settings +$wgDBprefix = ""; +>>>>>>> +""", ["\n# MySQL specific settings", 1]), + (""" +<<<<<<< +## is writable, then uncomment this: +***1*** +======= +## is writable, then set this to true: +$wgEnableUploads = false; +>>>>>>> +""", [-1]), + (""" +<<<<<<< +***1*** +$wgMathPath = "{$wgUploadPath}/math"; +$wgMathDirectory = "{$wgUploadDirectory}/math"; +$wgTmpDirectory = "{$wgUploadDirectory}/tmp"; +======= +$wgUseTeX = false; +>>>>>>> +""", [1]), + # order of these rules is important + (""" +<<<<<<< +$configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) ); +$wgCacheEpoch = max( $wgCacheEpoch, $configdate ); +***1*** +?> +======= +$wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) ); +>>>>>>> +""", [0, 1]), + (""" +<<<<<<< +$configdate = gmdate( 'YmdHis', @filemtime( __FILE__ ) ); +$wgCacheEpoch = max( $wgCacheEpoch, $configdate ); +***1*** +======= +$wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) ); +>>>>>>> +""", [0, 1]), + (""" +<<<<<<< +?> +======= +# When you make changes to this configuration file, this will make +# sure that cached pages are cleared. +$wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) ); +>>>>>>> +""", [0]), + (""" +<<<<<<< +***1*** +?> +======= +# When you make changes to this configuration file, this will make +# sure that cached pages are cleared. +$wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) ); +>>>>>>> +""", [1, 0]), + (""" +<<<<<<< +***1*** +======= +# When you make changes to this configuration file, this will make +# sure that cached pages are cleared. +$wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) ); +>>>>>>> +""", [1, 0]), + ] +} + class Application(deploy.Application): parametrized_files = ['LocalSettings.php', 'php.ini'] deprecated_keys = set(['WIZARD_IP']) | php.deprecated_keys @@ -41,13 +141,60 @@ class Application(deploy.Application): handler = install.ArgHandler("mysql", "admin", "email") handler.add(install.Arg("title", help="Title of your new MediaWiki install")) return handler - def install(self, options): + def checkConfig(self, deployment): + return os.path.isfile(os.path.join(deployment.location, "LocalSettings.php")) + def detectVersion(self, deployment): + contents = deployment.read("includes/DefaultSettings.php") + regex = make_filename_regex("wgVersion")[1] + match = regex.search(contents) + if not match: return None + return distutils.version.LooseVersion(match.group(2)[1:-1]) + def checkWeb(self, d, out=None): + page = d.fetch("/index.php?title=Main_Page") + if type(out) is list: + out.append(page) + return page.find("