Add source_size as option for exporting sfdisk layout, compute size better for image

This commit is contained in:
asonix 2023-01-14 20:50:00 -06:00
parent ae75263c4a
commit 86602b2f0d
2 changed files with 12 additions and 13 deletions

View file

@ -39,7 +39,7 @@ class Partition:
attributes = dict(
name=self.name,
start=self.start,
size=self.size,
size=self.size or self.source_size,
type=self.type,
attrs=self.attrs,
)
@ -128,17 +128,18 @@ def get_partition(p: Dict[str, Any], out_file: str) -> Partition:
def compute_image_size(partitions: List[Partition]) -> int:
# leave some space for backup gpt
size = 512
for p in partitions:
if p.size is None:
if p.source_size is None:
cmd = ["du", "-B", "512", "--apparent-size", p.source]
proc = subprocess.run(cmd, check=True, stdout=subprocess.PIPE)
size += int(proc.stdout)
else:
size += p.source_size
p = partitions[~0]
size = 33 + p.start # 33 is magic number for fitting end GPT section
if p.size is None:
if p.source_size is None:
cmd = ["du", "-B", "512", "--apparent-size", p.source]
proc = subprocess.run(cmd, check=True, stdout=subprocess.PIPE)
size += int(proc.stdout)
else:
size += p.size
size += p.source_size
else:
size += p.size
return size

View file

@ -36,8 +36,6 @@ let
preConfigure = ''
make mrproper
sed -i"" 's/cm4io.dtb/blade.dtb/' configs/soquartz-rk3566_defconfig
cp "${bl31Blobs}/bin/rk35/rk3568_bl31_v1.28.elf" "bl31.elf"
cp "${rkbinBlobs}/bin/rk35/rk3566_ddr_1056MHz_v1.13.bin" ram_init.bin
'';