From: Edward Z. Yang Date: Tue, 18 Aug 2009 20:00:15 +0000 (-0400) Subject: Move upgrade code to wizard.app modules. X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/commitdiff_plain/c237524be936cf002169ec7aefac4d3b23b008e1 Move upgrade code to wizard.app modules. Signed-off-by: Edward Z. Yang --- diff --git a/TODO b/TODO index 42aa9bf..d261dda 100644 --- a/TODO +++ b/TODO @@ -2,17 +2,11 @@ The Git Autoinstaller TODO NOW: -- Make sure massmigrate cleanly ignores already migrated - installs - Push su code to migrate, not mass-migrate (only do it as root, this serves as a safe guard) -- Move migration code into Wizard, since we already deal - with installation there anyway (this TODO has been updated - accordingly) - Make parallel-find.pl use `sudo -u username git describe --tags` to determine version -- Remove .scripts/version generation in install script - Make the installer use 'wizard install' /or/ do a migration after doing a normal install (the latter makes it easier for mass-rollbacks). @@ -30,6 +24,9 @@ TODO NOW: - The great initial deploy: - Turn on mediawiki new autoinstaller - Migrate all mediawiki installs + - Build research scripts, determine if a re-migration is necessary + +- Make upgrade and install take version as a parameter - Redo Wordpress conversion, with an eye for automating everything possible (such as downloading the tarball and unpacking) diff --git a/wizard/app/mediawiki.py b/wizard/app/mediawiki.py index 5c18b15..966a6a9 100644 --- a/wizard/app/mediawiki.py +++ b/wizard/app/mediawiki.py @@ -1,7 +1,7 @@ import re import os -from wizard import app, deploy, install, util +from wizard import app, deploy, install, shell, util from wizard.app import php def make_filename_regex(var): @@ -48,6 +48,7 @@ class Application(deploy.Application): pass os.chmod("config", 0777) # XXX: vaguely sketchy + postdata = { 'Sitename': options.title, 'EmergencyContact': options.email, @@ -67,4 +68,7 @@ class Application(deploy.Application): if result.find("Installation successful") == -1: raise install.Failure() os.rename('config/LocalSettings.php', 'LocalSettings.php') + def upgrade(self, options): + sh = shell.Shell() + sh.call("php", "maintenance/update.php") diff --git a/wizard/command/upgrade.py b/wizard/command/upgrade.py index d67d5cd..fb04a2d 100644 --- a/wizard/command/upgrade.py +++ b/wizard/command/upgrade.py @@ -25,6 +25,7 @@ def main(argv, baton): repo = open(".git/WIZARD_REPO", "r").read() version = open(".git/WIZARD_UPGRADE_VERSION", "r").read() command.chdir(sh.eval("git", "config", "remote.origin.url")) + d = make_deployment_from_cwd() else: d = make_deployment_from_cwd() repo = d.application.repository(options.srv_path) @@ -67,7 +68,7 @@ def main(argv, baton): # - merge could fail (race); that's /really/ dangerous. sh.call("git", "pull", temp_wc_dir, "master") # run update script - sh.call(".scripts/update") + d.application.upgrade(options) # XXX: frob .htaccess to make site accessible # XXX: - check if .htaccess changed, first. Upgrade # process might have frobbed it. Don't be diff --git a/wizard/deploy.py b/wizard/deploy.py index 7ea4ba2..fa3f5a1 100644 --- a/wizard/deploy.py +++ b/wizard/deploy.py @@ -281,6 +281,18 @@ class Application(object): subs = subst(deployment) if not subs and key not in self.deprecated_keys: logging.warning("No substitutions for %s" % key) + def install(self, options): + """ + Run for 'wizard configure' (and, by proxy, 'wizard install') + to configure an application. + """ + raise NotImplemented + def upgrade(self, options): + """ + Run for 'wizard upgrade' to upgrade database schemas and other + non-versioned data in an application. + """ + raise NotImplemented @property def extractors(self): """