Move run() code from __init__() to run().
Also, the conf hash needs to referenced from self and not as a global.
This commit is contained in:
parent
291bf4492a
commit
979f553056
@ -41,10 +41,6 @@ class Lorax:
|
|||||||
self.conf['tmpdir'] = tempfile.gettempdir()
|
self.conf['tmpdir'] = tempfile.gettempdir()
|
||||||
self.conf['datadir'] = '/usr/share/lorax'
|
self.conf['datadir'] = '/usr/share/lorax'
|
||||||
|
|
||||||
print("\n+=======================================================+")
|
|
||||||
print("| Setting up work directories and configuration data... |")
|
|
||||||
print("+=======================================================+\n")
|
|
||||||
|
|
||||||
if repos != []:
|
if repos != []:
|
||||||
self.repo, self.extrarepos = self._collectRepos(repos)
|
self.repo, self.extrarepos = self._collectRepos(repos)
|
||||||
else:
|
else:
|
||||||
@ -54,9 +50,6 @@ class Lorax:
|
|||||||
self.output = output
|
self.output = output
|
||||||
self.mirrorlist = mirrorlist
|
self.mirrorlist = mirrorlist
|
||||||
self.updates = updates
|
self.updates = updates
|
||||||
self.buildinstdir, self.treedir, self.cachedir = self._initializeDirs()
|
|
||||||
self.yumconf = self._writeYumConf()
|
|
||||||
self.buildarch = self.getBuildArch()
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""run()
|
"""run()
|
||||||
@ -65,11 +58,18 @@ class Lorax:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
print("\n+=======================================================+")
|
||||||
|
print("| Setting up work directories and configuration data... |")
|
||||||
|
print("+=======================================================+\n")
|
||||||
|
|
||||||
|
self.buildinstdir, self.treedir, self.cachedir = self._initializeDirs()
|
||||||
|
self.yumconf = self._writeYumConf()
|
||||||
|
|
||||||
print("\n+================================================+")
|
print("\n+================================================+")
|
||||||
print("| Creating instroot tree to build images from... |")
|
print("| Creating instroot tree to build images from... |")
|
||||||
print("+================================================+\n")
|
print("+================================================+\n")
|
||||||
|
|
||||||
self.instroot = InstRoot(conf=self.conf, yumconf=self.yumconf, arch=self.buildarch, treedir=self.treedir, updates=self.updates)
|
self.instroot = InstRoot(conf=self.conf, yumconf=self.yumconf, arch=self.getBuildArch(), treedir=self.treedir, updates=self.updates)
|
||||||
|
|
||||||
def showVersion(self, driver=None):
|
def showVersion(self, driver=None):
|
||||||
"""showVersion(driver)
|
"""showVersion(driver)
|
||||||
@ -100,8 +100,8 @@ class Lorax:
|
|||||||
else:
|
else:
|
||||||
os.unlink(item)
|
os.unlink(item)
|
||||||
|
|
||||||
if os.path.isdir(conf['tmpdir']):
|
if os.path.isdir(self.conf['tmpdir']):
|
||||||
shutil.rmtree(conf['tmpdir'], ignore_errors=True)
|
shutil.rmtree(self.conf['tmpdir'], ignore_errors=True)
|
||||||
|
|
||||||
def getBuildArch(self):
|
def getBuildArch(self):
|
||||||
"""getBuildArch()
|
"""getBuildArch()
|
||||||
@ -186,13 +186,13 @@ class Lorax:
|
|||||||
if not os.path.isdir(self.output):
|
if not os.path.isdir(self.output):
|
||||||
os.makedirs(self.output, mode=0755)
|
os.makedirs(self.output, mode=0755)
|
||||||
|
|
||||||
conf['tmpdir'] = tempfile.mkdtemp('XXXXXX', 'lorax.tmp.', conf['tmpdir'])
|
self.conf['tmpdir'] = tempfile.mkdtemp('XXXXXX', 'lorax.tmp.', self.conf['tmpdir'])
|
||||||
buildinstdir = tempfile.mkdtemp('XXXXXX', 'buildinstall.tree.', conf['tmpdir'])
|
buildinstdir = tempfile.mkdtemp('XXXXXX', 'buildinstall.tree.', self.conf['tmpdir'])
|
||||||
treedir = tempfile.mkdtemp('XXXXXX', 'treedir.', conf['tmpdir'])
|
treedir = tempfile.mkdtemp('XXXXXX', 'treedir.', self.conf['tmpdir'])
|
||||||
cachedir = tempfile.mkdtemp('XXXXXX', 'yumcache.', conf['tmpdir'])
|
cachedir = tempfile.mkdtemp('XXXXXX', 'yumcache.', self.conf['tmpdir'])
|
||||||
|
|
||||||
print("Working directories:")
|
print("Working directories:")
|
||||||
print(" tmpdir = %s" % (conf['tmpdir'],))
|
print(" tmpdir = %s" % (self.conf['tmpdir'],))
|
||||||
print(" buildinstdir = %s" % (buildinstdir,))
|
print(" buildinstdir = %s" % (buildinstdir,))
|
||||||
print(" treedir = %s" % (treedir,))
|
print(" treedir = %s" % (treedir,))
|
||||||
print(" cachedir = %s" % (cachedir,))
|
print(" cachedir = %s" % (cachedir,))
|
||||||
@ -206,7 +206,7 @@ class Lorax:
|
|||||||
to the temporary yum.conf file on success, None of failure.
|
to the temporary yum.conf file on success, None of failure.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
tmpdir = conf['tmpdir']
|
tmpdir = self.conf['tmpdir']
|
||||||
(fd, yumconf) = tempfile.mkstemp(prefix='yum.conf', dir=tmpdir)
|
(fd, yumconf) = tempfile.mkstemp(prefix='yum.conf', dir=tmpdir)
|
||||||
f = os.fdopen(fd, 'w')
|
f = os.fdopen(fd, 'w')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user