From 0caedf9b845c1eed604a9a338bce97f21bd7e1be Mon Sep 17 00:00:00 2001 From: Dostoievski Batista Date: Tue, 23 Jul 2024 15:45:33 -0300 Subject: [PATCH] Making patch-builder script executable This change, together with other change in tools repository, makes patch_builder script executable and update the metadata module to utilize the $PATCH_BUILDER_PATH env variable to fetch the xsd schema. We update the README file and the recipes examples to correctly represent theses change. Test plan: PASS: Call patch-builder in different ways, using: "patch-builder --recipe " "stx shell -c 'patch-builder --recipe '" PASS: Test building patches with different recipes: Recipe with one packages Recipe with multiple packages Recipe with pre and post install script Recipe with precheck scripts Depends-On: https://review.opendev.org/c/starlingx/tools/+/924770 Story: 2010676 Task: 50643 Change-Id: If46cf8c388efaa05d80458393049558a193ce656 Signed-off-by: Dostoievski Batista --- .../stx/patch/EXAMPLES/patch-recipe-sample-binary.xml | 1 + .../stx/patch/EXAMPLES/patch-recipe-sample-insvc.xml | 1 + .../stx/patch/EXAMPLES/patch-recipe-sample-large.xml | 1 + build-tools/stx/patch/EXAMPLES/patch-recipe-sample.xml | 1 + build-tools/stx/patch/README.md | 4 ++-- build-tools/stx/patch/metadata.py | 9 +++++++-- .../stx/patch/{patch_builder.py => patch_builder} | 2 +- 7 files changed, 14 insertions(+), 5 deletions(-) rename build-tools/stx/patch/{patch_builder.py => patch_builder} (99%) 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 3c5ce4e2..2e6df778 100644 --- a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-binary.xml +++ b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-binary.xml @@ -18,6 +18,7 @@ + scripts/pre-install.sh scripts/post-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 334dc372..9477475e 100644 --- a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-insvc.xml +++ b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-insvc.xml @@ -13,6 +13,7 @@ + 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 bf6db8e4..63e01c28 100644 --- a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-large.xml +++ b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-large.xml @@ -18,6 +18,7 @@ + scripts/pre-install.sh scripts/post-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 d3461d6c..aaa64a74 100644 --- a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample.xml +++ b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample.xml @@ -18,6 +18,7 @@ + scripts/pre-install.sh scripts/post-install.sh diff --git a/build-tools/stx/patch/README.md b/build-tools/stx/patch/README.md index 21efa0c2..22e0a925 100644 --- a/build-tools/stx/patch/README.md +++ b/build-tools/stx/patch/README.md @@ -41,7 +41,7 @@ The patch builder requires the following tags in the input xml (or patch recipe) scripts/pre-install.sh scripts/post-install.sh @@ -81,5 +81,5 @@ $ pip install -r requirements.txt - Build your patch: ```bash -$ ./patch_builder.py --recipe EXAMPLES\patch-recipe-sample.xml +$ ./patch-builder --recipe EXAMPLES\patch-recipe-sample.xml ``` diff --git a/build-tools/stx/patch/metadata.py b/build-tools/stx/patch/metadata.py index 54b335d3..7c8f92e2 100644 --- a/build-tools/stx/patch/metadata.py +++ b/build-tools/stx/patch/metadata.py @@ -20,7 +20,8 @@ from xml.dom import minidom logger = logging.getLogger('metadata_parser') utils.set_logger(logger) -INPUT_XML_SCHEMA = 'config/patch-recipe-schema.xsd' +PATCH_BUILDER_PATH = os.environ.get('PATCH_BUILDER_PATH') +INPUT_XML_SCHEMA = f'{PATCH_BUILDER_PATH}/config/patch-recipe-schema.xsd' # Metadata components PATCH_ROOT_TAG = 'patch' @@ -51,6 +52,10 @@ class PatchMetadata(object): self.binary_packages = [] self.requires = [] + # Verify if the path to the patch builder folder is set + if not PATCH_BUILDER_PATH: + raise Exception("Environment variable PATCH_BUILDER_PATH is not set.") + def __str__(self): return json.dumps(self.__dict__) @@ -211,6 +216,6 @@ class PatchMetadata(object): if __name__ == "__main__": - patch_recipe_file = "EXAMPLES/patch-recipe-sample.xml" + patch_recipe_file = f"${PATCH_BUILDER_PATH}/EXAMPLES/patch-recipe-sample.xml" patch_metadata = PatchMetadata(patch_recipe_file) patch_metadata.parse_input_xml_data() diff --git a/build-tools/stx/patch/patch_builder.py b/build-tools/stx/patch/patch_builder similarity index 99% rename from build-tools/stx/patch/patch_builder.py rename to build-tools/stx/patch/patch_builder index dd4a07e9..b604cb39 100755 --- a/build-tools/stx/patch/patch_builder.py +++ b/build-tools/stx/patch/patch_builder @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (c) 2023 Wind River Systems, Inc. +# Copyright (c) 2023-2024 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 #