X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/blobdiff_plain/f44a2198d46f2262bd24af3491ad2b0d73e2d518..093db3de33bf80917b4b64f18112c6274c91afe3:/wizard/app/mediawiki.py?ds=sidebyside diff --git a/wizard/app/mediawiki.py b/wizard/app/mediawiki.py index cf9fa01..507c0cb 100644 --- a/wizard/app/mediawiki.py +++ b/wizard/app/mediawiki.py @@ -1,11 +1,24 @@ import re import distutils.version import os +import lxml.cssselect +import lxml.etree +import StringIO +import logging -from wizard import app, install, resolve, shell, util +from wizard import app, install, resolve, shell, sql, util from wizard.app import php +# 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, { @@ -18,73 +31,123 @@ seed = util.dictmap(make_filename_regex, { 'WIZARD_DBUSER': 'wgDBuser', 'WIZARD_DBPASSWORD': 'wgDBpassword', 'WIZARD_SECRETKEY': ('wgSecretKey', 'wgProxyKey'), + 'WIZARD_UPGRADEKEY': 'wgUpgradeKey', }) class Application(app.Application): - parametrized_files = ['LocalSettings.php', 'php.ini'] + 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("mysql", "admin", "email", "title") + 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): - contents = deployment.read("includes/DefaultSettings.php") - regex = php.re_var("wgVersion") - match = regex.search(contents) - if not match: return None - return distutils.version.LooseVersion(match.group(2)[1:-1]) - def checkWeb(self, deployment, out=None): - page = deployment.fetch("/index.php?title=Main_Page") - if type(out) is list: - out.append(page) - return page.find("