diff options
author | 2008-07-28 03:48:15 +0000 | |
---|---|---|
committer | 2014-06-22 00:21:25 +0200 | |
commit | 5f0db96de0a9e4012a347134e72464a09d6dbd83 (patch) | |
tree | 4f8d39face71cb1e7855b136162ea09d6f778f65 | |
parent | adding a new module to create/parse quickstart profiles (diff) | |
download | gli-qs.tar.gz gli-qs.tar.bz2 gli-qs.zip |
updates to GLIPortage to increase capabilities of it's command-line mode.qs
svn path=/branches/qs/; revision=1912
-rw-r--r-- | src/GLIPortage.py | 96 |
1 files changed, 91 insertions, 5 deletions
diff --git a/src/GLIPortage.py b/src/GLIPortage.py index fd5a200..9766a5f 100644 --- a/src/GLIPortage.py +++ b/src/GLIPortage.py @@ -12,6 +12,7 @@ import re import os import sys import GLIUtility +import GLILogger from GLIException import GLIException class GLIPortage(object): @@ -330,7 +331,7 @@ class GLIPortage(object): def usage(progname): print """ -Usage: %s [-c|--chroot-dir <chroot directory>] [-g|--grp] [-s|--stage3] [-h|--help] +Usage: %s [-c|--chroot-dir <chroot directory>] [-g|--grp] [-s|--stage3] [-l|--logfile <logfile>] [-h|--help] Options: @@ -345,11 +346,14 @@ Options: -k|--kernel Install kernel and modules from LiveCD into the chroot + -l|--logfile Sets the logfile for the ouput. defaults to cwd/install.log + -h|--help Display this help """ % (progname) if __name__ == "__main__": chroot_dir = "/mnt/gentoo" + logfile = None mode = None grp_packages = [] progname = sys.argv.pop(0) @@ -357,6 +361,8 @@ if __name__ == "__main__": arg = sys.argv.pop(0) if arg == "-c" or arg == "--chroot-dir": chroot_dir = sys.argv.pop(0) + elif arg == "-l" or arg == "--logfile": + logfile = sys.argv.pop(0) elif arg == "-g" or arg == "--grp": mode = "grp" elif arg == "-s" or arg == "--stage3": @@ -371,8 +377,8 @@ if __name__ == "__main__": sys.exit(1) else: grp_packages.append(arg) - - gliportage = GLIPortage(chroot_dir, True, None, False, None, None) + logger = GLILogger.Logger(logfile) + gliportage = GLIPortage(chroot_dir, logger, True, None, False) if mode == "stage3": try: systempkgs = gliportage.get_system_packages() @@ -441,8 +447,88 @@ if __name__ == "__main__": gliportage.add_pkg_to_world(pkg) print "GRP install complete!" elif mode == "kernel": - kernelpkg = gliportage.get_best_version_vdb("sys-kernel/livecd-kernel") - gliportage.copy_pkg_to_chroot(kernelpkg) + #Code copied from GLIArchTemplate + GLIUtility.spawn(r"find /var/db/pkg -type f -name CONTENTS | xargs awk '/^obj \/lib\/modules\// { print $2; }' > /tmp/kernel_modules") + files = GLIUtility.spawn('ls -1 --color=no /boot/System* /boot/kernel* /boot/initr* $(for i in $(find "/lib/modules/" -type f); do grep --quiet "^${i}$" /tmp/kernel_modules || echo ${i}; done); rm /tmp/kernel_modules 2>/dev/null', return_output=True)[1].strip().split("\n") + if not files: + print "Error: could not determine files to copy for livecd-kernel" + sys.exit(1) + if not GLIUtility.exitsuccess(GLIUtility.spawn("cp -p --parents %s %s/" % (" ".join(files), chroot_dir))): + print "Error: could not copy kernel, initramfs, or modules" + sys.exit(1) + GLIUtility.spawn("depmod -a") + portage_info = {} + for line in GLIUtility.spawn(r"emerge --info 2>/dev/null | grep '^[A-Z0-9_]\+=' | sed -e 's:\" \([A-Z]\):\"\n\1:g'", chroot=chroot_dir, return_output=True)[1].strip().split("\n"): + parts = line.split("=", 1) + portage_info[parts[0]] = parts[1].strip("'\"") + arch = portage_info["ACCEPT_KEYWORDS"].split(" ")[0].strip("~") + values = { + 'CATEGORY': "sys-kernel", + 'CBUILD': portage_info['CHOST'], + 'CFLAGS': portage_info['CFLAGS'], + 'CHOST': portage_info['CHOST'], + 'CONTENTS': "", +# 'COUNTER': "0", + 'CXXFLAGS': portage_info.get("CXXFLAGS", ""), + 'DEPEND': "", + 'DESCRIPTION': "LiveCD kernel as installed by GLI", + 'EAPI': "0", + 'FEATURES': "", + 'HOMEPAGE': "http://www.gentoo.org/proj/en/releng/installer/", + 'INHERITED': "eutils", + 'KEYWORDS': arch, + 'LICENSE': "", + 'NEEDED': "", + 'PDEPEND': "", + 'PF': "livecd-kernel-1", + 'PROVIDE': "virtual/alsa", + 'RDEPEND': "", + 'SLOT': "0", + 'USE': arch + } + vdbdir = chroot_dir + "/var/db/pkg/sys-kernel/livecd-kernel-1" + os.mkdir(vdbdir) + for tmpfile in values: + fileout = open(vdbdir + "/" + tmpfile, "w") + fileout.write(values[tmpfile] + "\n") + fileout.close() + fileout = open(vdbdir + "/livecd-kernel-1.ebuild", "w") + fileout.write("inherit eutils\n\nDESCRIPTION=\"LiveCD kernel as installed by GLI\"\nHOMEPAGE=\"http://www.gentoo.org/proj/en/releng/installer/\"\nSRC_URI=\nLICENSE=\nSLOT=0\nKEYWORDS=\"%s\"\nIUSE=\nDEPEND=\nPROVIDE=virtual/alsa\n" % arch) + fileout.close() + print "wrote ebuild" + counter = gliportage.update_counter() + counter_f = open(vdbdir + "/COUNTER", "w") + counter_f.write(str(counter)) + counter_f.close() + GLIUtility.spawn("echo | bzip2 > %s/environment.bz2" % vdbdir) + print "counter stuff done" + kernelpkg = gliportage.get_best_version_vdb_chroot("sys-kernel/livecd-kernel") +# print "Copying "+kernelpkg+" to chroot environment" +# gliportage.copy_pkg_to_chroot(kernelpkg) + print "Normally we would've copied the livecd-kernel via the GRP process, but now done a different way" + #20:05 <+agaffney> dberkholz: you can't do the kernel anymore, since it's not a binpkg + #20:05 <+agaffney> I got rid of that behavior + #20:05 <+agaffney> just copy the contents of /boot and /lib/modules + #20:05 <+agaffney> that's what the installer does + + gliportage.add_pkg_to_world(kernelpkg) + + try: + os.stat(chroot_dir + "/usr/src/linux") + except: + kernels = os.listdir(chroot_dir+"/usr/src") + found_a_kernel = False + counter = 0 + while not found_a_kernel: + if (len(kernels[counter]) > 6) and (kernels[counter][0:6]=="linux-"): + exitstatus = GLIUtility.spawn("ln -s /usr/src/"+kernels[counter]+ " /usr/src/linux",chroot=chroot_dir) + if not GLIUtility.exitsuccess(exitstatus): + print "Error: Could not make a /usr/src/linux symlink" + sys.exit(1) + found_a_kernel = True + else : + counter = counter + 1 + print "Kernel sources:"+kernel_pkg+" emerged and /usr/src/linux symlinked." print "LiveCD kernel installed!" else: print "You must specify an operating mode (-g or -s)!" |