Call lorax as a process not a library

Doing this allows lorax to move to DNF (and Python3) without needing to
wait for pungi to be updated.
This commit is contained in:
Brian C. Lane 2015-02-11 16:13:22 -08:00 committed by Dennis Gilmore
parent 9947c7e0cd
commit 13526d1c49
2 changed files with 49 additions and 43 deletions

View File

@ -20,7 +20,6 @@ import os
import re
import shutil
import sys
import gzip
import pungi.util
import pprint
import lockfile
@ -29,7 +28,6 @@ import urlgrabber.progress
import subprocess
import createrepo
import ConfigParser
import pylorax
from fnmatch import fnmatch
import arch as arch_module
@ -1371,59 +1369,67 @@ class Pungi(PungiBase):
def doBuildinstall(self):
"""Run lorax on the tree."""
# the old ayum object has transaction data that confuse lorax, reinit.
self._inityum()
cmd = ["lorax"]
cmd.extend(["--workdir", self.workdir])
cmd.extend(["--logfile", os.path.join(self.config.get('pungi', 'destdir'), 'logs/lorax.log')])
try:
# Convert url method to a repo
self.ksparser.handler.repo.methodToRepo()
except:
pass
for repo in self.ksparser.handler.repo.repoList:
if repo.mirrorlist:
# The not bool() thing is because pykickstart is yes/no on
# whether to ignore groups, but yum is a yes/no on whether to
# include groups. Awkward.
cmd.extend(["--mirrorlist", repo.mirrorlist])
else:
cmd.extend(["--source", repo.baseurl])
# Add the repo in the destdir to our yum object
self._add_yum_repo('ourtree',
'file://%s' % self.topdir,
cost=10)
product = self.config.get('pungi', 'family')
version = self.config.get('pungi', 'version')
release = '%s %s' % (self.config.get('pungi', 'family'), self.config.get('pungi', 'version'))
variant = self.config.get('pungi', 'variant')
bugurl = self.config.get('pungi', 'bugurl')
isfinal = self.config.get('pungi', 'isfinal')
volid = self._shortenVolID()
workdir = self.workdir
outputdir = self.topdir
cmd.extend(["--source", "file://%s" % self.topdir])
cmd.extend(["--product", self.config.get('pungi', 'family')])
cmd.extend(["--version", self.config.get('pungi', 'version')])
cmd.extend(["--release", "%s %s" % (self.config.get('pungi', 'family'), self.config.get('pungi', 'version'))])
if self.config.get('pungi', 'variant'):
cmd.extend(["--variant", self.config.get('pungi', 'variant')])
cmd.extend(["--bugurl", self.config.get('pungi', 'bugurl')])
if self.config.get('pungi', 'isfinal'):
cmd.append("--isfinal")
cmd.extend(["--volid", self._shortenVolID()])
# on ppc64 we need to tell lorax to only use ppc64 packages so that the media will run on all 64 bit ppc boxes
if self.tree_arch == 'ppc64':
self.ayum.arch.setup_arch('ppc64')
self.ayum.compatarch = 'ppc64'
cmd.extend(["--buildarch", "ppc64"])
elif self.tree_arch == 'ppc64le':
self.ayum.arch.setup_arch('ppc64le')
self.ayum.compatarch = 'ppc64le'
cmd.extend(["--buildarch", "ppc64le"])
# Only supported mac hardware is x86 make sure we only enable mac support on arches that need it
if self.tree_arch in ['x86_64']:
if self.config.getboolean('pungi','nomacboot'):
domacboot = False
else:
domacboot = True
if self.tree_arch in ['x86_64'] and not self.config.getboolean('pungi','nomacboot'):
cmd.append("--macboot")
else:
domacboot = False
# run the command
lorax = pylorax.Lorax()
try:
conf_file = self.config.get('lorax', 'conf_file')
lorax.configure(conf_file=conf_file)
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
lorax.configure()
cmd.append("--nomacboot")
try:
installpkgs = self.config.get('lorax', 'installpkgs').split(" ")
cmd.extend(["--conf", self.config.get('lorax', 'conf_file')])
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
installpkgs = None
pass
lorax.run(self.ayum, product=product, version=version, release=release,
variant=variant, bugurl=bugurl, isfinal=isfinal, domacboot=domacboot,
workdir=workdir, outputdir=outputdir, volid=volid, installpkgs=installpkgs)
try:
cmd.extend(["--installpkgs", self.config.get('lorax', 'installpkgs')])
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
pass
# Allow the output directory to exist.
cmd.append("--force")
# MUST be last in the list
cmd.append(self.topdir)
self.logger.info(" ".join(cmd))
pypungi.util._doRunCommand(cmd, self.logger)
# write out the tree data for snake
self.writeinfo('tree: %s' % self.mkrelative(self.topdir))

View File

@ -44,7 +44,7 @@ def _doRunCommand(command, logger, rundir='/tmp', output=subprocess.PIPE, error=
if p1.returncode != 0:
logger.error("Got an error from %s" % command[0])
logger.error(err)
raise OSError, "Got an error from %s: %s" % (command[0], err)
raise OSError, "Got an error (%d) from %s: %s" % (p1.returncode, command[0], err)
def _link(local, target, logger, force=False):
"""Simple function to link or copy a package, removing target optionally."""