forked from Mirror/pmbootstrap
WIP: start ripping out args (MR 2252)
Cease merging pmbootstrap.cfg into args, implement a Context type to let us pull globals out of thin air (as an intermediate workaround) and rip args out of a lot of the codebase. This is just a first pass, after this we can split all the state that leaked over into Context into types with narrower scopes (like a BuildContext(), etc). Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
bfea00e03a
commit
34dd9d42ba
129 changed files with 1393 additions and 1300 deletions
|
@ -6,11 +6,11 @@ from pmb.helpers import logging
|
|||
|
||||
import pmb.config
|
||||
import pmb.chroot.apk
|
||||
from pmb.core import Chroot
|
||||
from pmb.core.types import PmbArgs
|
||||
from pmb.core import Chroot, get_context
|
||||
from pmb.types import PmbArgs
|
||||
|
||||
|
||||
def list_chroot(args: PmbArgs, suffix: Chroot, remove_prefix=True):
|
||||
def list_chroot(suffix: Chroot, remove_prefix=True):
|
||||
ret = []
|
||||
prefix = pmb.config.initfs_hook_prefix
|
||||
for pkgname in pmb.chroot.apk.installed(suffix).keys():
|
||||
|
@ -22,41 +22,41 @@ def list_chroot(args: PmbArgs, suffix: Chroot, remove_prefix=True):
|
|||
return ret
|
||||
|
||||
|
||||
def list_aports(args: PmbArgs):
|
||||
def list_aports():
|
||||
ret = []
|
||||
prefix = pmb.config.initfs_hook_prefix
|
||||
for path in glob.glob(f"{args.aports}/*/{prefix}*"):
|
||||
for path in glob.glob(f"{get_context().config.aports}/*/{prefix}*"):
|
||||
ret.append(os.path.basename(path)[len(prefix):])
|
||||
return ret
|
||||
|
||||
|
||||
def ls(args: PmbArgs, suffix: Chroot):
|
||||
hooks_chroot = list_chroot(args, suffix)
|
||||
hooks_aports = list_aports(args)
|
||||
def ls(suffix: Chroot):
|
||||
hooks_chroot = list_chroot(suffix)
|
||||
hooks_aports = list_aports()
|
||||
|
||||
for hook in hooks_aports:
|
||||
line = f"* {hook} ({'' if hook in hooks_chroot else 'not '}installed)"
|
||||
logging.info(line)
|
||||
|
||||
|
||||
def add(args: PmbArgs, hook, suffix: Chroot):
|
||||
if hook not in list_aports(args):
|
||||
def add(hook, suffix: Chroot):
|
||||
if hook not in list_aports():
|
||||
raise RuntimeError("Invalid hook name!"
|
||||
" Run 'pmbootstrap initfs hook_ls'"
|
||||
" to get a list of all hooks.")
|
||||
prefix = pmb.config.initfs_hook_prefix
|
||||
pmb.chroot.apk.install(args, [f"{prefix}{hook}"], suffix)
|
||||
pmb.chroot.apk.install([f"{prefix}{hook}"], suffix)
|
||||
|
||||
|
||||
def delete(args: PmbArgs, hook, suffix: Chroot):
|
||||
if hook not in list_chroot(args, suffix):
|
||||
def delete(hook, suffix: Chroot):
|
||||
if hook not in list_chroot(suffix):
|
||||
raise RuntimeError("There is no such hook installed!")
|
||||
prefix = pmb.config.initfs_hook_prefix
|
||||
pmb.chroot.root(args, ["apk", "del", f"{prefix}{hook}"], suffix)
|
||||
pmb.chroot.root(["apk", "del", f"{prefix}{hook}"], suffix)
|
||||
|
||||
|
||||
def update(args: PmbArgs, suffix: Chroot):
|
||||
"""
|
||||
Rebuild and update all hooks that are out of date
|
||||
"""
|
||||
pmb.chroot.apk.install(args, list_chroot(args, suffix, False), suffix)
|
||||
pmb.chroot.apk.install(list_chroot(suffix, False), suffix)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue