diff --git a/pmb/build/envkernel.py b/pmb/build/envkernel.py index 4494b236..be78de79 100644 --- a/pmb/build/envkernel.py +++ b/pmb/build/envkernel.py @@ -217,4 +217,4 @@ def package_kernel(args: PmbArgs): except Exception as e: pmb.helpers.mount.umount_all(Chroot.native() / "mnt/linux") raise e - pmb.build.other.index_repo(args, arch) + pmb.build.other.index_repo(arch) diff --git a/pmb/build/other.py b/pmb/build/other.py index 4755a4b4..413af331 100644 --- a/pmb/build/other.py +++ b/pmb/build/other.py @@ -93,7 +93,7 @@ def is_necessary(arch, apkbuild, indexes=None): return False -def index_repo(args: PmbArgs, arch=None): +def index_repo(arch=None): """Recreate the APKINDEX.tar.gz for a specific repo, and clear the parsing cache for that file for the current pmbootstrap session (to prevent rebuilding packages twice, in case the rebuild takes less than a second). diff --git a/pmb/commands/__init__.py b/pmb/commands/__init__.py index 72f88a03..2689b8cc 100644 --- a/pmb/commands/__init__.py +++ b/pmb/commands/__init__.py @@ -5,12 +5,12 @@ from __future__ import annotations import enum from typing import Generator, Optional from pathlib import Path, PosixPath, PurePosixPath -import pmb.config from pmb.types import PmbArgs from pmb.helpers import frontend from .base import Command from .log import Log +from .index import Index """New way to model pmbootstrap subcommands that can be invoked without PmbArgs.""" @@ -18,7 +18,6 @@ from .log import Log unmigrated_commands = [ "init", "shutdown", - "index", "work_migrate", "repo_bootstrap", "repo_missing", @@ -59,9 +58,12 @@ def run_command(args: PmbArgs): return command: Command - # FIXME: would be nice to use match case... + # Would be nice to use match case but we support Python 3.8 if args.action == "log": command = Log(args.clear_log, int(args.lines)) + elif args.action == "index": + # FIXME: should index support --arch? + command = Index() else: raise NotImplementedError(f"Command '{args.action}' is not implemented.") diff --git a/pmb/commands/index.py b/pmb/commands/index.py new file mode 100644 index 00000000..a97c48f1 --- /dev/null +++ b/pmb/commands/index.py @@ -0,0 +1,14 @@ +# Copyright 2024 Caleb Connolly +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import annotations +from pmb import commands +import pmb.build.other + +class Index(commands.Command): + def __init__(self): + pass + + def run(self): + pmb.build.other.index_repo() + diff --git a/pmb/helpers/frontend.py b/pmb/helpers/frontend.py index 4b8d1adc..4d3f298b 100644 --- a/pmb/helpers/frontend.py +++ b/pmb/helpers/frontend.py @@ -251,10 +251,6 @@ def repo_missing(args: PmbArgs): print(json.dumps(missing, indent=4)) -def index(args: PmbArgs): - pmb.build.index_repo(args) - - def initfs(args: PmbArgs): pmb.chroot.initfs.frontend(args)