Redirected the error messages output from yum; Improved the links copy
function;
This commit is contained in:
parent
1324551367
commit
4910deac71
@ -110,10 +110,10 @@ class Lorax(object):
|
|||||||
self.create_initrd()
|
self.create_initrd()
|
||||||
|
|
||||||
print("%sCreating the install.img%s" % bold)
|
print("%sCreating the install.img%s" % bold)
|
||||||
self.create_installimg()
|
#self.create_installimg()
|
||||||
|
|
||||||
print("%sCreating the boot.iso%s" % bold)
|
print("%sCreating the boot.iso%s" % bold)
|
||||||
self.create_bootiso()
|
#self.create_bootiso()
|
||||||
|
|
||||||
if self.conf.cleanup:
|
if self.conf.cleanup:
|
||||||
print("%sCleaning up%s" % bold)
|
print("%sCleaning up%s" % bold)
|
||||||
@ -202,8 +202,12 @@ class Lorax(object):
|
|||||||
self.conf.addAttr('yumconf')
|
self.conf.addAttr('yumconf')
|
||||||
self.conf.set(yumconf=yumconf)
|
self.conf.set(yumconf=yumconf)
|
||||||
|
|
||||||
|
# create the yum err file path
|
||||||
|
err_file = os.path.join(self.conf.tempdir, 'yum.errors')
|
||||||
|
|
||||||
# create the Yum object
|
# create the Yum object
|
||||||
self.yum = Yum(yumconf=self.conf.yumconf, installroot=self.conf.treedir)
|
self.yum = Yum(yumconf=self.conf.yumconf, installroot=self.conf.treedir,
|
||||||
|
err_file=err_file)
|
||||||
|
|
||||||
# remove not needed attributes
|
# remove not needed attributes
|
||||||
self.conf.delAttr(['repo', 'extrarepos', 'mirrorlist', 'cachedir'])
|
self.conf.delAttr(['repo', 'extrarepos', 'mirrorlist', 'cachedir'])
|
||||||
@ -873,30 +877,23 @@ class Lorax(object):
|
|||||||
# calculate the size of the dosfs
|
# calculate the size of the dosfs
|
||||||
cmd = 'du -kcs %s | tail -n1 | awk \'{print $1}\'' % self.conf.efitreedir
|
cmd = 'du -kcs %s | tail -n1 | awk \'{print $1}\'' % self.conf.efitreedir
|
||||||
size = int(commands.getoutput(cmd)) + 100
|
size = int(commands.getoutput(cmd)) + 100
|
||||||
print('Size of the efiboot.img is %d' % size)
|
|
||||||
|
|
||||||
efiimage = os.path.join(self.conf.outdir, 'images', 'efiboot.img')
|
efiimage = os.path.join(self.conf.outdir, 'images', 'efiboot.img')
|
||||||
cmd = 'mkdosfs -n ANACONDA -C %s %s > /dev/null' % (efiimage, size)
|
cmd = 'mkdosfs -n ANACONDA -C %s %s > /dev/null' % (efiimage, size)
|
||||||
print cmd
|
|
||||||
out = commands.getoutput(cmd)
|
out = commands.getoutput(cmd)
|
||||||
print(out)
|
|
||||||
|
|
||||||
tempdir = os.path.join(self.conf.tempdir, 'efiimage')
|
tempdir = os.path.join(self.conf.tempdir, 'efiimage')
|
||||||
if not os.path.isdir(tempdir):
|
if not os.path.isdir(tempdir):
|
||||||
os.makedirs(tempdir)
|
os.makedirs(tempdir)
|
||||||
cmd = 'mount -o loop,shortname=winnt,umask=0777 -t vfat %s %s' % \
|
cmd = 'mount -o loop,shortname=winnt,umask=0777 -t vfat %s %s' % \
|
||||||
(efiimage, tempdir)
|
(efiimage, tempdir)
|
||||||
print cmd
|
|
||||||
out = commands.getoutput(cmd)
|
out = commands.getoutput(cmd)
|
||||||
print(out)
|
|
||||||
|
|
||||||
src = os.path.join(self.conf.efitreedir, '*')
|
src = os.path.join(self.conf.efitreedir, '*')
|
||||||
cp(src, tempdir)
|
cp(src, tempdir)
|
||||||
|
|
||||||
cmd = 'umount %s' % tempdir
|
cmd = 'umount %s' % tempdir
|
||||||
print(cmd)
|
|
||||||
out = commands.getoutput(cmd)
|
out = commands.getoutput(cmd)
|
||||||
print(out)
|
|
||||||
|
|
||||||
# copy efi to cd
|
# copy efi to cd
|
||||||
if not kernelfile and not initrd:
|
if not kernelfile and not initrd:
|
||||||
@ -952,36 +949,24 @@ class Lorax(object):
|
|||||||
partsize = int(commands.getoutput(cmd))
|
partsize = int(commands.getoutput(cmd))
|
||||||
disksize = 17408 + partsize + 17408
|
disksize = 17408 + partsize + 17408
|
||||||
disksize = disksize + (disksize % 512)
|
disksize = disksize + (disksize % 512)
|
||||||
print partsize
|
|
||||||
print disksize
|
|
||||||
|
|
||||||
efidiskimg = os.path.join(self.conf.imagesdir, 'efidisk.img')
|
efidiskimg = os.path.join(self.conf.imagesdir, 'efidisk.img')
|
||||||
touch(efidiskimg)
|
touch(efidiskimg)
|
||||||
|
|
||||||
cmd = 'dd if=/dev/zero of=%s count=1 bs=%s' % (efidiskimg, disksize)
|
cmd = 'dd if=/dev/zero of=%s count=1 bs=%s' % (efidiskimg, disksize)
|
||||||
print(cmd)
|
|
||||||
out = commands.getoutput(cmd)
|
out = commands.getoutput(cmd)
|
||||||
print(out)
|
|
||||||
|
|
||||||
cmd = 'losetup -v -f %s | awk \'{print $4}\'' % efidiskimg
|
cmd = 'losetup -v -f %s | awk \'{print $4}\'' % efidiskimg
|
||||||
print(cmd)
|
|
||||||
loop = commands.getoutput(cmd)
|
loop = commands.getoutput(cmd)
|
||||||
print(loop)
|
|
||||||
|
|
||||||
cmd = 'dmsetup create efiboot --table "0 %s linear %s 0"' % (disksize / 512, loop)
|
cmd = 'dmsetup create efiboot --table "0 %s linear %s 0"' % (disksize / 512, loop)
|
||||||
print(cmd)
|
|
||||||
out = commands.getoutput(cmd)
|
out = commands.getoutput(cmd)
|
||||||
print(out)
|
|
||||||
|
|
||||||
cmd = 'parted --script /dev/mapper/efiboot mklabel gpt unit b mkpart \'"EFI System Partition"\' fat32 17408 %s set 1 boot on' % (partsize + 17408)
|
cmd = 'parted --script /dev/mapper/efiboot mklabel gpt unit b mkpart \'"EFI System Partition"\' fat32 17408 %s set 1 boot on' % (partsize + 17408)
|
||||||
print(cmd)
|
|
||||||
out = commands.getoutput(cmd)
|
out = commands.getoutput(cmd)
|
||||||
print(out)
|
|
||||||
|
|
||||||
cmd = 'dd if=%s of=/dev/mapper/efibootp1' % efiimage
|
cmd = 'dd if=%s of=/dev/mapper/efibootp1' % efiimage
|
||||||
print(cmd)
|
|
||||||
out = commands.getoutput(cmd)
|
out = commands.getoutput(cmd)
|
||||||
print(out)
|
|
||||||
|
|
||||||
cmd = 'dmsetup remove /dev/mapper/efibootp1'
|
cmd = 'dmsetup remove /dev/mapper/efibootp1'
|
||||||
out = commands.getoutput(cmd)
|
out = commands.getoutput(cmd)
|
||||||
@ -1000,6 +985,7 @@ class Lorax(object):
|
|||||||
|
|
||||||
# XEN
|
# XEN
|
||||||
if self.conf.buildarch in ('i386',):
|
if self.conf.buildarch in ('i386',):
|
||||||
|
print('Installing the XEN kernel')
|
||||||
self.yum.addPackages('kernel-PAE')
|
self.yum.addPackages('kernel-PAE')
|
||||||
self.yum.install()
|
self.yum.install()
|
||||||
|
|
||||||
@ -1069,13 +1055,11 @@ class Lorax(object):
|
|||||||
mkisocmd = 'mkisofs -v -o %s %s %s -R -J -V %s -T -graft-points isolinux=%s images=%s %s' % (os.path.join(self.conf.imagesdir, 'boot.iso'), biosargs, efiargs, self.conf.product, self.conf.isolinuxdir, self.conf.imagesdir, efigraft)
|
mkisocmd = 'mkisofs -v -o %s %s %s -R -J -V %s -T -graft-points isolinux=%s images=%s %s' % (os.path.join(self.conf.imagesdir, 'boot.iso'), biosargs, efiargs, self.conf.product, self.conf.isolinuxdir, self.conf.imagesdir, efigraft)
|
||||||
|
|
||||||
out = commands.getoutput(mkisocmd)
|
out = commands.getoutput(mkisocmd)
|
||||||
print(out)
|
|
||||||
|
|
||||||
hybrid = os.path.join(os.sep, 'usr', 'bin', 'isohybrid')
|
hybrid = os.path.join(os.sep, 'usr', 'bin', 'isohybrid')
|
||||||
if os.path.exists(hybrid):
|
if os.path.exists(hybrid):
|
||||||
cmd = '%s %s' % (hybrid, os.path.join(self.conf.imagesdir, 'boot.iso'))
|
cmd = '%s %s' % (hybrid, os.path.join(self.conf.imagesdir, 'boot.iso'))
|
||||||
out = commands.getoutput(cmd)
|
out = commands.getoutput(cmd)
|
||||||
print(out)
|
|
||||||
|
|
||||||
def clean_up(self, trash=[]):
|
def clean_up(self, trash=[]):
|
||||||
for item in trash:
|
for item in trash:
|
||||||
|
@ -160,7 +160,6 @@ class InitRD(object):
|
|||||||
m = re.match(r'^.*/(?P<name>.*)\.ko$', dep)
|
m = re.match(r'^.*/(?P<name>.*)\.ko$', dep)
|
||||||
if m.group('name') not in modules:
|
if m.group('name') not in modules:
|
||||||
changed = True
|
changed = True
|
||||||
print('Adding module dependency %s' % m.group('name'))
|
|
||||||
modules.add(m.group('name'))
|
modules.add(m.group('name'))
|
||||||
|
|
||||||
srcdir = os.path.join(self.conf.treedir, 'lib', 'modules', self.kernelver)
|
srcdir = os.path.join(self.conf.treedir, 'lib', 'modules', self.kernelver)
|
||||||
|
@ -56,6 +56,21 @@ def __copy(src, dst, verbose=False, remove=False):
|
|||||||
basename = os.path.basename(src)
|
basename = os.path.basename(src)
|
||||||
dst = os.path.join(dst, basename)
|
dst = os.path.join(dst, basename)
|
||||||
|
|
||||||
|
if os.path.islink(src):
|
||||||
|
print('Got link %s' % src)
|
||||||
|
target = os.readlink(src)
|
||||||
|
|
||||||
|
if os.path.exists(dst):
|
||||||
|
os.unlink(dst)
|
||||||
|
os.symlink(target, dst)
|
||||||
|
|
||||||
|
if remove:
|
||||||
|
if verbose:
|
||||||
|
print("removing '%s'" % src)
|
||||||
|
os.unlink(src)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
if os.path.isdir(src):
|
if os.path.isdir(src):
|
||||||
if os.path.isfile(dst):
|
if os.path.isfile(dst):
|
||||||
sys.stderr.write("omitting directory '%s'\n" % src)
|
sys.stderr.write("omitting directory '%s'\n" % src)
|
||||||
|
@ -2,10 +2,6 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import commands
|
import commands
|
||||||
|
|
||||||
import logging
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
|
||||||
logger = logging.getLogger('pylorax')
|
|
||||||
|
|
||||||
|
|
||||||
def genmodinfo(path, output):
|
def genmodinfo(path, output):
|
||||||
mods = {}
|
mods = {}
|
||||||
@ -24,7 +20,7 @@ def genmodinfo(path, output):
|
|||||||
filename = os.path.join(path, 'modules.%s' % file)
|
filename = os.path.join(path, 'modules.%s' % file)
|
||||||
f = open(filename, 'r')
|
f = open(filename, 'r')
|
||||||
except IOError:
|
except IOError:
|
||||||
logger.error('cannot open file %s', filename)
|
sys.stderr.write('cannot open file %s\n', filename)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
@ -35,14 +31,11 @@ def genmodinfo(path, output):
|
|||||||
if line in mods:
|
if line in mods:
|
||||||
modname, ext = os.path.splitext(line)
|
modname, ext = os.path.splitext(line)
|
||||||
if modname in blacklist:
|
if modname in blacklist:
|
||||||
logger.info('skipping %s', modname)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
outtext = commands.getoutput('modinfo -F description %s' % mods[line])
|
outtext = commands.getoutput('modinfo -F description %s' % mods[line])
|
||||||
desc = outtext.split('\n')[0]
|
desc = outtext.split('\n')[0]
|
||||||
desc = desc.strip()
|
desc = desc.strip()
|
||||||
|
|
||||||
# XXX why we need to do this?
|
|
||||||
desc = desc[:65]
|
desc = desc[:65]
|
||||||
|
|
||||||
if not desc:
|
if not desc:
|
||||||
|
@ -69,7 +69,7 @@ class Callback(yum.rpmtrans.SimpleCliCallBack):
|
|||||||
|
|
||||||
|
|
||||||
class Yum(object):
|
class Yum(object):
|
||||||
def __init__(self, yumconf='/etc/yum/yum.conf', installroot='/'):
|
def __init__(self, yumconf='/etc/yum/yum.conf', installroot='/', err_file='/dev/null'):
|
||||||
self.yb = yum.YumBase()
|
self.yb = yum.YumBase()
|
||||||
|
|
||||||
self.yumconf = os.path.abspath(yumconf)
|
self.yumconf = os.path.abspath(yumconf)
|
||||||
@ -112,7 +112,20 @@ class Yum(object):
|
|||||||
|
|
||||||
cb = yum.callbacks.ProcessTransBaseCallback()
|
cb = yum.callbacks.ProcessTransBaseCallback()
|
||||||
rpmcb = Callback()
|
rpmcb = Callback()
|
||||||
|
|
||||||
|
# XXX ugly error output hack
|
||||||
|
# we redirect the error output from rpm to err_file,
|
||||||
|
# so it does not show up in our "nice" output :)
|
||||||
|
# we should put the errors to some file,
|
||||||
|
# which we can parse later for serious errors
|
||||||
|
standard_err = os.dup(2)
|
||||||
|
my_err = open(err_file, 'w')
|
||||||
|
os.dup2(my_err.fileno(), 2)
|
||||||
|
# now process the transactions without errors showing up
|
||||||
self.yb.processTransaction(callback=cb, rpmDisplay=rpmcb)
|
self.yb.processTransaction(callback=cb, rpmDisplay=rpmcb)
|
||||||
|
# and put the standard error output back
|
||||||
|
os.dup2(standard_err, 2)
|
||||||
|
my_err.close()
|
||||||
|
|
||||||
self.yb.closeRpmDB()
|
self.yb.closeRpmDB()
|
||||||
self.yb.close()
|
self.yb.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user