/[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 1182 Revision 1184
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.2 2005/12/23 22:32:57 agaffney Exp $ 8$Id: GLIPortage.py,v 1.4 2005/12/24 17:29:33 agaffney Exp $
9""" 9"""
10 10
11import os 11import os
12import re 12import re
13import GLIUtility 13import GLIUtility
54 important_node = node 54 important_node = node
55 return important_node 55 return important_node
56 56
57class GLIPortage(object): 57class GLIPortage(object):
58 58
59 def __init__(self, chroot_dir, logger, debug): 59 def __init__(self, chroot_dir, grp_install, logger, debug):
60 os.environ['ROOT'] = chroot_dir 60 os.environ['ROOT'] = chroot_dir
61 import portage, portage_dep 61 import portage, portage_dep
62 self.vdb = portage.db["/"]["vartree"].dbapi 62 self.vdb = portage.db["/"]["vartree"].dbapi
63 self.tree = portage.db[chroot_dir]["porttree"].dbapi 63 self.tree = portage.db[chroot_dir]["porttree"].dbapi
64 self._chroot_dir = chroot_dir 64 self._chroot_dir = chroot_dir
65 self._logger = logger 65 self._logger = logger
66 self._debug = debug 66 self._debug = debug
67 self._grp_install = grp_install
67 68
68 def resolve_deps(self, dep_list): 69 def resolve_deps(self, dep_list):
69 if dep_list and dep_list[0] == "||": 70 if dep_list and dep_list[0] == "||":
70 for dep in dep_list[1:]: 71 for dep in dep_list[1:]:
71 if isinstance(dep, list): 72 if isinstance(dep, list):
116 for atom in db.cp_all(): 117 for atom in db.cp_all():
117 for pkg in db.match(atom): 118 for pkg in db.match(atom):
118 if graph.has_node(pkg): 119 if graph.has_node(pkg):
119 graph.remove(pkg) 120 graph.remove(pkg)
120 121
121 def get_deps(self, pkgs, grp_install): 122 def get_deps(self, pkgs):
122 if not grp_install: 123 if not self._grp_install:
123 del(os.environ['ROOT']) 124 del(os.environ['ROOT'])
124 return GLIUtility.spawn("emerge -p " + pkgs + r" | grep -e '^\[[a-z]' | cut -d ']' -f2 | sed -e 's:^ ::' -e 's: .\+$::'", chroot=self._chroot_dir, return_output=True)[1].split("\n") 125 return GLIUtility.spawn("emerge -p " + pkgs + r" | grep -e '^\[[a-z]' | cut -d ']' -f2 | sed -e 's:^ ::' -e 's: .\+$::'", chroot=self._chroot_dir, return_output=True)[1].split("\n")
125 os.environ['ROOT'] = self._chroot_dir 126 os.environ['ROOT'] = self._chroot_dir
126 else: 127 else:
127 pkglist = [] 128 return GLIUtility.spawn("../../runtimedeps.py " + pkgs, return_output=True)[1].split("\n")[:-1]
128 graph = depgraph()
129 for pkg in pkgs.split():
130 if not self.vdb.match(pkg):
131 self._logger.log("get_deps(): " + pkg + " is not available via GRP...ignoring")
132 continue
133 self.calc_required_pkgs(pkg, graph)
134 while graph.node_count():
135 leaf_nodes = graph.leaf_nodes()
136 if not leaf_nodes:
137 node = graph.important_node()
138 pkglist.append(node)
139 graph.remove(node)
140 continue
141 pkglist.extend(leaf_nodes)
142 for node in leaf_nodes:
143 graph.remove(node)
144 return pkglist
145 129
146 def copy_pkg_to_chroot(self, package): 130 def copy_pkg_to_chroot(self, package):
147 symlinks = { '/bin/': '/mnt/livecd/bin/', '/boot/': '/mnt/livecd/boot/', '/lib/': '/mnt/livecd/lib/', 131 symlinks = { '/bin/': '/mnt/livecd/bin/', '/boot/': '/mnt/livecd/boot/', '/lib/': '/mnt/livecd/lib/',
148 '/opt/': '/mnt/livecd/opt/', '/sbin/': '/mnt/livecd/sbin/', '/usr/': '/mnt/livecd/usr/', 132 '/opt/': '/mnt/livecd/opt/', '/sbin/': '/mnt/livecd/sbin/', '/usr/': '/mnt/livecd/usr/',
149 '/etc/gconf/': '/usr/livecd/gconf/' } 133 '/etc/gconf/': '/usr/livecd/gconf/' }
221 expr = re.compile('^(.+?)(-\d.+)?$') 205 expr = re.compile('^(.+?)(-\d.+)?$')
222 res = expr.match(package) 206 res = expr.match(package)
223 if res: 207 if res:
224 GLIUtility.spawn("echo " + res.group(1) + " >> " + self._chroot_dir + "/var/lib/portage/world") 208 GLIUtility.spawn("echo " + res.group(1) + " >> " + self._chroot_dir + "/var/lib/portage/world")
225 209
226 def get_best_version_vdb(self, package): 210# def get_best_version_vdb(self, package):
227 return portage.best(vdb.match(package)) 211# return portage.best(vdb.match(package))
228 212#
229 def get_best_version_tree(self, package): 213# def get_best_version_tree(self, package):
230 return portage.best(tree.match(package)) 214# return portage.best(tree.match(package))

Legend:
Removed from v.1182  
changed lines
  Added in v.1184

  ViewVC Help
Powered by ViewVC 1.1.20