installtree: remove workdir and kernels
Since we want all the modules in the runtime image, there's no need to deal with the individual kernels. And workdir was only being used to mess with the modules, so we don't need that either.
This commit is contained in:
parent
756b44948e
commit
a5b7ac5e6e
@ -178,8 +178,7 @@ class Lorax(BaseLoraxClass):
|
|||||||
logger.debug("self.arch.%s = %s", attr, getattr(self.arch,attr))
|
logger.debug("self.arch.%s = %s", attr, getattr(self.arch,attr))
|
||||||
|
|
||||||
logger.info("setting up install tree")
|
logger.info("setting up install tree")
|
||||||
self.installtree = LoraxInstallTree(self.yum, self.arch.libdir,
|
self.installtree = LoraxInstallTree(self.yum, 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,
|
product = DataHolder(name=product, version=version, release=release,
|
||||||
|
@ -69,9 +69,4 @@ class LoraxRequiredCommands(dict):
|
|||||||
return missing
|
return missing
|
||||||
|
|
||||||
|
|
||||||
# kernel types
|
|
||||||
K_NORMAL = 0
|
|
||||||
K_PAE = 1
|
|
||||||
K_XEN = 2
|
|
||||||
|
|
||||||
FS_OVERHEAD = 512
|
FS_OVERHEAD = 512
|
||||||
|
@ -39,12 +39,11 @@ from sysutils import *
|
|||||||
|
|
||||||
class LoraxInstallTree(BaseLoraxClass):
|
class LoraxInstallTree(BaseLoraxClass):
|
||||||
|
|
||||||
def __init__(self, yum, libdir, workdir):
|
def __init__(self, yum, libdir):
|
||||||
BaseLoraxClass.__init__(self)
|
BaseLoraxClass.__init__(self)
|
||||||
self.yum = yum
|
self.yum = yum
|
||||||
self.root = self.yum.installroot
|
self.root = self.yum.installroot
|
||||||
self.libdir = libdir
|
self.libdir = libdir
|
||||||
self.workdir = workdir
|
|
||||||
|
|
||||||
self.lcmds = constants.LoraxRequiredCommands()
|
self.lcmds = constants.LoraxRequiredCommands()
|
||||||
|
|
||||||
@ -178,9 +177,9 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
os.symlink("../modules", joinpaths(self.root, "lib/modules"))
|
os.symlink("../modules", joinpaths(self.root, "lib/modules"))
|
||||||
os.symlink("../firmware", joinpaths(self.root, "lib/firmware"))
|
os.symlink("../firmware", joinpaths(self.root, "lib/firmware"))
|
||||||
|
|
||||||
def cleanup_kernel_modules(self, keepmodules, kernel):
|
def cleanup_kernel_modules(self, keepmodules, kernelver):
|
||||||
logger.info("cleaning up kernel modules for %s", kernel.version)
|
logger.info("cleaning up kernel modules for %s", kernelver)
|
||||||
moddir = joinpaths(self.root, "modules", kernel.version)
|
moddir = joinpaths(self.root, "modules", kernelver)
|
||||||
fwdir = joinpaths(self.root, "firmware")
|
fwdir = joinpaths(self.root, "firmware")
|
||||||
|
|
||||||
# expand required modules
|
# expand required modules
|
||||||
@ -307,9 +306,9 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
for modname in sorted(modlist.keys()):
|
for modname in sorted(modlist.keys()):
|
||||||
fobj.write(modlist[modname])
|
fobj.write(modlist[modname])
|
||||||
|
|
||||||
def compress_modules(self, kernel):
|
def compress_modules(self, kernelver):
|
||||||
logger.debug("compressing modules for %s", kernel.version)
|
logger.debug("compressing modules for %s", kernelver)
|
||||||
moddir = joinpaths(self.root, "modules", kernel.version)
|
moddir = joinpaths(self.root, "modules", kernelver)
|
||||||
|
|
||||||
for root, _, fnames in os.walk(moddir):
|
for root, _, fnames in os.walk(moddir):
|
||||||
for fname in filter(lambda f: f.endswith(".ko"), fnames):
|
for fname in filter(lambda f: f.endswith(".ko"), fnames):
|
||||||
@ -323,13 +322,13 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
|
|
||||||
os.unlink(path)
|
os.unlink(path)
|
||||||
|
|
||||||
def run_depmod(self, kernel):
|
def run_depmod(self, kernelver):
|
||||||
logger.debug("running depmod for %s", kernel.version)
|
logger.debug("running depmod for %s", kernelver)
|
||||||
systemmap = "System.map-{0.version}".format(kernel)
|
systemmap = "System.map-{0}".format(kernelver)
|
||||||
systemmap = joinpaths(self.root, "boot", systemmap)
|
systemmap = joinpaths(self.root, "boot", systemmap)
|
||||||
|
|
||||||
cmd = [self.lcmds.DEPMOD, "-a", "-F", systemmap, "-b", self.root,
|
cmd = [self.lcmds.DEPMOD, "-a", "-F", systemmap, "-b", self.root,
|
||||||
kernel.version]
|
kernelver]
|
||||||
|
|
||||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||||
retcode = proc.wait()
|
retcode = proc.wait()
|
||||||
@ -337,7 +336,7 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
logger.critical(proc.stdout.read())
|
logger.critical(proc.stdout.read())
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
moddir = joinpaths(self.root, "modules", kernel.version)
|
moddir = joinpaths(self.root, "modules", kernelver)
|
||||||
|
|
||||||
# remove *map files
|
# remove *map files
|
||||||
mapfiles = joinpaths(moddir, "*map")
|
mapfiles = joinpaths(moddir, "*map")
|
||||||
@ -348,9 +347,6 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
for fname in ["build", "source"]:
|
for fname in ["build", "source"]:
|
||||||
os.unlink(joinpaths(moddir, fname))
|
os.unlink(joinpaths(moddir, fname))
|
||||||
|
|
||||||
# move modules out of the tree
|
|
||||||
shutil.move(moddir, self.workdir)
|
|
||||||
|
|
||||||
def move_repos(self):
|
def move_repos(self):
|
||||||
src = joinpaths(self.root, "etc/yum.repos.d")
|
src = joinpaths(self.root, "etc/yum.repos.d")
|
||||||
dst = joinpaths(self.root, "etc/anaconda.repos.d")
|
dst = joinpaths(self.root, "etc/anaconda.repos.d")
|
||||||
@ -527,15 +523,10 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
dst = joinpaths(self.root, "sbin")
|
dst = joinpaths(self.root, "sbin")
|
||||||
shutil.copy2(src, dst)
|
shutil.copy2(src, dst)
|
||||||
|
|
||||||
def compress(self, initrd, kernel, type="xz", speed="9"):
|
def compress(self, outfile, type="xz", speed="9"):
|
||||||
chdir = lambda: os.chdir(self.root)
|
chdir = lambda: os.chdir(self.root)
|
||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
||||||
# move corresponding modules to the tree
|
|
||||||
logger.debug("moving modules inside initrd")
|
|
||||||
shutil.move(joinpaths(self.workdir, kernel.version),
|
|
||||||
joinpaths(self.root, "modules"))
|
|
||||||
|
|
||||||
find = subprocess.Popen([self.lcmds.FIND, "."], stdout=subprocess.PIPE,
|
find = subprocess.Popen([self.lcmds.FIND, "."], stdout=subprocess.PIPE,
|
||||||
preexec_fn=chdir)
|
preexec_fn=chdir)
|
||||||
|
|
||||||
@ -545,48 +536,18 @@ class LoraxInstallTree(BaseLoraxClass):
|
|||||||
preexec_fn=chdir)
|
preexec_fn=chdir)
|
||||||
|
|
||||||
compressed = subprocess.Popen([type, "-%s" % speed], stdin=cpio.stdout,
|
compressed = subprocess.Popen([type, "-%s" % speed], stdin=cpio.stdout,
|
||||||
stdout=open(initrd.fpath, "wb"))
|
stdout=open(outfile, "wb"))
|
||||||
|
|
||||||
logger.debug("compressing")
|
logger.debug("compressing")
|
||||||
rc = compressed.wait()
|
rc = compressed.wait()
|
||||||
|
|
||||||
# move modules out of the tree again
|
|
||||||
logger.debug("moving modules outside initrd")
|
|
||||||
shutil.move(joinpaths(self.root, "modules", kernel.version),
|
|
||||||
self.workdir)
|
|
||||||
|
|
||||||
elapsed = time.time() - start
|
elapsed = time.time() - start
|
||||||
|
|
||||||
return True, elapsed
|
return True, elapsed
|
||||||
|
|
||||||
def install_kernel_modules(self, keepmodules):
|
def install_kernel_modules(self, keepmodules):
|
||||||
self.move_modules()
|
self.move_modules()
|
||||||
for kernel in self.kernels:
|
for kernel in os.listdir(joinpaths(self.root, "modules")):
|
||||||
self.cleanup_kernel_modules(keepmodules, kernel)
|
self.cleanup_kernel_modules(keepmodules, kernel)
|
||||||
self.compress_modules(kernel)
|
self.compress_modules(kernel)
|
||||||
self.run_depmod(kernel)
|
self.run_depmod(kernel)
|
||||||
|
|
||||||
@property
|
|
||||||
def kernels(self):
|
|
||||||
kerneldir = joinpaths(self.root, "boot")
|
|
||||||
# FIXME: kernel search path?
|
|
||||||
kpattern = re.compile(r"vmlinuz-(?P<ver>[-._0-9a-z]+?"
|
|
||||||
r"(?P<pae>(PAE)?)(?P<xen>(xen)?))$")
|
|
||||||
|
|
||||||
kernels = []
|
|
||||||
for fname in os.listdir(kerneldir):
|
|
||||||
match = kpattern.match(fname)
|
|
||||||
if match:
|
|
||||||
ktype = constants.K_NORMAL
|
|
||||||
if match.group("pae"):
|
|
||||||
ktype = constants.K_PAE
|
|
||||||
elif match.group("xen"):
|
|
||||||
ktype = constants.K_XEN
|
|
||||||
|
|
||||||
kernels.append(DataHolder(fname=fname,
|
|
||||||
fpath=joinpaths(kerneldir, fname),
|
|
||||||
version=match.group("ver"),
|
|
||||||
ktype=ktype))
|
|
||||||
|
|
||||||
kernels = sorted(kernels, key=operator.attrgetter("ktype"))
|
|
||||||
return kernels
|
|
||||||
|
Loading…
Reference in New Issue
Block a user