Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10887 - main/trunk/pym/_emerge
Date: Wed, 02 Jul 2008 02:01:47
Message-Id: E1KDrfC-0006Ev-6W@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-07-02 02:01:41 +0000 (Wed, 02 Jul 2008)
3 New Revision: 10887
4
5 Modified:
6 main/trunk/pym/_emerge/__init__.py
7 Log:
8 Split out a Binpkg class from code inside Scheduler._execute_task().
9
10
11 Modified: main/trunk/pym/_emerge/__init__.py
12 ===================================================================
13 --- main/trunk/pym/_emerge/__init__.py 2008-07-02 01:15:44 UTC (rev 10886)
14 +++ main/trunk/pym/_emerge/__init__.py 2008-07-02 02:01:41 UTC (rev 10887)
15 @@ -2070,6 +2070,89 @@
16 return e.status
17 return os.EX_OK
18
19 +class Binpkg(SlotObject):
20 +
21 + __slots__ = ("find_blockers",
22 + "ldpath_mtimes", "logger", "opts",
23 + "pkg", "pkg_count", "prefetcher", "scheduler",
24 + "settings")
25 +
26 + def execute(self):
27 +
28 + find_blockers = self.find_blockers
29 + ldpath_mtimes = self.ldpath_mtimes
30 + logger = self.logger
31 + opts = self.opts
32 + pkg = self.pkg
33 + pkg_count = self.pkg_count
34 + scheduler = self.scheduler
35 + settings = self.settings
36 +
37 + # The prefetcher has already completed or it
38 + # could be running now. If it's running now,
39 + # wait for it to complete since it holds
40 + # a lock on the file being fetched. The
41 + # portage.locks functions are only designed
42 + # to work between separate processes. Since
43 + # the lock is held by the current process,
44 + # use the scheduler and fetcher methods to
45 + # synchronize with the fetcher.
46 + prefetcher = self.prefetcher
47 + if prefetcher is not None:
48 + if not prefetcher.isAlive():
49 + prefetcher.cancel()
50 + else:
51 + retval = prefetcher.poll()
52 +
53 + if retval is None:
54 + waiting_msg = ("Fetching '%s' " + \
55 + "in the background. " + \
56 + "To view fetch progress, run `tail -f " + \
57 + "/var/log/emerge-fetch.log` in another " + \
58 + "terminal.") % prefetcher.pkg_path
59 + msg_prefix = colorize("GOOD", " * ")
60 + from textwrap import wrap
61 + waiting_msg = "".join("%s%s\n" % (msg_prefix, line) \
62 + for line in wrap(waiting_msg, 65))
63 + writemsg(waiting_msg, noiselevel=-1)
64 +
65 + while retval is None:
66 + scheduler.schedule()
67 + retval = prefetcher.poll()
68 + del prefetcher
69 +
70 + fetcher = BinpkgFetcher(pkg=pkg, pretend=opts.pretend,
71 + use_locks=("distlocks" in settings.features))
72 + pkg_path = fetcher.pkg_path
73 +
74 + if opts.getbinpkg:
75 + retval = fetcher.execute()
76 + if fetcher.remote:
77 + msg = " --- (%s of %s) Fetching Binary (%s::%s)" %\
78 + (pkg_count.curval, pkg_count.maxval, pkg.cpv, pkg_path)
79 + short_msg = "emerge: (%s of %s) %s Fetch" % \
80 + (pkg_count.curval, pkg_count.maxval, pkg.cpv)
81 + logger.log(msg, short_msg=short_msg)
82 +
83 + if retval != os.EX_OK:
84 + return retval
85 +
86 + if opts.fetchonly:
87 + return os.EX_OK
88 +
89 + msg = " === (%s of %s) Merging Binary (%s::%s)" % \
90 + (pkg_count.curval, pkg_count.maxval, pkg.cpv, pkg_path)
91 + short_msg = "emerge: (%s of %s) %s Merge Binary" % \
92 + (pkg_count.curval, pkg_count.maxval, pkg.cpv)
93 + logger.log(msg, short_msg=short_msg)
94 + merge = BinpkgMerge(find_blockers=find_blockers,
95 + ldpath_mtimes=ldpath_mtimes, pkg=pkg, pretend=opts.pretend,
96 + pkg_path=pkg_path, settings=settings)
97 + retval = merge.execute()
98 + if retval != os.EX_OK:
99 + return retval
100 + return os.EX_OK
101 +
102 class BinpkgFetcher(Task):
103
104 __slots__ = ("use_locks", "pkg", "pretend",
105 @@ -2148,7 +2231,6 @@
106
107 if self.cancelled:
108 return
109 - writemsg(">>> starting parallel binpkg fetcher\n")
110
111 fd_pipes = self.fd_pipes
112 if fd_pipes is None:
113 @@ -6801,6 +6883,9 @@
114 __slots__ = ("buildpkg", "buildpkgonly",
115 "fetch_all_uri", "fetchonly", "pretend")
116
117 + class _binpkg_opts_class(SlotObject):
118 + __slots__ = ("fetchonly", "getbinpkg", "pretend")
119 +
120 class _pkg_count_class(SlotObject):
121 __slots__ = ("curval", "maxval")
122
123 @@ -6824,6 +6909,10 @@
124 self._build_opts = self._build_opts_class()
125 for k in self._build_opts.__slots__:
126 setattr(self._build_opts, k, "--" + k.replace("_", "-") in myopts)
127 + self._binpkg_opts = self._binpkg_opts_class()
128 + for k in self._binpkg_opts.__slots__:
129 + setattr(self._binpkg_opts, k, "--" + k.replace("_", "-") in myopts)
130 +
131 self.edebug = 0
132 if settings.get("PORTAGE_DEBUG", "") == "1":
133 self.edebug = 1
134 @@ -7245,63 +7334,24 @@
135 settings=pkgsettings, scheduler=self._sched_iface)
136 retval = build.execute()
137 if retval != os.EX_OK:
138 - raise self._pkg_failure(retval)
139 + if fetchonly:
140 + failed_fetches.append(pkg.cpv)
141 + else:
142 + raise self._pkg_failure(retval)
143
144 elif x.type_name == "binary":
145 - # The prefetcher have already completed or it
146 - # could be running now. If it's running now,
147 - # wait for it to complete since it holds
148 - # a lock on the file being fetched. The
149 - # portage.locks functions are only designed
150 - # to work between separate processes. Since
151 - # the lock is held by the current process,
152 - # use the scheduler and fetcher methods to
153 - # synchronize with the fetcher.
154 - prefetcher = prefetchers.get(pkg)
155 - if prefetcher is not None:
156 - if not prefetcher.isAlive():
157 - prefetcher.cancel()
158 + binpkg = Binpkg(find_blockers=self._find_blockers(pkg),
159 + ldpath_mtimes=ldpath_mtimes, logger=self._logger,
160 + opts=self._binpkg_opts, pkg=pkg, pkg_count=pkg_count,
161 + prefetcher=prefetchers.get(pkg), settings=pkgsettings,
162 + scheduler=self._sched_iface)
163 + retval = binpkg.execute()
164 + if retval != os.EX_OK:
165 + if fetchonly:
166 + failed_fetches.append(pkg.cpv)
167 else:
168 - retval = None
169 - while retval is None:
170 - self._schedule()
171 - retval = prefetcher.poll()
172 - del prefetcher
173 + raise self._pkg_failure(retval)
174
175 - fetcher = BinpkgFetcher(pkg=pkg, pretend=pretend,
176 - use_locks=("distlocks" in pkgsettings.features))
177 - mytbz2 = fetcher.pkg_path
178 - y = mytbz2
179 - if "--getbinpkg" in self.myopts:
180 - retval = fetcher.execute()
181 - if fetcher.remote:
182 - msg = " --- (%s of %s) Fetching Binary (%s::%s)" %\
183 - (mergecount, len(mymergelist), pkg_key, mytbz2)
184 - short_msg = "emerge: (%s of %s) %s Fetch" % \
185 - (mergecount, len(mymergelist), pkg_key)
186 - emergelog(xterm_titles, msg, short_msg=short_msg)
187 -
188 - if retval != os.EX_OK:
189 - failed_fetches.append(pkg.cpv)
190 - if not fetchonly:
191 - raise self._pkg_failure()
192 -
193 - if "--fetchonly" in self.myopts or \
194 - "--fetch-all-uri" in self.myopts:
195 - self.curval += 1
196 - return
197 -
198 - short_msg = "emerge: ("+str(mergecount)+" of "+str(len(mymergelist))+") "+x[pkgindex]+" Merge Binary"
199 - emergelog(xterm_titles, " === ("+str(mergecount)+\
200 - " of "+str(len(mymergelist))+") Merging Binary ("+\
201 - x[pkgindex]+"::"+mytbz2+")", short_msg=short_msg)
202 - merge = BinpkgMerge(find_blockers=self._find_blockers(pkg),
203 - ldpath_mtimes=ldpath_mtimes, pkg=pkg, pretend=pretend,
204 - pkg_path=fetcher.pkg_path, settings=pkgsettings)
205 - retval = merge.execute()
206 - if retval != os.EX_OK:
207 - raise self._pkg_failure(retval)
208 - #need to check for errors
209 if not buildpkgonly:
210 if not (fetchonly or oneshot or pretend) and \
211 args_set.findAtomForPackage(pkg):
212
213 --
214 gentoo-commits@l.g.o mailing list