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

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

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

Revision 1673 Revision 1674
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
248 return GLIUtility.spawn("portageq best_version / " + package, chroot=self._chroot_dir, return_output=True)[1].strip() 247 return GLIUtility.spawn("portageq best_version / " + package, chroot=self._chroot_dir, return_output=True)[1].strip()
249 248
250# def get_best_version_tree(self, package): 249# def get_best_version_tree(self, package):
251# return portage.best(tree.match(package)) 250# return portage.best(tree.match(package))
252 251
253 def emerge(self, packages, add_to_world=True): 252 def emerge(self, packages, add_to_world=True, grp_install=False):
254 if isinstance(packages, str): 253 if isinstance(packages, str):
255 packages = packages.split() 254 packages = packages.split()
256 self._cc.addNotification("progress", (0, "Calculating dependencies for " + " ".join(packages))) 255 self._cc.addNotification("progress", (0, "Calculating dependencies for " + " ".join(packages)))
257 pkglist = self.get_deps(packages) 256 pkglist = self.get_deps(packages)
258 if self._debug: self._logger.log("install_packages(): pkglist is " + str(pkglist)) 257 if self._debug: self._logger.log("install_packages(): pkglist is " + str(pkglist))
259 for i, pkg in enumerate(pkglist): 258 for i, pkg in enumerate(pkglist):
260 if not pkg: continue 259 if not pkg: continue
261 if self._debug: self._logger.log("install_packages(): processing package " + pkg) 260 if self._debug: self._logger.log("install_packages(): processing package " + pkg)
262 self._cc.addNotification("progress", (float(i) / len(pkglist), "Emerging " + pkg + " (" + str(i+1) + "/" + str(len(pkglist)) + ")")) 261 self._cc.addNotification("progress", (float(i) / len(pkglist), "Emerging " + pkg + " (" + str(i+1) + "/" + str(len(pkglist)) + ")"))
263 if not self._grp_install or not self.get_best_version_vdb("=" + pkg): 262 if not grp_install or not self.get_best_version_vdb("=" + pkg):
264 status = GLIUtility.spawn("emerge -1 =" + pkg, display_on_tty8=True, chroot=self._chroot_dir, logfile=self._compile_logfile, append_log=True) 263 status = GLIUtility.spawn("emerge -1 =" + pkg, display_on_tty8=True, chroot=self._chroot_dir, logfile=self._compile_logfile, append_log=True)
265# status = self._emerge("=" + pkg) 264# status = self._emerge("=" + pkg)
266 if not GLIUtility.exitsuccess(status): 265 if not GLIUtility.exitsuccess(status):
267 raise GLIException("EmergePackageError", "fatal", "emerge", "Could not emerge " + pkg + "!") 266 raise GLIException("EmergePackageError", "fatal", "emerge", "Could not emerge " + pkg + "!")
268 else: 267 else:

Legend:
Removed from v.1673  
changed lines
  Added in v.1674

  ViewVC Help
Powered by ViewVC 1.1.20