Browse Source

stx: add new environment variable OSTREE_OSNAME

The OSTREE_OSNAME is required for building ostree, initramfs-ostree and
other related packages. Set it as an environment variable, allowing the
ostree name to be modified in the stx.conf.

Set OSTREE_OSNAME in $build_environment of debbuilder.conf, which is
used to setup the building environment, and add new function set_environ_vars()
in debbuilder.py to replace the @OSTREE_OSNAME@ in $build_environment
with environment variable.

Story: 2008846
Task: 43907

Signed-off-by: Yue Tao <Yue.Tao@windriver.com>
Change-Id: I4e1adf9d385ff82888146220932fd1451b557646
changes/28/817128/8
Yue Tao 3 months ago
committed by Yue Tao
parent
commit
99214533ea
  1. 1
      stx.conf.sample
  2. 2
      stx/lib/stx/stx_control.py
  3. 2
      stx/stx-build-tools-chart/stx-builder/configmap/localrc.sample
  4. 4
      stx/toCOPY/pkgbuilder/debbuilder.conf
  5. 17
      stx/toCOPY/pkgbuilder/debbuilder.py

1
stx.conf.sample

@ -7,6 +7,7 @@ proxyserver = opendev.org
proxyport = 8080
buildbranch = master
manifest = default.xml
ostree_osname = wrlinux
[builder]
uid = 1000

2
stx/lib/stx/stx_control.py

@ -85,6 +85,7 @@ class HandleControlTask:
sourceslist = self.stxconfig.getConfig('repomgr', 'sourceslist')
deblist = self.stxconfig.getConfig('repomgr', 'deblist')
dsclist = self.stxconfig.getConfig('repomgr', 'dsclist')
ostree_osname = self.stxconfig.getConfig('project', 'ostree_osname')
if sourceslist:
if not (deblist or dsclist):
self.logger.warning('*************************************\
@ -155,6 +156,7 @@ stx-pkgbuilder/configmap/')
line = line.replace("@MANIFEST@", manifest)
line = line.replace("@HOSTUSERNAME@", hostusername)
line = line.replace("@CENGNURL@", cengnurl)
line = line.replace("@OSTREE_OSNAME@", ostree_osname)
if sourceslist:
line = line.replace("@fetch@", "true")
line = line.replace("@SOURCESLIST@", sourceslist)

2
stx/stx-build-tools-chart/stx-builder/configmap/localrc.sample

@ -49,3 +49,5 @@ export REPOMGR_URL=http://@PROJECT@-stx-repomgr:8080
export REPOMGR_DEPLOY_URL=http://@PROJECT@-stx-repomgr:80/
export BUILDER_URL=http://@PROJECT@-stx-pkgbuilder:8080/pkgbuilder/
export OSTREE_OSNAME=@OSTREE_OSNAME@

4
stx/toCOPY/pkgbuilder/debbuilder.conf

@ -25,5 +25,9 @@ $purge_build_directory = 'always';
$extra_repositories = ['deb [trusted=yes] http://stx-stx-repomgr:80/deb-local-binary bullseye main',
'deb [trusted=yes] http://stx-stx-repomgr:80/deb-local-build bullseye main'];
$log_colour = 1;
$build_environment = {
'OSTREE_OSNAME' => '@OSTREE_OSNAME@'
};
1;

17
stx/toCOPY/pkgbuilder/debbuilder.py

@ -22,6 +22,7 @@ BUILD_ENGINE = 'sbuild'
DEBDIST = 'bullseye'
STX_LOCALRC = '/usr/local/bin/stx/stx-localrc'
SBUILD_CONF = '/etc/sbuild/sbuild.conf'
ENVIRON_VARS = ['OSTREE_OSNAME']
class Debbuilder:
@ -51,6 +52,7 @@ class Debbuilder:
self.sbuild_processes = {}
self.ctlog = None
self.set_extra_repos()
self.set_environ_vars()
@property
def state(self):
@ -64,6 +66,21 @@ class Debbuilder:
def mode(self, mode):
self._mode = mode
def set_environ_vars(self):
if not os.path.exists(STX_LOCALRC):
self.logger.warning('stx-localrc does not exist')
return
for var in ENVIRON_VARS:
cmd = "grep '^export *%s=.*' %s | cut -d \\= -f 2" % (var, STX_LOCALRC)
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True, shell=True)
outs, errs = process.communicate()
value = outs.strip().split("\n")[0]
if value:
cmd = "sed -ie 's#@%s@#%s#g' %s" % (var, value, SBUILD_CONF)
process = subprocess.Popen(cmd, shell=True, stdout=self.ctlog, stderr=self.ctlog)
def set_extra_repos(self):
repomgr_url = None
if not os.path.exists(STX_LOCALRC):

Loading…
Cancel
Save