Make Lorax.arch and Lorax.product into objects
arch has three attributes: .buildarch, .basearch, and .libdir product has six: .name, .version, .release, .variant, .bugurl, and is_beta This makes it easier to pass this data into functions/templates.
This commit is contained in:
parent
17c9c8bfaf
commit
b186317213
@ -55,25 +55,17 @@ from treeinfo import TreeInfo
|
|||||||
from discinfo import DiscInfo
|
from discinfo import DiscInfo
|
||||||
import images
|
import images
|
||||||
|
|
||||||
|
class ArchData(object):
|
||||||
ARCHMAPS = {
|
lib64_arches = ("x86_64", "ppc64", "sparc64", "s390x", "ia64")
|
||||||
"i386": {"base": "i386", "efi": "IA32", "is64": False},
|
archmap = {"i386": "i386", "i586":"i386", "i686":"i386", "x86_64":"x86_64",
|
||||||
"i586": {"base": "i386", "efi": "IA32", "is64": False},
|
"ppc":"ppc", "ppc64": "ppc",
|
||||||
"i686": {"base": "i386", "efi": "IA32", "is64": False},
|
"sparc":"sparc", "sparcv9":"sparc", "sparc64":"sparc",
|
||||||
"x86_64": {"base": "x86_64", "efi": "X64", "is64": True},
|
"s390":"s390", "s390x":"s390x",
|
||||||
"ppc": {"base": "ppc", "efi": "", "is64": False},
|
}
|
||||||
"ppc64": {"base": "ppc", "efi": "", "is64": True},
|
def __init__(self, buildarch):
|
||||||
"s390": {"base": "s390", "efi": "", "is64": False},
|
self.buildarch = buildarch
|
||||||
"s390x": {"base": "s390x", "efi": "", "is64": True},
|
self.basearch = self.archmap.get(buildarch) or buildarch
|
||||||
"sparc": {"base": "sparc", "efi": "", "is64": False},
|
self.libdir = "lib64" if buildarch in self.lib64_arches else "lib"
|
||||||
"sparcv9": {"base": "sparc", "efi": "", "is64": False},
|
|
||||||
"sparc64": {"base": "sparc", "efi": "", "is64": True},
|
|
||||||
"ia64": {"base": "ia64", "efi": "IA64", "is64": True}
|
|
||||||
}
|
|
||||||
|
|
||||||
LIB32 = "lib"
|
|
||||||
LIB64 = "lib64"
|
|
||||||
|
|
||||||
|
|
||||||
class Lorax(BaseLoraxClass):
|
class Lorax(BaseLoraxClass):
|
||||||
|
|
||||||
@ -183,48 +175,30 @@ class Lorax(BaseLoraxClass):
|
|||||||
logger.debug("using install root: {0}".format(self.yum.installroot))
|
logger.debug("using install root: {0}".format(self.yum.installroot))
|
||||||
|
|
||||||
logger.info("setting up build architecture")
|
logger.info("setting up build architecture")
|
||||||
|
self.arch = ArchData(self.get_buildarch())
|
||||||
self.buildarch = self.get_buildarch()
|
for attr in ('buildarch', 'basearch', 'libdir'):
|
||||||
logger.debug("set buildarch = {0.buildarch}".format(self))
|
logger.debug("self.arch.%s = %s", attr, getattr(self.arch,attr))
|
||||||
|
|
||||||
archmap = ARCHMAPS.get(self.buildarch)
|
|
||||||
assert archmap is not None
|
|
||||||
|
|
||||||
self.basearch = archmap.get("base")
|
|
||||||
self.efiarch = archmap.get("efi")
|
|
||||||
self.libdir = LIB64 if archmap.get("is64") else LIB32
|
|
||||||
logger.debug("set basearch = {0.basearch}".format(self))
|
|
||||||
logger.debug("set efiarch = {0.efiarch}".format(self))
|
|
||||||
logger.debug("set libdir = {0.libdir}".format(self))
|
|
||||||
|
|
||||||
logger.info("setting up install tree")
|
logger.info("setting up install tree")
|
||||||
self.installtree = LoraxInstallTree(self.yum, self.basearch,
|
self.installtree = LoraxInstallTree(self.yum, self.arch.basearch,
|
||||||
self.libdir, self.workdir)
|
self.arch.libdir, self.workdir)
|
||||||
|
|
||||||
logger.info("setting up build parameters")
|
logger.info("setting up build parameters")
|
||||||
|
product = DataHolder(name=product, version=version, release=release,
|
||||||
|
variant=variant, bugurl=bugurl, is_beta=is_beta)
|
||||||
self.product = product
|
self.product = product
|
||||||
self.version = version
|
logger.debug("product data: %s" % product)
|
||||||
self.release = release
|
|
||||||
logger.debug("set product = {0.product}".format(self))
|
|
||||||
logger.debug("set version = {0.version}".format(self))
|
|
||||||
logger.debug("set release = {0.release}".format(self))
|
|
||||||
|
|
||||||
# set up optional build parameters
|
|
||||||
self.variant = variant
|
|
||||||
self.bugurl = bugurl
|
|
||||||
self.is_beta = is_beta
|
|
||||||
logger.debug("set variant = {0.variant}".format(self))
|
|
||||||
logger.debug("set bugurl = {0.bugurl}".format(self))
|
|
||||||
logger.debug("set is_beta = {0.is_beta}".format(self))
|
|
||||||
|
|
||||||
logger.info("parsing the template")
|
logger.info("parsing the template")
|
||||||
tfile = joinpaths(self.conf.get("lorax", "sharedir"),
|
tfile = joinpaths(self.conf.get("lorax", "sharedir"),
|
||||||
self.conf.get("templates", "ramdisk"))
|
self.conf.get("templates", "ramdisk"))
|
||||||
|
|
||||||
tvars = { "basearch": self.basearch,
|
# TODO: normalize with arch templates:
|
||||||
"buildarch": self.buildarch,
|
# tvars = dict(product=product, arch=arch)
|
||||||
"libdir" : self.libdir,
|
tvars = { "basearch": self.arch.basearch,
|
||||||
"product": self.product.lower() }
|
"buildarch": self.arch.buildarch,
|
||||||
|
"libdir" : self.arch.libdir,
|
||||||
|
"product": self.product.name.lower() }
|
||||||
|
|
||||||
template = ltmpl.LoraxTemplate()
|
template = ltmpl.LoraxTemplate()
|
||||||
template = template.parse(tfile, tvars)
|
template = template.parse(tfile, tvars)
|
||||||
@ -251,8 +225,8 @@ class Lorax(BaseLoraxClass):
|
|||||||
self.installtree.yum.process_transaction(skipbroken)
|
self.installtree.yum.process_transaction(skipbroken)
|
||||||
|
|
||||||
# write .buildstamp
|
# write .buildstamp
|
||||||
buildstamp = BuildStamp(self.workdir, self.product, self.version,
|
buildstamp = BuildStamp(self.workdir, self.product.name, self.product.version,
|
||||||
self.bugurl, self.is_beta, self.buildarch)
|
self.product.bugurl, self.product.is_beta, self.arch.buildarch)
|
||||||
|
|
||||||
buildstamp.write()
|
buildstamp.write()
|
||||||
shutil.copy2(buildstamp.path, self.installtree.root)
|
shutil.copy2(buildstamp.path, self.installtree.root)
|
||||||
@ -315,18 +289,18 @@ class Lorax(BaseLoraxClass):
|
|||||||
self.installtree.get_anaconda_portions()
|
self.installtree.get_anaconda_portions()
|
||||||
|
|
||||||
# write .discinfo
|
# write .discinfo
|
||||||
discinfo = DiscInfo(self.workdir, self.release, self.basearch)
|
discinfo = DiscInfo(self.workdir, self.product.release, self.arch.basearch)
|
||||||
discinfo.write()
|
discinfo.write()
|
||||||
|
|
||||||
shutil.copy2(discinfo.path, self.outputdir)
|
shutil.copy2(discinfo.path, self.outputdir)
|
||||||
|
|
||||||
# create .treeinfo
|
# create .treeinfo
|
||||||
treeinfo = TreeInfo(self.workdir, self.product, self.version,
|
treeinfo = TreeInfo(self.workdir, self.product.name, self.product.version,
|
||||||
self.variant, self.basearch)
|
self.product.variant, self.arch.basearch)
|
||||||
|
|
||||||
# get the image class
|
# get the image class
|
||||||
factory = images.Factory()
|
factory = images.Factory()
|
||||||
imgclass = factory.get_class(self.basearch)
|
imgclass = factory.get_class(self.arch.basearch)
|
||||||
|
|
||||||
ctype = self.conf.get("compression", "type")
|
ctype = self.conf.get("compression", "type")
|
||||||
cspeed = self.conf.get("compression", "speed")
|
cspeed = self.conf.get("compression", "speed")
|
||||||
@ -334,10 +308,10 @@ class Lorax(BaseLoraxClass):
|
|||||||
i = imgclass(kernellist=kernels,
|
i = imgclass(kernellist=kernels,
|
||||||
installtree=self.installtree,
|
installtree=self.installtree,
|
||||||
outputroot=self.outputdir,
|
outputroot=self.outputdir,
|
||||||
product=self.product,
|
product=self.product.name,
|
||||||
version=self.version,
|
version=self.product.version,
|
||||||
treeinfo=treeinfo,
|
treeinfo=treeinfo,
|
||||||
basearch=self.basearch,
|
basearch=self.arch.basearch,
|
||||||
ctype=ctype,
|
ctype=ctype,
|
||||||
cspeed=cspeed)
|
cspeed=cspeed)
|
||||||
|
|
||||||
@ -383,7 +357,7 @@ class Lorax(BaseLoraxClass):
|
|||||||
|
|
||||||
# compress install tree (create initrd)
|
# compress install tree (create initrd)
|
||||||
logger.info("creating the initrd")
|
logger.info("creating the initrd")
|
||||||
i.create_initrd(self.libdir)
|
i.create_initrd(self.arch.libdir)
|
||||||
|
|
||||||
# create boot iso
|
# create boot iso
|
||||||
logger.info("creating boot iso")
|
logger.info("creating boot iso")
|
||||||
|
Loading…
Reference in New Issue
Block a user