| … | |
… | |
| 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. |
| 6 | Gentoo Linux Installer |
6 | Gentoo Linux Installer |
| 7 | |
7 | |
| 8 | $Id: GLIPortage.py,v 1.6 2005/12/25 14:14:43 agaffney Exp $ |
8 | $Id: GLIPortage.py,v 1.7 2005/12/26 01:51:36 agaffney Exp $ |
| 9 | """ |
9 | """ |
| 10 | |
10 | |
| 11 | import os |
|
|
| 12 | import re |
11 | import re |
| 13 | import GLIUtility |
12 | import GLIUtility |
|
|
13 | import GLIException |
| 14 | |
14 | |
| 15 | class MissingPackagesError(Exception): |
15 | class MissingPackagesError(Exception): |
| 16 | pass |
16 | pass |
| 17 | |
17 | |
| 18 | class depgraph: |
18 | class depgraph: |
| … | |
… | |
| 56 | |
56 | |
| 57 | class GLIPortage(object): |
57 | class GLIPortage(object): |
| 58 | |
58 | |
| 59 | def __init__(self, chroot_dir, grp_install, logger, debug): |
59 | def __init__(self, chroot_dir, grp_install, logger, debug): |
| 60 | self._chroot_dir = chroot_dir |
60 | self._chroot_dir = chroot_dir |
|
|
61 | self._grp_install = grp_install |
| 61 | self._logger = logger |
62 | self._logger = logger |
| 62 | self._debug = debug |
63 | self._debug = debug |
| 63 | self._grp_install = grp_install |
|
|
| 64 | |
|
|
| 65 | def resolve_deps(self, dep_list): |
|
|
| 66 | if dep_list and dep_list[0] == "||": |
|
|
| 67 | for dep in dep_list[1:]: |
|
|
| 68 | if isinstance(dep, list): |
|
|
| 69 | try: |
|
|
| 70 | atoms = resolve_deps(dep) |
|
|
| 71 | except MissingPackagesError: |
|
|
| 72 | continue |
|
|
| 73 | else: |
|
|
| 74 | atoms = [dep] |
|
|
| 75 | all_found = True |
|
|
| 76 | for atom in atoms: |
|
|
| 77 | if not atom.startswith("!") and not self.vdb.match(atom): |
|
|
| 78 | all_found = False |
|
|
| 79 | break |
|
|
| 80 | if all_found: |
|
|
| 81 | return atoms |
|
|
| 82 | raise MissingPackagesError(dep_list) |
|
|
| 83 | atoms = [] |
|
|
| 84 | for dep in dep_list: |
|
|
| 85 | if isinstance(dep, list): |
|
|
| 86 | atoms.extend(resolve_deps(dep)) |
|
|
| 87 | elif not dep.startswith("!"): |
|
|
| 88 | if not self.vdb.match(dep): |
|
|
| 89 | raise MissingPackagesError([dep]) |
|
|
| 90 | atoms.append(dep) |
|
|
| 91 | return atoms |
|
|
| 92 | |
64 | |
| 93 | def get_deps(self, pkgs): |
65 | def get_deps(self, pkgs): |
| 94 | if not self._grp_install: |
66 | pkglist = [] |
|
|
67 | if isinstance(pkgs, str): |
|
|
68 | pkgs = pkgs.split() |
|
|
69 | for pkg in pkgs: |
|
|
70 | if not self._grp_install or not self.get_best_version_vdb(pkg): |
| 95 | del(os.environ['ROOT']) |
71 | # del(os.environ['ROOT']) |
| 96 | 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") |
72 | tmppkglist = 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") |
| 97 | os.environ['ROOT'] = self._chroot_dir |
73 | # os.environ['ROOT'] = self._chroot_dir |
| 98 | else: |
74 | else: |
| 99 | return GLIUtility.spawn("python ../../runtimedeps.py " + pkgs, return_output=True)[1].split("\n")[:-1] |
75 | tmppkglist = GLIUtility.spawn("env ROOT=" + self._chroot_dir + " python ../../runtimedeps.py " + pkg, return_output=True)[1].split("\n")[:-1] |
|
|
76 | for tmppkg in tmppkglist: |
|
|
77 | if not tmppkg in pkglist: |
|
|
78 | pkglist.append(tmppkg) |
|
|
79 | return pkglist |
| 100 | |
80 | |
| 101 | def copy_pkg_to_chroot(self, package): |
81 | def copy_pkg_to_chroot(self, package): |
| 102 | symlinks = { '/bin/': '/mnt/livecd/bin/', '/boot/': '/mnt/livecd/boot/', '/lib/': '/mnt/livecd/lib/', |
82 | symlinks = { '/bin/': '/mnt/livecd/bin/', '/boot/': '/mnt/livecd/boot/', '/lib/': '/mnt/livecd/lib/', |
| 103 | '/opt/': '/mnt/livecd/opt/', '/sbin/': '/mnt/livecd/sbin/', '/usr/': '/mnt/livecd/usr/', |
83 | '/opt/': '/mnt/livecd/opt/', '/sbin/': '/mnt/livecd/sbin/', '/usr/': '/mnt/livecd/usr/', |
| 104 | '/etc/gconf/': '/usr/livecd/gconf/' } |
84 | '/etc/gconf/': '/usr/livecd/gconf/' } |
| … | |
… | |
| 178 | if res: |
158 | if res: |
| 179 | GLIUtility.spawn("echo " + res.group(1) + " >> " + self._chroot_dir + "/var/lib/portage/world") |
159 | GLIUtility.spawn("echo " + res.group(1) + " >> " + self._chroot_dir + "/var/lib/portage/world") |
| 180 | |
160 | |
| 181 | def get_best_version_vdb(self, package): |
161 | def get_best_version_vdb(self, package): |
| 182 | return GLIUtility.spawn("portageq best_version / " + package, return_output=True)[1].strip() |
162 | return GLIUtility.spawn("portageq best_version / " + package, return_output=True)[1].strip() |
| 183 | # |
163 | |
| 184 | # def get_best_version_tree(self, package): |
164 | # def get_best_version_tree(self, package): |
| 185 | # return portage.best(tree.match(package)) |
165 | # return portage.best(tree.match(package)) |