Add pre-check script to the patch
This commit add the deploy_precheck element to XML, allowing the patch writer to add script used on the pre-check process of the deploy. Test Plan: - Enter the builder container $ stx shell $ cd $MY_REPO/build-tools/stx/patch - Build patch $ ./patch_builder.py --recipe EXAMPLES/patch-recipe-sample.xml - Verify if file has been added to .patch Story: 2010676 Task: 49013 Change-Id: I18ae7fcbf046362d53a67bc290ffc9b1a0b888ad Signed-off-by: Dostoievski Batista <dostoievski.albinobatista@windriver.com>
This commit is contained in:
parent
6b30d6b35d
commit
d81f194e69
@ -20,6 +20,7 @@
|
||||
<!-- Pre and Post install hook scripts -->
|
||||
<pre_install>scripts/pre-install.sh</pre_install>
|
||||
<post_install>scripts/post-install.sh</post_install>
|
||||
<deploy_precheck></deploy_precheck>
|
||||
<!-- Packages to be included -->
|
||||
<stx_packages>
|
||||
<!-- Starlingx packages -->
|
||||
|
@ -15,6 +15,7 @@
|
||||
<!-- Pre and Post install hook scripts are optional -->
|
||||
<pre_install></pre_install>
|
||||
<post_install></post_install>
|
||||
<deploy_precheck></deploy_precheck>
|
||||
<!-- Packages to be included -->
|
||||
<stx_packages>
|
||||
<!-- Starlingx packages -->
|
||||
|
@ -20,6 +20,7 @@
|
||||
<!-- Pre and Post install hook scripts -->
|
||||
<pre_install>scripts/pre-install.sh</pre_install>
|
||||
<post_install>scripts/post-install.sh</post_install>
|
||||
<deploy_precheck>scripts/deploy-precheck.sh</deploy_precheck>
|
||||
<!-- Packages to be included -->
|
||||
<stx_packages>
|
||||
<!-- Starlingx packages -->
|
||||
|
@ -20,6 +20,7 @@
|
||||
<!-- Pre and Post install hook scripts are optional -->
|
||||
<pre_install>scripts/pre-install.sh</pre_install>
|
||||
<post_install>scripts/post-install.sh</post_install>
|
||||
<deploy_precheck>scripts/deploy-precheck.sh</deploy_precheck>
|
||||
<!-- Packages to be included -->
|
||||
<stx_packages>
|
||||
<!-- Starlingx packages -->
|
||||
|
@ -22,6 +22,7 @@
|
||||
<xs:element name="semantics" type="xs:string"/>
|
||||
<xs:element name="pre_install" type="xs:string"/>
|
||||
<xs:element name="post_install" type="xs:string"/>
|
||||
<xs:element name="deploy_precheck" type="xs:string"/>
|
||||
<xs:element name="stx_packages">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
|
@ -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]:
|
||||
|
@ -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
|
||||
|
24
build-tools/stx/patch/scripts/deploy-precheck.sh
Normal file
24
build-tools/stx/patch/scripts/deploy-precheck.sh
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user