patch-builder: Making patch scripts optional

With this change, the following fields are not longer mandatory
in the patch XML:

- pre_start
- post_start
- pre_install
- post_install
- activation_scripts

If these are omitted from the patch XML, the patch-builder
will simply consider them empty.

Test plan:
pass - Generate patch using XML without patch script fields
       and confirm metadata.xml in patch still has them
       with empty values

Story: 2011498
Task: 52893

Change-Id: I66bb034694a3cd51b7b31ba850dcc90a7e79aca7
Signed-off-by: Leonardo Fagundes Luz Serrano <Leonardo.FagundesLuzSerrano@windriver.com>
This commit is contained in:
Leonardo Fagundes Luz Serrano
2025-10-08 13:09:27 -03:00
parent 67ed517c9e
commit e53283011a
2 changed files with 7 additions and 7 deletions

View File

@@ -20,11 +20,11 @@
</xs:complexType>
</xs:element>
<xs:element name="semantics" type="xs:string"/>
<xs:element name="pre_start" type="xs:string"/>
<xs:element name="post_start" type="xs:string"/>
<xs:element name="pre_install" type="xs:string"/>
<xs:element name="post_install" type="xs:string"/>
<xs:element name="activation_scripts">
<xs:element name="pre_start" type="xs:string" minOccurs="0"/>
<xs:element name="post_start" type="xs:string" minOccurs="0"/>
<xs:element name="pre_install" type="xs:string" minOccurs="0"/>
<xs:element name="post_install" type="xs:string" minOccurs="0"/>
<xs:element name="activation_scripts" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="script" type="xs:string" maxOccurs="unbounded" minOccurs="0"/>

View File

@@ -183,7 +183,7 @@ class PatchMetadata(object):
# For each patch script, validate the path provided
self.patch_script_paths = {
script_id: self.check_script_path(patch_recipe[script_id])
script_id: self.check_script_path(patch_recipe.get(script_id, None))
for script_id in PATCH_SCRIPTS.keys()
}
@@ -192,7 +192,7 @@ 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]:
if ACTIVATION_SCRIPTS in patch_recipe and '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 = []