pkgbuilder: Added debug log for chroot setting
Some debug messages are added during chroot setting up These log messages can be captured in the '/localdisk/pkgbuilder.log' and the build log of package like: in $MY_WORKSPACE/std/tsconfig/tsconfig_*amd64.build under line 'Chroot Setup Commands' Story: 2008846 Task: 45861 Signed-off-by: Haiqing Bai <haiqing.bai@windriver.com> Change-Id: I83ae957c3d11c04ed3f487088ce6e1156cf16ec9
This commit is contained in:
parent
2898c9b3b8
commit
a3e3870b60
@ -20,8 +20,7 @@ from flask import request
|
||||
import logging
|
||||
|
||||
app = Flask(__name__)
|
||||
log = logging.getLogger('pkgbuilder')
|
||||
dbuilder = Debbuilder('private', log)
|
||||
dbuilder = None
|
||||
|
||||
|
||||
@app.route('/pkgbuilder/state', methods=['GET'])
|
||||
@ -154,6 +153,8 @@ if __name__ == '__main__':
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
log_format = logging.Formatter('pkgbuilder: %(levelname)s %(message)s')
|
||||
handler.setFormatter(log_format)
|
||||
log = logging.getLogger('pkgbuilder')
|
||||
log.addHandler(handler)
|
||||
dbuilder = Debbuilder('private', log)
|
||||
|
||||
app.run(host='0.0.0.0', port=80, debug=True)
|
||||
|
@ -32,15 +32,19 @@ $build_environment = {
|
||||
};
|
||||
$external_commands = {
|
||||
"chroot-setup-commands" => [
|
||||
'echo "chroot-setup-commands starts:"',
|
||||
'cp /etc/apt/sources.list tmp.list',
|
||||
'cat tmp.list',
|
||||
'sed -i "1 i\deb [trusted=yes] http://stx-stx-repomgr:80/deb-local-binary @DEBIAN_DISTRIBUTION@ main" tmp.list',
|
||||
'sed -i "1 i\deb [trusted=yes] http://stx-stx-repomgr:80/deb-local-build @DEBIAN_DISTRIBUTION@ main" tmp.list',
|
||||
'echo "deb @CENGNURL@/debian/debian/deb.debian.org/debian/@DEBIAN_DISTRIBUTION@-@DEBIAN_VERSION@ @DEBIAN_DISTRIBUTION@ main" >> tmp.list',
|
||||
'echo "deb-src @CENGNURL@/debian/debian/deb.debian.org/debian/@DEBIAN_DISTRIBUTION@-@DEBIAN_VERSION@ @DEBIAN_DISTRIBUTION@ main" >> tmp.list',
|
||||
'awk \'!a[$0]++\' tmp.list > new.list && mv -f new.list /etc/apt/sources.list',
|
||||
'cat /etc/apt/sources.list',
|
||||
'echo "Package: *" > /etc/apt/preferences.d/local_repos',
|
||||
'echo "Pin: origin stx-stx-repomgr" >> /etc/apt/preferences.d/local_repos',
|
||||
'echo "Pin-Priority: 900" >> /etc/apt/preferences.d/local_repos',
|
||||
'echo "chroot-setup-commands ends"',
|
||||
],
|
||||
};
|
||||
|
||||
|
@ -69,18 +69,30 @@ class Debbuilder:
|
||||
|
||||
def set_environ_vars(self):
|
||||
if not os.path.exists(STX_LOCALRC):
|
||||
self.logger.warning('stx-localrc does not exist')
|
||||
self.logger.error("%s does not exist", STX_LOCALRC)
|
||||
return
|
||||
self.logger.debug("%s does exist", STX_LOCALRC)
|
||||
|
||||
for var in ENVIRON_VARS:
|
||||
self.logger.debug("Fetching %s from stx-localrc", var)
|
||||
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].strip('"')
|
||||
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)
|
||||
self.logger.debug('The fetch 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 fetch %s from %s", var, STX_LOCALRC)
|
||||
break
|
||||
else:
|
||||
if not outs:
|
||||
self.logger.error("Got null when fetch %s from %s", var, STX_LOCALRC)
|
||||
break
|
||||
value = outs.strip().split("\n")[0].strip('"')
|
||||
self.logger.debug("Got value %s for %s", value, var)
|
||||
replace_cmd = "sed -i -e 's#@%s@#%s#g' %s" % (var, value, SBUILD_CONF)
|
||||
self.logger.debug('The replacing command is %s', replace_cmd)
|
||||
ret = os.system(replace_cmd)
|
||||
self.logger.debug('The return value of macro replacing is %d', ret)
|
||||
|
||||
def set_extra_repos(self):
|
||||
repomgr_url = None
|
||||
|
Loading…
Reference in New Issue
Block a user