Doing this allows lorax to move to DNF (and Python3) without needing to
wait for pungi to be updated.
---
src/pypungi/__init__.py | 82 ++++++++++++++++++++++++++-----------------------
src/pypungi/util.py | 2 +-
2 files changed, 45 insertions(+), 39 deletions(-)
diff --git a/src/pypungi/__init__.py b/src/pypungi/__init__.py
index c1318ce..0e4b316 100644
--- a/src/pypungi/__init__.py
+++ b/src/pypungi/__init__.py
@@ -20,7 +20,6 @@ import os
import re
import shutil
import sys
-import gzip
import pypungi.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(pypungi.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')])
- # 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', 'name')
- version = self.config.get('pungi', 'version')
- release = '%s %s' % (self.config.get('pungi', 'name'),
self.config.get('pungi', 'version'))
+ try:
+ # Convert url method to a repo
+ self.ksparser.handler.repo.methodToRepo()
+ except:
+ pass
- variant = self.config.get('pungi', 'flavor')
- bugurl = self.config.get('pungi', 'bugurl')
- isfinal = self.config.get('pungi', 'isfinal')
+ 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])
- volid = self._shortenVolID()
- workdir = self.workdir
- outputdir = self.topdir
+ # Add the repo in the destdir to our yum object
+ cmd.extend(["--source", "file://%s" % self.topdir])
+ cmd.extend(["--product", self.config.get('pungi',
'name')])
+ cmd.extend(["--version", self.config.get('pungi',
'version')])
+ cmd.extend(["--release", "%s %s" %
(self.config.get('pungi', 'name'), self.config.get('pungi',
'version'))])
+ if self.config.get('pungi', 'flavor'):
+ cmd.extend(["--variant", self.config.get('pungi',
'flavor')])
+ 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
+ cmd.append("--nomacboot")
- # run the command
- lorax = pylorax.Lorax()
try:
- conf_file = self.config.get('lorax', 'conf_file')
- lorax.configure(conf_file=conf_file)
+ cmd.extend(["--conf", self.config.get('lorax',
'conf_file')])
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
- lorax.configure()
+ pass
try:
- installpkgs = self.config.get('lorax',
'installpkgs').split(" ")
+ cmd.extend(["--installpkgs", self.config.get('lorax',
'installpkgs')])
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
- installpkgs = None
+ pass
+
+ # Allow the output directory to exist.
+ cmd.append("--force")
+
+ # MUST be last in the list
+ cmd.append(self.topdir)
- 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)
+ 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))
diff --git a/src/pypungi/util.py b/src/pypungi/util.py
index 800cf7f..a60b78d 100644
--- a/src/pypungi/util.py
+++ b/src/pypungi/util.py
@@ -34,7 +34,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."""
--
2.1.0