Merge "Store ostree tarball (software.tar) during patch upload"
This commit is contained in:
commit
13a5dd7ca6
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
Copyright (c) 2017 Wind River Systems, Inc.
|
||||
Copyright (c) 2017-2022 Wind River Systems, Inc.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
@ -27,6 +27,11 @@ class ContentFail(PatchError):
|
|||
pass
|
||||
|
||||
|
||||
class OSTreeTarMissingFailure(PatchError):
|
||||
"""OSTree Tarball Missing error."""
|
||||
pass
|
||||
|
||||
|
||||
class SemanticFail(PatchError):
|
||||
"""Semantic check error."""
|
||||
pass
|
||||
|
|
|
@ -35,12 +35,13 @@ from cgcs_patch.patch_functions import SW_VERSION
|
|||
from cgcs_patch.patch_functions import root_package_dir
|
||||
from cgcs_patch.exceptions import MetadataFail
|
||||
from cgcs_patch.exceptions import ContentFail
|
||||
from cgcs_patch.exceptions import SemanticFail
|
||||
from cgcs_patch.exceptions import OSTreeTarMissingFailure
|
||||
from cgcs_patch.exceptions import PatchError
|
||||
from cgcs_patch.exceptions import PatchFail
|
||||
from cgcs_patch.exceptions import PatchInvalidRequest
|
||||
from cgcs_patch.exceptions import PatchValidationFailure
|
||||
from cgcs_patch.exceptions import PatchMismatchFailure
|
||||
from cgcs_patch.exceptions import SemanticFail
|
||||
from cgcs_patch.patch_functions import LOG
|
||||
from cgcs_patch.patch_functions import audit_log_info
|
||||
from cgcs_patch.patch_functions import patch_dir
|
||||
|
@ -1380,31 +1381,19 @@ class PatchController(PatchService):
|
|||
# Handle operation
|
||||
for patch_id in patch_list:
|
||||
patch_sw_version = self.patch_data.metadata[patch_id]["sw_version"]
|
||||
for contentname in self.patch_data.contents[patch_id]:
|
||||
contentfile = self.get_store_filename(patch_sw_version, contentname)
|
||||
if not os.path.isfile(contentfile):
|
||||
# We're deleting the patch anyway, so the missing file
|
||||
# doesn't really matter
|
||||
continue
|
||||
abs_ostree_tar_dir = package_dir[patch_sw_version]
|
||||
ostree_tar_filename = "%s/%s-software.tar" % (abs_ostree_tar_dir, patch_id)
|
||||
if not os.path.isfile(ostree_tar_filename):
|
||||
# We're deleting the patch anyway, so the missing file
|
||||
# doesn't really matter
|
||||
continue
|
||||
|
||||
try:
|
||||
os.remove(contentfile)
|
||||
except OSError:
|
||||
msg = "Failed to remove Content %s" % contentfile
|
||||
LOG.exception(msg)
|
||||
raise ContentFail(msg)
|
||||
|
||||
for action in constants.SEMANTIC_ACTIONS:
|
||||
action_file = os.path.join(semantics_dir, action, patch_id)
|
||||
if not os.path.isfile(action_file):
|
||||
continue
|
||||
|
||||
try:
|
||||
os.remove(action_file)
|
||||
except OSError:
|
||||
msg = "Failed to remove semantic %s" % action_file
|
||||
LOG.exception(msg)
|
||||
raise SemanticFail(msg)
|
||||
try:
|
||||
os.remove(ostree_tar_filename)
|
||||
except OSError:
|
||||
msg = "Failed to remove ostree tarball %s" % ostree_tar_filename
|
||||
LOG.exception(msg)
|
||||
raise OSTreeTarMissingFailure(msg)
|
||||
|
||||
try:
|
||||
# Delete the metadata
|
||||
|
|
|
@ -805,7 +805,6 @@ class PatchFile(object):
|
|||
|
||||
abs_patch = os.path.abspath(patch)
|
||||
abs_metadata_dir = os.path.abspath(metadata_dir)
|
||||
|
||||
# Create a temporary working directory
|
||||
tmpdir = tempfile.mkdtemp(prefix="patch_")
|
||||
|
||||
|
@ -845,16 +844,15 @@ class PatchFile(object):
|
|||
LOG.exception(msg)
|
||||
raise PatchMismatchFailure(msg)
|
||||
|
||||
patch_sw_version = thispatch.metadata[patch_id]["sw_version"]
|
||||
abs_ostree_tar_dir = package_dir[patch_sw_version]
|
||||
if not os.path.exists(abs_ostree_tar_dir):
|
||||
os.makedirs(abs_ostree_tar_dir)
|
||||
|
||||
shutil.move("metadata.xml",
|
||||
"%s/%s-metadata.xml" % (abs_metadata_dir, patch_id))
|
||||
|
||||
if not metadata_only:
|
||||
for rpmname in thispatch.contents[patch_id]:
|
||||
patch_sw_version = thispatch.metadata[patch_id]["sw_version"]
|
||||
rpm_dir = package_dir[patch_sw_version]
|
||||
if not os.path.exists(rpm_dir):
|
||||
os.makedirs(rpm_dir)
|
||||
shutil.move(rpmname, "%s/" % rpm_dir)
|
||||
shutil.move("software.tar",
|
||||
"%s/%s-software.tar" % (abs_ostree_tar_dir, patch_id))
|
||||
|
||||
except PatchValidationFailure as e:
|
||||
raise e
|
||||
|
|
Loading…
Reference in New Issue