Replace pmaports channels stable, stable-next (MR 2032)

Translate the pmaports channels "stable" to "v20.05" and "stable-next"
to "v21.03", so these have the same channel name as the pmaports.git
branch name.

The original plan was to switch the "stable" channel from the "v20.05"
branch to the "v21.03" branch when the release is done. However, now
that we are close to that, I'm realizing that this would not be useful.
It would lead to conflicts in the dir with locally built packages
(default: ~/.local/var/pmbootstrap/packages/$CHANNEL). And it would make
it awkward to go back to a previous branch (we may name it old-stable
for the time being, but what after that, old-old-stable?).
This commit is contained in:
Oliver Smith 2021-03-02 19:47:58 +01:00
parent 5c1c126647
commit 278dfced61
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
13 changed files with 90 additions and 25 deletions

View File

@ -34,10 +34,10 @@ pmaports_min_version = "7"
# Version of the work folder (as asked during 'pmbootstrap init'). Increase # Version of the work folder (as asked during 'pmbootstrap init'). Increase
# this number, whenever migration is required and provide the migration code, # this number, whenever migration is required and provide the migration code,
# see migrate_work_folder()). # see migrate_work_folder()).
work_version = 5 work_version = 6
# Minimum required version of postmarketos-ondev (pmbootstrap install --ondev). # Minimum required version of postmarketos-ondev (pmbootstrap install --ondev).
# Try to support the current versions of all channels (edge, stable). When # Try to support the current versions of all channels (edge, v21.03). When
# bumping > 0.4.0, remove compat code in pmb/install/_install.py (search for # bumping > 0.4.0, remove compat code in pmb/install/_install.py (search for
# get_ondev_pkgver). # get_ondev_pkgver).
ondev_min_version = "0.2.0" ondev_min_version = "0.2.0"
@ -138,6 +138,9 @@ locales = [
] ]
# Legacy channels and their new names (pmb#2015)
pmaports_channels_legacy = {"stable": "v20.05",
"stable-next": "v21.03"}
# #
# CHROOT # CHROOT
# #
@ -165,7 +168,7 @@ chroot_host_path = os.environ["PATH"] + ":/usr/sbin/"
# Folders, that get mounted inside the chroot # Folders, that get mounted inside the chroot
# $WORK gets replaced with args.work # $WORK gets replaced with args.work
# $ARCH gets replaced with the chroot architecture (eg. x86_64, armhf) # $ARCH gets replaced with the chroot architecture (eg. x86_64, armhf)
# $CHANNEL gets replaced with the release channel (e.g. edge, stable) # $CHANNEL gets replaced with the release channel (e.g. edge, v21.03)
chroot_mount_bind = { chroot_mount_bind = {
"/proc": "/proc", "/proc": "/proc",
"$WORK/cache_apk_$ARCH": "/var/cache/apk", "$WORK/cache_apk_$ARCH": "/var/cache/apk",

View File

@ -80,7 +80,7 @@ def ask_for_channel(args):
""" Ask for the postmarketOS release channel. The channel dictates, which """ Ask for the postmarketOS release channel. The channel dictates, which
pmaports branch pmbootstrap will check out, and which repository URLs pmaports branch pmbootstrap will check out, and which repository URLs
will be used when initializing chroots. will be used when initializing chroots.
:returns: channel name (e.g. "edge", "stable") """ :returns: channel name (e.g. "edge", "v21.03") """
channels_cfg = pmb.helpers.git.parse_channels_cfg(args) channels_cfg = pmb.helpers.git.parse_channels_cfg(args)
count = len(channels_cfg["channels"]) count = len(channels_cfg["channels"])

View File

@ -6,6 +6,7 @@ import os
import pmb.config import pmb.config
import pmb.helpers.git import pmb.helpers.git
import pmb.helpers.pmaports
def check_legacy_folder(): def check_legacy_folder():
@ -107,6 +108,9 @@ def read_config(args):
check_version_pmaports(ret["version"]) check_version_pmaports(ret["version"])
check_version_pmbootstrap(ret["pmbootstrap_min_version"]) check_version_pmbootstrap(ret["pmbootstrap_min_version"])
# Translate legacy channel names
ret["channel"] = pmb.helpers.pmaports.get_channel_new(ret["channel"])
# Cache and return # Cache and return
args.cache[cache_key] = ret args.cache[cache_key] = ret
return ret return ret
@ -153,7 +157,7 @@ def init(args):
def switch_to_channel_branch(args, channel_new): def switch_to_channel_branch(args, channel_new):
""" Checkout the channel's branch in pmaports.git. """ Checkout the channel's branch in pmaports.git.
:channel_new: channel name (e.g. "edge", "stable") :channel_new: channel name (e.g. "edge", "v21.03")
:returns: True if another branch was checked out, False otherwise """ :returns: True if another branch was checked out, False otherwise """
# Check current pmaports branch channel # Check current pmaports branch channel
channel_current = read_config(args)["channel"] channel_current = read_config(args)["channel"]

View File

@ -8,6 +8,7 @@ import time
import pmb.build import pmb.build
import pmb.chroot.apk import pmb.chroot.apk
import pmb.config import pmb.config
import pmb.helpers.pmaports
import pmb.helpers.run import pmb.helpers.run
@ -138,11 +139,13 @@ def parse_channels_cfg(args):
if channel == "channels.cfg": if channel == "channels.cfg":
continue # meta section continue # meta section
ret["channels"][channel] = {} channel_new = pmb.helpers.pmaports.get_channel_new(channel)
ret["channels"][channel_new] = {}
for key in ["description", "branch_pmaports", "branch_aports", for key in ["description", "branch_pmaports", "branch_aports",
"mirrordir_alpine"]: "mirrordir_alpine"]:
value = cfg.get(channel, key) value = cfg.get(channel, key)
ret["channels"][channel][key] = value ret["channels"][channel_new][key] = value
args.cache[cache_key] = ret args.cache[cache_key] = ret
return ret return ret

View File

@ -199,6 +199,34 @@ def migrate_work_folder(args):
migrate_success(args, 5) migrate_success(args, 5)
current = 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" {args.work}/packages")
logging.info(" stable => v20.05")
logging.info(" stable-next => v21.03")
if not pmb.helpers.cli.confirm(args):
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(args, False)
# Migrate
packages_dir = f"{args.work}/packages"
for old, new in pmb.config.pmaports_channels_legacy.items():
if os.path.exists(f"{packages_dir}/{old}"):
pmb.helpers.run.root(args, ["mv", old, new], packages_dir)
# Update version file
migrate_success(args, 6)
current = 6
# Can't migrate, user must delete it # Can't migrate, user must delete it
if current != required: if current != required:
raise RuntimeError("Sorry, we can't migrate that automatically. Please" raise RuntimeError("Sorry, we can't migrate that automatically. Please"

View File

@ -222,3 +222,19 @@ def check_arches(arches, arch):
if value in arches: if value in arches:
return True return True
return False return False
def get_channel_new(channel):
""" Translate legacy channel names to the new ones. Legacy names are still
supported for compatibility with old branches (pmb#2015).
:param channel: name as read from pmaports.cfg or channels.cfg, like
"edge", "v21.03" etc., or potentially a legacy name
like "stable".
:returns: name in the new format, e.g. "edge" or "v21.03"
"""
legacy_cfg = pmb.config.pmaports_channels_legacy
if channel in legacy_cfg:
ret = legacy_cfg[channel]
logging.verbose(f"Legacy channel '{channel}' translated to '{ret}'")
return ret
return channel

View File

@ -39,13 +39,13 @@ def test_switch_to_channel_branch(args, monkeypatch, tmpdir):
# Fail: git error (could be any error, but here: branch does not exist) # Fail: git error (could be any error, but here: branch does not exist)
with pytest.raises(RuntimeError) as e: with pytest.raises(RuntimeError) as e:
func(args, "stable") func(args, "v20.05")
assert str(e.value).startswith("Failed to switch branch") assert str(e.value).startswith("Failed to switch branch")
# Success: switch channel and change branch # Success: switch channel and change branch
run_git(["checkout", "-b", "v20.05"]) run_git(["checkout", "-b", "v20.05"])
run_git(["checkout", "master"]) run_git(["checkout", "master"])
assert func(args, "stable") is True assert func(args, "v20.05") is True
branch = pmb.helpers.git.rev_parse(args, path, extra_args=["--abbrev-ref"]) branch = pmb.helpers.git.rev_parse(args, path, extra_args=["--abbrev-ref"])
assert branch == "v20.05" assert branch == "v20.05"

View File

@ -29,9 +29,9 @@ def test_chroot_save_init(args, tmpdir, monkeypatch):
return 1234567890.1234 return 1234567890.1234
monkeypatch.setattr(time, "time", fake_time) monkeypatch.setattr(time, "time", fake_time)
# Pretend channel=stable in pmaports.cfg # Pretend channel=v20.05 in pmaports.cfg
def read_config(args): def read_config(args):
return {"channel": "stable"} return {"channel": "v20.05"}
monkeypatch.setattr(pmb.config.pmaports, "read_config", read_config) monkeypatch.setattr(pmb.config.pmaports, "read_config", read_config)
args.work = str(tmpdir) args.work = str(tmpdir)
@ -41,7 +41,7 @@ def test_chroot_save_init(args, tmpdir, monkeypatch):
expected = ("[chroot-init-dates]\n" expected = ("[chroot-init-dates]\n"
"native = 1234567890\n\n" "native = 1234567890\n\n"
"[chroot-channels]\n" "[chroot-channels]\n"
"native = stable\n\n") "native = v20.05\n\n")
with open(args.work + "/workdir.cfg", "r") as handle: with open(args.work + "/workdir.cfg", "r") as handle:
assert handle.read() == expected assert handle.read() == expected
@ -51,8 +51,8 @@ def test_chroot_save_init(args, tmpdir, monkeypatch):
"native = 1234567890\n" "native = 1234567890\n"
"buildroot_armhf = 1234567890\n\n" "buildroot_armhf = 1234567890\n\n"
"[chroot-channels]\n" "[chroot-channels]\n"
"native = stable\n" "native = v20.05\n"
"buildroot_armhf = stable\n\n") "buildroot_armhf = v20.05\n\n")
with open(args.work + "/workdir.cfg", "r") as handle: with open(args.work + "/workdir.cfg", "r") as handle:
assert handle.read() == expected assert handle.read() == expected
@ -104,7 +104,7 @@ def test_chroot_check_channel(args, tmpdir, monkeypatch):
# Write workdir.cfg # Write workdir.cfg
with open(f"{args.work}/workdir.cfg", "w") as handle: with open(f"{args.work}/workdir.cfg", "w") as handle:
handle.write("[chroot-channels]\nnative = stable\n\n") handle.write("[chroot-channels]\nnative = v20.05\n\n")
# workdir.cfg: no entry for buildroot_armhf chroot # workdir.cfg: no entry for buildroot_armhf chroot
with pytest.raises(RuntimeError) as e: with pytest.raises(RuntimeError) as e:
@ -114,11 +114,11 @@ def test_chroot_check_channel(args, tmpdir, monkeypatch):
# Chroot was created for wrong channel # Chroot was created for wrong channel
with pytest.raises(RuntimeError) as e: with pytest.raises(RuntimeError) as e:
func(args, "native") func(args, "native")
exp = "created for the 'stable' channel, but you are on the 'edge'" exp = "created for the 'v20.05' channel, but you are on the 'edge'"
assert exp in str(e.value) assert exp in str(e.value)
# Check runs through without raising an exception # Check runs through without raising an exception
channel = "stable" channel = "v20.05"
func(args, "native") func(args, "native")

View File

@ -37,11 +37,11 @@ def test_crossdirect_rust(args):
working. """ working. """
pmbootstrap_run(args, ["-y", "zap"]) pmbootstrap_run(args, ["-y", "zap"])
try: try:
# Switch to "stable" channel, as the stable release of alpine is more # Switch to "v20.05" channel, as a stable release of alpine is more
# likely to have the same rustc version across various architectures. # likely to have the same rustc version across various architectures.
# If armv7/x86_64 have a different rustc version, this test will fail: # If armv7/x86_64 have a different rustc version, this test will fail:
# 'found crate `std` compiled by an incompatible version of rustc' # 'found crate `std` compiled by an incompatible version of rustc'
pmb.config.pmaports.switch_to_channel_branch(args, "stable") pmb.config.pmaports.switch_to_channel_branch(args, "v20.05")
pmbootstrap_run(args, ["build_init", "-barmv7"]) pmbootstrap_run(args, ["build_init", "-barmv7"])
pmbootstrap_run(args, ["chroot", "--add=rust", "-barmv7", "--", pmbootstrap_run(args, ["chroot", "--add=rust", "-barmv7", "--",

View File

@ -116,10 +116,14 @@ def test_parse_channels_cfg(args):
"branch_pmaports": "master", "branch_pmaports": "master",
"branch_aports": "master", "branch_aports": "master",
"mirrordir_alpine": "edge"}, "mirrordir_alpine": "edge"},
"stable": {"description": "For workgroups", "v20.05": {"description": "For workgroups",
"branch_pmaports": "v20.05", "branch_pmaports": "v20.05",
"branch_aports": "3.11-stable", "branch_aports": "3.11-stable",
"mirrordir_alpine": "v3.11"}}} "mirrordir_alpine": "v3.11"},
"v21.03": {"description": "Second beta release",
"branch_pmaports": "v21.03",
"branch_aports": "3.13-stable",
"mirrordir_alpine": "v3.13"}}}
assert pmb.helpers.git.parse_channels_cfg(args) == exp assert pmb.helpers.git.parse_channels_cfg(args) == exp

View File

@ -36,7 +36,7 @@ def test_alpine_apkindex_path(args):
def test_urls(args, monkeypatch): def test_urls(args, monkeypatch):
func = pmb.helpers.repo.urls func = pmb.helpers.repo.urls
channel = "stable" channel = "v20.05"
args.mirror_alpine = "http://localhost/alpine/" args.mirror_alpine = "http://localhost/alpine/"
# Second mirror with /master at the end is legacy, gets fixed by func. # Second mirror with /master at the end is legacy, gets fixed by func.
@ -50,7 +50,7 @@ def test_urls(args, monkeypatch):
return {"channel": channel} return {"channel": channel}
monkeypatch.setattr(pmb.config.pmaports, "read_config", read_config) monkeypatch.setattr(pmb.config.pmaports, "read_config", read_config)
# Channel: stable # Channel: v20.05
assert func(args) == ["/mnt/pmbootstrap-packages", assert func(args) == ["/mnt/pmbootstrap-packages",
"http://localhost/pmos1/v20.05", "http://localhost/pmos1/v20.05",
"http://localhost/pmos2/v20.05", "http://localhost/pmos2/v20.05",

View File

@ -296,5 +296,5 @@ def test_questions_hostname(args, monkeypatch):
def test_questions_channel(args, monkeypatch): def test_questions_channel(args, monkeypatch):
fake_answers(monkeypatch, ["invalid-channel", "stable"]) fake_answers(monkeypatch, ["invalid-channel", "v20.05"])
assert pmb.config.init.ask_for_channel(args) == "stable" assert pmb.config.init.ask_for_channel(args) == "v20.05"

View File

@ -8,8 +8,15 @@ branch_pmaports=master
branch_aports=master branch_aports=master
mirrordir_alpine=edge mirrordir_alpine=edge
# Legacy channel name, gets translated to v20.05
[stable] [stable]
description=For workgroups description=For workgroups
branch_pmaports=v20.05 branch_pmaports=v20.05
branch_aports=3.11-stable branch_aports=3.11-stable
mirrordir_alpine=v3.11 mirrordir_alpine=v3.11
[v21.03]
description=Second beta release
branch_pmaports=v21.03
branch_aports=3.13-stable
mirrordir_alpine=v3.13