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
|
from pmb.core.context import get_context
|
||||||
|
|
||||||
|
|
||||||
def build(flavor: str | None, chroot: Chroot) -> None:
|
def build(chroot: Chroot) -> None:
|
||||||
# Update mkinitfs and hooks
|
# Update mkinitfs and hooks
|
||||||
pmb.chroot.apk.install(["postmarketos-mkinitfs"], chroot)
|
pmb.chroot.apk.install(["postmarketos-mkinitfs"], chroot)
|
||||||
pmb.chroot.initfs_hooks.update(chroot)
|
pmb.chroot.initfs_hooks.update(chroot)
|
||||||
pmaports_cfg = pmb.config.pmaports.read_config()
|
|
||||||
|
|
||||||
# Call mkinitfs
|
# Call mkinitfs
|
||||||
logging.info(f"({chroot}) mkinitfs {flavor}")
|
logging.info(f"({chroot}) mkinitfs")
|
||||||
if pmaports_cfg.get("supported_mkinitfs_without_flavors", False):
|
pmb.chroot.root(["mkinitfs"], chroot)
|
||||||
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
|
Extract the initramfs to /tmp/initfs-extracted or the initramfs-extra to
|
||||||
/tmp/initfs-extra-extracted and return the outside extraction path.
|
/tmp/initfs-extra-extracted and return the outside extraction path.
|
||||||
"""
|
"""
|
||||||
# Extraction folder
|
# Extraction folder
|
||||||
inside = "/tmp/initfs-extracted"
|
inside = "/tmp/initfs-extracted"
|
||||||
|
initfs_file = "/boot/initramfs"
|
||||||
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:
|
if extra:
|
||||||
inside = "/tmp/initfs-extra-extracted"
|
inside = "/tmp/initfs-extra-extracted"
|
||||||
initfs_file += "-extra"
|
initfs_file += "-extra"
|
||||||
|
@ -77,35 +63,33 @@ def extract(flavor: str | None, chroot: Chroot, extra: bool = False) -> Path:
|
||||||
return outside
|
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"
|
tmp = "/tmp/initfs-extracted"
|
||||||
if extra:
|
if extra:
|
||||||
tmp = "/tmp/initfs-extra-extracted"
|
tmp = "/tmp/initfs-extra-extracted"
|
||||||
extract(flavor, suffix, extra)
|
extract(suffix, extra)
|
||||||
pmb.chroot.root(["ls", "-lahR", "."], suffix, Path(tmp), "stdout")
|
pmb.chroot.root(["ls", "-lahR", "."], suffix, Path(tmp), "stdout")
|
||||||
pmb.chroot.root(["rm", "-r", tmp], suffix)
|
pmb.chroot.root(["rm", "-r", tmp], suffix)
|
||||||
|
|
||||||
|
|
||||||
def frontend(args: PmbArgs) -> None:
|
def frontend(args: PmbArgs) -> None:
|
||||||
# Find the appropriate kernel flavor
|
|
||||||
context = get_context()
|
context = get_context()
|
||||||
chroot = Chroot.rootfs(context.config.device)
|
chroot = Chroot.rootfs(context.config.device)
|
||||||
flavor = pmb.chroot.other.kernel_flavor_installed(chroot)
|
|
||||||
|
|
||||||
# Handle initfs actions
|
# Handle initfs actions
|
||||||
action = args.action_initfs
|
action = args.action_initfs
|
||||||
if action == "build":
|
if action == "build":
|
||||||
build(flavor, chroot)
|
build(chroot)
|
||||||
elif action == "extract":
|
elif action == "extract":
|
||||||
dir = extract(flavor, chroot)
|
dir = extract(chroot)
|
||||||
logging.info(f"Successfully extracted initramfs to: {dir}")
|
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}")
|
logging.info(f"Successfully extracted initramfs-extra to: {dir_extra}")
|
||||||
elif action == "ls":
|
elif action == "ls":
|
||||||
logging.info("*** initramfs ***")
|
logging.info("*** initramfs ***")
|
||||||
ls(flavor, chroot)
|
ls(chroot)
|
||||||
logging.info("*** initramfs-extra ***")
|
logging.info("*** initramfs-extra ***")
|
||||||
ls(flavor, chroot, True)
|
ls(chroot, True)
|
||||||
|
|
||||||
# Handle hook actions
|
# Handle hook actions
|
||||||
elif action == "hook_ls":
|
elif action == "hook_ls":
|
||||||
|
@ -117,7 +101,7 @@ def frontend(args: PmbArgs) -> None:
|
||||||
pmb.chroot.initfs_hooks.delete(args.hook, chroot)
|
pmb.chroot.initfs_hooks.delete(args.hook, chroot)
|
||||||
|
|
||||||
# Rebuild the initfs after adding/removing a hook
|
# Rebuild the initfs after adding/removing a hook
|
||||||
build(flavor, chroot)
|
build(chroot)
|
||||||
|
|
||||||
if action in ["ls", "extract"]:
|
if action in ["ls", "extract"]:
|
||||||
link = "https://wiki.postmarketos.org/wiki/Initramfs_development"
|
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)
|
# Rebuild the initramfs, just to make sure (see #69)
|
||||||
flavor = pmb.helpers.frontend._parse_flavor(config.device, args.autoinstall)
|
flavor = pmb.helpers.frontend._parse_flavor(config.device, args.autoinstall)
|
||||||
if 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
|
# Do the export, print all files
|
||||||
logging.info(f"Export symlinks to: {target}")
|
logging.info(f"Export symlinks to: {target}")
|
||||||
|
|
|
@ -32,7 +32,7 @@ def kernel(
|
||||||
# Rebuild the initramfs, just to make sure (see #69)
|
# Rebuild the initramfs, just to make sure (see #69)
|
||||||
flavor = pmb.helpers.frontend._parse_flavor(deviceinfo.codename, autoinstall)
|
flavor = pmb.helpers.frontend._parse_flavor(deviceinfo.codename, autoinstall)
|
||||||
if 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
|
# Check kernel config
|
||||||
pmb.parse.kconfig.check(flavor, must_exist=False)
|
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)
|
# installed a hook without pmbootstrap - see #69 for more info)
|
||||||
# Packages will be built if necessary as part of this step
|
# Packages will be built if necessary as part of this step
|
||||||
pmb.chroot.apk.install(install_packages, chroot)
|
pmb.chroot.apk.install(install_packages, chroot)
|
||||||
flavor = pmb.chroot.other.kernel_flavor_installed(chroot)
|
pmb.chroot.initfs.build(chroot)
|
||||||
pmb.chroot.initfs.build(flavor, chroot)
|
|
||||||
|
|
||||||
# Set the user password
|
# Set the user password
|
||||||
setup_login(args, config, chroot)
|
setup_login(args, config, chroot)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue