From fee99ba459da7e1c436bdd07b46b5b78e8425808 Mon Sep 17 00:00:00 2001 From: Scott Little Date: Tue, 12 Sep 2023 16:01:10 -0400 Subject: [PATCH] cengn reference removal - debian mirror.starlingx.cengn.ca no longer exists. CENGN is kindly forwarding requests to the new location mirror.starlingx.windriver.com for now, but that will only last a few months. We need to replace all the references with the new URL. I will also remove as many 'cengn' references as possible, replacing them with 'stx_mirror' Partial-Bug: 2033555 Signed-off-by: Scott Little Change-Id: Icea255bcf628d0535991156a729ef21421646bfc --- stx/lib/stx/stx_control.py | 37 ++++++++++++++++++- .../stx-builder/configmap/localrc.sample | 4 ++ stx/toCOPY/pkgbuilder/debbuilder.py | 23 ++++++------ tox.ini | 2 +- 4 files changed, 52 insertions(+), 14 deletions(-) diff --git a/stx/lib/stx/stx_control.py b/stx/lib/stx/stx_control.py index a88d82db..795c9acc 100644 --- a/stx/lib/stx/stx_control.py +++ b/stx/lib/stx/stx_control.py @@ -87,8 +87,36 @@ class HandleControlTask: proxyport = self.config.get('project', 'proxyport') buildbranch = self.config.get('project', 'buildbranch') manifest = self.config.get('project', 'manifest') - stx_mirror_url = self.config.get('repomgr', 'stx_mirror_url') - stx_mirror_strategy = self.config.get('repomgr', 'stx_mirror_strategy') + # The cengn references below are obsolete, and are retained for + # backward compatibility with preexisting build environmnets. + # Please use stx_mirror versions instead. + cengnurl = None + try: + stx_mirror_url = self.config.get('repomgr', 'stx_mirror_url') + except Exception: + # second chance using old cengnurl + try: + cengnurl = self.config.get('repomgr', 'cengnurl') + stx_mirror_url = cengnurl + except Exception: + # Fail on stx_mirror_url without catching the error this time + stx_mirror_url = self.config.get('repomgr', 'stx_mirror_url') + + cengnstrategy = None + try: + stx_mirror_strategy = self.config.get('repomgr', 'stx_mirror_strategy') + except Exception: + try: + # second chance using old cengnstrategy + cengnstrategy = self.config.get('repomgr', 'cengnstrategy') + stx_mirror_strategy = cengnstrategy + if cengnstrategy == 'cengn': + stx_mirror_strategy = 'stx_mirror' + if cengnstrategy == 'cengn_first': + stx_mirror_strategy = 'stx_mirror_first' + except Exception: + # Fail on stx_mirror_strategy without catching the error this time + stx_mirror_strategy = self.config.get('repomgr', 'stx_mirror_strategy') sourceslist = self.config.get('repomgr', 'sourceslist') deblist = self.config.get('repomgr', 'deblist') dsclist = self.config.get('repomgr', 'dsclist') @@ -171,6 +199,11 @@ stx-pkgbuilder/configmap/') line = line.replace("@BUILDBRANCH@", buildbranch) line = line.replace("@MANIFEST@", manifest) line = line.replace("@HOSTUSERNAME@", hostusername) + # The cengn references below are obsolete, and are retained for + # backward compatibility with preexisting build environmnets. + # Please use stx_mirror versions instead. + line = line.replace("@CENGNURL@", stx_mirror_url) + line = line.replace("@CENGNSTRATEGY@", stx_mirror_strategy) line = line.replace("@STX_MIRROR_URL@", stx_mirror_url) line = line.replace("@STX_MIRROR_STRATEGY@", stx_mirror_strategy) line = line.replace("@OSTREE_OSNAME@", ostree_osname) diff --git a/stx/stx-build-tools-chart/stx-builder/configmap/localrc.sample b/stx/stx-build-tools-chart/stx-builder/configmap/localrc.sample index e95610cc..5cfeddfa 100644 --- a/stx/stx-build-tools-chart/stx-builder/configmap/localrc.sample +++ b/stx/stx-build-tools-chart/stx-builder/configmap/localrc.sample @@ -36,6 +36,10 @@ export MANIFEST=@MANIFEST@ export HOSTUSERNAME=@HOSTUSERNAME@ +export CENGNURL=@CENGNURL@ +# CENGN_STRATEGY value: [ cengn|cengn_first|upstream|upstream_first ] +export CENGN_STRATEGY=@CENGNSTRATEGY@ + export STX_MIRROR_URL=@STX_MIRROR_URL@ # STX_MIRROR_STRATEGY value: [ stx_mirror|stx_mirror_first|upstream|upstream_first ] diff --git a/stx/toCOPY/pkgbuilder/debbuilder.py b/stx/toCOPY/pkgbuilder/debbuilder.py index 579ae8f8..65f5be80 100644 --- a/stx/toCOPY/pkgbuilder/debbuilder.py +++ b/stx/toCOPY/pkgbuilder/debbuilder.py @@ -83,17 +83,18 @@ class Debbuilder: return self.logger.debug("%s does exist", STX_LOCALRC) - # backward compatability with CENGNURL - self.logger.debug("Fixing CENGNURL references in stx-localrc") - cmd = "sed -i 's#CENGNURL#STX_MIRROR_URL#' %s" % (STX_LOCALRC) - self.logger.debug('The substitution command is %s', cmd) - try: - outs = subprocess.check_output(cmd, shell=True).decode() - except Exception as e: - self.logger.error(str(e)) - self.logger.error("Failed to substitute %s in %s", "CENGNURL", STX_LOCALRC) - return - # end of backward compatibility + # dpanech: this doesn't work becauise STX_LOCALRC is mounted read-only from the host + ## backward compatability with CENGNURL + #self.logger.debug("Fixing CENGNURL references in stx-localrc") + #cmd = "sed -i 's#CENGNURL#STX_MIRROR_URL#' %s" % (STX_LOCALRC) + #self.logger.debug('The substitution command is %s', cmd) + #try: + # outs = subprocess.check_output(cmd, shell=True).decode() + #except Exception as e: + # self.logger.error(str(e)) + # self.logger.error("Failed to substitute %s in %s", "CENGNURL", STX_LOCALRC) + # return + ## end of backward compatibility for var in ENVIRON_VARS: self.logger.debug("Fetching %s from stx-localrc", var) diff --git a/tox.ini b/tox.ini index c2c55467..b8cf062a 100644 --- a/tox.ini +++ b/tox.ini @@ -61,7 +61,7 @@ commands = # W504 line break after binary operator # F401 'XXXXX' imported but unused show-source = True -ignore = E123,E125,E501,H404,H405,W504,F401 +ignore = E123,E125,E265,E266,E501,H404,H405,W504,F401 exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,release-tag-* [testenv:venv]