From 652d1a1afdb0b15616f091c20f74d60c74fe52dd Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sun, 1 Sep 2024 15:51:59 +0200 Subject: [PATCH] pmb.helpers.other: drop old migration code (MR 2395) Get rid of 3 years and older migration code, so we don't need to maintain it anymore. If the user should have run "pmbootstrap init" 3 years ago and suddenly upgrades to pmbootstrap v3, then they will just need to delete their work dir (as pmbootstrap instructs to do) and start over. This is fine, the work dir is just a bunch of caches and locally built packages. --- pmb/helpers/other.py | 144 ------------------------------------------- 1 file changed, 144 deletions(-) diff --git a/pmb/helpers/other.py b/pmb/helpers/other.py index de7dc8e4..8f7eebb5 100644 --- a/pmb/helpers/other.py +++ b/pmb/helpers/other.py @@ -1,7 +1,6 @@ # Copyright 2023 Oliver Smith # SPDX-License-Identifier: GPL-3.0-or-later from pmb.core.context import get_context -from pmb.core.arch import Arch from pmb.helpers import logging import os from pathlib import Path @@ -95,149 +94,6 @@ def migrate_work_folder(): " (from version " + str(current) + " to " + str(required) + ")!" ) - # 0 => 1 - if current == 0: - # Ask for confirmation - logging.info("Changelog:") - logging.info("* Building chroots have a different username (#709)") - logging.info("Migration will do the following:") - logging.info("* Zap your chroots") - logging.info(f"* Adjust '{context.config.work / 'config_abuild/abuild.conf'}'") - if not pmb.helpers.cli.confirm(): - raise RuntimeError("Aborted.") - - # Zap and update abuild.conf - pmb.chroot.zap(False) - conf = context.config.work / "config_abuild/abuild.conf" - if os.path.exists(conf): - pmb.helpers.run.root(["sed", "-i", "s./home/user/./home/pmos/.g", conf]) - # Update version file - migrate_success(context.config.work, 1) - current = 1 - - # 1 => 2 - if current == 1: - # Ask for confirmation - logging.info("Changelog:") - logging.info("* Fix: cache_distfiles was writable for everyone") - logging.info("Migration will do the following:") - logging.info(f"* Fix permissions of '{context.config.work / 'cache_distfiles'}'") - if not pmb.helpers.cli.confirm(): - raise RuntimeError("Aborted.") - - # Fix permissions - dir = "/var/cache/distfiles" - for cmd in [ - ["chown", "-R", "root:abuild", dir], - ["chmod", "-R", "664", dir], - ["chmod", "a+X", dir], - ]: - pmb.chroot.root(cmd) - migrate_success(context.config.work, 2) - current = 2 - - if current == 2: - # Ask for confirmation - logging.info("Changelog:") - logging.info("* Device chroots have a different user UID (#1576)") - logging.info("Migration will do the following:") - logging.info("* Zap your chroots") - if not pmb.helpers.cli.confirm(): - raise RuntimeError("Aborted.") - - # Zap chroots - pmb.chroot.zap(False) - - # Update version file - migrate_success(context.config.work, 3) - current = 3 - - if current == 3: - # Ask for confirmation - path = context.config.work / "cache_git" - logging.info("Changelog:") - logging.info("* pmbootstrap clones repositories with host system's") - logging.info(" 'git' instead of using it from an Alpine chroot") - logging.info("Migration will do the following:") - logging.info("* Check if 'git' is installed") - logging.info(f"* Change ownership to your user: {path}") - if not pmb.helpers.cli.confirm(): - raise RuntimeError("Aborted.") - - # Require git, set cache_git ownership - pmb.config.init.require_programs() - if os.path.exists(path): - uid_gid = f"{os.getuid()}:{os.getgid()}" - pmb.helpers.run.root(["chown", "-R", uid_gid, path]) - else: - os.makedirs(path, 0o700, True) - - # Update version file - migrate_success(context.config.work, 4) - current = 4 - - if current == 4: - # Ask for confirmation - logging.info("Changelog:") - logging.info("* packages built by pmbootstrap are in a channel subdir") - logging.info("Migration will do the following:") - logging.info("* Move existing packages to edge subdir (if any)") - logging.info("* Zap your chroots") - if not pmb.helpers.cli.confirm(): - raise RuntimeError("Aborted.") - - # Zap chroots - pmb.chroot.zap(False) - - # Move packages to edge subdir - edge_path = context.config.work / "packages/edge" - pmb.helpers.run.root(["mkdir", "-p", edge_path]) - for arch in Arch.supported(): - old_path = context.config.work / "packages" / arch - new_path = edge_path / arch - if old_path.exists(): - if new_path.exists(): - raise RuntimeError( - f"Won't move '{old_path}' to" - f" '{new_path}', destination already" - " exists! Consider 'pmbootstrap zap -p'" - f" to delete '{context.config.work}/packages'." - ) - pmb.helpers.run.root(["mv", old_path, new_path]) - pmb.helpers.run.root(["chown", pmb.config.chroot_uid_user, edge_path]) - - # Update version file - migrate_success(context.config.work, 5) - current = 5 - - if current == 5: - # Ask for confirmation - logging.info("Changelog:") - logging.info("* besides edge, pmaports channels have the same name") - logging.info(" as the branch now (pmbootstrap#2015)") - logging.info("Migration will do the following:") - logging.info("* Zap your chroots") - logging.info("* Adjust subdirs of your locally built packages dir:") - logging.info(f" {context.config.work}/packages") - logging.info(" stable => v20.05") - logging.info(" stable-next => v21.03") - if not pmb.helpers.cli.confirm(): - raise RuntimeError("Aborted.") - - # Zap chroots to avoid potential "ERROR: Chroot 'native' was created - # for the 'stable' channel, but you are on the 'v20.05' channel now." - pmb.chroot.zap(False) - - # Migrate - packages_dir = f"{context.config.work}/packages" - for old, new in pmb.config.pmaports_channels_legacy.items(): - if os.path.exists(f"{packages_dir}/{old}"): - pmb.helpers.run.root(["mv", old, new], packages_dir) - - # Update version file - migrate_success(context.config.work, 6) - current = 6 - if current == 6: # Ask for confirmation logging.info("Changelog:")