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 <https://bugzilla.wikimedia.org/show_bug.cgi?id=29588>.
+# 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 <seed>` for more information."""
return 'LocalSettings.php', php.re_var(var)
def checkWeb(self, deployment):
return self.checkWebPage(deployment, "/index.php?title=Main_Page", outputs=["<!-- Served"])
def install(self, version, options):
+ if version >= distutils.version.LooseVersion("1.17.0"):
+ self.install_1_17_0(options)
+ else:
+ self.install_old(options)
+ def install_1_17_0(self, options):
+ util.soft_unlink("LocalSettings.php")
+ try:
+ result = shell.eval(
+ "php", "maintenance/install.php",
+ "--dbname", options.dsn.database,
+ "--dbpass", options.dsn.password,
+ "--dbserver", options.dsn.host,
+ "--dbuser", options.dsn.username,
+ "--email", options.email,
+ "--pass", options.admin_password,
+ options.title, options.admin_name,
+ log=True)
+ except shell.CallError as e:
+ raise app.RecoverableInstallFailure("Install script returned non-zero exit code\nSTDOUT: %s\nSTDERR: %s" % (e.stdout, e.stderr))
+ logging.debug("Install script output:\n\n" + result)
+ # See [Note: Maintenance script exit codes]
+ results = result.rstrip().split()
+ if not results or not results[-1] == "done":
+ raise app.RecoverableInstallFailure(result)
+
+ def install_old(self, options):
util.soft_unlink("LocalSettings.php")
os.chmod("config", 0777) # XXX: vaguely sketchy
result = shell.eval("php", "maintenance/update.php", "--quick", log=True)
except shell.CallError as e:
raise app.UpgradeFailure("Update script returned non-zero exit code\nSTDOUT: %s\nSTDERR: %s" % (e.stdout, e.stderr))
+ logging.debug("Upgrade script output:\n\n" + result)
+ # See [Note: Maintenance script exit codes]
results = result.rstrip().split()
if not results or not results[-1] == "Done.":
raise app.UpgradeFailure(result)