forked from Mirror/pmbootstrap
The repo bootstrap logic has worked well enough in the initial systemd bringup. But we have decided to replace the approach of building packages multiple times during the repo_bootstrap with building each package only once and adding -stage0 packages where necessary (currently only a systemd-stage0 package). Advantages: * Replace the often breaking repo_bootstrap logic with something less fragile (repo_bootstrap is currently broken again). * Can get rid of the whole bootstrap logic in pmaports.cfg, pmbootstrap, build.postmarketos.org. This will make pmbootstrap and bpo easier to maintain. * Fix problems we have seen when upgrading two or more of (systemd, dbus, linux-pam-pmos) at once: it doesn't pass in CI and it doesn't pass in BPO * You don't need to do a whole bootstrap at once, it is again broken down by package. This means if building one package fails (locally or in bpo), we don't need to do the whole thing again, just start at the package that failed. This also means it is much easier to optimize e.g. the stage0 packages to build faster. * Fixes some specific bugs we currently have (abuild twice in pmaports, bpo tests disabled because of that, ...) Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2588
102 lines
3 KiB
Python
102 lines
3 KiB
Python
# Copyright 2024 Caleb Connolly
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
from __future__ import annotations
|
|
from pmb.types import PmbArgs
|
|
from pmb.helpers import frontend
|
|
|
|
from .base import Command
|
|
from .aportgen import Aportgen
|
|
from .flasher import Flasher
|
|
from .log import Log
|
|
from .index import Index
|
|
from .shutdown import Shutdown
|
|
from .test import Test
|
|
from .pkgrel_bump import PkgrelBump
|
|
from .pkgver_bump import PkgverBump
|
|
from .pull import Pull
|
|
from .kconfig import KConfigCheck, KConfigEdit, KConfigMigrate
|
|
|
|
"""New way to model pmbootstrap subcommands that can be invoked without PmbArgs."""
|
|
|
|
# Commands that are still invoked via pmb/helpers/frontend.py
|
|
unmigrated_commands = [
|
|
"init",
|
|
"work_migrate",
|
|
"repo_missing",
|
|
"export",
|
|
"sideload",
|
|
"netboot",
|
|
"initfs",
|
|
"qemu",
|
|
"aportupgrade",
|
|
"newapkbuild",
|
|
"lint",
|
|
"status",
|
|
"ci",
|
|
"zap",
|
|
"stats",
|
|
"update",
|
|
"build_init",
|
|
"chroot",
|
|
"install",
|
|
"checksum",
|
|
"build",
|
|
"apkbuild_parse",
|
|
"apkindex_parse",
|
|
"config",
|
|
"bootimg_analyze",
|
|
]
|
|
|
|
|
|
def run_command(args: PmbArgs) -> None:
|
|
# Handle deprecated command format
|
|
if args.action in unmigrated_commands:
|
|
getattr(frontend, args.action)(args)
|
|
return
|
|
|
|
command: Command
|
|
match args.action:
|
|
case "aportgen":
|
|
command = Aportgen(args.packages, args.fork_alpine, args.fork_alpine_retain_branch)
|
|
case "flasher":
|
|
command = Flasher(
|
|
args.action_flasher,
|
|
# FIXME: defaults copied from pmb/helpers/arguments.py
|
|
# we should have these defaults defined in one place!
|
|
getattr(args, "autoinstall", True),
|
|
getattr(args, "cmdline", None),
|
|
args.flash_method,
|
|
getattr(args, "no_reboot", None),
|
|
getattr(args, "partition", None),
|
|
getattr(args, "resume", None),
|
|
)
|
|
case "log":
|
|
command = Log(args.clear_log, args.lines)
|
|
case "index":
|
|
# FIXME: should index support --arch?
|
|
command = Index()
|
|
case "shutdown":
|
|
command = Shutdown()
|
|
case "test":
|
|
command = Test(args.action_test)
|
|
case "pkgrel_bump":
|
|
command = PkgrelBump(args.packages, args.dry, args.auto)
|
|
case "pkgver_bump":
|
|
command = PkgverBump(args.packages)
|
|
case "pull":
|
|
command = Pull()
|
|
case "kconfig":
|
|
match args.action_kconfig:
|
|
case "check":
|
|
command = KConfigCheck(
|
|
args.kconfig_check_details, args.file, args.package, args.keep_going
|
|
)
|
|
case "edit":
|
|
command = KConfigEdit(args.package[0], args.arch, args.xconfig, args.nconfig)
|
|
case "migrate":
|
|
command = KConfigMigrate(args.package, args.arch)
|
|
case _:
|
|
raise NotImplementedError(f"Command '{args.action}' is not implemented.")
|
|
|
|
command.run()
|