Skip to content

Commit

Permalink
Arch: Simplify kernel logic
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanDeMeyer committed Aug 3, 2020
1 parent 72387bd commit 7f42510
Showing 1 changed file with 5 additions and 37 deletions.
42 changes: 5 additions & 37 deletions mkosi
Original file line number Diff line number Diff line change
Expand Up @@ -2223,20 +2223,8 @@ def install_arch(args: CommandLineArguments, root: str, do_run_build_script: boo
run_pacman_key(["--init"])
run_pacman_key(["--populate", keyring])

# the base metapackage is mandatory
packages = {"base"}

official_kernel_packages = {
"linux",
"linux-lts",
"linux-hardened",
"linux-zen",
}

kernel_packages = official_kernel_packages.intersection(args.packages)
if len(kernel_packages) > 1:
warn('More than one kernel will be installed: {}', ' '.join(kernel_packages))

if not do_run_build_script and args.bootable:
if args.output_format == OutputFormat.gpt_ext4:
packages.add("e2fsprogs")
Expand All @@ -2247,9 +2235,6 @@ def install_arch(args: CommandLineArguments, root: str, do_run_build_script: boo
if args.encrypt:
packages.add("cryptsetup")
packages.add("device-mapper")
if not kernel_packages:
# No user-specified kernel
kernel_packages.add("linux")
if args.bios_partno:
packages.add("grub")

Expand All @@ -2276,28 +2261,11 @@ def install_arch(args: CommandLineArguments, root: str, do_run_build_script: boo
return line
patch_file(os.path.join(root, "etc/mkinitcpio.conf"), jj)

# Disable fallback images to save time. We override the preset files
# before installing any kernels to have the updated config available
# when the mkinitcpio pacman hook is run during installation.
presetdir = os.path.join(root, "etc/mkinitcpio.d")
for kernel in kernel_packages:
preset = os.path.join(presetdir, f"{kernel}.preset")
with open(preset, "w") as f:
f.write(
dedent(
f"""
ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-{kernel}"
PRESETS=('default')
default_image="/boot/initramfs-{kernel}.img"
"""
)
)

# Install the user-specified packages and kernel
packages = set(args.packages)
if not do_run_build_script and args.bootable:
packages |= kernel_packages
if not do_run_build_script and args.bootable and not any(["linux" in package for package in args.packages]):
# No user-specified kernel
packages.add("linux")

if do_run_build_script:
packages.update(args.build_packages)
Expand Down Expand Up @@ -2359,14 +2327,14 @@ def install_arch(args: CommandLineArguments, root: str, do_run_build_script: boo
)
)

def run_pacman(packages: List[str]) -> CompletedProcess:
def run_pacman(packages: Set[str]) -> None:
if len(packages) == 0:
return

cmdline = ["pacman", "--noconfirm", "--config", pacman_conf, "-S", *packages]

try:
return run(cmdline, check=True)
run(cmdline, check=True)
finally:
stop_gpg_agent()

Expand Down

0 comments on commit 7f42510

Please sign in to comment.