Allow specifying buildarch on the command line (#771382)

Some repos may contain anaconda packages for more architectures,
so it's not possible to get the right buildarch.
This patch allows optional specifying of the buildarch on the
command line when running lorax.
If the buildarch is not specified manually, lorax tries to get
it from the anaconda package as before.
If there's no anaconda package in the repository, don't fallback
to the system architecture and continue, because this is pointless.
We need the anaconda package.
This commit is contained in:
Martin Gracik 2012-01-05 11:26:59 +01:00
parent 31c60b119b
commit 1bbc546147
2 changed files with 10 additions and 6 deletions

View File

@ -125,7 +125,7 @@ class Lorax(BaseLoraxClass):
logger.addHandler(fh)
def run(self, ybo, product, version, release, variant="", bugurl="",
isfinal=False, workdir=None, outputdir=None):
isfinal=False, workdir=None, outputdir=None, buildarch=None):
assert self._configured
@ -163,8 +163,11 @@ class Lorax(BaseLoraxClass):
self.inroot = ybo.conf.installroot
logger.debug("using install root: {0}".format(self.inroot))
if not buildarch:
buildarch = get_buildarch(ybo)
logger.info("setting up build architecture")
self.arch = ArchData(get_buildarch(ybo))
self.arch = ArchData(buildarch)
for attr in ('buildarch', 'basearch', 'libdir'):
logger.debug("self.arch.%s = %s", attr, getattr(self.arch,attr))
@ -252,8 +255,7 @@ def get_buildarch(ybo):
buildarch = anaconda.arch
break
if not buildarch:
# fallback to the system architecture
logger.warning("using system architecture")
buildarch = os.uname()[4]
logger.critical("no anaconda package in the repository")
sys.exit(1)
return buildarch

View File

@ -70,6 +70,8 @@ def main(args):
optional.add_option("-e", "--excludepkgs", default=[],
action="append", metavar="STRING",
help="package glob to exclude (may be listed multiple times)")
optional.add_option("--buildarch", default=None,
help="build architecture", metavar="STRING")
# add the option groups to the parser
parser.add_option_group(required)
@ -121,7 +123,7 @@ def main(args):
lorax.configure(conf_file=opts.config)
lorax.run(yb, opts.product, opts.version, opts.release,
opts.variant, opts.bugurl, opts.is_beta,
workdir=tempdir, outputdir=outputdir)
workdir=tempdir, outputdir=outputdir, buildarch=opts.buildarch)
def get_yum_base_object(installroot, repositories, mirrorlists=[],