@@ -115,6 +115,12 @@ DISTRO_INSTALL_PKG_CMD = {
115115 "suse" : ZYPPER_INSTALL ,
116116}
117117
118+ DISTRO_UPDATE_PKG_CMD = {
119+ "redhat" : ["yum" , "update" ],
120+ "debian" : ["apt" , "update" , "-q" ],
121+ "suse" : ["zypper" , "update" ],
122+ }
123+
118124# List of base system packages required to enable ci automation
119125CI_SYSTEM_BASE_PKGS = {
120126 "common" : ["make" , "sudo" , "tar" ],
@@ -347,19 +353,27 @@ def pkg_install(pkg_list, distro, test_distro=False, dry_run=False):
347353 "(dryrun)" if dry_run else "" , " " .join (pkg_list )
348354 )
349355 )
356+ distro_family = DISTRO_PKG_TYPE_MAP [distro ]
350357 install_cmd = []
358+ update_cmd = DISTRO_UPDATE_PKG_CMD .get (distro_family , [])
351359 if dry_run :
352360 install_cmd .append ("echo" )
361+ if update_cmd :
362+ update_cmd .insert (0 , "echo" )
353363 if os .geteuid () != 0 :
354364 install_cmd .append ("sudo" )
365+ if update_cmd :
366+ update_cmd .append ("sudo" )
355367
356- distro_family = DISTRO_PKG_TYPE_MAP [distro ]
357368 if dry_run and distro_family in DRYRUN_DISTRO_INSTALL_PKG_CMD :
358369 cmd = DRYRUN_DISTRO_INSTALL_PKG_CMD [distro_family ]
359370 else :
360371 cmd = DISTRO_INSTALL_PKG_CMD [distro_family ]
361372 install_cmd .extend (cmd )
362373
374+ if update_cmd :
375+ subprocess .check_call (update_cmd )
376+
363377 if distro in ["centos" , "redhat" , "rocky" , "eurolinux" ]:
364378 # CentOS and Redhat need epel-release to access oauthlib and jsonschema
365379 subprocess .check_call (install_cmd + ["epel-release" ])
0 commit comments