VERSION_NUMBER="$(VERSION_NUMBER)" \
VERSION_CODE="$(VERSION_CODE)" \
SUPPORTED_DEVICES="$$(SUPPORTED_DEVICES)" \
+ KERNEL_SIZE="$$(KERNEL_SIZE)" \
+ IMAGE_SIZE="$$(IMAGE_SIZE)" \
$(TOPDIR)/scripts/json_add_image_info.py $$@
endef
endif
VERSION_NUMBER="$(VERSION_NUMBER)" \
VERSION_CODE="$(VERSION_CODE)" \
SUPPORTED_DEVICES="$(SUPPORTED_DEVICES)" \
+ KERNEL_SIZE="$(KERNEL_SIZE)" \
+ IMAGE_SIZE="$(IMAGE_SIZE)" \
$(TOPDIR)/scripts/json_add_image_info.py $$@
endef
VERSION_NUMBER="$(VERSION_NUMBER)" \
VERSION_CODE="$(VERSION_CODE)" \
SUPPORTED_DEVICES="$(SUPPORTED_DEVICES)" \
+ KERNEL_SIZE="$(KERNEL_SIZE)" \
+ IMAGE_SIZE="$(IMAGE_SIZE)" \
$(TOPDIR)/scripts/json_add_image_info.py $$@
endef
#!/usr/bin/env python3
-from os import getenv
+from os import getenv, path
from pathlib import Path
from sys import argv
import hashlib
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")
sha256_hash = hashlib.sha256()
else:
hash_unsigned = hash_file
+file_size = path.getsize(file_path)
+
file_info = {
"metadata_version": 1,
"target": "{}/{}".format(getenv("TARGET"), getenv("SUBTARGET")),
"name": getenv("FILE_NAME"),
"sha256": hash_file,
"sha256_unsigned": hash_unsigned,
+ "size": file_size,
}
],
"device_packages": getenv("DEVICE_PACKAGES").split(),
},
}
+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"):
file_info["profiles"][device_id]["images"][0]["filesystem"] = getenv(
"FILE_FILESYSTEM"