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..cca63a11 100644 --- a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-binary.xml +++ b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-binary.xml @@ -20,6 +20,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..cbb8e52c 100644 --- a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-insvc.xml +++ b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-insvc.xml @@ -15,6 +15,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..949742f0 100644 --- a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-large.xml +++ b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample-large.xml @@ -20,6 +20,7 @@ scripts/pre-install.sh scripts/post-install.sh + scripts/deploy-precheck.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..dac6c229 100644 --- a/build-tools/stx/patch/EXAMPLES/patch-recipe-sample.xml +++ b/build-tools/stx/patch/EXAMPLES/patch-recipe-sample.xml @@ -20,6 +20,7 @@ scripts/pre-install.sh scripts/post-install.sh + scripts/deploy-precheck.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..2f130749 100644 --- a/build-tools/stx/patch/config/patch-recipe-schema.xsd +++ b/build-tools/stx/patch/config/patch-recipe-schema.xsd @@ -22,6 +22,7 @@ + diff --git a/build-tools/stx/patch/metadata.py b/build-tools/stx/patch/metadata.py index c39948fb..86b78fbe 100644 --- a/build-tools/stx/patch/metadata.py +++ b/build-tools/stx/patch/metadata.py @@ -35,6 +35,7 @@ WARNINGS = 'warnings' REBOOT_REQUIRED = 'reboot_required' PRE_INSTALL = 'pre_install' POST_INSTALL = 'post_install' +DEPLOY_PRECHECK = 'deploy_precheck' UNREMOVABLE = 'unremovable' REQUIRES = 'requires' REQUIRES_PATCH_ID = 'req_patch_id' @@ -96,6 +97,7 @@ class PatchMetadata(object): # strip path from pre_install and post_install scripts self.pre_install = self.pre_install.split('/')[-1] self.post_install = self.post_install.split('/')[-1] + self.deploy_precheck = self.deploy_precheck.split('/')[-1] top_tag = ET.Element(PATCH_ROOT_TAG) self.__add_text_tag_to_xml(top_tag, PATCH_ID, self.patch_id) @@ -125,6 +127,7 @@ class PatchMetadata(object): self.__add_text_tag_to_xml(top_tag, PRE_INSTALL, self.pre_install) self.__add_text_tag_to_xml(top_tag, POST_INSTALL, self.post_install) + self.__add_text_tag_to_xml(top_tag, DEPLOY_PRECHECK, self.deploy_precheck) packages_tag = ET.SubElement(top_tag, PACKAGES) for package in sorted(self.debs): @@ -155,6 +158,7 @@ class PatchMetadata(object): self.reboot_required = patch_recipe[REBOOT_REQUIRED] self.pre_install = self.check_script_path(patch_recipe[PRE_INSTALL]) self.post_install = self.check_script_path(patch_recipe[POST_INSTALL]) + self.deploy_precheck = self.check_script_path(patch_recipe[DEPLOY_PRECHECK]) self.unremovable = patch_recipe[UNREMOVABLE] self.status = patch_recipe[STATUS] if 'id' in patch_recipe[REQUIRES]: diff --git a/build-tools/stx/patch/patch_builder.py b/build-tools/stx/patch/patch_builder.py index 34095246..69b3e4fe 100755 --- a/build-tools/stx/patch/patch_builder.py +++ b/build-tools/stx/patch/patch_builder.py @@ -85,6 +85,7 @@ class PatchBuilder(object): pre_install = self.metadata.pre_install post_install = self.metadata.post_install + deploy_precheck = self.metadata.deploy_precheck # pre/post install scripts if pre_install: logger.debug(f"Copying pre-install script: {pre_install}") @@ -94,6 +95,10 @@ class PatchBuilder(object): logger.debug(f"Copying post-install script: {post_install}") self.copy_script(post_install) + if deploy_precheck: + logger.debug(f"Copying pre-check deploy script: {deploy_precheck}") + self.copy_script(deploy_precheck) + if not pre_install and not post_install and self.metadata.reboot_required == 'N': logger.warn("In service patch without restart scripts provided") @@ -129,6 +134,9 @@ class PatchBuilder(object): if self.metadata.post_install: filelist.append(self.metadata.post_install) + if self.metadata.deploy_precheck: + filelist.append(self.metadata.deploy_precheck) + # Generate the local signature file logger.debug(f"Generating signature for patch files {filelist}") sig = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF diff --git a/build-tools/stx/patch/scripts/deploy-precheck.sh b/build-tools/stx/patch/scripts/deploy-precheck.sh new file mode 100644 index 00000000..21eef534 --- /dev/null +++ b/build-tools/stx/patch/scripts/deploy-precheck.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# +# +# Copyright (c) 2023 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +# +# The patching subsystem provides a patch-functions bash source file +# with useful function and variable definitions. +# +. /etc/patching/patch-functions + +# +# Declare an overall script return code +# +declare -i GLOBAL_RC=$PATCH_STATUS_OK + +echo "Pre deploy check script" + +# +# Exit the script with the overall return code +# +exit $GLOBAL_RC