1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-24 21:15:10 +03:00

pmb/install: have size_boot, size_root in MiB (MR 1946)

Prepare for a future patch, that adds reserved space in MiB, by changing
size_boot and size_root from bytes to MB everywhere. This is what we need
most of the time and allows to drop some /1024**2 statements.
This commit is contained in:
Oliver Smith 2020-06-06 18:39:21 +02:00 committed by Bart Ribbers
parent 63fc2b621a
commit 2fc0794e30
No known key found for this signature in database
GPG key ID: 699D16185DAFAE61
4 changed files with 15 additions and 15 deletions

View file

@ -58,8 +58,8 @@ def create_and_mount_image(args, size_boot, size_root, split=False):
"""
Create a new image file, and mount it as /dev/install.
:param size_boot: size of the boot partition in bytes
:param size_root: size of the root partition in bytes
:param size_boot: size of the boot partition in MiB
:param size_root: size of the root partition in MiB
:param split: create separate images for boot and root partitions
"""
@ -79,7 +79,7 @@ def create_and_mount_image(args, size_boot, size_root, split=False):
pmb.chroot.root(args, ["rm", img_path])
# Make sure there is enough free space
size_mb = round((size_boot + size_root) / (1024**2))
size_mb = round(size_boot + size_root)
disk_data = os.statvfs(args.work)
free = round((disk_data.f_bsize * disk_data.f_bavail) / (1024**2))
if size_mb > free:
@ -88,8 +88,8 @@ def create_and_mount_image(args, size_boot, size_root, split=False):
# Create empty image files
pmb.chroot.user(args, ["mkdir", "-p", "/home/pmos/rootfs"])
size_mb_full = str(size_mb) + "M"
size_mb_boot = str(round(size_boot / (1024**2))) + "M"
size_mb_root = str(round(size_root / (1024**2))) + "M"
size_mb_boot = str(round(size_boot)) + "M"
size_mb_root = str(round(size_root)) + "M"
images = {img_path_full: size_mb_full}
if split:
images = {img_path_boot: size_mb_boot,
@ -117,8 +117,8 @@ def create(args, size_boot, size_root):
"""
Create /dev/install (the "install blockdevice").
:param size_boot: size of the boot partition in bytes
:param size_root: size of the root partition in bytes
:param size_boot: size of the boot partition in MiB
:param size_root: size of the root partition in MiB
"""
pmb.helpers.mount.umount_all(
args, args.work + "/chroot_native/dev/install")