X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/blobdiff_plain/bf58b59267060bdb462476d824b086131b444cd4..5f835f44034f079fe644879e8c27580a48e937cd:/wizard/app/mediawiki.py diff --git a/wizard/app/mediawiki.py b/wizard/app/mediawiki.py index 7ae7583..83018ce 100644 --- a/wizard/app/mediawiki.py +++ b/wizard/app/mediawiki.py @@ -1,26 +1,248 @@ import re +import distutils.version +import os +import lxml.cssselect +import lxml.etree +import StringIO +import logging -from wizard import app, deploy, util +from wizard import app, install, resolve, shell, sql, util from wizard.app import php -@app.filename_regex_extractor -def make_extractor(var): - return 'LocalSettings.php', re.compile('^\$' + re.escape(var) + r'''\s*=\s*((["\']).*\2);$''', re.M) - -class Application(deploy.Application): - @property - def extractors(self): - if not self._extractors: - self._extractors = util.dictmap(make_extractor, - {'WIZARD_IP': 'IP' # obsolete - ,'WIZARD_SITENAME': 'wgSitename' - ,'WIZARD_SCRIPTPATH': 'wgScriptPath' - ,'WIZARD_EMERGENCYCONTACT': 'wgEmergencyContact' - ,'WIZARD_DBSERVER': 'wgDBserver' - ,'WIZARD_DBNAME': 'wgDBname' - ,'WIZARD_DBUSER': 'wgDBuser' - ,'WIZARD_DBPASSWORD': 'wgDBpassword' - ,'WIZARD_PROXYKEY': 'wgProxyKey' - }) - self._extractors.update(php.extractors) - return self._extractors +# Note: Maintenance script exit codes +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# MediaWiki has notoriously spotty support for exit codes. It has +# gotten better, but there are still always cases that slip through, +# such as . +# As a result, we check both for exit codes AND for the "success" +# message in stdout. + +def make_filename_regex(var): + """See :ref:`versioning config ` for more information.""" + return 'LocalSettings.php', php.re_var(var) + +seed = util.dictmap(make_filename_regex, { + 'WIZARD_IP': 'IP', # obsolete, remove after we're done + 'WIZARD_SITENAME': 'wgSitename', + 'WIZARD_META_NAMESPACE': 'wgMetaNamespace', + 'WIZARD_SCRIPTPATH': 'wgScriptPath', + 'WIZARD_SERVER': 'wgServer', + 'WIZARD_EMERGENCYCONTACT': ('wgEmergencyContact', 'wgPasswordSender'), + 'WIZARD_DBSERVER': 'wgDBserver', + 'WIZARD_DBNAME': 'wgDBname', + 'WIZARD_DBUSER': 'wgDBuser', + 'WIZARD_DBPASSWORD': 'wgDBpassword', + 'WIZARD_SECRETKEY': ('wgSecretKey', 'wgProxyKey'), + 'WIZARD_UPGRADEKEY': 'wgUpgradeKey', + }) + +class Application(app.Application): + fullname = "MediaWiki" + database = "mysql" + parametrized_files = ['LocalSettings.php'] + php.parametrized_files + deprecated_keys = set(['WIZARD_IP']) | php.deprecated_keys + extractors = app.make_extractors(seed) + extractors.update(php.extractors) + substitutions = app.make_substitutions(seed) + substitutions.update(php.substitutions) + install_schema = install.ArgSchema("db", "admin", "email", "title") + random_keys = set(['WIZARD_SECRETKEY', 'WIZARD_UPGRADEKEY']) + def download(self, version): + series = ".".join(str(version).split(".")[:2]) + return "http://download.wikimedia.org/mediawiki/%s/mediawiki-%s.tar.gz" % (series, version) + def checkConfig(self, deployment): + return os.path.isfile("LocalSettings.php") + def detectVersion(self, deployment): + return self.detectVersionFromFile("includes/DefaultSettings.php", php.re_var("wgVersion")) + def checkWeb(self, deployment): + return self.checkWebPage(deployment, "/index.php?title=Main_Page", outputs=["