diff --git a/pmb/helpers/frontend.py b/pmb/helpers/frontend.py index c2294980..5879bc4c 100644 --- a/pmb/helpers/frontend.py +++ b/pmb/helpers/frontend.py @@ -194,6 +194,12 @@ def initfs(args): def install(args): + if args.rsync and args.full_disk_encryption: + raise ValueError("Installation using rsync is not compatible with full" + " disk encryption.") + if args.rsync and not args.sdcard: + raise ValueError("Installation using rsync only works on sdcard.") + pmb.install.install(args) diff --git a/pmb/install/__init__.py b/pmb/install/__init__.py index f09e3689..e2f2bb45 100644 --- a/pmb/install/__init__.py +++ b/pmb/install/__init__.py @@ -19,3 +19,4 @@ along with pmbootstrap. If not, see . from pmb.install.install import install from pmb.install.partition import partition from pmb.install.format import format +from pmb.install.partition import partitions_mount diff --git a/pmb/install/format.py b/pmb/install/format.py index a2f084f6..1e51795e 100644 --- a/pmb/install/format.py +++ b/pmb/install/format.py @@ -49,14 +49,20 @@ def format_and_mount_root(args): def format_and_mount_pm_crypt(args): + # Block device if args.full_disk_encryption: device = "/dev/mapper/pm_crypt" else: device = "/dev/installp2" + + # Format + if not args.rsync: + logging.info("(native) format " + device) + pmb.chroot.root(args, ["mkfs.ext4", "-F", "-q", "-L", "pmOS_root", device]) + + # Mount mountpoint = "/mnt/install" - logging.info("(native) format " + device + " (ext4), mount to " + - mountpoint) - pmb.chroot.root(args, ["mkfs.ext4", "-F", "-q", "-L", "pmOS_root", device]) + logging.info("(native) mount " + device + " to " + mountpoint) pmb.chroot.root(args, ["mkdir", "-p", mountpoint]) pmb.chroot.root(args, ["mount", device, mountpoint]) diff --git a/pmb/install/install.py b/pmb/install/install.py index 98b00f06..ec61f796 100644 --- a/pmb/install/install.py +++ b/pmb/install/install.py @@ -86,9 +86,18 @@ def copy_files_from_chroot(args): continue folders += [os.path.basename(path)] - # Run the copy command - pmb.chroot.root(args, ["cp", "-a"] + folders + ["/mnt/install/"], - working_dir=mountpoint) + # Update or copy all files + if args.rsync: + pmb.chroot.apk.install(args, ["rsync"]) + rsync_flags = "-a" + if args.verbose: + rsync_flags += "vP" + pmb.chroot.root(args, ["rsync", rsync_flags, "--delete"] + folders + ["/mnt/install/"], + working_dir=mountpoint) + pmb.chroot.root(args, ["rm", "-rf", "/mnt/install/home"]) + else: + pmb.chroot.root(args, ["cp", "-a"] + folders + ["/mnt/install/"], + working_dir=mountpoint) def copy_files_other(args): @@ -100,7 +109,7 @@ def copy_files_other(args): for key in glob.glob(args.work + "/config_apk_keys/*.pub"): pmb.helpers.run.root(args, ["cp", key, rootfs + "/etc/apk/keys/"]) - # Create /home/{user} + # Create /home/{user} from /etc/skel homedir = rootfs + "/home/" + args.user pmb.helpers.run.root(args, ["mkdir", rootfs + "/home"]) pmb.helpers.run.root(args, ["cp", "-a", rootfs + "/etc/skel", homedir]) @@ -196,8 +205,11 @@ def install_system_image(args): logging.info("*** (3/5) PREPARE INSTALL BLOCKDEVICE ***") pmb.chroot.shutdown(args, True) (size_image, size_boot) = get_subpartitions_size(args) - pmb.install.blockdevice.create(args, size_image) - pmb.install.partition(args, size_boot) + if not args.rsync: + pmb.install.blockdevice.create(args, size_image) + pmb.install.partition(args, size_boot) + pmb.install.partitions_mount(args) + if args.full_disk_encryption: logging.info("WARNING: Full disk encryption is enabled!") logging.info("Make sure that osk-sdl has been properly configured for your device") diff --git a/pmb/install/partition.py b/pmb/install/partition.py index 97ddc379..9df3dda6 100644 --- a/pmb/install/partition.py +++ b/pmb/install/partition.py @@ -81,6 +81,3 @@ def partition(args, size_boot): for command in commands: pmb.chroot.root(args, ["parted", "-s", "/dev/install"] + command, check=False) - - # Mount new partitions - partitions_mount(args) diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py index af643935..4890d50f 100644 --- a/pmb/parse/arguments.py +++ b/pmb/parse/arguments.py @@ -266,6 +266,8 @@ def arguments(): " chroot and install to sdcard or image file") install.add_argument("--sdcard", help="path to the sdcard device," " eg. /dev/mmcblk0") + install.add_argument("--rsync", help="update the sdcard using rsync," + " only works with --no-fde", action="store_true") install.add_argument("--cipher", help="cryptsetup cipher used to" " encrypt the system partition, eg. aes-xts-plain64") install.add_argument("--iter-time", help="cryptsetup iteration time (in"