diff --git a/build-tools/stx/patch/config/patch-recipe-schema.xsd b/build-tools/stx/patch/config/patch-recipe-schema.xsd
index 4b26bf4b..65cad608 100644
--- a/build-tools/stx/patch/config/patch-recipe-schema.xsd
+++ b/build-tools/stx/patch/config/patch-recipe-schema.xsd
@@ -20,6 +20,7 @@
+
diff --git a/build-tools/stx/patch/fetch_debs.py b/build-tools/stx/patch/fetch_debs.py
index 47f985a0..cb448f9a 100644
--- a/build-tools/stx/patch/fetch_debs.py
+++ b/build-tools/stx/patch/fetch_debs.py
@@ -42,6 +42,7 @@ class FetchDebs(object):
# In general: /localdisk/loadbuild//
self.loadbuild_root = utils.get_env_variable('MY_BUILD_PKG_DIR')
+ # TODO: These directories should be inputs, not hardcoded.
self.output_dir = os.path.join(self.loadbuild_root, 'dl_debs')
self.apt_src_file = os.path.join(self.loadbuild_root, 'aptsrc')
diff --git a/build-tools/stx/patch/metadata.py b/build-tools/stx/patch/metadata.py
index 4a8fb48f..e0d14a74 100644
--- a/build-tools/stx/patch/metadata.py
+++ b/build-tools/stx/patch/metadata.py
@@ -45,6 +45,7 @@ BINARY_PACKAGES = 'binary_packages'
SEMANTICS = 'semantics'
ACTIVATION_SCRIPTS = 'activation_scripts'
EXTRA_CONTENT = 'extra_content'
+PRECHECK_SCRIPTS_FLAG = 'precheck_scripts'
class PatchMetadata(object):
@@ -122,6 +123,11 @@ class PatchMetadata(object):
else:
raise Exception('Supported values for "Reboot Required" are Y or N, for "Yes" or "No" respectively')
+ if self.precheck_scripts_flag.upper() in ["Y","N"]:
+ self.__add_text_tag_to_xml(top_tag, PRECHECK_SCRIPTS_FLAG, self.precheck_scripts_flag.upper())
+ else:
+ raise Exception('Supported values for "Precheck Scripts" are Y or N, for "Yes" or "No" respectively')
+
self.__add_text_tag_to_xml(top_tag, SEMANTICS, self.semantics)
requires_atg = ET.SubElement(top_tag, REQUIRES)
@@ -194,6 +200,10 @@ class PatchMetadata(object):
self.warnings = patch_recipe[WARNINGS]
self.reboot_required = patch_recipe[REBOOT_REQUIRED]
+ self.precheck_scripts_flag = 'N'
+ if PRECHECK_SCRIPTS_FLAG in patch_recipe:
+ self.precheck_scripts_flag = patch_recipe[PRECHECK_SCRIPTS_FLAG]
+
# For each patch script, validate the path provided
self.patch_script_paths = {
script_id: self.check_script_path(patch_recipe.get(script_id, None))
diff --git a/build-tools/stx/patch/patch-builder b/build-tools/stx/patch/patch-builder
index 3870d462..e7ffda75 100755
--- a/build-tools/stx/patch/patch-builder
+++ b/build-tools/stx/patch/patch-builder
@@ -135,14 +135,20 @@ class PatchBuilder(object):
logger.info(f"Adding: {item}")
extra_tar.add(item, arcname=os.path.join("extra", os.path.basename(item)))
- # 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:
- logger.info(f"Patch includes the software package, getting scripts from deb file...")
+ # Precheck Scripts:
+ # If the patch includes the 'software' package or
+ # if the patch XML has the 'precheck_scripts' flag set to 'Y',
+ # extract precheck scripts from software.deb and put them in the patch file
+ if 'software' in self.metadata.stx_packages or \
+ self.metadata.precheck_scripts_flag == 'Y':
+ logger.info(f"Adding precheck scripts...")
# create temporary folder to hold our files until we copy them to the patch
tmp_folder = tempfile.mkdtemp(prefix='deb_')
+ # Fetch software deb
+ fetch_debs.FetchDebs(need_dl_stx_pkgs = ['software']).fetch_stx_packages()
+
# Collect files
files_to_get = [constants.PRECHECK_SCRIPTS["DEPLOY_PRECHECK"],
constants.PRECHECK_SCRIPTS["UPGRADE_UTILS"]]