@@ -58,6 +58,7 @@ IMAGE_TEMPLATE_VARS:swu = " \
SWU_NAME \
SWU_FILE_NODES \
SWU_BOOTLOADER_FILE_NODE \
+ SWU_SCRIPTS_NODE \
"
# Add the bootloader file
@@ -123,6 +124,29 @@ python add_ebg_update(){
d.appendVar('SWU_ADDITIONAL_FILES', " " + efi_boot_loader_file)
}
+SWU_EXTEND_SW_DESCRIPTION += "add_scripts"
+python add_scripts(){
+ swu_scripts = d.getVar('SWU_SCRIPTS')
+ if not swu_scripts:
+ return
+ swu_script_entries = [ s for s in swu_scripts.split() ]
+ script_node_list = []
+ for entry in swu_script_entries:
+ script_file, script_type = entry.split(':')
+ node = f"""
+ {{
+ filename = "{script_file}";
+ type = "{script_type}";
+ sha256 = "{script_file}-sha256";
+ }},"""
+ script_node_list.append(node)
+ d.appendVar('SWU_ADDITIONAL_FILES', " " + script_file)
+ d.appendVar('SRC_URI', f" file://{script_file}")
+
+ swu_scripts_node = "scripts: (" + ''.join([n for n in script_node_list]) + ");"
+ d.appendVar('SWU_SCRIPTS_NODE', swu_scripts_node)
+}
+
# convert between swupdate compressor name and imagetype extension
def get_swu_compression_type(d):
swu_ct = d.getVar('SWU_COMPRESSION_TYPE')
@@ -21,6 +21,35 @@ window is still possible.
If the variable `SWU_EBG_UPDATE` is set to `"1"` the update is also stored in
the `*.swu` file.
+## SWUpdate scripts
+
+It is possible to add [scripts](https://sbabic.github.io/swupdate/sw-description.html?#scripts) to a swu file.
+
+To add a script entry in isar-cip-core set the variable `SWU_SCRIPTS`.
+The content of the variable has the following pattern:
+`<script_file_name>:<script_type>`
+
+The file referenced by `script_file_name` is added to the variables `SRC_URI`
+and `SWU_ADDITIONAL_FILES`. Therefore, it needs to be safed in a `FILESPATH`
+location.
+
+Example:
+
+```
+SWU_SCRIPTS = "postinstall.sh:postinstall"
+```
+This will add `file://postinstall.sh` to the variable `SRC_URI` and
+`postinstall.sh` to `SWU_ADDTIONAL_FILES`. The sw-description will contain
+the following section:
+```
+ scripts: (
+ {
+ filename = "postinstall.sh";
+ type = "postinstall";
+ sha256 = "<sha256 of postinstall.sh>";
+ },):
+```
+
# Building and testing the CIP Core image
Set up `kas-container` as described in the [top-level README](../README.md).
@@ -35,4 +35,5 @@ software =
};
sha256 = "linux.efi-sha256";
}${SWU_FILE_NODES});
+ ${SWU_SCRIPTS_NODE}
}