OLD | NEW |
1 #!/usr/bin/python2.6 | 1 #!/usr/bin/python2.6 |
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Program to run emerge in parallel, for significant speedup. | 6 """Program to run emerge in parallel, for significant speedup. |
7 | 7 |
8 Usage: | 8 Usage: |
9 ./parallel_emerge [--board=BOARD] [--workon=PKGS] [--no-workon-deps] | 9 ./parallel_emerge [--board=BOARD] [--workon=PKGS] [--no-workon-deps] |
10 [--force-remote-binary=PKGS] [emerge args] package | 10 [--force-remote-binary=PKGS] [emerge args] package |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 remote_ready = PrebuiltsReady(pkg, remote_pkgs, remote_ready_cache) | 1185 remote_ready = PrebuiltsReady(pkg, remote_pkgs, remote_ready_cache) |
1186 if remote_ready and (local_mtime <= remote_mtime or pkg in cycles): | 1186 if remote_ready and (local_mtime <= remote_mtime or pkg in cycles): |
1187 MergeChildren(pkg, "mandatory") | 1187 MergeChildren(pkg, "mandatory") |
1188 else: | 1188 else: |
1189 MergeChildren(pkg, "mandatory_source") | 1189 MergeChildren(pkg, "mandatory_source") |
1190 | 1190 |
1191 def UsePrebuiltPackages(remote_pkgs): | 1191 def UsePrebuiltPackages(remote_pkgs): |
1192 """Update packages that can use prebuilts to do so.""" | 1192 """Update packages that can use prebuilts to do so.""" |
1193 start = time.time() | 1193 start = time.time() |
1194 | 1194 |
1195 # The bintree is the database of binary packages. By default, it's | 1195 # Build list of prebuilt packages |
1196 # empty. | |
1197 bintree = emerge.trees[root]["bintree"] | |
1198 bindb = bintree.dbapi | |
1199 root_config = emerge.root_config | |
1200 pkgsettings = emerge.depgraph._frozen_config.pkgsettings[root] | |
1201 prebuilt_pkgs = {} | 1196 prebuilt_pkgs = {} |
1202 | |
1203 # Populate the DB with packages | |
1204 bintree.populate("--getbinpkg" in emerge.opts, | |
1205 "--getbinpkgonly" in emerge.opts) | |
1206 | |
1207 # Build list of prebuilt packages | |
1208 for pkg, info in deps_map.iteritems(): | 1197 for pkg, info in deps_map.iteritems(): |
1209 if info and info["action"] == "merge": | 1198 if info and info["action"] == "merge": |
1210 if (not info["force_remote_binary"] and info["mandatory_source"] or | 1199 if (not info["force_remote_binary"] and info["mandatory_source"] or |
1211 "--usepkgonly" not in emerge.opts and pkg not in remote_pkgs): | 1200 "--usepkgonly" not in emerge.opts and pkg not in remote_pkgs): |
1212 continue | 1201 continue |
1213 | 1202 |
1214 db_keys = list(bindb._aux_cache_keys) | 1203 db_pkg = emerge.depgraph._pkg(pkg, "binary", emerge.root_config) |
1215 try: | 1204 if info["force_remote_binary"]: |
1216 db_vals = bindb.aux_get(pkg, db_keys + ["MTIME"]) | 1205 # Undo our earlier hacks to the use flags so that the use flags |
1217 except KeyError: | 1206 # display correctly. |
1218 # No binary package | 1207 db_pkg.use.enabled = db_pkg.metadata["USE"].split() |
1219 continue | |
1220 | |
1221 mtime = int(db_vals.pop() or 0) | |
1222 metadata = zip(db_keys, db_vals) | |
1223 db_pkg = Package(built=True, cpv=pkg, installed=False, | |
1224 metadata=metadata, onlydeps=False, mtime=mtime, | |
1225 operation="merge", root_config=root_config, | |
1226 type_name="binary") | |
1227 prebuilt_pkgs[pkg] = db_pkg | 1208 prebuilt_pkgs[pkg] = db_pkg |
1228 | 1209 |
1229 # Calculate what packages need to be rebuilt due to changes in use flags. | 1210 # Calculate what packages need to be rebuilt due to changes in use flags. |
| 1211 pkgsettings = emerge.depgraph._frozen_config.pkgsettings[root] |
1230 for pkg, db_pkg in prebuilt_pkgs.iteritems(): | 1212 for pkg, db_pkg in prebuilt_pkgs.iteritems(): |
1231 if not self.CheckUseFlags(pkgsettings, db_pkg, self.package_db[pkg]): | 1213 if not self.CheckUseFlags(pkgsettings, db_pkg, self.package_db[pkg]): |
1232 MergeChildren(pkg, "mandatory_source") | 1214 MergeChildren(pkg, "mandatory_source") |
1233 | 1215 |
1234 # Convert eligible packages to binaries. | 1216 # Convert eligible packages to binaries. |
1235 for pkg, info in deps_map.iteritems(): | 1217 for pkg, info in deps_map.iteritems(): |
1236 if info and info["action"] == "merge" and pkg in prebuilt_pkgs: | 1218 if info and info["action"] == "merge" and pkg in prebuilt_pkgs: |
1237 if not info["mandatory_source"] or info["force_remote_binary"]: | 1219 if not info["mandatory_source"] or info["force_remote_binary"]: |
1238 self.package_db[pkg] = prebuilt_pkgs[pkg] | 1220 self.package_db[pkg] = prebuilt_pkgs[pkg] |
1239 | 1221 |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1894 # need to upgrade the rest of the packages. So we'll go ahead and do that. | 1876 # need to upgrade the rest of the packages. So we'll go ahead and do that. |
1895 if portage_upgrade: | 1877 if portage_upgrade: |
1896 args = sys.argv[1:] + ["--nomerge=sys-apps/portage"] | 1878 args = sys.argv[1:] + ["--nomerge=sys-apps/portage"] |
1897 os.execvp(os.path.realpath(sys.argv[0]), args) | 1879 os.execvp(os.path.realpath(sys.argv[0]), args) |
1898 | 1880 |
1899 print "Done" | 1881 print "Done" |
1900 sys.exit(0) | 1882 sys.exit(0) |
1901 | 1883 |
1902 if __name__ == "__main__": | 1884 if __name__ == "__main__": |
1903 main() | 1885 main() |
OLD | NEW |