From 89323a9afea707904227b7bc18317a173b176a40 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Tue, 6 Oct 2020 11:34:19 +0200 Subject: [PATCH] pmbootstrap install: add --ondev --no-rootfs Skip building the postmarketOS rootfs, and allow either installing a pre-built pmOS rootfs, or even another operating system. --- pmb/helpers/frontend.py | 4 ++++ pmb/install/_install.py | 37 +++++++++++++++++++++---------------- pmb/parse/arguments.py | 3 +++ 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/pmb/helpers/frontend.py b/pmb/helpers/frontend.py index 4de25663..311576d0 100644 --- a/pmb/helpers/frontend.py +++ b/pmb/helpers/frontend.py @@ -223,6 +223,10 @@ def install(args): if args.rsync: raise ValueError("--on-device-installer cannot be combined with" " --rsync") + else: + if not args.ondev_rootfs: + raise ValueError("--no-rootfs can only be combined with --ondev." + " Do you mean --no-image?") # On-device installer overrides if args.on_device_installer: diff --git a/pmb/install/_install.py b/pmb/install/_install.py index 15413f47..8369c69d 100644 --- a/pmb/install/_install.py +++ b/pmb/install/_install.py @@ -594,10 +594,11 @@ def install_recovery_zip(args): def install_on_device_installer(args, step, steps): # Generate the rootfs image - suffix_rootfs = f"rootfs_{args.device}" - install_system_image(args, 0, suffix_rootfs, step=step, steps=steps, - split=True) - step += 2 + if args.ondev_rootfs: + suffix_rootfs = f"rootfs_{args.device}" + install_system_image(args, 0, suffix_rootfs, step=step, steps=steps, + split=True) + step += 2 # Prepare the installer chroot logging.info(f"*** ({step}/{steps}) CREATE ON-DEVICE INSTALLER ROOTFS ***") @@ -610,12 +611,14 @@ def install_on_device_installer(args, step, steps): pmb.chroot.apk.install(args, packages, suffix_installer) # Move rootfs image into installer chroot - img = f"{args.device}-root.img" - img_path_src = f"{args.work}/chroot_native/home/pmos/rootfs/{img}" - img_path_dest = f"{args.work}/chroot_{suffix_installer}/var/lib/rootfs.img" - logging.info(f"({suffix_installer}) add {img} as /var/lib/rootfs.img") - pmb.install.losetup.umount(args, img_path_src) - pmb.helpers.run.root(args, ["mv", img_path_src, img_path_dest]) + if args.ondev_rootfs: + img = f"{args.device}-root.img" + img_path_src = f"{args.work}/chroot_native/home/pmos/rootfs/{img}" + img_path_dest = f"{args.work}/chroot_{suffix_installer}/var/lib/" \ + "rootfs.img" + logging.info(f"({suffix_installer}) add {img} as /var/lib/rootfs.img") + pmb.install.losetup.umount(args, img_path_src) + pmb.helpers.run.root(args, ["mv", img_path_src, img_path_dest]) # Run ondev-prepare, so it may generate nice configs from the channel # properties (e.g. to display the version number), or transform the image @@ -636,9 +639,10 @@ def install_on_device_installer(args, step, steps): # Remove $DEVICE-boot.img (we will generate a new one if --split was # specified, otherwise the separate boot image is not needed) - img_boot = f"{args.device}-boot.img" - logging.info(f"(native) rm {img_boot}") - pmb.chroot.root(args, ["rm", f"/home/pmos/rootfs/{img_boot}"]) + if args.ondev_rootfs: + img_boot = f"{args.device}-boot.img" + logging.info(f"(native) rm {img_boot}") + pmb.chroot.root(args, ["rm", f"/home/pmos/rootfs/{img_boot}"]) # Generate installer image size_reserve = round(os.path.getsize(img_path_dest) / 1024 / 1024) + 200 @@ -717,7 +721,7 @@ def install(args): elif args.android_recovery_zip: steps = 4 elif args.on_device_installer: - steps = 8 + steps = 8 if args.ondev_rootfs else 5 else: steps = 5 @@ -728,8 +732,9 @@ def install(args): build=False) step += 1 - create_device_rootfs(args, step, steps) - step += 1 + if args.ondev_rootfs: + create_device_rootfs(args, step, steps) + step += 1 if args.no_image: return diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py index c6ef4508..7ff0d1b1 100644 --- a/pmb/parse/arguments.py +++ b/pmb/parse/arguments.py @@ -116,6 +116,9 @@ def arguments_install(subparser): group.add_argument("--no-local-pkgs", dest="install_local_pkgs", help="do not install locally compiled packages and" " package signing keys", action="store_false") + group.add_argument("--no-rootfs", dest="ondev_rootfs", + help="do not generate the postmarketOS rootfs to be" + " installed", action="store_false") def arguments_export(subparser):