pmb.helpers: Handle workdir version suffix from 2.3.x (MR 2447)

For the gitlab.com -> gitlab.postmarketos.org migration we needed to
also migrate the workdir in pmb v2 since pmb v3 is not ready yet.

Therefore we need to handle that "7-2.x" workdir version and migrate
correctly when switching to pmbootstrap v3.

See https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2445
This commit is contained in:
Luca Weiss 2024-10-21 22:04:50 +02:00 committed by Caleb Connolly
parent 83d6a26291
commit a1e982aa1e
No known key found for this signature in database
GPG key ID: 0583312B195F64B6

View file

@ -82,10 +82,16 @@ def migrate_work_folder():
# Read current version # Read current version
context = get_context() context = get_context()
current = 0 current = 0
suffix: str | None = None
path = context.config.work / "version" path = context.config.work / "version"
if os.path.exists(path): if os.path.exists(path):
with open(path) as f: with open(path) as f:
current = int(f.read().rstrip()) # pmb 2.3.x added a suffix due to conflicting work versions
# We need to be able to handle that going forward
version_parts = f.read().rstrip().split("-")
current = int(version_parts[0])
if len(version_parts) == 2:
suffix = version_parts[1]
# Compare version, print warning or do nothing # Compare version, print warning or do nothing
required = pmb.config.work_version required = pmb.config.work_version
@ -96,7 +102,8 @@ def migrate_work_folder():
" (from version " + str(current) + " to " + str(required) + ")!" " (from version " + str(current) + " to " + str(required) + ")!"
) )
if current == 6: # version 6 and version 7 from 2.3.x branch are equivalent for this and we need to migrate
if current == 6 or (current == 7 and suffix == "2.x"):
# Ask for confirmation # Ask for confirmation
logging.info("Changelog:") logging.info("Changelog:")
logging.info("* Major refactor for pmb 3.0.0") logging.info("* Major refactor for pmb 3.0.0")