forked from Mirror/pmbootstrap
Optional --rsync parameter for pmbootstrap install only copies the diff (#1151)
Should reduce wear of sd card. Example usage: pmbootstrap install --sdcard=/dev/mmcblk0 --no-fde --rsync More rsync output with pmbootstrap -v.
This commit is contained in:
parent
cd7280e1ee
commit
bdeec7a255
6 changed files with 36 additions and 12 deletions
|
@ -194,6 +194,12 @@ def initfs(args):
|
||||||
|
|
||||||
|
|
||||||
def install(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)
|
pmb.install.install(args)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,3 +19,4 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
||||||
from pmb.install.install import install
|
from pmb.install.install import install
|
||||||
from pmb.install.partition import partition
|
from pmb.install.partition import partition
|
||||||
from pmb.install.format import format
|
from pmb.install.format import format
|
||||||
|
from pmb.install.partition import partitions_mount
|
||||||
|
|
|
@ -49,14 +49,20 @@ def format_and_mount_root(args):
|
||||||
|
|
||||||
|
|
||||||
def format_and_mount_pm_crypt(args):
|
def format_and_mount_pm_crypt(args):
|
||||||
|
# Block device
|
||||||
if args.full_disk_encryption:
|
if args.full_disk_encryption:
|
||||||
device = "/dev/mapper/pm_crypt"
|
device = "/dev/mapper/pm_crypt"
|
||||||
else:
|
else:
|
||||||
device = "/dev/installp2"
|
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"
|
mountpoint = "/mnt/install"
|
||||||
logging.info("(native) format " + device + " (ext4), mount to " +
|
logging.info("(native) mount " + device + " to " + mountpoint)
|
||||||
mountpoint)
|
|
||||||
pmb.chroot.root(args, ["mkfs.ext4", "-F", "-q", "-L", "pmOS_root", device])
|
|
||||||
pmb.chroot.root(args, ["mkdir", "-p", mountpoint])
|
pmb.chroot.root(args, ["mkdir", "-p", mountpoint])
|
||||||
pmb.chroot.root(args, ["mount", device, mountpoint])
|
pmb.chroot.root(args, ["mount", device, mountpoint])
|
||||||
|
|
||||||
|
|
|
@ -86,9 +86,18 @@ def copy_files_from_chroot(args):
|
||||||
continue
|
continue
|
||||||
folders += [os.path.basename(path)]
|
folders += [os.path.basename(path)]
|
||||||
|
|
||||||
# Run the copy command
|
# Update or copy all files
|
||||||
pmb.chroot.root(args, ["cp", "-a"] + folders + ["/mnt/install/"],
|
if args.rsync:
|
||||||
working_dir=mountpoint)
|
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):
|
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"):
|
for key in glob.glob(args.work + "/config_apk_keys/*.pub"):
|
||||||
pmb.helpers.run.root(args, ["cp", key, rootfs + "/etc/apk/keys/"])
|
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
|
homedir = rootfs + "/home/" + args.user
|
||||||
pmb.helpers.run.root(args, ["mkdir", rootfs + "/home"])
|
pmb.helpers.run.root(args, ["mkdir", rootfs + "/home"])
|
||||||
pmb.helpers.run.root(args, ["cp", "-a", rootfs + "/etc/skel", homedir])
|
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 ***")
|
logging.info("*** (3/5) PREPARE INSTALL BLOCKDEVICE ***")
|
||||||
pmb.chroot.shutdown(args, True)
|
pmb.chroot.shutdown(args, True)
|
||||||
(size_image, size_boot) = get_subpartitions_size(args)
|
(size_image, size_boot) = get_subpartitions_size(args)
|
||||||
pmb.install.blockdevice.create(args, size_image)
|
if not args.rsync:
|
||||||
pmb.install.partition(args, size_boot)
|
pmb.install.blockdevice.create(args, size_image)
|
||||||
|
pmb.install.partition(args, size_boot)
|
||||||
|
pmb.install.partitions_mount(args)
|
||||||
|
|
||||||
if args.full_disk_encryption:
|
if args.full_disk_encryption:
|
||||||
logging.info("WARNING: Full disk encryption is enabled!")
|
logging.info("WARNING: Full disk encryption is enabled!")
|
||||||
logging.info("Make sure that osk-sdl has been properly configured for your device")
|
logging.info("Make sure that osk-sdl has been properly configured for your device")
|
||||||
|
|
|
@ -81,6 +81,3 @@ def partition(args, size_boot):
|
||||||
for command in commands:
|
for command in commands:
|
||||||
pmb.chroot.root(args, ["parted", "-s", "/dev/install"] +
|
pmb.chroot.root(args, ["parted", "-s", "/dev/install"] +
|
||||||
command, check=False)
|
command, check=False)
|
||||||
|
|
||||||
# Mount new partitions
|
|
||||||
partitions_mount(args)
|
|
||||||
|
|
|
@ -266,6 +266,8 @@ def arguments():
|
||||||
" chroot and install to sdcard or image file")
|
" chroot and install to sdcard or image file")
|
||||||
install.add_argument("--sdcard", help="path to the sdcard device,"
|
install.add_argument("--sdcard", help="path to the sdcard device,"
|
||||||
" eg. /dev/mmcblk0")
|
" 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"
|
install.add_argument("--cipher", help="cryptsetup cipher used to"
|
||||||
" encrypt the system partition, eg. aes-xts-plain64")
|
" encrypt the system partition, eg. aes-xts-plain64")
|
||||||
install.add_argument("--iter-time", help="cryptsetup iteration time (in"
|
install.add_argument("--iter-time", help="cryptsetup iteration time (in"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue