Change-Id: I276069bb1c33c1ef9a6c3eaac5ce409c211a9a51
Signed-off-by: Gui Chen <gui.chen@intel.com>
else:
return DEFAULT_GSITECONF
else:
return DEFAULT_GSITECONF
+def inbootstrap():
+ if os.path.exists(os.path.join("/", ".chroot.lock")):
+ return True
+ return (os.stat("/").st_ino != 2)
+
class ConfigMgr(object):
prefer_backends = ["zypp", "yum"]
class ConfigMgr(object):
prefer_backends = ["zypp", "yum"]
"local_pkgs_path": None,
"release": None,
"logfile": None,
"local_pkgs_path": None,
"release": None,
"logfile": None,
"record_pkgs": [],
"pack_to": None,
"name_prefix": None,
"record_pkgs": [],
"pack_to": None,
"name_prefix": None,
self.create['name'])
self.create['name'] = self.create['release'] + '_' + self.create['name']
self.create['name'])
self.create['name'] = self.create['release'] + '_' + self.create['name']
+ if not self.create['logfile']:
+ self.create['logfile'] = os.path.join(self.create['outdir'],
+ self.create['name'] + ".log")
+ self.create['releaselog'] = True
+
+ if self.create['logfile']:
+ logfile_dir = os.path.dirname(self.create['logfile'])
+ if not os.path.exists(logfile_dir):
+ os.makedirs(logfile_dir)
+ msger.set_interactive(False)
+ if inbootstrap():
+ mode = 'a'
+ else:
+ mode = 'w'
+ msger.set_logfile(self.create['logfile'], mode)
+
msger.info("Retrieving repo metadata:")
ksrepos = kickstart.get_repos(ks,
self.create['extrarepos'],
msger.info("Retrieving repo metadata:")
ksrepos = kickstart.get_repos(ks,
self.create['extrarepos'],
import pwd
from optparse import SUPPRESS_HELP
import pwd
from optparse import SUPPRESS_HELP
-from mic import msger, rt_util
from mic.utils import cmdln, errors, rpmmisc
from mic.conf import configmgr
from mic.plugin import pluginmgr
from mic.utils import cmdln, errors, rpmmisc
from mic.conf import configmgr
from mic.plugin import pluginmgr
if os.path.isdir(logfile_abs_path):
raise errors.Usage("logfile's path %s should be file"
% self.options.logfile)
if os.path.isdir(logfile_abs_path):
raise errors.Usage("logfile's path %s should be file"
% self.options.logfile)
- if not os.path.exists(os.path.dirname(logfile_abs_path)):
- os.makedirs(os.path.dirname(logfile_abs_path))
- msger.set_interactive(False)
- if rt_util.inbootstrap():
- mode = 'a'
- else:
- mode = 'w'
- msger.set_logfile(logfile_abs_path, mode)
- configmgr.create['logfile'] = self.options.logfile
+ configmgr.create['logfile'] = logfile_abs_path
if self.options.config:
configmgr.reset()
if self.options.config:
configmgr.reset()
outimages.append(new_kspath)
# save log file, logfile is only available in creator attrs
outimages.append(new_kspath)
# save log file, logfile is only available in creator attrs
- if hasattr(self, 'logfile') and not self.logfile:
- log_path = _rpath(self.name + ".log")
- # touch the log file, else outimages will filter it out
- with open(log_path, 'w') as wf:
- wf.write('')
- msger.set_logfile(log_path)
- outimages.append(_rpath(self.name + ".log"))
+ if hasattr(self, 'releaselog') and self.releaselog:
+ final_logfile = _rpath(self.name+'.log')
+ shutil.move(self.logfile, final_logfile)
+ self.logfile = final_logfile
+ outimages.append(self.logfile)
# rename iso and usbimg
for f in os.listdir(destdir):
# rename iso and usbimg
for f in os.listdir(destdir):