Introduce class Lorax and class InstRoot.
The lorax driver program will instantiate the Lorax class, which drives the creation of the install images. The InstRoot class is the main object that represents the contents of the instroot image (the tree that boot and stage2 images are made from).
This commit is contained in:
parent
9546387afd
commit
81e7702393
@ -102,49 +102,25 @@ if __name__ == "__main__":
|
|||||||
sys.stderr.write("ERROR: Missing repo to use for image generation.\n")
|
sys.stderr.write("ERROR: Missing repo to use for image generation.\n")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print("\n+=======================================================+")
|
lorax = pylorax.Lorax(repos=args, output=output, mirrorlist=mirrorlist)
|
||||||
print("| Setting up work directories and configuration data... |")
|
lorax.run()
|
||||||
print("+=======================================================+\n")
|
|
||||||
|
|
||||||
# collect all repos specified on the command line. the first repo is
|
|
||||||
# designated the main repo (I guess)
|
|
||||||
repo, extrarepos = pylorax.collectRepos(args)
|
|
||||||
|
|
||||||
# create directories that we will be using for image generation
|
|
||||||
buildinstdir, treedir, cachedir = pylorax.initializeDirs(output)
|
|
||||||
|
|
||||||
# write out yum.conf used for image generation
|
|
||||||
yumconf = pylorax.writeYumConf(cachedir=cachedir, repo=repo, extrarepos=extrarepos, mirrorlist=mirrorlist)
|
|
||||||
if yumconf is None:
|
|
||||||
sys.stderr.write("ERROR: Could not generate temporary yum.conf file.\n")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
buildarch = pylorax.getBuildArch()
|
|
||||||
|
|
||||||
print("\n+================================================+")
|
|
||||||
print("| Creating instroot tree to build images from... |")
|
|
||||||
print("+================================================+\n")
|
|
||||||
|
|
||||||
# upd-instroot
|
|
||||||
if not pylorax.instroot.createInstRoot(yumconf=yumconf, arch=buildarch, treedir=treedir, updates=updates):
|
|
||||||
sys.stderr.write("ERROR: Could not create inst root.\n")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
print("\n+=======================================+")
|
|
||||||
print("| Writing meta data to instroot tree... |")
|
|
||||||
print("+=======================================+\n")
|
|
||||||
|
|
||||||
# write .treeinfo file
|
|
||||||
if not pylorax.treeinfo.write(family=product, variant=variant, version=version, arch=buildarch, outdir=output):
|
|
||||||
sys.stderr.write("Error writing %s/.treeinfo file.\n" % (output,))
|
|
||||||
|
|
||||||
# mk-images
|
|
||||||
# XXX
|
|
||||||
|
|
||||||
# write .discinfo file
|
|
||||||
if not pylorax.discinfo.write(release=release, arch=buildarch, outdir=output):
|
|
||||||
sys.stderr.write("Error writing %s/.discinfo file.\n" % (output,))
|
|
||||||
|
|
||||||
# clean up
|
|
||||||
if cleanup:
|
if cleanup:
|
||||||
pylorax.cleanup()
|
lorax.cleanup()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# print("\n+=======================================+")
|
||||||
|
# print("| Writing meta data to instroot tree... |")
|
||||||
|
# print("+=======================================+\n")
|
||||||
|
#
|
||||||
|
# # write .treeinfo file
|
||||||
|
# if not pylorax.treeinfo.write(family=product, variant=variant, version=version, arch=buildarch, outdir=output):
|
||||||
|
# sys.stderr.write("Error writing %s/.treeinfo file.\n" % (output,))
|
||||||
|
#
|
||||||
|
# # mk-images
|
||||||
|
# # XXX
|
||||||
|
#
|
||||||
|
# # write .discinfo file
|
||||||
|
# if not pylorax.discinfo.write(release=release, arch=buildarch, outdir=output):
|
||||||
|
# sys.stderr.write("Error writing %s/.discinfo file.\n" % (output,))
|
||||||
|
@ -40,190 +40,207 @@ conf['confdir'] = '/etc/lorax'
|
|||||||
conf['tmpdir'] = tempfile.gettempdir()
|
conf['tmpdir'] = tempfile.gettempdir()
|
||||||
conf['datadir'] = '/usr/share/lorax'
|
conf['datadir'] = '/usr/share/lorax'
|
||||||
|
|
||||||
def show_version(prog):
|
class Lorax:
|
||||||
"""show_version(prog)
|
def __init__(self, repos=[], output=None, mirrorlist=[], updates=None):
|
||||||
|
print("\n+=======================================================+")
|
||||||
|
print("| Setting up work directories and configuration data... |")
|
||||||
|
print("+=======================================================+\n")
|
||||||
|
|
||||||
Display program name (prog) and version number. If prog is an empty
|
if repos != []:
|
||||||
string or None, use the value 'pylorax'.
|
self.repo, self.extrarepos = self._collectRepos(repos)
|
||||||
|
else:
|
||||||
|
self.repo = None
|
||||||
|
self.extrarepos = []
|
||||||
|
|
||||||
"""
|
self.output = output
|
||||||
|
self.mirrorlist = mirrorlist
|
||||||
|
self.updates = updates
|
||||||
|
self.buildinstdir, self.treedir, self.cachedir = self._initializeDirs()
|
||||||
|
self.yumconf = self._writeYumConf()
|
||||||
|
self.buildarch = self.getBuildArch()
|
||||||
|
|
||||||
if prog is None or prog == '':
|
def run(self):
|
||||||
prog = 'pylorax'
|
"""run()
|
||||||
|
|
||||||
print "%s version %d.%d" % (prog, version[0], version[1],)
|
Generate install images.
|
||||||
|
|
||||||
def collectRepos(args):
|
"""
|
||||||
"""collectRepos(args)
|
|
||||||
|
|
||||||
Get the main repo (the first one) and then build a list of all remaining
|
print("\n+================================================+")
|
||||||
repos in the list. Sanitize each repo URL for proper yum syntax.
|
print("| Creating instroot tree to build images from... |")
|
||||||
|
print("+================================================+\n")
|
||||||
|
|
||||||
"""
|
self.instroot = pylorax.instroot.InstRoot(yumconf=self.yumconf, arch=self.buildarch, treedir=self.treedir, updates=self.updates)
|
||||||
|
|
||||||
if args is None or args == []:
|
def showVersion(self, driver=None):
|
||||||
return '', []
|
"""showVersion(driver)
|
||||||
|
|
||||||
repolist = []
|
Display program name (driver) and version number. If prog is an empty
|
||||||
for repospec in args:
|
string or None, use the value 'pylorax'.
|
||||||
if repospec.startswith('/'):
|
|
||||||
repo = "file://%s" % (repospec,)
|
|
||||||
print("Adding local repo:\n %s" % (repo,))
|
|
||||||
repolist.append(repo)
|
|
||||||
elif repospec.startswith('http://') or repospec.startswith('ftp://'):
|
|
||||||
print("Adding remote repo:\n %s" % (repospec,))
|
|
||||||
repolist.append(repospec)
|
|
||||||
|
|
||||||
repo = repolist[0]
|
"""
|
||||||
extrarepos = []
|
|
||||||
|
|
||||||
if len(repolist) > 1:
|
if prog is None or prog == '':
|
||||||
for extra in repolist[1:]:
|
prog = 'pylorax'
|
||||||
print("Adding extra repo:\n %s" % (extra,))
|
|
||||||
extrarepos.append(extra)
|
|
||||||
|
|
||||||
return repo, extrarepos
|
print "%s version %d.%d" % (prog, version[0], version[1],)
|
||||||
|
|
||||||
def initializeDirs(output):
|
def cleanup(self, trash=[]):
|
||||||
"""initializeDirs(output)
|
"""cleanup(trash)
|
||||||
|
|
||||||
Create directories used for image generation. The only required
|
Given a list of things to remove, cleanup() will remove them if it can.
|
||||||
parameter is the main output directory specified by the user.
|
Never fails, just tries to remove things and returns regardless of
|
||||||
|
failures removing things.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not os.path.isdir(output):
|
if trash != []:
|
||||||
os.makedirs(output, mode=0755)
|
for item in trash:
|
||||||
|
if os.path.isdir(item):
|
||||||
|
shutil.rmtree(item, ignore_errors=True)
|
||||||
|
else:
|
||||||
|
os.unlink(item)
|
||||||
|
|
||||||
conf['tmpdir'] = tempfile.mkdtemp('XXXXXX', 'lorax.tmp.', conf['tmpdir'])
|
if os.path.isdir(conf['tmpdir']):
|
||||||
buildinstdir = tempfile.mkdtemp('XXXXXX', 'buildinstall.tree.', conf['tmpdir'])
|
shutil.rmtree(conf['tmpdir'], ignore_errors=True)
|
||||||
treedir = tempfile.mkdtemp('XXXXXX', 'treedir.', conf['tmpdir'])
|
|
||||||
cachedir = tempfile.mkdtemp('XXXXXX', 'yumcache.', conf['tmpdir'])
|
|
||||||
|
|
||||||
print("Working directories:")
|
def getBuildArch(self):
|
||||||
print(" tmpdir = %s" % (conf['tmpdir'],))
|
"""getBuildArch()
|
||||||
print(" buildinstdir = %s" % (buildinstdir,))
|
|
||||||
print(" treedir = %s" % (treedir,))
|
|
||||||
print(" cachedir = %s" % (cachedir,))
|
|
||||||
|
|
||||||
return buildinstdir, treedir, cachedir
|
Query the configured yum repositories to determine our build architecture,
|
||||||
|
which is the architecture of the anaconda package in the repositories.
|
||||||
|
|
||||||
def writeYumConf(cachedir=None, repo=None, extrarepos=[], mirrorlist=[]):
|
This function is based on a subset of what repoquery(1) does.
|
||||||
"""writeYumConf(cachedir=None, repo=None, [extrarepos=[], mirrorlist=[]])
|
|
||||||
|
|
||||||
Generate a temporary yum.conf file for image generation. The required
|
"""
|
||||||
parameters are the cachedir that yum should use and the main repo to use.
|
|
||||||
|
|
||||||
Optional parameters are a list of extra repositories to add to the
|
uname_arch = os.uname()[4]
|
||||||
yum.conf file. The mirrorlist parameter is a list of yum mirrorlists
|
|
||||||
that should be added to the yum.conf file.
|
|
||||||
|
|
||||||
Returns the path to the temporary yum.conf file on success, None of failure.
|
if self.yumconf == '' or self.yumconf is None or not os.path.isfile(self.yumconf):
|
||||||
"""
|
return uname_arch
|
||||||
|
|
||||||
if cachedir is None or repo is None:
|
repoq = yum.YumBase()
|
||||||
return None
|
repoq.doConfigSetup()
|
||||||
|
|
||||||
tmpdir = conf['tmpdir']
|
try:
|
||||||
(fd, yumconf) = tempfile.mkstemp(prefix='yum.conf', dir=tmpdir)
|
repoq.doRepoSetup()
|
||||||
f = os.fdopen(fd, 'w')
|
except yum.Errors.RepoError, e:
|
||||||
|
sys.stderr.write("ERROR: could not query yum repository for build arch, defaulting to %s\n" % (uname_arch,))
|
||||||
|
return uname_arch
|
||||||
|
|
||||||
f.write("[main]\n")
|
repoq.doSackSetup(rpmUtils.arch.getArchList())
|
||||||
f.write("cachedir=%s\n" % (cachedir,))
|
repoq.doTsSetup()
|
||||||
f.write("keepcache=0\n")
|
|
||||||
f.write("gpgcheck=0\n")
|
|
||||||
f.write("plugins=0\n")
|
|
||||||
f.write("reposdir=\n")
|
|
||||||
f.write("tsflags=nodocs\n\n")
|
|
||||||
f.write("[loraxrepo]\n")
|
|
||||||
f.write("name=lorax repo\n")
|
|
||||||
f.write("baseurl=%s\n" % (repo,))
|
|
||||||
f.write("enabled=1\n\n")
|
|
||||||
|
|
||||||
if extrarepos != []:
|
ret_arch = None
|
||||||
n = 1
|
for pkg in repoq.pkgSack.simplePkgList():
|
||||||
for extra in extrarepos:
|
(n, a, e, v, r) = pkg
|
||||||
f.write("[lorax-extrarepo-%d]\n" % (n,))
|
if n == 'anaconda':
|
||||||
f.write("name=lorax extra repo %d\n" % (n,))
|
ret_arch = a
|
||||||
f.write("baseurl=%s\n" % (extra,))
|
break
|
||||||
f.write("enabled=1\n")
|
|
||||||
n += 1
|
|
||||||
|
|
||||||
if mirrorlist != []:
|
if ret_arch is None:
|
||||||
n = 1
|
ret_arch = uname_arch
|
||||||
for mirror in mirrorlist:
|
|
||||||
f.write("[lorax-mirrorlistrepo-%d]\n" % (n,))
|
|
||||||
f.write("name=lorax mirrorlist repo %d\n" % (n,))
|
|
||||||
f.write("mirrorlist=%s\n" % (extra,))
|
|
||||||
f.write("enabled=1\n")
|
|
||||||
n += 1
|
|
||||||
|
|
||||||
f.close()
|
print("Building images for %s" % (ret_arch,))
|
||||||
print("Wrote lorax yum configuration to %s" % (yumconf,))
|
|
||||||
|
|
||||||
return yumconf
|
return ret_arch
|
||||||
|
|
||||||
def getBuildArch(yumconf=None):
|
def _collectRepos(self, repos):
|
||||||
"""getBuildArch(yumconf=None)
|
"""_collectRepos(repos)
|
||||||
|
|
||||||
Query the configured yum repositories to determine our build architecture,
|
Get the main repo (the first one) and then build a list of all remaining
|
||||||
which is the architecture of the anaconda package in the repositories.
|
repos in the list. Sanitize each repo URL for proper yum syntax.
|
||||||
|
|
||||||
The required argument is yumconf, which is the path to the yum configuration
|
"""
|
||||||
file to use.
|
|
||||||
|
|
||||||
This function is based on a subset of what repoquery(1) does.
|
if repos is None or repos == []:
|
||||||
|
return '', []
|
||||||
|
|
||||||
"""
|
repolist = []
|
||||||
|
for repospec in repos:
|
||||||
|
if repospec.startswith('/'):
|
||||||
|
repo = "file://%s" % (repospec,)
|
||||||
|
print("Adding local repo:\n %s" % (repo,))
|
||||||
|
repolist.append(repo)
|
||||||
|
elif repospec.startswith('http://') or repospec.startswith('ftp://'):
|
||||||
|
print("Adding remote repo:\n %s" % (repospec,))
|
||||||
|
repolist.append(repospec)
|
||||||
|
|
||||||
uname_arch = os.uname()[4]
|
repo = repolist[0]
|
||||||
|
extrarepos = []
|
||||||
|
|
||||||
if yumconf == '' or yumconf is None or not os.path.isfile(yumconf):
|
if len(repolist) > 1:
|
||||||
return uname_arch
|
for extra in repolist[1:]:
|
||||||
|
print("Adding extra repo:\n %s" % (extra,))
|
||||||
|
extrarepos.append(extra)
|
||||||
|
|
||||||
repoq = yum.YumBase()
|
return repo, extrarepos
|
||||||
repoq.doConfigSetup()
|
|
||||||
|
|
||||||
try:
|
def initializeDirs(self):
|
||||||
repoq.doRepoSetup()
|
"""_initializeDirs()
|
||||||
except yum.Errors.RepoError, e:
|
|
||||||
sys.stderr.write("ERROR: could not query yum repository for build arch, defaulting to %s\n" % (uname_arch,))
|
|
||||||
return uname_arch
|
|
||||||
|
|
||||||
repoq.doSackSetup(rpmUtils.arch.getArchList())
|
Create directories used for image generation.
|
||||||
repoq.doTsSetup()
|
|
||||||
|
|
||||||
ret_arch = None
|
"""
|
||||||
for pkg in repoq.pkgSack.simplePkgList():
|
|
||||||
(n, a, e, v, r) = pkg
|
|
||||||
if n == 'anaconda':
|
|
||||||
ret_arch = a
|
|
||||||
break
|
|
||||||
|
|
||||||
if ret_arch is None:
|
if not os.path.isdir(self.output):
|
||||||
ret_arch = uname_arch
|
os.makedirs(self.output, mode=0755)
|
||||||
|
|
||||||
print("Building images for %s" % (ret_arch,))
|
conf['tmpdir'] = tempfile.mkdtemp('XXXXXX', 'lorax.tmp.', conf['tmpdir'])
|
||||||
|
buildinstdir = tempfile.mkdtemp('XXXXXX', 'buildinstall.tree.', conf['tmpdir'])
|
||||||
|
treedir = tempfile.mkdtemp('XXXXXX', 'treedir.', conf['tmpdir'])
|
||||||
|
cachedir = tempfile.mkdtemp('XXXXXX', 'yumcache.', conf['tmpdir'])
|
||||||
|
|
||||||
return ret_arch
|
print("Working directories:")
|
||||||
|
print(" tmpdir = %s" % (conf['tmpdir'],))
|
||||||
|
print(" buildinstdir = %s" % (buildinstdir,))
|
||||||
|
print(" treedir = %s" % (treedir,))
|
||||||
|
print(" cachedir = %s" % (cachedir,))
|
||||||
|
|
||||||
def cleanup(trash=[]):
|
return buildinstdir, treedir, cachedir
|
||||||
"""cleanup(trash)
|
|
||||||
|
|
||||||
Given a list of things to remove, cleanup() will remove them if it can.
|
def _writeYumConf():
|
||||||
Never fails, just tries to remove things and returns regardless of
|
"""_writeYumConf()
|
||||||
failures removing things.
|
|
||||||
|
|
||||||
"""
|
Generate a temporary yum.conf file for image generation. Returns the path
|
||||||
|
to the temporary yum.conf file on success, None of failure.
|
||||||
|
"""
|
||||||
|
|
||||||
if trash != []:
|
tmpdir = conf['tmpdir']
|
||||||
for item in trash:
|
(fd, yumconf) = tempfile.mkstemp(prefix='yum.conf', dir=tmpdir)
|
||||||
if os.path.isdir(item):
|
f = os.fdopen(fd, 'w')
|
||||||
shutil.rmtree(item, ignore_errors=True)
|
|
||||||
else:
|
|
||||||
os.unlink(item)
|
|
||||||
|
|
||||||
if os.path.isdir(conf['tmpdir']):
|
f.write("[main]\n")
|
||||||
shutil.rmtree(conf['tmpdir'], ignore_errors=True)
|
f.write("cachedir=%s\n" % (self.cachedir,))
|
||||||
|
f.write("keepcache=0\n")
|
||||||
|
f.write("gpgcheck=0\n")
|
||||||
|
f.write("plugins=0\n")
|
||||||
|
f.write("reposdir=\n")
|
||||||
|
f.write("tsflags=nodocs\n\n")
|
||||||
|
f.write("[loraxrepo]\n")
|
||||||
|
f.write("name=lorax repo\n")
|
||||||
|
f.write("baseurl=%s\n" % (self.repo,))
|
||||||
|
f.write("enabled=1\n\n")
|
||||||
|
|
||||||
return
|
if self.extrarepos != []:
|
||||||
|
n = 1
|
||||||
|
for extra in self.extrarepos:
|
||||||
|
f.write("[lorax-extrarepo-%d]\n" % (n,))
|
||||||
|
f.write("name=lorax extra repo %d\n" % (n,))
|
||||||
|
f.write("baseurl=%s\n" % (extra,))
|
||||||
|
f.write("enabled=1\n")
|
||||||
|
n += 1
|
||||||
|
|
||||||
|
if self.mirrorlist != []:
|
||||||
|
n = 1
|
||||||
|
for mirror in self.mirrorlist:
|
||||||
|
f.write("[lorax-mirrorlistrepo-%d]\n" % (n,))
|
||||||
|
f.write("name=lorax mirrorlist repo %d\n" % (n,))
|
||||||
|
f.write("mirrorlist=%s\n" % (mirror,))
|
||||||
|
f.write("enabled=1\n")
|
||||||
|
n += 1
|
||||||
|
|
||||||
|
f.close()
|
||||||
|
print("Wrote lorax yum configuration to %s" % (yumconf,))
|
||||||
|
|
||||||
|
return yumconf
|
||||||
|
@ -29,9 +29,8 @@ import pylorax
|
|||||||
sys.path.insert(0, '/usr/share/yum-cli')
|
sys.path.insert(0, '/usr/share/yum-cli')
|
||||||
import yummain
|
import yummain
|
||||||
|
|
||||||
# Create inst root from which stage 1 and stage 2 images are built.
|
class InstRoot:
|
||||||
def createInstRoot(yumconf=None, arch=None, treedir=None, updates=None):
|
"""InstRoot(yumconf=None, arch=None, treedir=None, [updates=None])
|
||||||
"""createInstRoot(yumconf=None, arch=None, treedir=None, [updates=None])
|
|
||||||
|
|
||||||
Create a instroot tree for the specified architecture. The list of
|
Create a instroot tree for the specified architecture. The list of
|
||||||
packages to install are specified in the /etc/lorax/packages and
|
packages to install are specified in the /etc/lorax/packages and
|
||||||
@ -50,335 +49,310 @@ def createInstRoot(yumconf=None, arch=None, treedir=None, updates=None):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if yumconf is None or arch is None or treedir is None:
|
# Create inst root from which stage 1 and stage 2 images are built.
|
||||||
return False
|
def __init__(self, yumconf=None, arch=None, treedir=None, updates=None):
|
||||||
|
self.yumconf = yumconf
|
||||||
|
self.arch = arch
|
||||||
|
self.treedir = treedir
|
||||||
|
self.updates = updates
|
||||||
|
|
||||||
# on 64-bit systems, make sure we use lib64 as the lib directory
|
# XXX: these tests should raise exceptions
|
||||||
if arch.endswith('64') or arch == 's390x':
|
if yumconf is None or arch is None or treedir is None:
|
||||||
libdir = 'lib64'
|
return False
|
||||||
else:
|
|
||||||
libdir = 'lib'
|
|
||||||
|
|
||||||
# the directory where the instroot will be created
|
# on 64-bit systems, make sure we use lib64 as the lib directory
|
||||||
destdir = os.path.join(treedir, 'install')
|
if self.arch.endswith('64') or self.arch == 's390x':
|
||||||
os.makedirs(destdir)
|
self.libdir = 'lib64'
|
||||||
|
else:
|
||||||
|
self.libdir = 'lib'
|
||||||
|
|
||||||
# build a list of packages to install
|
# the directory where the instroot will be created
|
||||||
packages = set()
|
self.destdir = os.path.join(self.treedir, 'install')
|
||||||
|
if not os.path.isdir(self.destdir):
|
||||||
|
os.makedirs(self.destdir)
|
||||||
|
|
||||||
packages_files = []
|
# build a list of packages to install
|
||||||
packages_files.append(os.path.join(pylorax.conf['confdir'], 'packages'))
|
self.packages = self._getPackageList()
|
||||||
packages_files.append(os.path.join(pylorax.conf['confdir'], arch, 'packages'))
|
|
||||||
|
|
||||||
for pfile in packages_files:
|
# install the packages to the instroot
|
||||||
if os.path.isfile(pfile):
|
self._installPackages()
|
||||||
f = open(pfile, 'r')
|
|
||||||
for line in f.readlines():
|
|
||||||
line = line.strip()
|
|
||||||
|
|
||||||
if line.startswith('#') or line == '':
|
# scrub instroot
|
||||||
continue
|
self._scrubInstRoot()
|
||||||
|
|
||||||
if line.startswith('-'):
|
def _getPackageList(self):
|
||||||
try:
|
packages = set()
|
||||||
packages.remove(line[1:])
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
packages.add(line)
|
|
||||||
|
|
||||||
|
packages_files = []
|
||||||
|
packages_files.append(os.path.join(pylorax.conf['confdir'], 'packages'))
|
||||||
|
packages_files.append(os.path.join(pylorax.conf['confdir'], self.arch, 'packages'))
|
||||||
|
|
||||||
|
for pfile in packages_files:
|
||||||
|
if os.path.isfile(pfile):
|
||||||
|
f = open(pfile, 'r')
|
||||||
|
for line in f.readlines():
|
||||||
|
line = line.strip()
|
||||||
|
|
||||||
|
if line.startswith('#') or line == '':
|
||||||
|
continue
|
||||||
|
|
||||||
|
if line.startswith('-'):
|
||||||
|
try:
|
||||||
|
packages.remove(line[1:])
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
packages.add(line)
|
||||||
|
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
packages = list(packages)
|
||||||
|
packages.sort()
|
||||||
|
|
||||||
|
return packages
|
||||||
|
|
||||||
|
# Call yummain to install the list of packages to destdir
|
||||||
|
def _installPackages(self):
|
||||||
|
# build the list of arguments to pass to yum
|
||||||
|
arglist = ['-c', self.yumconf]
|
||||||
|
arglist.append("--installroot=%s" % (self.destdir,))
|
||||||
|
arglist += ['install', '-y'] + self.packages
|
||||||
|
|
||||||
|
# do some prep work on the destdir before calling yum
|
||||||
|
os.makedirs(os.path.join(self.destdir, 'usr', 'lib', 'debug'))
|
||||||
|
os.makedirs(os.path.join(self.destdir, 'usr', 'src', 'debug'))
|
||||||
|
os.makedirs(os.path.join(self.destdir, 'tmp'))
|
||||||
|
os.makedirs(os.path.join(self.destdir, 'var', 'log'))
|
||||||
|
os.makedirs(os.path.join(self.destdir, 'var', 'lib'))
|
||||||
|
os.symlink(os.path.join(os.path.sep, 'tmp'), os.path.join(self.destdir, 'var', 'lib', 'xkb'))
|
||||||
|
|
||||||
|
# XXX: sort through yum errcodes and return False for actual bad things
|
||||||
|
# we care about
|
||||||
|
errcode = yummain.user_main(arglist, exit_code=False)
|
||||||
|
|
||||||
|
# Scrub the instroot tree (remove files we don't want, modify settings, etc)
|
||||||
|
def _scrubInstRoot(self):
|
||||||
|
print
|
||||||
|
|
||||||
|
# drop custom configuration files in to the instroot
|
||||||
|
dogtailconf = os.path.join(pylorax.conf['datadir'], 'dogtail-%conf.xml')
|
||||||
|
if os.path.isfile(dogtailconf):
|
||||||
|
os.makedirs(os.path.join(destdir, '.gconf', 'desktop', 'gnome', 'interface'))
|
||||||
|
f = open(os.path.join(destdir, '.gconf', 'desktop', '%gconf.xml'), 'w')
|
||||||
f.close()
|
f.close()
|
||||||
|
f = open(os.path.join(destdir, '.gconf', 'desktop', 'gnome', '%gconf.xml'), 'w')
|
||||||
|
f.close()
|
||||||
|
dest = os.path.join(destdir, '.gconf', 'desktop', 'gnome', 'interface', '%gconf.xml')
|
||||||
|
print "Installing %s..." % (os.path.join(os.path.sep, '.gconf', 'desktop', 'gnome', 'interface', '%gconf.xml'),)
|
||||||
|
shutil.copy(dogtailconf, dest)
|
||||||
|
|
||||||
packages = list(packages)
|
# create selinux config
|
||||||
packages.sort()
|
if os.path.isfile(os.path.join(destdir, 'etc', 'selinux', 'targeted')):
|
||||||
|
src = os.path.join(pylorax.conf['datadir'], 'selinux-config')
|
||||||
|
if os.path.isfile(src):
|
||||||
|
dest = os.path.join(destdir, 'etc', 'selinux', 'config')
|
||||||
|
print "Installing %s..." % (os.path.join(os.path.sep, 'etc', 'selinux', 'config'),)
|
||||||
|
shutil.copy(src, dest)
|
||||||
|
|
||||||
# install the packages to the instroot
|
# create libuser.conf
|
||||||
if not installPackages(yumconf=yumconf, destdir=destdir, packages=packages):
|
src = os.path.join(pylorax.conf['datadir'], 'libuser.conf')
|
||||||
sys.stderr.write("ERROR: Could not install packages.\n")
|
dest = os.path.join(destdir, 'etc', 'libuser.conf')
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if not scrubInstRoot(destdir=destdir, libdir=libdir, arch=arch):
|
|
||||||
sys.stderr.write("ERROR: Could not scrub instroot.\n")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
# Call yummain to install the list of packages to destdir
|
|
||||||
def installPackages(yumconf=None, destdir=None, packages=None):
|
|
||||||
"""installPackages(yumconf=yumconf, destdir=destdir, packages=packages)
|
|
||||||
|
|
||||||
Call yummain to install the list of packages. All parameters are
|
|
||||||
required. yumconf is the yum configuration file created for this
|
|
||||||
run of lorax. destdir is the installroot that yum should install to.
|
|
||||||
packages is a list of package names that yum should install.
|
|
||||||
|
|
||||||
yum will resolve dependencies, so it is not necessary to list every
|
|
||||||
package you want in the instroot.
|
|
||||||
|
|
||||||
This function returns True on success, False on failre.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
if yumconf is None or destdir is None or packages is None or packages == []:
|
|
||||||
return False
|
|
||||||
|
|
||||||
# build the list of arguments to pass to yum
|
|
||||||
arglist = ['-c', yumconf]
|
|
||||||
arglist.append("--installroot=%s" % (destdir,))
|
|
||||||
arglist += ['install', '-y'] + packages
|
|
||||||
|
|
||||||
# do some prep work on the destdir before calling yum
|
|
||||||
os.makedirs(os.path.join(destdir, 'usr', 'lib', 'debug'))
|
|
||||||
os.makedirs(os.path.join(destdir, 'usr', 'src', 'debug'))
|
|
||||||
os.makedirs(os.path.join(destdir, 'tmp'))
|
|
||||||
os.makedirs(os.path.join(destdir, 'var', 'log'))
|
|
||||||
os.makedirs(os.path.join(destdir, 'var', 'lib'))
|
|
||||||
os.symlink(os.path.join(os.path.sep, 'tmp'), os.path.join(destdir, 'var', 'lib', 'xkb'))
|
|
||||||
|
|
||||||
# XXX: sort through yum errcodes and return False for actual bad things
|
|
||||||
# we care about
|
|
||||||
errcode = yummain.user_main(arglist, exit_code=False)
|
|
||||||
return True
|
|
||||||
|
|
||||||
# Scrub the instroot tree (remove files we don't want, modify settings, etc)
|
|
||||||
def scrubInstRoot(destdir=None, libdir='lib', arch=None):
|
|
||||||
"""scrubInstRoot(destdir=None, libdir='lib', arch=None)
|
|
||||||
|
|
||||||
Clean up the newly created instroot and make the tree more suitable to
|
|
||||||
run the installer.
|
|
||||||
|
|
||||||
destdir is the path to the instroot. libdir is the subdirectory in
|
|
||||||
/usr for libraries (either lib or lib64). arch is the architecture
|
|
||||||
the image is for (e.g., i386, x86_64, ppc, s390x, alpha, sparc).
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
if destdir is None or not os.path.isdir(destdir) or arch is None:
|
|
||||||
return False
|
|
||||||
|
|
||||||
print
|
|
||||||
|
|
||||||
# drop custom configuration files in to the instroot
|
|
||||||
dogtailconf = os.path.join(pylorax.conf['datadir'], 'dogtail-%conf.xml')
|
|
||||||
if os.path.isfile(dogtailconf):
|
|
||||||
os.makedirs(os.path.join(destdir, '.gconf', 'desktop', 'gnome', 'interface'))
|
|
||||||
f = open(os.path.join(destdir, '.gconf', 'desktop', '%gconf.xml'), 'w')
|
|
||||||
f.close()
|
|
||||||
f = open(os.path.join(destdir, '.gconf', 'desktop', 'gnome', '%gconf.xml'), 'w')
|
|
||||||
f.close()
|
|
||||||
dest = os.path.join(destdir, '.gconf', 'desktop', 'gnome', 'interface', '%gconf.xml')
|
|
||||||
print "Installing %s..." % (os.path.join(os.path.sep, '.gconf', 'desktop', 'gnome', 'interface', '%gconf.xml'),)
|
|
||||||
shutil.copy(dogtailconf, dest)
|
|
||||||
|
|
||||||
# create selinux config
|
|
||||||
if os.path.isfile(os.path.join(destdir, 'etc', 'selinux', 'targeted')):
|
|
||||||
src = os.path.join(pylorax.conf['datadir'], 'selinux-config')
|
|
||||||
if os.path.isfile(src):
|
if os.path.isfile(src):
|
||||||
dest = os.path.join(destdir, 'etc', 'selinux', 'config')
|
print "Installing %s..." % (os.path.join(os.path.sep, 'etc', 'libuser.conf'),)
|
||||||
print "Installing %s..." % (os.path.join(os.path.sep, 'etc', 'selinux', 'config'),)
|
|
||||||
shutil.copy(src, dest)
|
shutil.copy(src, dest)
|
||||||
|
|
||||||
# create libuser.conf
|
# figure out the gtk+ theme to keep
|
||||||
src = os.path.join(pylorax.conf['datadir'], 'libuser.conf')
|
gtkrc = os.path.join(destdir, 'etc', 'gtk-2.0', 'gtkrc')
|
||||||
dest = os.path.join(destdir, 'etc', 'libuser.conf')
|
gtk_theme_name = None
|
||||||
if os.path.isfile(src):
|
gtk_icon_themes = []
|
||||||
print "Installing %s..." % (os.path.join(os.path.sep, 'etc', 'libuser.conf'),)
|
gtk_engine = None
|
||||||
shutil.copy(src, dest)
|
|
||||||
|
|
||||||
# figure out the gtk+ theme to keep
|
if os.path.isfile(gtkrc):
|
||||||
gtkrc = os.path.join(destdir, 'etc', 'gtk-2.0', 'gtkrc')
|
print "\nReading %s..." % (os.path.join(os.path.sep, 'etc', 'gtk-2.0', 'gtkrc'),)
|
||||||
gtk_theme_name = None
|
f = open(gtkrc, 'r')
|
||||||
gtk_icon_themes = []
|
lines = f.readlines()
|
||||||
gtk_engine = None
|
f.close()
|
||||||
|
|
||||||
if os.path.isfile(gtkrc):
|
for line in lines:
|
||||||
print "\nReading %s..." % (os.path.join(os.path.sep, 'etc', 'gtk-2.0', 'gtkrc'),)
|
line = line.strip()
|
||||||
f = open(gtkrc, 'r')
|
if line.startswith('gtk-theme-name'):
|
||||||
lines = f.readlines()
|
gtk_theme_name = line[line.find('=') + 1:].replace('"', '').strip()
|
||||||
f.close()
|
print " gtk-theme-name: %s" % (gtk_theme_name,)
|
||||||
|
|
||||||
for line in lines:
|
# find the engine for this theme
|
||||||
line = line.strip()
|
gtkrc = os.path.join(destdir, 'usr', 'share', 'themes', gtk_theme_name, 'gtk-2.0', 'gtkrc')
|
||||||
if line.startswith('gtk-theme-name'):
|
if os.path.isfile(gtkrc):
|
||||||
gtk_theme_name = line[line.find('=') + 1:].replace('"', '').strip()
|
f = open(gtkrc, 'r')
|
||||||
print " gtk-theme-name: %s" % (gtk_theme_name,)
|
engine_lines = f.readlines()
|
||||||
|
|
||||||
# find the engine for this theme
|
|
||||||
gtkrc = os.path.join(destdir, 'usr', 'share', 'themes', gtk_theme_name, 'gtk-2.0', 'gtkrc')
|
|
||||||
if os.path.isfile(gtkrc):
|
|
||||||
f = open(gtkrc, 'r')
|
|
||||||
engine_lines = f.readlines()
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
for engine_line in engine_lines:
|
|
||||||
engine_line = engine_line.strip()
|
|
||||||
|
|
||||||
if engine_line.find('engine') != -1:
|
|
||||||
gtk_engine = engine_line[engine_line.find('"') + 1:].replace('"', '')
|
|
||||||
print " gtk-engine: %s" % (gtk_engine,)
|
|
||||||
break
|
|
||||||
elif line.startswith('gtk-icon-theme-name'):
|
|
||||||
icon_theme = line[line.find('=') + 1:].replace('"', '').strip()
|
|
||||||
print " gtk-icon-theme-name: %s" % (icon_theme,)
|
|
||||||
gtk_icon_themes.append(icon_theme)
|
|
||||||
|
|
||||||
# bring in all inherited themes
|
|
||||||
while True:
|
|
||||||
icon_theme_index = os.path.join(destdir, 'usr', 'share', 'icons', icon_theme, 'index.theme')
|
|
||||||
if os.path.isfile(icon_theme_index):
|
|
||||||
inherits = False
|
|
||||||
f = open(icon_theme_index, 'r')
|
|
||||||
icon_lines = f.readlines()
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
for icon_line in icon_lines:
|
for engine_line in engine_lines:
|
||||||
icon_line = icon_line.strip()
|
engine_line = engine_line.strip()
|
||||||
if icon_line.startswith('Inherits='):
|
|
||||||
inherits = True
|
if engine_line.find('engine') != -1:
|
||||||
icon_theme = icon_line[icon_line.find('=') + 1:].replace('"', '')
|
gtk_engine = engine_line[engine_line.find('"') + 1:].replace('"', '')
|
||||||
print " inherits gtk-icon-theme-name: %s" % (icon_theme,)
|
print " gtk-engine: %s" % (gtk_engine,)
|
||||||
gtk_icon_themes.append(icon_theme)
|
|
||||||
break
|
break
|
||||||
|
elif line.startswith('gtk-icon-theme-name'):
|
||||||
|
icon_theme = line[line.find('=') + 1:].replace('"', '').strip()
|
||||||
|
print " gtk-icon-theme-name: %s" % (icon_theme,)
|
||||||
|
gtk_icon_themes.append(icon_theme)
|
||||||
|
|
||||||
if not inherits:
|
# bring in all inherited themes
|
||||||
|
while True:
|
||||||
|
icon_theme_index = os.path.join(destdir, 'usr', 'share', 'icons', icon_theme, 'index.theme')
|
||||||
|
if os.path.isfile(icon_theme_index):
|
||||||
|
inherits = False
|
||||||
|
f = open(icon_theme_index, 'r')
|
||||||
|
icon_lines = f.readlines()
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
for icon_line in icon_lines:
|
||||||
|
icon_line = icon_line.strip()
|
||||||
|
if icon_line.startswith('Inherits='):
|
||||||
|
inherits = True
|
||||||
|
icon_theme = icon_line[icon_line.find('=') + 1:].replace('"', '')
|
||||||
|
print " inherits gtk-icon-theme-name: %s" % (icon_theme,)
|
||||||
|
gtk_icon_themes.append(icon_theme)
|
||||||
|
break
|
||||||
|
|
||||||
|
if not inherits:
|
||||||
|
break
|
||||||
|
else:
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
break
|
|
||||||
|
|
||||||
theme_path = os.path.join(destdir, 'usr', 'share', 'themes')
|
theme_path = os.path.join(destdir, 'usr', 'share', 'themes')
|
||||||
if os.path.isdir(theme_path):
|
if os.path.isdir(theme_path):
|
||||||
for theme in os.listdir(theme_path):
|
for theme in os.listdir(theme_path):
|
||||||
if theme != gtk_theme_name:
|
if theme != gtk_theme_name:
|
||||||
theme = os.path.join(theme_path, theme)
|
theme = os.path.join(theme_path, theme)
|
||||||
shutil.rmtree(theme, ignore_errors=True)
|
shutil.rmtree(theme, ignore_errors=True)
|
||||||
|
|
||||||
icon_path = os.path.join(destdir, 'usr', 'share', 'icons')
|
icon_path = os.path.join(destdir, 'usr', 'share', 'icons')
|
||||||
if os.path.isdir(icon_path):
|
if os.path.isdir(icon_path):
|
||||||
for icon in os.listdir(icon_path):
|
for icon in os.listdir(icon_path):
|
||||||
try:
|
try:
|
||||||
if gtk_icon_themes.index(icon):
|
if gtk_icon_themes.index(icon):
|
||||||
|
continue
|
||||||
|
except ValueError:
|
||||||
|
icon = os.path.join(icon_path, icon)
|
||||||
|
shutil.rmtree(icon, ignore_errors=True)
|
||||||
|
|
||||||
|
tmp_path = os.path.join(destdir, 'usr', libdir, 'gtk-2.0')
|
||||||
|
if os.path.isdir(tmp_path):
|
||||||
|
for subdir in os.listdir(tmp_path):
|
||||||
|
new_path = os.path.join(tmp_path, subdir, 'engines')
|
||||||
|
if os.path.isdir(new_path):
|
||||||
|
for engine in os.listdir(new_path):
|
||||||
|
if engine.find(gtk_engine) == -1:
|
||||||
|
tmp_engine = os.path.join(new_path, engine)
|
||||||
|
os.unlink(tmp_engine)
|
||||||
|
|
||||||
|
# clean out unused locales
|
||||||
|
langtable = os.path.join(destdir, 'usr', 'lib', 'anaconda', 'lang-table')
|
||||||
|
localepath = os.path.join(destdir, 'usr', 'share', 'locale')
|
||||||
|
if os.path.isfile(langtable):
|
||||||
|
locales = set()
|
||||||
|
all_locales = set()
|
||||||
|
|
||||||
|
f = open(langtable, 'r')
|
||||||
|
lines = f.readlines()
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
print "Keeping locales used during installation..."
|
||||||
|
for line in lines:
|
||||||
|
line = line.strip()
|
||||||
|
|
||||||
|
if line == '' or line.startswith('#'):
|
||||||
continue
|
continue
|
||||||
except ValueError:
|
|
||||||
icon = os.path.join(icon_path, icon)
|
|
||||||
shutil.rmtree(icon, ignore_errors=True)
|
|
||||||
|
|
||||||
tmp_path = os.path.join(destdir, 'usr', libdir, 'gtk-2.0')
|
fields = line.split('\t')
|
||||||
if os.path.isdir(tmp_path):
|
|
||||||
for subdir in os.listdir(tmp_path):
|
|
||||||
new_path = os.path.join(tmp_path, subdir, 'engines')
|
|
||||||
if os.path.isdir(new_path):
|
|
||||||
for engine in os.listdir(new_path):
|
|
||||||
if engine.find(gtk_engine) == -1:
|
|
||||||
tmp_engine = os.path.join(new_path, engine)
|
|
||||||
os.unlink(tmp_engine)
|
|
||||||
|
|
||||||
# clean out unused locales
|
if os.path.isdir(os.path.join(localepath, fields[1])):
|
||||||
langtable = os.path.join(destdir, 'usr', 'lib', 'anaconda', 'lang-table')
|
locales.add(fields[1])
|
||||||
localepath = os.path.join(destdir, 'usr', 'share', 'locale')
|
|
||||||
if os.path.isfile(langtable):
|
|
||||||
locales = set()
|
|
||||||
all_locales = set()
|
|
||||||
|
|
||||||
f = open(langtable, 'r')
|
locale = fields[3].split('.')[0]
|
||||||
lines = f.readlines()
|
if os.path.isdir(os.path.join(localepath, locale)):
|
||||||
f.close()
|
locales.add(locale)
|
||||||
|
|
||||||
print "Keeping locales used during installation..."
|
for locale in os.listdir(os.path.join(destdir, 'usr', 'share', 'locale')):
|
||||||
for line in lines:
|
all_locales.add(locale)
|
||||||
line = line.strip()
|
|
||||||
|
|
||||||
if line == '' or line.startswith('#'):
|
print "Removing unused locales..."
|
||||||
continue
|
locales_to_remove = list(all_locales.difference(locales))
|
||||||
|
for locale in locales_to_remove:
|
||||||
|
rmpath = os.path.join(destdir, 'usr', 'share', 'locale', locale)
|
||||||
|
shutil.rmtree(rmpath, ignore_errors=True)
|
||||||
|
|
||||||
fields = line.split('\t')
|
# fix up some links for man page related stuff
|
||||||
|
for file in ['nroff', 'groff', 'iconv', 'geqn', 'gtbl', 'gpic', 'grefer']:
|
||||||
|
src = os.path.join('mnt', 'sysimage', 'usr', 'bin', file)
|
||||||
|
dst = os.path.join(destdir, 'usr', 'bin', file)
|
||||||
|
if not os.path.isfile(dst):
|
||||||
|
os.symlink(src, dst)
|
||||||
|
|
||||||
if os.path.isdir(os.path.join(localepath, fields[1])):
|
# install anaconda stub programs as instroot programs
|
||||||
locales.add(fields[1])
|
for subdir in ['lib', 'firmware']:
|
||||||
|
subdir = os.path.join(destdir, subdir)
|
||||||
|
if not os.path.isdir(subdir):
|
||||||
|
os.makedirs(subdir)
|
||||||
|
|
||||||
locale = fields[3].split('.')[0]
|
for subdir in ['modules', 'firmware']:
|
||||||
if os.path.isdir(os.path.join(localepath, locale)):
|
src = os.path.join(os.path.sep, subdir)
|
||||||
locales.add(locale)
|
dst = os.path.join(destdir, 'lib', subdir)
|
||||||
|
shutil.rmtree(dst, ignore_errors=True)
|
||||||
for locale in os.listdir(os.path.join(destdir, 'usr', 'share', 'locale')):
|
|
||||||
all_locales.add(locale)
|
|
||||||
|
|
||||||
print "Removing unused locales..."
|
|
||||||
locales_to_remove = list(all_locales.difference(locales))
|
|
||||||
for locale in locales_to_remove:
|
|
||||||
rmpath = os.path.join(destdir, 'usr', 'share', 'locale', locale)
|
|
||||||
shutil.rmtree(rmpath, ignore_errors=True)
|
|
||||||
|
|
||||||
# fix up some links for man page related stuff
|
|
||||||
for file in ['nroff', 'groff', 'iconv', 'geqn', 'gtbl', 'gpic', 'grefer']:
|
|
||||||
src = os.path.join('mnt', 'sysimage', 'usr', 'bin', file)
|
|
||||||
dst = os.path.join(destdir, 'usr', 'bin', file)
|
|
||||||
if not os.path.isfile(dst):
|
|
||||||
os.symlink(src, dst)
|
os.symlink(src, dst)
|
||||||
|
|
||||||
# install anaconda stub programs as instroot programs
|
for prog in ['raidstart', 'raidstop', 'losetup', 'list-harddrives', 'loadkeys', 'mknod', 'sysklogd']:
|
||||||
for subdir in ['lib', 'firmware']:
|
stub = "%s-stub" % (prog,)
|
||||||
subdir = os.path.join(destdir, subdir)
|
src = os.path.join(destdir, 'usr', 'lib', 'anaconda', stub)
|
||||||
if not os.path.isdir(subdir):
|
dst = os.path.join(destdir, 'usr', 'bin', prog)
|
||||||
os.makedirs(subdir)
|
if os.path.isfile(src) and not os.path.isfile(dst):
|
||||||
|
shutil.copy2(src, dst)
|
||||||
|
|
||||||
for subdir in ['modules', 'firmware']:
|
# copy in boot loader files
|
||||||
src = os.path.join(os.path.sep, subdir)
|
bootpath = os.path.join(destdir, 'usr', 'lib', 'anaconda-runtime', 'boot')
|
||||||
dst = os.path.join(destdir, 'lib', subdir)
|
if not os.path.isdir(bootpath):
|
||||||
shutil.rmtree(dst, ignore_errors=True)
|
os.makedirs(bootpath)
|
||||||
os.symlink(src, dst)
|
|
||||||
|
|
||||||
for prog in ['raidstart', 'raidstop', 'losetup', 'list-harddrives', 'loadkeys', 'mknod', 'sysklogd']:
|
if arch == 'i386' or arch == 'x86_64':
|
||||||
stub = "%s-stub" % (prog,)
|
for bootfile in os.listdir(os.path.join(destdir, 'boot')):
|
||||||
src = os.path.join(destdir, 'usr', 'lib', 'anaconda', stub)
|
if bootfile.startswith('memtest'):
|
||||||
dst = os.path.join(destdir, 'usr', 'bin', prog)
|
src = os.path.join(destdir, 'boot', bootfile)
|
||||||
if os.path.isfile(src) and not os.path.isfile(dst):
|
dst = os.path.join(bootpath, bootfile)
|
||||||
|
shutil.copy2(src, dst)
|
||||||
|
elif arch.startswith('sparc'):
|
||||||
|
for bootfile in os.listdir(os.path.join(destdir, 'boot')):
|
||||||
|
if bootfile.endswith('.b'):
|
||||||
|
src = os.path.join(destdir, 'boot', bootfile)
|
||||||
|
dst = os.path.join(bootpath, bootfile)
|
||||||
|
shutil.copy2(src, dst)
|
||||||
|
elif arch.startswith('ppc'):
|
||||||
|
src = os.path.join(destdir, 'boot', 'efika.forth')
|
||||||
|
dst = os.path.join(bootpath, 'efika.forth')
|
||||||
shutil.copy2(src, dst)
|
shutil.copy2(src, dst)
|
||||||
|
elif arch == 'alpha':
|
||||||
|
src = os.path.join(destdir, 'boot', 'bootlx')
|
||||||
|
dst = os.path.join(bootpath, 'bootlx')
|
||||||
|
shutil.copy2(src, dst)
|
||||||
|
elif arch == 'ia64':
|
||||||
|
src = os.path.join(destdir, 'boot', 'efi', 'EFI', 'redhat')
|
||||||
|
shutil.rmtree(bootpath, ignore_errors=True)
|
||||||
|
shutil.copytree(src, bootpath)
|
||||||
|
|
||||||
# copy in boot loader files
|
# move the yum repos configuration directory
|
||||||
bootpath = os.path.join(destdir, 'usr', 'lib', 'anaconda-runtime', 'boot')
|
src = os.path.join(destdir, 'etc', 'yum.repos.d')
|
||||||
if not os.path.isdir(bootpath):
|
dst = os.path.join(destdir, 'etc', 'anaconda.repos.d')
|
||||||
os.makedirs(bootpath)
|
if os.path.isdir(src):
|
||||||
|
shutil.rmtree(dst, ignore_errors=True)
|
||||||
|
shutil.move(src, dst)
|
||||||
|
|
||||||
if arch == 'i386' or arch == 'x86_64':
|
# remove things we do not want in the instroot
|
||||||
for bootfile in os.listdir(os.path.join(destdir, 'boot')):
|
for subdir in ['boot', 'home', 'root', 'tmp']:
|
||||||
if bootfile.startswith('memtest'):
|
shutil.rmtree(os.path.join(destdir, subdir), ignore_errors=True)
|
||||||
src = os.path.join(destdir, 'boot', bootfile)
|
|
||||||
dst = os.path.join(bootpath, bootfile)
|
|
||||||
shutil.copy2(src, dst)
|
|
||||||
elif arch.startswith('sparc'):
|
|
||||||
for bootfile in os.listdir(os.path.join(destdir, 'boot')):
|
|
||||||
if bootfile.endswith('.b'):
|
|
||||||
src = os.path.join(destdir, 'boot', bootfile)
|
|
||||||
dst = os.path.join(bootpath, bootfile)
|
|
||||||
shutil.copy2(src, dst)
|
|
||||||
elif arch.startswith('ppc'):
|
|
||||||
src = os.path.join(destdir, 'boot', 'efika.forth')
|
|
||||||
dst = os.path.join(bootpath, 'efika.forth')
|
|
||||||
shutil.copy2(src, dst)
|
|
||||||
elif arch == 'alpha':
|
|
||||||
src = os.path.join(destdir, 'boot', 'bootlx')
|
|
||||||
dst = os.path.join(bootpath, 'bootlx')
|
|
||||||
shutil.copy2(src, dst)
|
|
||||||
elif arch == 'ia64':
|
|
||||||
src = os.path.join(destdir, 'boot', 'efi', 'EFI', 'redhat')
|
|
||||||
shutil.rmtree(bootpath, ignore_errors=True)
|
|
||||||
shutil.copytree(src, bootpath)
|
|
||||||
|
|
||||||
# move the yum repos configuration directory
|
for subdir in ['doc', 'info']:
|
||||||
src = os.path.join(destdir, 'etc', 'yum.repos.d')
|
shutil.rmtree(os.path.join(destdir, 'usr', 'share', subdir), ignore_errors=True)
|
||||||
dst = os.path.join(destdir, 'etc', 'anaconda.repos.d')
|
|
||||||
if os.path.isdir(src):
|
|
||||||
shutil.rmtree(dst, ignore_errors=True)
|
|
||||||
shutil.move(src, dst)
|
|
||||||
|
|
||||||
# remove things we do not want in the instroot
|
for libname in glob.glob(os.path.join(destdir, 'usr', libdir), 'libunicode-lite*'):
|
||||||
for subdir in ['boot', 'home', 'root', 'tmp']:
|
shutil.rmtree(libname, ignore_errors=True)
|
||||||
shutil.rmtree(os.path.join(destdir, subdir), ignore_errors=True)
|
|
||||||
|
|
||||||
for subdir in ['doc', 'info']:
|
|
||||||
shutil.rmtree(os.path.join(destdir, 'usr', 'share', subdir), ignore_errors=True)
|
|
||||||
|
|
||||||
for libname in glob.glob(os.path.join(destdir, 'usr', libdir), 'libunicode-lite*'):
|
|
||||||
shutil.rmtree(libname, ignore_errors=True)
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
Loading…
Reference in New Issue
Block a user