feat(image): flash full disk images into LUKS; add Raspberry Pi OS
Support distributions that ship a full .img (Raspberry Pi OS, moode, RetroPie, Manjaro ARM) rather than a rootfs tarball, by loop-mounting the image and copying its boot + root partitions into a fresh LUKS container. - distributions.yml/catalog.py/choosers.py: raspios catalog (lite64/desktop64/ lite32 via the stable _latest redirects) + choose_raspios. - plan.py: source_url override so a _latest redirect downloads under an .img.xz name that decompress_command recognises. - transfer.py: transfer_disk_image (loop-mount -> repartition -> LUKS -> rsync copy with progress, cp fallback -> fix boot fstab); transfer_image gains interactive= and routes encrypted non-arch images here; download_image gains force_prompt. - loopimg.py: losetup attach/detach/partition helper. - fsutil.drop_fstab_mount + register_encrypted_root: replace a stock image's existing / fstab line instead of colliding with it. - encryption.configure_encryption returns the onion address. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
28
lim/image/loopimg.py
Normal file
28
lim/image/loopimg.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""Attach a stock disk image as a loop device to read its partitions."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from lim import runner, ui
|
||||
from lim.errors import LimError
|
||||
|
||||
|
||||
def attach(image_path: Path) -> str:
|
||||
"""Attach the image via losetup with partition scanning; return /dev/loopN."""
|
||||
ui.info(f"Attaching {image_path} as a loop device...")
|
||||
loop = runner.output(
|
||||
["losetup", "-Pf", "--show", str(image_path)],
|
||||
sudo=True,
|
||||
error_msg=f"Attaching {image_path} as a loop device failed.",
|
||||
).strip()
|
||||
if not loop:
|
||||
raise LimError(f"losetup returned no device for {image_path}.")
|
||||
return loop
|
||||
|
||||
|
||||
def detach(loop: str) -> None:
|
||||
runner.run(["losetup", "-d", loop], sudo=True, check=False)
|
||||
|
||||
|
||||
def partition(loop: str, number: int) -> str:
|
||||
"""/dev/loop0 -> /dev/loop0p1 (losetup -P names partitions with a p suffix)."""
|
||||
return f"{loop}p{number}"
|
||||
Reference in New Issue
Block a user