Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r11645 - in main/trunk/pym: _emerge portage
Date: Tue, 07 Oct 2008 02:01:06
Message-Id: E1Kn1sl-0002xa-En@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-10-07 02:01:01 +0000 (Tue, 07 Oct 2008)
3 New Revision: 11645
4
5 Modified:
6 main/trunk/pym/_emerge/__init__.py
7 main/trunk/pym/portage/__init__.py
8 Log:
9 Bug #234301 - Add support to EbuildFetcher to collect elog messages that
10 might be generated during the pkg_nofetch phase. This involves maintaining
11 a lock on PORTAGE_BUILDDIR where the elog messages are collected, and
12 cleaning up PORTAGE_BUILDDIR before releasing the lock.
13
14
15 Modified: main/trunk/pym/_emerge/__init__.py
16 ===================================================================
17 --- main/trunk/pym/_emerge/__init__.py 2008-10-06 20:58:29 UTC (rev 11644)
18 +++ main/trunk/pym/_emerge/__init__.py 2008-10-07 02:01:01 UTC (rev 11645)
19 @@ -2238,14 +2238,17 @@
20
21 class EbuildFetcher(SpawnProcess):
22
23 - __slots__ = ("fetchonly", "fetchall", "pkg",)
24 + __slots__ = ("config_pool", "fetchonly", "fetchall", "pkg",) + \
25 + ("_build_dir",)
26
27 def _start(self):
28
29 root_config = self.pkg.root_config
30 portdb = root_config.trees["porttree"].dbapi
31 ebuild_path = portdb.findname(self.pkg.cpv)
32 - settings = root_config.settings
33 + settings = self.config_pool.allocate()
34 + self._build_dir = EbuildBuildDir(pkg=self.pkg, settings=settings)
35 + self._build_dir.lock()
36 phase = "fetch"
37 if self.fetchall:
38 phase = "fetchall"
39 @@ -2272,6 +2275,21 @@
40 self.env = fetch_env
41 SpawnProcess._start(self)
42
43 + def _wait_hook(self):
44 + # Collect elog messages that might have been
45 + # created by the pkg_nofetch phase.
46 + portage.elog.elog_process(self.pkg.cpv, self._build_dir.settings)
47 + try:
48 + shutil.rmtree(self._build_dir.settings["PORTAGE_BUILDDIR"])
49 + except EnvironmentError, e:
50 + if e.errno != errno.ENOENT:
51 + raise
52 + del e
53 + self._build_dir.unlock()
54 + self.config_pool.deallocate(self._build_dir.settings)
55 + self._build_dir = None
56 + SpawnProcess._wait_hook(self)
57 +
58 class EbuildBuildDir(SlotObject):
59
60 __slots__ = ("dir_path", "pkg", "settings",
61 @@ -2297,6 +2315,7 @@
62 portdb = root_config.trees["porttree"].dbapi
63 ebuild_path = portdb.findname(self.pkg.cpv)
64 settings = self.settings
65 + settings.setcpv(self.pkg)
66 debug = settings.get("PORTAGE_DEBUG") == "1"
67 use_cache = 1 # always true
68 portage.doebuild_environment(ebuild_path, "setup", root_config.root,
69 @@ -2349,7 +2368,7 @@
70
71 class EbuildBuild(CompositeTask):
72
73 - __slots__ = ("args_set", "background", "find_blockers",
74 + __slots__ = ("args_set", "config_pool", "find_blockers",
75 "ldpath_mtimes", "logger", "opts", "pkg", "pkg_count",
76 "prefetcher", "settings", "world_atom") + \
77 ("_build_dir", "_buildpkg", "_ebuild_path", "_issyspkg", "_tree")
78 @@ -2415,7 +2434,8 @@
79 if self.background:
80 fetch_log = self.scheduler.fetch.log_file
81
82 - fetcher = EbuildFetcher(fetchall=opts.fetch_all_uri,
83 + fetcher = EbuildFetcher(config_pool=self.config_pool,
84 + fetchall=opts.fetch_all_uri,
85 fetchonly=opts.fetchonly,
86 background=self.background, logfile=fetch_log,
87 pkg=pkg, scheduler=self.scheduler)
88 @@ -3439,7 +3459,7 @@
89 """
90
91 __slots__ = ("args_set",
92 - "binpkg_opts", "build_opts", "emerge_opts",
93 + "binpkg_opts", "build_opts", "config_pool", "emerge_opts",
94 "failed_fetches", "find_blockers", "logger", "mtimedb", "pkg",
95 "pkg_count", "pkg_to_replace", "prefetcher",
96 "settings", "statusMessage", "world_atom") + \
97 @@ -3492,6 +3512,7 @@
98
99 build = EbuildBuild(args_set=args_set,
100 background=self.background,
101 + config_pool=self.config_pool,
102 find_blockers=find_blockers,
103 ldpath_mtimes=ldpath_mtimes, logger=logger,
104 opts=build_opts, pkg=pkg, pkg_count=pkg_count,
105 @@ -8949,6 +8970,21 @@
106 __slots__ = ("build_dir", "build_log",
107 "fetch_log", "pkg", "returncode")
108
109 + class _ConfigPool(object):
110 + """Interface for a task to temporarily allocate a config
111 + instance from a pool. This allows a task to be constructed
112 + long before the config instance actually becomes needed, like
113 + when prefetchers are constructed for the whole merge list."""
114 + __slots__ = ("_root", "_allocate", "_deallocate")
115 + def __init__(self, root, allocate, deallocate):
116 + self._root = root
117 + self._allocate = allocate
118 + self._deallocate = deallocate
119 + def allocate(self):
120 + return self._allocate(self._root)
121 + def deallocate(self, settings):
122 + self._deallocate(settings)
123 +
124 def __init__(self, settings, trees, mtimedb, myopts,
125 spinner, mergelist, favorites, digraph):
126 PollScheduler.__init__(self)
127 @@ -9369,6 +9405,8 @@
128 elif pkg.type_name == "ebuild":
129
130 prefetcher = EbuildFetcher(background=True,
131 + config_pool=self._ConfigPool(pkg.root,
132 + self._allocate_config, self._deallocate_config),
133 fetchonly=1, logfile=self._fetch_log,
134 pkg=pkg, scheduler=self._sched_iface)
135
136 @@ -10005,6 +10043,8 @@
137 task = MergeListItem(args_set=self._args_set,
138 background=self._background, binpkg_opts=self._binpkg_opts,
139 build_opts=self._build_opts,
140 + config_pool=self._ConfigPool(pkg.root,
141 + self._allocate_config, self._deallocate_config),
142 emerge_opts=self.myopts,
143 failed_fetches=self._failed_fetches,
144 find_blockers=self._find_blockers(pkg), logger=self._logger,
145
146 Modified: main/trunk/pym/portage/__init__.py
147 ===================================================================
148 --- main/trunk/pym/portage/__init__.py 2008-10-06 20:58:29 UTC (rev 11644)
149 +++ main/trunk/pym/portage/__init__.py 2008-10-07 02:01:01 UTC (rev 11645)
150 @@ -5622,16 +5622,6 @@
151 if not emerge_skip_distfiles and \
152 need_distfiles and not fetch(
153 fetchme, mysettings, listonly=listonly, fetchonly=fetchonly):
154 - if have_build_dirs:
155 - # Create an elog message for this fetch failure since the
156 - # mod_echo module might push the original message off of the
157 - # top of the terminal and prevent the user from being able to
158 - # see it.
159 - from portage.elog.messages import eerror
160 - eerror("Fetch failed for '%s'" % mycpv,
161 - phase="unpack", key=mycpv)
162 - from portage.elog import elog_process
163 - elog_process(mysettings.mycpv, mysettings)
164 return 1
165
166 if mydo == "fetch" and listonly: