X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/blobdiff_plain/09066fc05e05e2a16051d97905905e9d567b7c10..a504eefd8719a52b14217c2a1152db151504f99a:/wizard/command/migrate.py diff --git a/wizard/command/migrate.py b/wizard/command/migrate.py index ebc39cf..83b3d1e 100644 --- a/wizard/command/migrate.py +++ b/wizard/command/migrate.py @@ -5,6 +5,9 @@ import logging from wizard import command, deploy, shell, util +# LEGACY (but still necessary, since we haven't migrated all of scripts +# yet. Maybe if we plugin-ify the commands interface move this.) + def main(argv, baton): options, args = parse_args(argv, baton) dir = os.path.abspath(args[0]) if args else os.getcwd() @@ -18,10 +21,6 @@ def main(argv, baton): deployment = deploy.ProductionCopy(".") - # deal with old-style migration, remove this later - if os.path.isfile(".scripts/old-version") and not os.path.isfile(".scripts-version"): - os.rename(".scripts/old-version", ".scripts-version") - os.unsetenv("GIT_DIR") # prevent some perverse errors try: @@ -45,13 +44,13 @@ def main(argv, baton): # well, we'll use that then version = deployment.application.makeVersion(str(e.real_version)) repo = version.application.repository(options.srv_path) - tag = version.scripts_tag + tag = version.wizard_tag try: sh.call("git", "--git-dir=%s" % repo, "rev-parse", tag) except shell.CallError: raise UnsupportedVersion(version.version) - with util.LockDirectory(".scripts-migrate-lock"): + with util.LockDirectory(".wizard-migrate-lock"): try: if options.force: perform_force(options) @@ -59,8 +58,8 @@ def main(argv, baton): check_variables(deployment, options) except KeyboardInterrupt: # revert it; barring zany race conditions this is safe - if os.path.exists(".scripts"): - shutil.rmtree(".scripts") + if os.path.exists(".wizard"): + shutil.rmtree(".wizard") if os.path.exists(".git"): shutil.rmtree(".git") @@ -71,15 +70,14 @@ Migrates a directory to our Git-based autoinstall format. Performs basic sanity checking and intelligently determines what repository and tag to use. -This command is meant to be run as the owner of the install -it is upgrading (see the scripts AFS kernel patch). Do -NOT run this command as root.""" +This command is meant to be run as the owner of the install it is +upgrading . Do NOT run this command as root.""" parser = command.WizardOptionParser(usage) baton.push(parser, "srv_path") parser.add_option("--dry-run", dest="dry_run", action="store_true", default=False, help="Prints would would be run without changing anything") parser.add_option("--force", "-f", dest="force", action="store_true", - default=False, help="If .git or .scripts directory already exists," + default=False, help="If .git or .wizard directory already exists," "delete them and migrate") parser.add_option("--force-version", dest="force_version", default=None, help="If .scripts-version tells lies, explicitly specify" @@ -91,16 +89,16 @@ NOT run this command as root.""" def perform_force(options): has_git = os.path.isdir(".git") - has_scripts = os.path.isdir(".scripts") + has_wizard = os.path.isdir(".wizard") if has_git: logging.warning("Force removing .git directory") if not options.dry_run: backup = util.safe_unlink(".git") logging.info(".git backed up to %s" % backup) - if has_scripts: - logging.warning("Force removing .scripts directory") - if not options.dry_run: backup = util.safe_unlink(".scripts") - logging.info(".scripts backed up to %s" % backup) + if has_wizard: + logging.warning("Force removing .wizard directory") + if not options.dry_run: backup = util.safe_unlink(".wizard") + logging.info(".wizard backed up to %s" % backup) def make_repository(sh, options, repo, tag): sh.call("git", "init") # create repository @@ -117,7 +115,7 @@ def make_repository(sh, options, repo, tag): else: logging.info("# create %s containing \"%s\"" % (file, data)) logging.info('# create .htaccess containing "Deny from all"') - # configure our remote (this is merely for convenience; wizard scripts + # configure our remote (this is merely for convenience; wizard # will not rely on this) sh.call("git", "remote", "add", "origin", repo) # configure what would normally be set up on a 'git clone' for consistency @@ -127,8 +125,8 @@ def make_repository(sh, options, repo, tag): sh.call("git", "fetch", "origin") # soft reset to our tag sh.call("git", "reset", tag, "--") - # checkout the .scripts directory - sh.call("git", "checkout", ".scripts") + # initialize the .wizard directory + util.init_wizard_dir() logging.info("Diffstat:\n" + sh.eval("git", "diff", "--stat")) # commit user local changes message = "Autoinstall migration.\n\n%s" % util.get_git_footer()