1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-12 19:09:56 +03:00

init: systemd: fix always switching pma to edge

Fix that pmbootstrap doesn't recognize v25.06 with systemd enabled as
valid channel and suggests switching to edge. This happens because
pmb.config.pmaports.read_config() unconditionally prepends "systemd-"
before the channel name if systemd is enabled, even though the init code
doesn't expect this.

The result is when running 'yes "" | pmbootstrap init' (as we do in BPO
and CI), pmbootstrap attempts to replace the correctly checked out
v25.06 branch with edge:

Fix for:
  [20:36:37] Available (12):
  [20:36:37] * edge: Rolling release / Most devices / Occasional breakage: https://postmarketos.org/edge
  [20:36:37] * v25.06: Upcoming stable release (DO NOT USE)
  [20:36:37] * v24.12: Latest release / Recommended for best stability
  [20:36:37] Channel [edge]:
  [20:36:37] Currently checked out branch 'v25.06' of pmaports.git is on channel 'v25.06'.
  [20:36:37] Switching to branch 'master' on channel 'edge'...
  …
  ERROR: pmbootstrap switched to the wrong branch: master

Related: https://builds.sr.ht/~postmarketos/job/1497179#task-bpo_setup-23

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2613
This commit is contained in:
Oliver Smith 2025-05-30 10:53:33 +02:00
parent c39ac5fe99
commit 26c310f374
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
2 changed files with 6 additions and 4 deletions

View file

@ -214,7 +214,7 @@ def ask_for_channel(config: Config) -> str:
# Otherwise, if valid: channel from pmaports.cfg of current branch
# The actual channel name is not saved in pmbootstrap_v3.cfg, because then
# we would need to sync it with what is checked out in pmaports.git.
default = pmb.config.pmaports.read_config()["channel"]
default = pmb.config.pmaports.read_config(add_systemd_prefix=False)["channel"]
choices = channels_cfg["channels"].keys()
if config.is_default_channel or default not in choices:
default = channels_cfg["meta"]["recommended"]

View file

@ -90,8 +90,10 @@ def read_config_repos() -> dict[str, configparser.SectionProxy]:
return ret
@Cache("aports")
def read_config(aports: Path | None = None) -> configparser.SectionProxy:
@Cache("aports", "add_systemd_prefix")
def read_config(
aports: Path | None = None, add_systemd_prefix: bool = True
) -> configparser.SectionProxy:
"""Read and verify pmaports.cfg. If aports is not
specified and systemd is enabled, the returned channel
will be the systemd one (e.g. systemd-edge instead of edge)
@ -128,7 +130,7 @@ def read_config(aports: Path | None = None) -> configparser.SectionProxy:
# Translate legacy channel names
ret["channel"] = pmb.helpers.pmaports.get_channel_new(ret["channel"])
if systemd:
if systemd and add_systemd_prefix:
ret["channel"] = "systemd-" + ret["channel"]
return ret