1 |
Author: zmedico |
2 |
Date: 2009-04-07 01:27:54 +0000 (Tue, 07 Apr 2009) |
3 |
New Revision: 13295 |
4 |
|
5 |
Modified: |
6 |
main/trunk/bin/repoman |
7 |
main/trunk/pym/_emerge/__init__.py |
8 |
main/trunk/pym/portage/dbapi/porttree.py |
9 |
Log: |
10 |
Add support to repoman for using layout.conf to control which repositories |
11 |
are used to satisfy dependencies. Thanks to Alistair Bush <ali_bush@g.o> |
12 |
for the initial patch. See the "QA Overlay Layout support" thread on the |
13 |
gentoo-dev mailing list for more information: |
14 |
|
15 |
http://archives.gentoo.org/gentoo-dev/msg_33c61550b4ed2b7b25dd5a4110e1ec81.xml |
16 |
|
17 |
|
18 |
Modified: main/trunk/bin/repoman |
19 |
=================================================================== |
20 |
--- main/trunk/bin/repoman 2009-04-07 01:07:52 UTC (rev 13294) |
21 |
+++ main/trunk/bin/repoman 2009-04-07 01:27:54 UTC (rev 13295) |
22 |
@@ -479,31 +479,35 @@ |
23 |
logging.info("Not in a version controlled repository; enabling pretend mode.") |
24 |
options.pretend = True |
25 |
|
26 |
-os.environ["PORTDIR"] = portdir |
27 |
-if portdir_overlay != portdir: |
28 |
- os.environ["PORTDIR_OVERLAY"] = portdir_overlay |
29 |
-else: |
30 |
- os.environ["PORTDIR_OVERLAY"] = "" |
31 |
+# Ensure that PORTDIR_OVERLAY contains the repository corresponding to $PWD. |
32 |
+repoman_settings = portage.config(local_config=False) |
33 |
+repoman_settings['PORTDIR_OVERLAY'] = "%s %s" % \ |
34 |
+ (repoman_settings.get('PORTDIR_OVERLAY', ''), portdir_overlay) |
35 |
+repoman_settings.backup_changes('PORTDIR_OVERLAY') |
36 |
|
37 |
+root = '/' |
38 |
+trees = { |
39 |
+ root : {'porttree' : portage.portagetree(root, settings=repoman_settings)} |
40 |
+} |
41 |
+portdb = trees[root]['porttree'].dbapi |
42 |
+ |
43 |
+# Constrain dependency resolution to the master(s) |
44 |
+# that are specified in layout.conf. |
45 |
+portdir_overlay = os.path.realpath(portdir_overlay) |
46 |
+repo_info = portdb._repo_info[portdir_overlay] |
47 |
+portdb.porttrees = list(repo_info.eclass_db.porttrees) |
48 |
+portdir = portdb.porttrees[0] |
49 |
+ |
50 |
logging.info('Setting paths:') |
51 |
-logging.info('PORTDIR = "' + os.environ['PORTDIR'] + '"') |
52 |
-logging.info('PORTDIR_OVERLAY = "' + os.environ['PORTDIR_OVERLAY']+'"') |
53 |
+logging.info('PORTDIR = "' + portdir + '"') |
54 |
+logging.info('PORTDIR_OVERLAY = "%s"' % ' '.join(portdb.porttrees[1:])) |
55 |
|
56 |
-# Now that PORTDIR_OVERLAY is properly overridden, create the portdb. |
57 |
-repoman_settings = portage.config(local_config=False, |
58 |
- config_incrementals=portage.const.INCREMENTALS) |
59 |
-trees = portage.create_trees() |
60 |
-trees["/"]["porttree"].settings = repoman_settings |
61 |
-portdb = trees["/"]["porttree"].dbapi |
62 |
portdb.mysettings = repoman_settings |
63 |
-setconfig = load_default_config(repoman_settings, trees["/"]) |
64 |
-root_config = RootConfig(repoman_settings, trees["/"], setconfig) |
65 |
+root_config = RootConfig(repoman_settings, trees[root], None) |
66 |
# We really only need to cache the metadata that's necessary for visibility |
67 |
# filtering. Anything else can be discarded to reduce memory consumption. |
68 |
portdb._aux_cache_keys.clear() |
69 |
portdb._aux_cache_keys.update(["EAPI", "KEYWORDS", "SLOT"]) |
70 |
-# dep_zapdeps looks at the vardbapi, but it shouldn't for repoman. |
71 |
-del trees["/"]["vartree"] |
72 |
|
73 |
myreporoot = os.path.basename(portdir_overlay) |
74 |
myreporoot += mydir[len(portdir_overlay):] |
75 |
@@ -543,24 +547,27 @@ |
76 |
logging.exception("Couldn't read USE flags from use.desc") |
77 |
sys.exit(1) |
78 |
|
79 |
-# retrieve a list of current licenses in portage |
80 |
+# get lists of valid keywords and licenses |
81 |
+kwlist = set(portage.grabfile(os.path.join(portdir, "profiles", "arch.list"))) |
82 |
liclist = set(portage.listdir(os.path.join(portdir, "licenses"))) |
83 |
+ |
84 |
+if portdir_overlay != portdir: |
85 |
+ for porttree in portdb.porttrees[1:]: |
86 |
+ try: |
87 |
+ liclist.update(os.listdir(os.path.join(porttree, "licenses"))) |
88 |
+ except OSError: |
89 |
+ pass |
90 |
+ kwlist.update(portage.grabfile(os.path.join(porttree, |
91 |
+ "profiles", "arch.list"))) |
92 |
+ |
93 |
if not liclist: |
94 |
logging.fatal("Couldn't find licenses?") |
95 |
sys.exit(1) |
96 |
-if portdir_overlay != portdir: |
97 |
- liclist.update(portage.listdir(os.path.join(portdir_overlay, "licenses"))) |
98 |
|
99 |
-# retrieve list of offical keywords |
100 |
-kwlist = set(portage.grabfile(os.path.join(portdir, "profiles", "arch.list"))) |
101 |
if not kwlist: |
102 |
logging.fatal("Couldn't read KEYWORDS from arch.list") |
103 |
sys.exit(1) |
104 |
|
105 |
-if portdir_overlay != portdir: |
106 |
- kwlist.update(portage.grabfile( |
107 |
- os.path.join(portdir_overlay, "profiles", "arch.list"))) |
108 |
- |
109 |
scanlist=[] |
110 |
if repolevel==2: |
111 |
#we are inside a category directory |
112 |
|
113 |
Modified: main/trunk/pym/_emerge/__init__.py |
114 |
=================================================================== |
115 |
--- main/trunk/pym/_emerge/__init__.py 2009-04-07 01:07:52 UTC (rev 13294) |
116 |
+++ main/trunk/pym/_emerge/__init__.py 2009-04-07 01:27:54 UTC (rev 13295) |
117 |
@@ -770,7 +770,10 @@ |
118 |
self.iuse_implicit = tuple(sorted(settings._get_implicit_iuse())) |
119 |
self.root = self.settings["ROOT"] |
120 |
self.setconfig = setconfig |
121 |
- self.sets = self.setconfig.getSets() |
122 |
+ if setconfig is None: |
123 |
+ self.sets = {} |
124 |
+ else: |
125 |
+ self.sets = self.setconfig.getSets() |
126 |
self.visible_pkgs = PackageVirtualDbapi(self.settings) |
127 |
|
128 |
def create_world_atom(pkg, args_set, root_config): |
129 |
|
130 |
Modified: main/trunk/pym/portage/dbapi/porttree.py |
131 |
=================================================================== |
132 |
--- main/trunk/pym/portage/dbapi/porttree.py 2009-04-07 01:07:52 UTC (rev 13294) |
133 |
+++ main/trunk/pym/portage/dbapi/porttree.py 2009-04-07 01:27:54 UTC (rev 13295) |
134 |
@@ -190,8 +190,14 @@ |
135 |
level=logging.ERROR, noiselevel=-1) |
136 |
else: |
137 |
porttrees.append(master_path) |
138 |
+ |
139 |
if not porttrees: |
140 |
- porttrees.append(porttree_root) |
141 |
+ # Make PORTDIR the default master, but only if this |
142 |
+ # repo doesn't provide profiles.desc itself. |
143 |
+ profiles_desc = os.path.join(path, 'profiles', 'profiles.desc') |
144 |
+ if not os.path.exists(profiles_desc): |
145 |
+ porttrees.append(porttree_root) |
146 |
+ |
147 |
porttrees.append(path) |
148 |
|
149 |
eclass_db = None |
150 |
@@ -227,11 +233,15 @@ |
151 |
db_ro=db_ro) |
152 |
else: |
153 |
for x in self.porttrees: |
154 |
+ if x in self.auxdb: |
155 |
+ continue |
156 |
# location, label, auxdbkeys |
157 |
self.auxdb[x] = self.auxdbmodule( |
158 |
self.depcachedir, x, filtered_auxdbkeys, gid=portage_gid) |
159 |
if "metadata-transfer" not in self.mysettings.features: |
160 |
for x in self.porttrees: |
161 |
+ if x in self._pregen_auxdb: |
162 |
+ continue |
163 |
if os.path.isdir(os.path.join(x, "metadata", "cache")): |
164 |
self._pregen_auxdb[x] = self.metadbmodule( |
165 |
x, "metadata/cache", filtered_auxdbkeys, readonly=True) |