/[gli]/branches/qs/src/GLIPortage.py
Gentoo

Diff of /branches/qs/src/GLIPortage.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1339 Revision 1832
3# This source code is distributed under the terms of version 2 of the GNU 3# This source code is distributed under the terms of version 2 of the GNU
4# General Public License as published by the Free Software Foundation, a copy 4# General Public License as published by the Free Software Foundation, a copy
5# of which can be found in the main directory of this project. 5# of which can be found in the main directory of this project.
6Gentoo Linux Installer 6Gentoo Linux Installer
7 7
8$Id: GLIPortage.py,v 1.50 2006/03/05 04:16:04 agaffney Exp $ 8$Id: GLIPortage.py,v 1.57 2006/09/13 18:29:13 agaffney Exp $
9""" 9"""
10 10
11import re 11import re
12import os 12import os
13import sys 13import sys
14import GLIUtility 14import GLIUtility
15from GLIException import GLIException 15from GLIException import GLIException
16 16
17class GLIPortage(object): 17class GLIPortage(object):
18 18
19 def __init__(self, chroot_dir, grp_install, logger, debug, cc, compile_logfile): 19 def __init__(self, chroot_dir, logger, debug, cc, compile_logfile):
20 self._chroot_dir = chroot_dir 20 self._chroot_dir = chroot_dir
21 self._grp_install = grp_install
22 self._logger = logger 21 self._logger = logger
23 self._debug = debug 22 self._debug = debug
24 self._cc = cc 23 self._cc = cc
25 self._compile_logfile = compile_logfile 24 self._compile_logfile = compile_logfile
26 25
27 def get_deps(self, pkgs): 26 def get_deps(self, pkgs, grp_install=False):
28 pkglist = [] 27 pkglist = []
29 if isinstance(pkgs, str): 28 if isinstance(pkgs, str):
30 pkgs = pkgs.split() 29 pkgs = pkgs.split()
31 for pkg in pkgs: 30 for pkg in pkgs:
32 if not pkg: continue 31 if not pkg: continue
33 if self._debug: self._logger.log("get_deps(): pkg is " + pkg) 32 if self._debug: self._logger.log("get_deps(): pkg is " + pkg)
34 if not self._grp_install or not self.get_best_version_vdb(pkg): 33 if not grp_install or not self.get_best_version_vdb(pkg):
35 if self._debug: self._logger.log("get_deps(): grabbing compile deps") 34 if self._debug: self._logger.log("get_deps(): grabbing compile deps")
36 tmppkglist = GLIUtility.spawn("emerge -p " + pkg + r" 2>/dev/null | grep -e '^\[[a-z]' | cut -d ']' -f2 | sed -e 's:^ ::' -e 's: .\+$::'", chroot=self._chroot_dir, return_output=True)[1].strip().split("\n") 35 tmppkglist = GLIUtility.spawn("emerge -p " + pkg + r" 2>/dev/null | grep -e '^\[[a-z]' | cut -d ']' -f2 | sed -e 's:^ ::' -e 's: .\+$::'", chroot=self._chroot_dir, return_output=True)[1].strip().split("\n")
37 else: 36 else:
38 if self._debug: self._logger.log("get_deps(): grabbing binary deps") 37 if self._debug: self._logger.log("get_deps(): grabbing binary deps")
39 # The runtimedeps.py script generates a package install order that is *very* different from emerge itself 38 # The runtimedeps.py script generates a package install order that is *very* different from emerge itself
49 if self._debug: self._logger.log("get_deps(): checking to see if " + tmppkg + " is already in pkglist") 48 if self._debug: self._logger.log("get_deps(): checking to see if " + tmppkg + " is already in pkglist")
50 if not tmppkg in pkglist and not self.get_best_version_vdb_chroot("=" + tmppkg): 49 if not tmppkg in pkglist and not self.get_best_version_vdb_chroot("=" + tmppkg):
51 if self._debug: self._logger.log("get_deps(): adding " + tmppkg + " to pkglist") 50 if self._debug: self._logger.log("get_deps(): adding " + tmppkg + " to pkglist")
52 pkglist.append(tmppkg) 51 pkglist.append(tmppkg)
53 if self._debug: self._logger.log("get_deps(): pkglist is " + str(pkglist)) 52 if self._debug: self._logger.log("get_deps(): pkglist is " + str(pkglist))
53 if not pkglist:
54 raise GLIException("GetDepListError", 'fatal', 'get_deps', "Dep list is empty. This usually means there is no portage tree in the chroot")
54 return pkglist 55 return pkglist
55 56
56 def parse_vdb_contents(self, file): 57 def parse_vdb_contents(self, file):
57 entries = [] 58 entries = []
58 try: 59 try:
68 elif parts[0] == "sym": 69 elif parts[0] == "sym":
69 entries.append(" ".join(parts[1:4])) 70 entries.append(" ".join(parts[1:4]))
70 entries.sort() 71 entries.sort()
71 return entries 72 return entries
72 73
74 def update_counter(self):
75 try:
76 counter_f = open(self._chroot_dir + "/var/cache/edb/counter", "r")
77 counter = int(counter_f.readline().strip())
78 counter_f.close()
79 except:
80 counter = 0
81 counter += 1
82 if not os.path.isdir(self._chroot_dir + "/var"):
83 os.mkdir(self._chroot_dir + "/var", 0755)
84 if not os.path.isdir(self._chroot_dir + "/var/cache"):
85 os.mkdir(self._chroot_dir + "/var/cache", 0755)
86 if not os.path.isdir(self._chroot_dir + "/var/cache/edb"):
87 os.mkdir(self._chroot_dir + "/var/cache/edb", 0775)
88 # chown to root:portage
89 try:
90 counter_f = open(self._chroot_dir + "/var/cache/edb/counter", "w")
91 counter_f.write(str(counter))
92 counter_f.close()
93 except:
94 raise GLIException("UpdateCounterError", 'fatal', 'update_counter', "could not write new counter value")
95 return counter
96
73 def copy_pkg_to_chroot(self, package, use_root=False, ignore_missing=False): 97 def copy_pkg_to_chroot(self, package, use_root=False, ignore_missing=False):
74 symlinks = { '/bin': '/mnt/livecd/bin/', '/boot': '/mnt/livecd/boot/', '/lib': '/mnt/livecd/lib/', 98 symlinks = { '/bin': '/mnt/livecd/bin/', '/boot': '/mnt/livecd/boot/', '/lib': '/mnt/livecd/lib/',
75 '/opt': '/mnt/livecd/opt/', '/sbin': '/mnt/livecd/sbin/', '/usr': '/mnt/livecd/usr/', 99 '/opt': '/mnt/livecd/opt/', '/sbin': '/mnt/livecd/sbin/', '/usr': '/mnt/livecd/usr/',
76 '/etc/gconf': '/usr/livecd/gconf/' } 100 '/etc/gconf': '/usr/livecd/gconf/' }
77 101
78 tmpdir = "/var/tmp/portage" 102 tmpdir = "/var/tmp"
79 image_dir = tmpdir + "/" + package.split("/")[1] + "/image" 103 image_dir = tmpdir + "/portage/" + package + "/image"
80 root_cmd = "" 104 root_cmd = ""
81 tmp_chroot_dir = self._chroot_dir 105 tmp_chroot_dir = self._chroot_dir
82 portage_tmpdir = "/var/tmp/portage" 106 portage_tmpdir = "/var/tmp"
83 vdb_dir = "/var/db/pkg/" 107 vdb_dir = "/var/db/pkg/"
84 if use_root: 108 if use_root:
85 root_cmd = "ROOT=" + self._chroot_dir 109 root_cmd = "ROOT=" + self._chroot_dir
86 tmp_chroot_dir = "" 110 tmp_chroot_dir = ""
87 portage_tmpdir = self._chroot_dir + "/var/tmp/portage" 111 portage_tmpdir = self._chroot_dir + "/var/tmp"
88 vdb_dir = self._chroot_dir + "/var/db/pkg/" 112 vdb_dir = self._chroot_dir + "/var/db/pkg/"
89 113
90 # Create /tmp, /var/tmp, and /var/lib/portage with proper permissions 114 # Create /tmp, /var/tmp, and /var/lib/portage with proper permissions
91 oldumask = os.umask(0) 115 oldumask = os.umask(0)
92 if not os.path.exists(self._chroot_dir + "/tmp"): 116 if not os.path.exists(self._chroot_dir + "/tmp"):
129 # Copy the vdb entry for the package from the LiveCD to the chroot 153 # Copy the vdb entry for the package from the LiveCD to the chroot
130 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): copying vdb entry for " + package) 154 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): copying vdb entry for " + package)
131 if not GLIUtility.exitsuccess(GLIUtility.spawn("mkdir -p " + self._chroot_dir + "/var/db/pkg/" + package + " && cp -a /var/db/pkg/" + package + "/* " + self._chroot_dir + "/var/db/pkg/" + package, logfile=self._compile_logfile, append_log=True)): 155 if not GLIUtility.exitsuccess(GLIUtility.spawn("mkdir -p " + self._chroot_dir + "/var/db/pkg/" + package + " && cp -a /var/db/pkg/" + package + "/* " + self._chroot_dir + "/var/db/pkg/" + package, logfile=self._compile_logfile, append_log=True)):
132 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not copy vdb entry for " + package) 156 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not copy vdb entry for " + package)
133 157
158 # Update COUNTER
159 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): calling update_counter() to get updated COUNTER value for " + package)
160 counter = self.update_counter()
161 try:
162 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): updating COUNTER value (%s) in vdb entry for %s" % (self._chroot_dir + "/var/db/pkg/" + package + "/COUNTER", package))
163 counter_f = open(self._chroot_dir + "/var/db/pkg/" + package + "/COUNTER", "w")
164 counter_f.write(str(counter))
165 counter_f.close()
166 except:
167 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not update COUNTER for " + package)
168
134 # Create the image dir in the chroot 169 # Create the image dir in the chroot
135 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running 'mkdir -p " + self._chroot_dir + image_dir + "'") 170 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running 'mkdir -p " + self._chroot_dir + image_dir + "'")
136 if not GLIUtility.exitsuccess(GLIUtility.spawn("mkdir -p " + self._chroot_dir + image_dir, logfile=self._compile_logfile, append_log=True)): 171 if not GLIUtility.exitsuccess(GLIUtility.spawn("mkdir -p " + self._chroot_dir + image_dir, logfile=self._compile_logfile, append_log=True)):
137 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not create image dir for " + package) 172 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not create image dir for " + package)
138 173
139 # Create list of files for tar to work with from CONTENTS file in vdb entry 174 # Create list of files for tar to work with from CONTENTS file in vdb entry
140 entries = self.parse_vdb_contents("/var/db/pkg/" + package + "/CONTENTS") 175 entries = self.parse_vdb_contents("/var/db/pkg/" + package + "/CONTENTS")
141 if not entries: 176 if not entries:
142 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): no files for " + package + "...skipping tar and symlink fixup") 177 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): no files for " + package + "...skipping tar and symlink fixup")
143 else: 178 else:
144 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot: files for " + package + ": " + str(entries)) 179# if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot: files for " + package + ": " + str(entries))
145 try: 180 try:
146 tarfiles = open("/tmp/tarfilelist", "w") 181 tarfiles = open("/tmp/tarfilelist", "w")
147 for entry in entries: 182 for entry in entries:
148 parts = entry.split(" ") 183 parts = entry.split(" ")
149# # Hack for symlink crappiness 184# # Hack for symlink crappiness
159 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running 'tar -cp --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -xp'") 194 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running 'tar -cp --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -xp'")
160 if not GLIUtility.exitsuccess(GLIUtility.spawn("tar -cp --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -xp", logfile=self._compile_logfile, append_log=True)): 195 if not GLIUtility.exitsuccess(GLIUtility.spawn("tar -cp --files-from=/tmp/tarfilelist --no-recursion 2>/dev/null | tar -C " + self._chroot_dir + image_dir + " -xp", logfile=self._compile_logfile, append_log=True)):
161 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute tar for " + package) 196 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute tar for " + package)
162 197
163 # Fix mode, uid, and gid of directories 198 # Fix mode, uid, and gid of directories
164 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running find " + self._chroot_dir + image_dir + " -type d 2>/dev/null | sed -e 's:^" + self._chroot_dir + image_dir + "::' | grep -v '^$'") 199 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running find " + self._chroot_dir + image_dir + " -mindepth 1 -type d 2>/dev/null | sed -e 's:^" + self._chroot_dir + image_dir + "::' | grep -v '^$'")
165 dirlist = GLIUtility.spawn("find " + self._chroot_dir + image_dir + " -type d 2>/dev/null | sed -e 's:^" + self._chroot_dir + image_dir + "::' | grep -v '^$'", return_output=True)[1].strip().split("\n") 200 dirlist = GLIUtility.spawn("find " + self._chroot_dir + image_dir + " -mindepth 1 -type d 2>/dev/null | sed -e 's:^" + self._chroot_dir + image_dir + "::' | grep -v '^$'", return_output=True)[1].strip().split("\n")
166 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): found the following directories: " + str(dirlist)) 201 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): found the following directories: " + str(dirlist))
167 if not dirlist or dirlist[0] == "": 202 if not dirlist or dirlist[0] == "":
168 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "directory list entry for " + package + "...this shouldn't happen!") 203 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "directory list entry for " + package + "...this shouldn't happen!")
169 for dir in dirlist: 204 for dir in dirlist:
170 dirstat = os.stat(dir) 205 dirstat = os.stat(dir)
181# if not GLIUtility.exitsuccess(GLIUtility.spawn("mv " + self._chroot_dir + image_dir + symlinks[symlink] + " " + self._chroot_dir + image_dir + symlink)): 216# if not GLIUtility.exitsuccess(GLIUtility.spawn("mv " + self._chroot_dir + image_dir + symlinks[symlink] + " " + self._chroot_dir + image_dir + symlink)):
182# raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not fix " + symlink + " symlink ickiness for " + package) 217# raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not fix " + symlink + " symlink ickiness for " + package)
183 218
184 # Run pkg_setup 219 # Run pkg_setup
185 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running pkg_setup for " + package) 220 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running pkg_setup for " + package)
186 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " ebuild " + vdb_dir + package + "/*.ebuild setup", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)): 221 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " FEATURES=noauto ebuild " + vdb_dir + package + "/*.ebuild setup", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)):
187 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute pkg_setup for " + package) 222 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute pkg_setup for " + package)
188 223
189 # Run pkg_preinst 224 # Run pkg_preinst
190 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running preinst for " + package) 225 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running preinst for " + package)
191 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " ebuild " + vdb_dir + package + "/*.ebuild preinst", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)): 226 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " FEATURES=noauto ebuild " + vdb_dir + package + "/*.ebuild preinst", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)):
192 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute preinst for " + package) 227 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute preinst for " + package)
193 228
194 # Copy files from image_dir to chroot 229 # Copy files from image_dir to chroot
195 if not entries: 230 if not entries:
196 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): no files for " + package + "...skipping copy from image dir to /") 231 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): no files for " + package + "...skipping copy from image dir to /")
200 if not GLIUtility.exitsuccess(GLIUtility.spawn("tar -C " + self._chroot_dir + image_dir + "/ -cp . | tar -C " + self._chroot_dir + "/ -xp", logfile=self._compile_logfile, append_log=True)): 235 if not GLIUtility.exitsuccess(GLIUtility.spawn("tar -C " + self._chroot_dir + image_dir + "/ -cp . | tar -C " + self._chroot_dir + "/ -xp", logfile=self._compile_logfile, append_log=True)):
201 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not copy files from " + image_dir + " to / for " + package) 236 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not copy files from " + image_dir + " to / for " + package)
202 237
203 # Run pkg_postinst 238 # Run pkg_postinst
204 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running postinst for " + package) 239 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): running postinst for " + package)
205 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " ebuild " + vdb_dir + package + "/*.ebuild postinst", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)): 240 if not GLIUtility.exitsuccess(GLIUtility.spawn("env " + root_cmd + " PORTAGE_TMPDIR=" + portage_tmpdir + " FEATURES=noauto ebuild " + vdb_dir + package + "/*.ebuild postinst", chroot=tmp_chroot_dir, logfile=self._compile_logfile, append_log=True)):
206 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute postinst for " + package) 241 raise GLIException("CopyPackageToChrootError", 'fatal', 'copy_pkg_to_chroot', "Could not execute postinst for " + package)
207 242
208 # Remove image_dir 243 # Remove image_dir
209 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): removing " + image_dir + " for " + package) 244 if self._debug: self._logger.log("DEBUG: copy_pkg_to_chroot(): removing " + image_dir + " for " + package)
210 if not GLIUtility.exitsuccess(GLIUtility.spawn("rm -rf " + self._chroot_dir + image_dir, logfile=self._compile_logfile, append_log=True)): 245 if not GLIUtility.exitsuccess(GLIUtility.spawn("rm -rf " + self._chroot_dir + image_dir, logfile=self._compile_logfile, append_log=True)):
221 package = self.get_best_version_vdb_chroot(package) 256 package = self.get_best_version_vdb_chroot(package)
222 if not package: return False 257 if not package: return False
223 expr = re.compile('^=?(.+?/.+?)(-\d.+)?$') 258 expr = re.compile('^=?(.+?/.+?)(-\d.+)?$')
224 res = expr.match(package) 259 res = expr.match(package)
225 if res: 260 if res:
226 GLIUtility.spawn("echo " + res.group(1) + " >> " + self._chroot_dir + "/var/lib/portage/world") 261 world_f = open(self._chroot_dir + "/var/lib/portage/world", "a")
262 world_f.write(res.group(1) + "\n")
263 world_f.close()
227 264
228 def get_best_version_vdb(self, package): 265 def get_best_version_vdb(self, package):
229 if package.startswith('='): 266 if package.startswith('='):
230 package = package[1:] 267 package = package[1:]
231 if GLIUtility.is_file("/var/db/pkg/" + package): 268 if GLIUtility.is_file("/var/db/pkg/" + package):
246 return GLIUtility.spawn("portageq best_version / " + package, chroot=self._chroot_dir, return_output=True)[1].strip() 283 return GLIUtility.spawn("portageq best_version / " + package, chroot=self._chroot_dir, return_output=True)[1].strip()
247 284
248# def get_best_version_tree(self, package): 285# def get_best_version_tree(self, package):
249# return portage.best(tree.match(package)) 286# return portage.best(tree.match(package))
250 287
251 def emerge(self, packages, add_to_world=True): 288 def emerge(self, packages, grp_install=False, add_to_world=True):
252 if isinstance(packages, str): 289 if isinstance(packages, str):
253 packages = packages.split() 290 packages = packages.split()
254 self._cc.addNotification("progress", (0, "Calculating dependencies for " + " ".join(packages))) 291 self._cc.addNotification("progress", (0, "Calculating dependencies for " + " ".join(packages)))
255 pkglist = self.get_deps(packages) 292 pkglist = self.get_deps(packages, grp_install)
256 if self._debug: self._logger.log("install_packages(): pkglist is " + str(pkglist)) 293 if self._debug: self._logger.log("install_packages(): pkglist is " + str(pkglist))
257 for i, pkg in enumerate(pkglist): 294 for i, pkg in enumerate(pkglist):
258 if not pkg: continue 295 if not pkg: continue
259 if self._debug: self._logger.log("install_packages(): processing package " + pkg) 296 if self._debug: self._logger.log("install_packages(): processing package " + pkg)
260 self._cc.addNotification("progress", (float(i) / len(pkglist), "Emerging " + pkg + " (" + str(i+1) + "/" + str(len(pkglist)) + ")")) 297 self._cc.addNotification("progress", (float(i) / len(pkglist), "Emerging " + pkg + " (" + str(i+1) + "/" + str(len(pkglist)) + ")"))
261 if not self._grp_install or not self.get_best_version_vdb("=" + pkg): 298 if not grp_install or not self.get_best_version_vdb("=" + pkg):
262 status = GLIUtility.spawn("emerge -1 =" + pkg, display_on_tty8=True, chroot=self._chroot_dir, logfile=self._compile_logfile, append_log=True) 299 status = GLIUtility.spawn("emerge -1 =" + pkg, display_on_tty8=True, chroot=self._chroot_dir, logfile=self._compile_logfile, append_log=True)
263# status = self._emerge("=" + pkg) 300# status = self._emerge("=" + pkg)
264 if not GLIUtility.exitsuccess(status): 301 if not GLIUtility.exitsuccess(status):
265 raise GLIException("EmergePackageError", "fatal", "emerge", "Could not emerge " + pkg + "!") 302 raise GLIException("EmergePackageError", "fatal", "emerge", "Could not emerge " + pkg + "!")
266 else: 303 else:
287 by using files from the LiveCD. 324 by using files from the LiveCD.
288 325
289 -s|--stage3 Create a stage3 equivelant in the chroot directory by using 326 -s|--stage3 Create a stage3 equivelant in the chroot directory by using
290 files from the LiveCD. 327 files from the LiveCD.
291 328
329 -k|--kernel Install kernel and modules from LiveCD into the chroot
330
292 -h|--help Display this help 331 -h|--help Display this help
293""" % (progname) 332""" % (progname)
294 333
295if __name__ == "__main__": 334if __name__ == "__main__":
296 chroot_dir = "/mnt/gentoo" 335 chroot_dir = "/mnt/gentoo"
303 chroot_dir = sys.argv.pop(0) 342 chroot_dir = sys.argv.pop(0)
304 elif arg == "-g" or arg == "--grp": 343 elif arg == "-g" or arg == "--grp":
305 mode = "grp" 344 mode = "grp"
306 elif arg == "-s" or arg == "--stage3": 345 elif arg == "-s" or arg == "--stage3":
307 mode = "stage3" 346 mode = "stage3"
347 elif arg == "-k" or arg == "--kernel":
348 mode = "kernel"
308 elif arg == "-h" or arg == "--help": 349 elif arg == "-h" or arg == "--help":
309 usage(progname) 350 usage(progname)
310 sys.exit(0) 351 sys.exit(0)
311 elif arg[0] == "-": 352 elif arg[0] == "-":
312 usage(progname) 353 usage(progname)
374 elif mode == "grp": 415 elif mode == "grp":
375 for pkg in grp_packages: 416 for pkg in grp_packages:
376 if not gliportage.get_best_version_vdb(pkg): 417 if not gliportage.get_best_version_vdb(pkg):
377 print "Package " + pkg + " is not available for install from the LiveCD" 418 print "Package " + pkg + " is not available for install from the LiveCD"
378 continue 419 continue
379 pkglist = gliportage.get_deps(pkg) 420 pkglist = gliportage.get_deps(pkg, True)
380 for i, tmppkg in enumerate(pkglist): 421 for i, tmppkg in enumerate(pkglist):
381 print "Copying " + tmppkg + " (" + str(i+1) + "/" + str(len(pkglist)) + ")" 422 print "Copying " + tmppkg + " (" + str(i+1) + "/" + str(len(pkglist)) + ")"
382 gliportage.copy_pkg_to_chroot(tmppkg) 423 gliportage.copy_pkg_to_chroot(tmppkg)
383 gliportage.add_pkg_to_world(pkg) 424 gliportage.add_pkg_to_world(pkg)
384 print "GRP install complete!" 425 print "GRP install complete!"
426 elif mode == "kernel":
427 kernelpkg = gliportage.get_best_version_vdb("sys-kernel/livecd-kernel")
428 gliportage.copy_pkg_to_chroot(kernelpkg)
429 print "LiveCD kernel installed!"
385 else: 430 else:
386 print "You must specify an operating mode (-g or -s)!" 431 print "You must specify an operating mode (-g or -s)!"
387 usage(progname) 432 usage(progname)
388 sys.exit(1) 433 sys.exit(1)

Legend:
Removed from v.1339  
changed lines
  Added in v.1832

  ViewVC Help
Powered by ViewVC 1.1.20