mirror of
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git
synced 2025-07-25 13:35:09 +03:00
initfs: drop support for initramfs flavor
Official mkinitfs flavors were dropped long ago. v23.12 already
released with "supported_mkinitfs_without_flavors=True". So there is
no need to keep this around anymore.
Follow-up from 527fc9359f
This commit is contained in:
parent
799140da2b
commit
e69c3979b7
4 changed files with 16 additions and 33 deletions
|
@ -12,38 +12,24 @@ from pmb.core import Chroot
|
|||
from pmb.core.context import get_context
|
||||
|
||||
|
||||
def build(flavor: str | None, chroot: Chroot) -> None:
|
||||
def build(chroot: Chroot) -> None:
|
||||
# Update mkinitfs and hooks
|
||||
pmb.chroot.apk.install(["postmarketos-mkinitfs"], chroot)
|
||||
pmb.chroot.initfs_hooks.update(chroot)
|
||||
pmaports_cfg = pmb.config.pmaports.read_config()
|
||||
|
||||
# Call mkinitfs
|
||||
logging.info(f"({chroot}) mkinitfs {flavor}")
|
||||
if pmaports_cfg.get("supported_mkinitfs_without_flavors", False):
|
||||
logging.info(f"({chroot}) mkinitfs")
|
||||
pmb.chroot.root(["mkinitfs"], chroot)
|
||||
else:
|
||||
if flavor is None:
|
||||
raise AssertionError("flavor was none despite mkinitfs supporting omitted flavor")
|
||||
release_file = chroot / "usr/share/kernel" / flavor / "kernel.release"
|
||||
with release_file.open() as handle:
|
||||
release = handle.read().rstrip()
|
||||
pmb.chroot.root(["mkinitfs", "-o", f"/boot/initramfs-{flavor}", release], chroot)
|
||||
|
||||
|
||||
def extract(flavor: str | None, chroot: Chroot, extra: bool = False) -> Path:
|
||||
def extract(chroot: Chroot, extra: bool = False) -> Path:
|
||||
"""
|
||||
Extract the initramfs to /tmp/initfs-extracted or the initramfs-extra to
|
||||
/tmp/initfs-extra-extracted and return the outside extraction path.
|
||||
"""
|
||||
# Extraction folder
|
||||
inside = "/tmp/initfs-extracted"
|
||||
|
||||
pmaports_cfg = pmb.config.pmaports.read_config()
|
||||
if pmaports_cfg.get("supported_mkinitfs_without_flavors", False):
|
||||
initfs_file = "/boot/initramfs"
|
||||
else:
|
||||
initfs_file = f"/boot/initramfs-${flavor}"
|
||||
if extra:
|
||||
inside = "/tmp/initfs-extra-extracted"
|
||||
initfs_file += "-extra"
|
||||
|
@ -77,35 +63,33 @@ def extract(flavor: str | None, chroot: Chroot, extra: bool = False) -> Path:
|
|||
return outside
|
||||
|
||||
|
||||
def ls(flavor: str | None, suffix: Chroot, extra: bool = False) -> None:
|
||||
def ls(suffix: Chroot, extra: bool = False) -> None:
|
||||
tmp = "/tmp/initfs-extracted"
|
||||
if extra:
|
||||
tmp = "/tmp/initfs-extra-extracted"
|
||||
extract(flavor, suffix, extra)
|
||||
extract(suffix, extra)
|
||||
pmb.chroot.root(["ls", "-lahR", "."], suffix, Path(tmp), "stdout")
|
||||
pmb.chroot.root(["rm", "-r", tmp], suffix)
|
||||
|
||||
|
||||
def frontend(args: PmbArgs) -> None:
|
||||
# Find the appropriate kernel flavor
|
||||
context = get_context()
|
||||
chroot = Chroot.rootfs(context.config.device)
|
||||
flavor = pmb.chroot.other.kernel_flavor_installed(chroot)
|
||||
|
||||
# Handle initfs actions
|
||||
action = args.action_initfs
|
||||
if action == "build":
|
||||
build(flavor, chroot)
|
||||
build(chroot)
|
||||
elif action == "extract":
|
||||
dir = extract(flavor, chroot)
|
||||
dir = extract(chroot)
|
||||
logging.info(f"Successfully extracted initramfs to: {dir}")
|
||||
dir_extra = extract(flavor, chroot, True)
|
||||
dir_extra = extract(chroot, True)
|
||||
logging.info(f"Successfully extracted initramfs-extra to: {dir_extra}")
|
||||
elif action == "ls":
|
||||
logging.info("*** initramfs ***")
|
||||
ls(flavor, chroot)
|
||||
ls(chroot)
|
||||
logging.info("*** initramfs-extra ***")
|
||||
ls(flavor, chroot, True)
|
||||
ls(chroot, True)
|
||||
|
||||
# Handle hook actions
|
||||
elif action == "hook_ls":
|
||||
|
@ -117,7 +101,7 @@ def frontend(args: PmbArgs) -> None:
|
|||
pmb.chroot.initfs_hooks.delete(args.hook, chroot)
|
||||
|
||||
# Rebuild the initfs after adding/removing a hook
|
||||
build(flavor, chroot)
|
||||
build(chroot)
|
||||
|
||||
if action in ["ls", "extract"]:
|
||||
link = "https://wiki.postmarketos.org/wiki/Initramfs_development"
|
||||
|
|
|
@ -32,7 +32,7 @@ def frontend(args: PmbArgs) -> None: # FIXME: ARGS_REFACTOR
|
|||
# Rebuild the initramfs, just to make sure (see #69)
|
||||
flavor = pmb.helpers.frontend._parse_flavor(config.device, args.autoinstall)
|
||||
if args.autoinstall:
|
||||
pmb.chroot.initfs.build(flavor, Chroot(ChrootType.ROOTFS, config.device))
|
||||
pmb.chroot.initfs.build(Chroot(ChrootType.ROOTFS, config.device))
|
||||
|
||||
# Do the export, print all files
|
||||
logging.info(f"Export symlinks to: {target}")
|
||||
|
|
|
@ -32,7 +32,7 @@ def kernel(
|
|||
# Rebuild the initramfs, just to make sure (see #69)
|
||||
flavor = pmb.helpers.frontend._parse_flavor(deviceinfo.codename, autoinstall)
|
||||
if autoinstall:
|
||||
pmb.chroot.initfs.build(flavor, Chroot(ChrootType.ROOTFS, deviceinfo.codename))
|
||||
pmb.chroot.initfs.build(Chroot(ChrootType.ROOTFS, deviceinfo.codename))
|
||||
|
||||
# Check kernel config
|
||||
pmb.parse.kconfig.check(flavor, must_exist=False)
|
||||
|
|
|
@ -1395,8 +1395,7 @@ def create_device_rootfs(args: PmbArgs, step: int, steps: int) -> None:
|
|||
# installed a hook without pmbootstrap - see #69 for more info)
|
||||
# Packages will be built if necessary as part of this step
|
||||
pmb.chroot.apk.install(install_packages, chroot)
|
||||
flavor = pmb.chroot.other.kernel_flavor_installed(chroot)
|
||||
pmb.chroot.initfs.build(flavor, chroot)
|
||||
pmb.chroot.initfs.build(chroot)
|
||||
|
||||
# Set the user password
|
||||
setup_login(args, config, chroot)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue