@@ -29,11 +29,8 @@ class AzL3TdnfPackageManager(TdnfPackageManager):
2929 def __init__ (self , env_layer , execution_config , composite_logger , telemetry_writer , status_handler ):
3030 super (AzL3TdnfPackageManager , self ).__init__ (env_layer , execution_config , composite_logger , telemetry_writer , status_handler )
3131
32- # Support to get updates and their dependencies
33- self .tdnf_check = 'sudo tdnf -q list updates <SNAPSHOTTIME>'
34-
3532 # Install update
36- self .install_security_updates_azgps_coordinated_cmd = 'sudo tdnf -y upgrade --skip-broken <SNAPSHOTTIME> '
33+ self .install_security_updates_azgps_coordinated_cmd = 'sudo tdnf -y upgrade --skip-broken'
3734
3835 # Strict SDP specializations
3936 self .TDNF_MINIMUM_VERSION_FOR_STRICT_SDP = "3.5.8-3.azl3" # minimum version of tdnf required to support Strict SDP in Azure Linux
@@ -51,14 +48,11 @@ def __init__(self, env_layer, execution_config, composite_logger, telemetry_writ
5148 execution_config .included_classifications_list = [Constants .PackageClassification .CRITICAL , Constants .PackageClassification .SECURITY , Constants .PackageClassification .OTHER ]
5249
5350 # region Strict SDP using SnapshotTime
54- @staticmethod
55- def __generate_command_with_snapshotposixtime_if_specified (command_template , snapshot_posix_time = str ()):
56- # type: (str, str) -> str
57- if snapshot_posix_time == str ():
58- return command_template .replace ('<SNAPSHOTTIME>' , str ())
51+ def _Base__add_additional_parameters_as_required_to_cmd (self , cmd ):
52+ if self .max_patch_publish_date == str ():
53+ return cmd
5954 else :
60- return command_template .replace ('<SNAPSHOTTIME>' , ('--snapshottime={0}' .format (str (snapshot_posix_time ))))
61- # endregion
55+ return cmd + ' --snapshottime={0}' .format (str (self .max_patch_publish_date ))
6256
6357 # region Get Available Updates
6458 # region Classification-based (incl. All) update check
@@ -69,28 +63,15 @@ def get_all_updates(self, cached=False):
6963 self .composite_logger .log_debug ("[AzL3TDNF] Get all updates : [Cached={0}][PackagesCount={1}]]" .format (str (cached ), len (self .all_updates_cached )))
7064 return self .all_updates_cached , self .all_update_versions_cached # allows for high performance reuse in areas of the code explicitly aware of the cache
7165
72- out = self .invoke_package_manager (self .__generate_command_with_snapshotposixtime_if_specified (self .tdnf_check , self . max_patch_publish_date ))
66+ out = self .invoke_package_manager (self ._Base__add_additional_parameters_as_required_to_cmd (self .tdnf_check ))
7367 self .all_updates_cached , self .all_update_versions_cached = self .extract_packages_and_versions (out )
7468 self .composite_logger .log_debug ("[AzL3TDNF] Get all updates : [Cached={0}][PackagesCount={1}]]" .format (str (False ), len (self .all_updates_cached )))
7569 return self .all_updates_cached , self .all_update_versions_cached
7670
77- def get_security_updates (self ):
78- """Get missing security updates. NOTE: Classification based categorization of patches is not available in Azure Linux as of now"""
79- self .composite_logger .log_verbose ("[AzL3TDNF] Discovering all packages as 'security' packages, since TDNF does not support package classification..." )
80- security_packages , security_package_versions = self .get_all_updates (cached = False )
81- self .composite_logger .log_debug ("[AzL3TDNF] Discovered 'security' packages. [Count={0}]" .format (len (security_packages )))
82- return security_packages , security_package_versions
83-
84- def get_other_updates (self ):
85- """Get missing other updates."""
86- self .composite_logger .log_verbose ("[AzL3TDNF] Discovering 'other' packages..." )
87- return [], []
88-
8971 def set_max_patch_publish_date (self , max_patch_publish_date = str ()):
9072 """Set the max patch publish date in POSIX time for strict SDP"""
91- self .composite_logger .log_debug ("[AzL3TDNF] Setting max patch publish date. [MaxPatchPublishDate={0}]" .format (str (max_patch_publish_date )))
9273 self .max_patch_publish_date = str (self .env_layer .datetime .datetime_string_to_posix_time (max_patch_publish_date , '%Y%m%dT%H%M%SZ' )) if max_patch_publish_date != str () else max_patch_publish_date
93- self .composite_logger .log_debug ("[AzL3TDNF] Set max patch publish date. [MaxPatchPublishDatePosixTime ={0}]" .format (str (self .max_patch_publish_date )))
74+ self .composite_logger .log_debug ("[AzL3TDNF] Set max patch publish date in posix time for Strict SDP . [MaxPatchPublishDate ={0}][MaxPatchPublishDatePosixTime={1}] " .format (str ( max_patch_publish_date ), str (self .max_patch_publish_date )))
9475 # endregion
9576
9677 # endregion
@@ -101,7 +82,7 @@ def install_updates_fail_safe(self, excluded_packages):
10182
10283 def install_security_updates_azgps_coordinated (self ):
10384 """Install security updates in Azure Linux following strict SDP"""
104- command = self .__generate_command_with_snapshotposixtime_if_specified (self .install_security_updates_azgps_coordinated_cmd , self . max_patch_publish_date )
85+ command = self ._Base__add_additional_parameters_as_required_to_cmd (self .install_security_updates_azgps_coordinated_cmd )
10586 out , code = self .invoke_package_manager_advanced (command , raise_on_exception = False )
10687 return code , out
10788
0 commit comments