Move arch-specific logic out of installtree
Any decisions about arch-specific stuff should happen in the Lorax class or the arch-specific templates/code. Move that logic up to Lorax.run() and remove installtree.basearch.
This commit is contained in:
parent
051af505ae
commit
9b9f021caf
@ -179,8 +179,8 @@ class Lorax(BaseLoraxClass):
|
||||
logger.debug("self.arch.%s = %s", attr, getattr(self.arch,attr))
|
||||
|
||||
logger.info("setting up install tree")
|
||||
self.installtree = LoraxInstallTree(self.yum, self.arch.basearch,
|
||||
self.arch.libdir, self.workdir)
|
||||
self.installtree = LoraxInstallTree(self.yum, self.arch.libdir,
|
||||
self.workdir)
|
||||
|
||||
logger.info("setting up build parameters")
|
||||
product = DataHolder(name=product, version=version, release=release,
|
||||
@ -233,10 +233,11 @@ class Lorax(BaseLoraxClass):
|
||||
self.installtree.remove_locales()
|
||||
|
||||
logger.info("creating keymaps")
|
||||
self.installtree.create_keymaps()
|
||||
if self.arch.basearch not in ("s390", "s390x"):
|
||||
self.installtree.create_keymaps(basearch=self.arch.basearch)
|
||||
|
||||
logger.info("creating screenfont")
|
||||
self.installtree.create_screenfont()
|
||||
self.installtree.create_screenfont(basearch=self.arch.basearch)
|
||||
|
||||
logger.info("moving stubs")
|
||||
self.installtree.move_stubs()
|
||||
@ -254,6 +255,9 @@ class Lorax(BaseLoraxClass):
|
||||
self.installtree.create_depmod_conf()
|
||||
|
||||
# misc tree modifications
|
||||
if self.arch.basearch in ("s390", "s390x"):
|
||||
# TODO: move this to the arch template
|
||||
self.installtree.misc_s390_modifications()
|
||||
self.installtree.misc_tree_modifications()
|
||||
|
||||
# get config files
|
||||
@ -262,6 +266,8 @@ class Lorax(BaseLoraxClass):
|
||||
|
||||
self.installtree.get_config_files(config_dir)
|
||||
self.installtree.setup_sshd(config_dir)
|
||||
if self.arch.basearch in ("s390", "s390x"):
|
||||
self.installtree.generate_ssh_keys()
|
||||
|
||||
# get anaconda portions
|
||||
self.installtree.get_anaconda_portions()
|
||||
|
@ -39,11 +39,10 @@ from sysutils import *
|
||||
|
||||
class LoraxInstallTree(BaseLoraxClass):
|
||||
|
||||
def __init__(self, yum, basearch, libdir, workdir):
|
||||
def __init__(self, yum, libdir, workdir):
|
||||
BaseLoraxClass.__init__(self)
|
||||
self.yum = yum
|
||||
self.root = self.yum.installroot
|
||||
self.basearch = basearch
|
||||
self.libdir = libdir
|
||||
self.workdir = workdir
|
||||
|
||||
@ -73,15 +72,11 @@ class LoraxInstallTree(BaseLoraxClass):
|
||||
# move the lang-table to etc
|
||||
shutil.move(langtable, joinpaths(self.root, "etc"))
|
||||
|
||||
def create_keymaps(self):
|
||||
if self.basearch in ("s390", "s390x"):
|
||||
# skip on s390
|
||||
return True
|
||||
|
||||
def create_keymaps(self, basearch):
|
||||
keymaps = joinpaths(self.root, "etc/keymaps.gz")
|
||||
|
||||
# look for override
|
||||
override = "keymaps-override-{0.basearch}".format(self)
|
||||
override = "keymaps-override-{0}".format(basearch)
|
||||
override = joinpaths(self.root, "usr/share/anaconda", override)
|
||||
if os.path.isfile(override):
|
||||
logger.debug("using keymaps override")
|
||||
@ -89,16 +84,16 @@ class LoraxInstallTree(BaseLoraxClass):
|
||||
else:
|
||||
# create keymaps
|
||||
cmd = [joinpaths(self.root, "usr/libexec/anaconda", "getkeymaps"),
|
||||
self.basearch, keymaps, self.root]
|
||||
basearch, keymaps, self.root]
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||
proc.wait()
|
||||
|
||||
return True
|
||||
|
||||
def create_screenfont(self):
|
||||
def create_screenfont(self, basearch):
|
||||
dst = joinpaths(self.root, "etc/screenfont.gz")
|
||||
|
||||
screenfont = "screenfont-{0.basearch}.gz".format(self)
|
||||
screenfont = "screenfont-{0}.gz".format(basearch)
|
||||
screenfont = joinpaths(self.root, "usr/share/anaconda", screenfont)
|
||||
if not os.path.isfile(screenfont):
|
||||
return False
|
||||
@ -367,24 +362,19 @@ class LoraxInstallTree(BaseLoraxClass):
|
||||
with open(joinpaths(self.root, "etc/depmod.d/dd.conf"), "w") as fobj:
|
||||
fobj.write(text)
|
||||
|
||||
def misc_tree_modifications(self):
|
||||
if self.basearch in ("s390", "s390x"):
|
||||
# copy linuxrc.s390
|
||||
src = joinpaths(self.root, "usr/share/anaconda/linuxrc.s390")
|
||||
dst = joinpaths(self.root, "sbin", "init")
|
||||
os.unlink(dst)
|
||||
shutil.copy2(src, dst)
|
||||
def misc_s390_modifications(self):
|
||||
# copy linuxrc.s390
|
||||
src = joinpaths(self.root, "usr/share/anaconda/linuxrc.s390")
|
||||
dst = joinpaths(self.root, "sbin", "init")
|
||||
os.unlink(dst)
|
||||
shutil.copy2(src, dst)
|
||||
|
||||
def misc_tree_modifications(self):
|
||||
# init symlinks
|
||||
target = "/sbin/init"
|
||||
name = joinpaths(self.root, "init")
|
||||
os.symlink(target, name)
|
||||
|
||||
# mtab symlink
|
||||
#target = "/proc/mounts"
|
||||
#name = joinpaths(self.root, "etc", "mtab")
|
||||
#os.symlink(target, name)
|
||||
|
||||
os.unlink(joinpaths(self.root, "etc/systemd/system/default.target"))
|
||||
os.symlink("/lib/systemd/system/anaconda.target", joinpaths(self.root, "etc/systemd/system/default.target"))
|
||||
|
||||
@ -496,33 +486,32 @@ class LoraxInstallTree(BaseLoraxClass):
|
||||
# change permissions
|
||||
chmod_(shadow, 400)
|
||||
|
||||
# generate ssh keys for s390
|
||||
if self.basearch in ("s390", "s390x"):
|
||||
logger.info("generating SSH1 RSA host key")
|
||||
rsa1 = joinpaths(self.root, "etc/ssh/ssh_host_key")
|
||||
cmd = [self.lcmds.SSHKEYGEN, "-q", "-t", "rsa1", "-f", rsa1,
|
||||
"-C", "", "-N", ""]
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
p.wait()
|
||||
def generate_ssh_keys(self):
|
||||
logger.info("generating SSH1 RSA host key")
|
||||
rsa1 = joinpaths(self.root, "etc/ssh/ssh_host_key")
|
||||
cmd = [self.lcmds.SSHKEYGEN, "-q", "-t", "rsa1", "-f", rsa1,
|
||||
"-C", "", "-N", ""]
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
p.wait()
|
||||
|
||||
logger.info("generating SSH2 RSA host key")
|
||||
rsa2 = joinpaths(self.root, "etc/ssh/ssh_host_rsa_key")
|
||||
cmd = [self.lcmds.SSHKEYGEN, "-q", "-t", "rsa", "-f", rsa2,
|
||||
"-C", "", "-N", ""]
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
p.wait()
|
||||
logger.info("generating SSH2 RSA host key")
|
||||
rsa2 = joinpaths(self.root, "etc/ssh/ssh_host_rsa_key")
|
||||
cmd = [self.lcmds.SSHKEYGEN, "-q", "-t", "rsa", "-f", rsa2,
|
||||
"-C", "", "-N", ""]
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
p.wait()
|
||||
|
||||
logger.info("generating SSH2 DSA host key")
|
||||
dsa = joinpaths(self.root, "etc/ssh/ssh_host_dsa_key")
|
||||
cmd = [self.lcmds.SSHKEYGEN, "-q", "-t", "dsa", "-f", dsa,
|
||||
"-C", "", "-N", ""]
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
p.wait()
|
||||
logger.info("generating SSH2 DSA host key")
|
||||
dsa = joinpaths(self.root, "etc/ssh/ssh_host_dsa_key")
|
||||
cmd = [self.lcmds.SSHKEYGEN, "-q", "-t", "dsa", "-f", dsa,
|
||||
"-C", "", "-N", ""]
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
p.wait()
|
||||
|
||||
# change key file permissions
|
||||
for key in [rsa1, rsa2, dsa]:
|
||||
chmod_(key, 0600)
|
||||
chmod_(key + ".pub", 0644)
|
||||
# change key file permissions
|
||||
for key in [rsa1, rsa2, dsa]:
|
||||
chmod_(key, 0600)
|
||||
chmod_(key + ".pub", 0644)
|
||||
|
||||
|
||||
def get_anaconda_portions(self):
|
||||
@ -579,11 +568,8 @@ class LoraxInstallTree(BaseLoraxClass):
|
||||
|
||||
@property
|
||||
def kernels(self):
|
||||
kerneldir = "boot"
|
||||
if self.basearch == "ia64":
|
||||
kerneldir = "boot/efi/EFI/redhat"
|
||||
|
||||
kerneldir = joinpaths(self.root, kerneldir)
|
||||
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)?))$")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user