build: include size-limits to device-metadata
Include the image and kernel size limitations defined for each device to the device metadata JSON. These informations are only added if defined. Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
parent
775523f628
commit
0ee1ede25a
2 changed files with 32 additions and 1 deletions
|
@ -647,6 +647,8 @@ define Device/Build/initramfs
|
||||||
VERSION_NUMBER="$(VERSION_NUMBER)" \
|
VERSION_NUMBER="$(VERSION_NUMBER)" \
|
||||||
VERSION_CODE="$(VERSION_CODE)" \
|
VERSION_CODE="$(VERSION_CODE)" \
|
||||||
SUPPORTED_DEVICES="$$(SUPPORTED_DEVICES)" \
|
SUPPORTED_DEVICES="$$(SUPPORTED_DEVICES)" \
|
||||||
|
KERNEL_SIZE="$$(KERNEL_SIZE)" \
|
||||||
|
IMAGE_SIZE="$$(IMAGE_SIZE)" \
|
||||||
$(TOPDIR)/scripts/json_add_image_info.py $$@
|
$(TOPDIR)/scripts/json_add_image_info.py $$@
|
||||||
endef
|
endef
|
||||||
endif
|
endif
|
||||||
|
@ -781,6 +783,8 @@ define Device/Build/image
|
||||||
VERSION_NUMBER="$(VERSION_NUMBER)" \
|
VERSION_NUMBER="$(VERSION_NUMBER)" \
|
||||||
VERSION_CODE="$(VERSION_CODE)" \
|
VERSION_CODE="$(VERSION_CODE)" \
|
||||||
SUPPORTED_DEVICES="$(SUPPORTED_DEVICES)" \
|
SUPPORTED_DEVICES="$(SUPPORTED_DEVICES)" \
|
||||||
|
KERNEL_SIZE="$(KERNEL_SIZE)" \
|
||||||
|
IMAGE_SIZE="$(IMAGE_SIZE)" \
|
||||||
$(TOPDIR)/scripts/json_add_image_info.py $$@
|
$(TOPDIR)/scripts/json_add_image_info.py $$@
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
@ -835,6 +839,8 @@ define Device/Build/artifact
|
||||||
VERSION_NUMBER="$(VERSION_NUMBER)" \
|
VERSION_NUMBER="$(VERSION_NUMBER)" \
|
||||||
VERSION_CODE="$(VERSION_CODE)" \
|
VERSION_CODE="$(VERSION_CODE)" \
|
||||||
SUPPORTED_DEVICES="$(SUPPORTED_DEVICES)" \
|
SUPPORTED_DEVICES="$(SUPPORTED_DEVICES)" \
|
||||||
|
KERNEL_SIZE="$(KERNEL_SIZE)" \
|
||||||
|
IMAGE_SIZE="$(IMAGE_SIZE)" \
|
||||||
$(TOPDIR)/scripts/json_add_image_info.py $$@
|
$(TOPDIR)/scripts/json_add_image_info.py $$@
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from os import getenv
|
from os import getenv, path
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from sys import argv
|
from sys import argv
|
||||||
import hashlib
|
import hashlib
|
||||||
|
@ -35,6 +35,17 @@ def get_titles():
|
||||||
return titles
|
return titles
|
||||||
|
|
||||||
|
|
||||||
|
def get_numerical_size(image_size):
|
||||||
|
if image_size.endswith("g"):
|
||||||
|
return int(image_size[:-1]) * 1024 * 1024 * 1024
|
||||||
|
elif image_size.endswith("m"):
|
||||||
|
return int(image_size[:-1]) * 1024 * 1024
|
||||||
|
elif image_size.endswith("k"):
|
||||||
|
return int(image_size[:-1]) * 1024
|
||||||
|
else:
|
||||||
|
return int(image_size)
|
||||||
|
|
||||||
|
|
||||||
device_id = getenv("DEVICE_ID")
|
device_id = getenv("DEVICE_ID")
|
||||||
|
|
||||||
sha256_hash = hashlib.sha256()
|
sha256_hash = hashlib.sha256()
|
||||||
|
@ -52,6 +63,8 @@ if file_path.with_suffix(file_path.suffix + ".sha256sum").exists():
|
||||||
else:
|
else:
|
||||||
hash_unsigned = hash_file
|
hash_unsigned = hash_file
|
||||||
|
|
||||||
|
file_size = path.getsize(file_path)
|
||||||
|
|
||||||
file_info = {
|
file_info = {
|
||||||
"metadata_version": 1,
|
"metadata_version": 1,
|
||||||
"target": "{}/{}".format(getenv("TARGET"), getenv("SUBTARGET")),
|
"target": "{}/{}".format(getenv("TARGET"), getenv("SUBTARGET")),
|
||||||
|
@ -67,6 +80,7 @@ file_info = {
|
||||||
"name": getenv("FILE_NAME"),
|
"name": getenv("FILE_NAME"),
|
||||||
"sha256": hash_file,
|
"sha256": hash_file,
|
||||||
"sha256_unsigned": hash_unsigned,
|
"sha256_unsigned": hash_unsigned,
|
||||||
|
"size": file_size,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"device_packages": getenv("DEVICE_PACKAGES").split(),
|
"device_packages": getenv("DEVICE_PACKAGES").split(),
|
||||||
|
@ -76,6 +90,17 @@ file_info = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if getenv("IMAGE_SIZE") or getenv("KERNEL_SIZE"):
|
||||||
|
file_info["profiles"][device_id]["file_size_limits"] = {}
|
||||||
|
if getenv("IMAGE_SIZE"):
|
||||||
|
file_info["profiles"][device_id]["file_size_limits"]["image"] = get_numerical_size(
|
||||||
|
getenv("IMAGE_SIZE")
|
||||||
|
)
|
||||||
|
if getenv("KERNEL_SIZE"):
|
||||||
|
file_info["profiles"][device_id]["file_size_limits"]["kernel"] = get_numerical_size(
|
||||||
|
getenv("KERNEL_SIZE")
|
||||||
|
)
|
||||||
|
|
||||||
if getenv("FILE_FILESYSTEM"):
|
if getenv("FILE_FILESYSTEM"):
|
||||||
file_info["profiles"][device_id]["images"][0]["filesystem"] = getenv(
|
file_info["profiles"][device_id]["images"][0]["filesystem"] = getenv(
|
||||||
"FILE_FILESYSTEM"
|
"FILE_FILESYSTEM"
|
||||||
|
|
Loading…
Reference in a new issue