diff --git a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-binary.xml b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-binary.xml
index 2e6df778..95e65f07 100644
--- a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-binary.xml
+++ b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-binary.xml
@@ -17,6 +17,7 @@
-->
+
scripts/pre-install.sh
diff --git a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-insvc.xml b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-insvc.xml
index 9477475e..1622a5e0 100644
--- a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-insvc.xml
+++ b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-insvc.xml
@@ -12,6 +12,7 @@
DEV
+
diff --git a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-large.xml b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-large.xml
index 63e01c28..e5c2623e 100644
--- a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-large.xml
+++ b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-large.xml
@@ -17,6 +17,7 @@
-->
+
scripts/pre-install.sh
diff --git a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample.xml b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample.xml
index aaa64a74..aee60f68 100644
--- a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample.xml
+++ b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample.xml
@@ -17,6 +17,7 @@
-->
+
scripts/pre-install.sh
diff --git a/build-tools/stx/patch/README.md b/build-tools/stx/patch/README.md
index 22e0a925..bab171d0 100644
--- a/build-tools/stx/patch/README.md
+++ b/build-tools/stx/patch/README.md
@@ -39,9 +39,16 @@ The patch builder requires the following tags in the input xml (or patch recipe)
-->
+
+
+
+
scripts/pre-install.sh
scripts/post-install.sh
diff --git a/build-tools/stx/patch/config/patch-recipe-schema.xsd b/build-tools/stx/patch/config/patch-recipe-schema.xsd
index 753942e4..cab7831e 100644
--- a/build-tools/stx/patch/config/patch-recipe-schema.xsd
+++ b/build-tools/stx/patch/config/patch-recipe-schema.xsd
@@ -22,6 +22,13 @@
+
+
+
+
+
+
+
diff --git a/build-tools/stx/patch/metadata.py b/build-tools/stx/patch/metadata.py
index 02cde61e..213cad72 100644
--- a/build-tools/stx/patch/metadata.py
+++ b/build-tools/stx/patch/metadata.py
@@ -45,6 +45,7 @@ PACKAGES = 'packages'
STX_PACKAGES = 'stx_packages'
BINARY_PACKAGES = 'binary_packages'
SEMANTICS = 'semantics'
+ACTIVATION_SCRIPTS = 'activation_scripts'
class PatchMetadata(object):
@@ -53,6 +54,7 @@ class PatchMetadata(object):
self.stx_packages = []
self.binary_packages = []
self.requires = []
+ self.activation_scripts = []
# Verify if the path to the patch builder folder is set
if not PATCH_BUILDER_PATH:
@@ -138,6 +140,13 @@ class PatchMetadata(object):
else:
self.__add_text_tag_to_xml(top_tag, POST_INSTALL, "")
+ if self.activation_scripts:
+ activation_scripts_tag = ET.SubElement(top_tag, ACTIVATION_SCRIPTS)
+ for script in self.activation_scripts:
+ self.__add_text_tag_to_xml(activation_scripts_tag, "script", script.split('/')[-1])
+ else:
+ self.__add_text_tag_to_xml(top_tag, ACTIVATION_SCRIPTS, "")
+
packages_tag = ET.SubElement(top_tag, PACKAGES)
for package in sorted(self.debs):
self.__add_text_tag_to_xml(packages_tag, "deb", package)
@@ -152,6 +161,19 @@ class PatchMetadata(object):
return [tag_content]
return tag_content
+ def _validate_activation_script(self, script_list):
+ '''
+ Validate if scripts filename start with an integer
+ '''
+ for fullpath_script in script_list:
+ try:
+ name = os.path.basename(fullpath_script)
+ int(name.split("-")[0])
+ except Exception:
+ logger.error("Error while parsing the activation script:")
+ logger.error("Filename '%s' doesn't start with an integer." % fullpath_script)
+ sys.exit(1)
+
def parse_metadata(self, patch_recipe):
self.patch_id = f"{patch_recipe[COMPONENT]}-{patch_recipe[SW_VERSION]}"
self.sw_version = patch_recipe[SW_VERSION]
@@ -172,6 +194,17 @@ class PatchMetadata(object):
if 'id' in patch_recipe[REQUIRES]:
self.requires = self.__tag_to_list(patch_recipe[REQUIRES]['id'])
self.semantics = patch_recipe[SEMANTICS]
+ if 'script' in patch_recipe[ACTIVATION_SCRIPTS]:
+ # the xml parser transform the 'script' value in string or in
+ # array depending on how much elements we add.
+ scripts_lst = []
+ if isinstance(patch_recipe[ACTIVATION_SCRIPTS]['script'], str):
+ scripts_lst.append(self.check_script_path(patch_recipe[ACTIVATION_SCRIPTS]['script']))
+ else:
+ for script in patch_recipe[ACTIVATION_SCRIPTS]['script']:
+ scripts_lst.append(self.check_script_path(script))
+ self._validate_activation_script(scripts_lst)
+ self.activation_scripts = scripts_lst
self.debs = []
if self.status != 'DEV' and self.status != 'REL':
@@ -202,7 +235,7 @@ class PatchMetadata(object):
logger.error(f"Line {error.line}: {error.message}")
sys.exit(1)
- print(xml_dict)
+ logger.info(xml_dict)
self.parse_metadata(xml_dict)
diff --git a/build-tools/stx/patch/patch-builder b/build-tools/stx/patch/patch-builder
index 99d9cbdb..dd0f1e34 100755
--- a/build-tools/stx/patch/patch-builder
+++ b/build-tools/stx/patch/patch-builder
@@ -97,6 +97,11 @@ class PatchBuilder(object):
logger.debug(f"Copying post-install script: {post_install}")
self.copy_rename_script(post_install, "POST_INSTALL")
+ # Copy all activate scripts
+ if self.metadata.activation_scripts:
+ for script in self.metadata.activation_scripts:
+ self.copy_rename_script(path_to_script=script, rename=False)
+
# if the patch includes the 'software' package we need to make deploy-precheck
# and upgrade_utils.py from .deb file accessible directly from patch file
if 'software' in self.metadata.stx_packages: