| 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 [emerge args] package" | 10 [emerge args] package" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 # permissions. It'd be easier if we could default to $USERNAME, but $USERNAME | 53 # permissions. It'd be easier if we could default to $USERNAME, but $USERNAME |
| 54 # is "root" here because we get called through sudo. | 54 # is "root" here because we get called through sudo. |
| 55 # | 55 # |
| 56 # We need to set this before importing any portage modules, because portage | 56 # We need to set this before importing any portage modules, because portage |
| 57 # looks up "PORTAGE_USERNAME" at import time. | 57 # looks up "PORTAGE_USERNAME" at import time. |
| 58 # | 58 # |
| 59 # NOTE: .bashrc sets PORTAGE_USERNAME = $USERNAME, so most people won't | 59 # NOTE: .bashrc sets PORTAGE_USERNAME = $USERNAME, so most people won't |
| 60 # encounter this case unless they have an old chroot or blow away the | 60 # encounter this case unless they have an old chroot or blow away the |
| 61 # environment by running sudo without the -E specifier. | 61 # environment by running sudo without the -E specifier. |
| 62 if "PORTAGE_USERNAME" not in os.environ: | 62 if "PORTAGE_USERNAME" not in os.environ: |
| 63 homedir = os.environ["HOME"] | 63 homedir = os.environ.get("HOME") |
| 64 if homedir.startswith("/home/"): | 64 if homedir: |
| 65 os.environ["PORTAGE_USERNAME"] = homedir.split("/")[2] | 65 os.environ["PORTAGE_USERNAME"] = os.path.basename(homedir) |
| 66 | 66 |
| 67 # Portage doesn't expose dependency trees in its public API, so we have to | 67 # Portage doesn't expose dependency trees in its public API, so we have to |
| 68 # make use of some private APIs here. These modules are found under | 68 # make use of some private APIs here. These modules are found under |
| 69 # /usr/lib/portage/pym/. | 69 # /usr/lib/portage/pym/. |
| 70 # | 70 # |
| 71 # TODO(davidjames): Update Portage to expose public APIs for these features. | 71 # TODO(davidjames): Update Portage to expose public APIs for these features. |
| 72 from _emerge.actions import adjust_configs | 72 from _emerge.actions import adjust_configs |
| 73 from _emerge.actions import load_emerge_config | 73 from _emerge.actions import load_emerge_config |
| 74 from _emerge.create_depgraph_params import create_depgraph_params | 74 from _emerge.create_depgraph_params import create_depgraph_params |
| 75 from _emerge.depgraph import backtrack_depgraph | 75 from _emerge.depgraph import backtrack_depgraph |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 | 1018 |
| 1019 It expects package identifiers to be passed to it via task_queue. When | 1019 It expects package identifiers to be passed to it via task_queue. When |
| 1020 the package is merged, it pushes (target, retval, outputstr) into the | 1020 the package is merged, it pushes (target, retval, outputstr) into the |
| 1021 done_queue. | 1021 done_queue. |
| 1022 """ | 1022 """ |
| 1023 | 1023 |
| 1024 settings, trees, mtimedb = emerge.settings, emerge.trees, emerge.mtimedb | 1024 settings, trees, mtimedb = emerge.settings, emerge.trees, emerge.mtimedb |
| 1025 opts, spinner = emerge.opts, emerge.spinner | 1025 opts, spinner = emerge.opts, emerge.spinner |
| 1026 opts["--nodeps"] = True | 1026 opts["--nodeps"] = True |
| 1027 while True: | 1027 while True: |
| 1028 # Wait for a new item to show up on the queue. This is a blocking wait, |
| 1029 # so if there's nothing to do, we just sit here. |
| 1028 target = task_queue.get() | 1030 target = task_queue.get() |
| 1029 print "Emerging", target | 1031 print "Emerging", target |
| 1030 db_pkg = package_db[target] | 1032 db_pkg = package_db[target] |
| 1031 db_pkg.root_config = emerge.root_config | 1033 db_pkg.root_config = emerge.root_config |
| 1032 install_list = [db_pkg] | 1034 install_list = [db_pkg] |
| 1033 output = tempfile.TemporaryFile() | 1035 output = tempfile.TemporaryFile() |
| 1034 outputstr = "" | 1036 outputstr = "" |
| 1035 if "--pretend" in opts: | 1037 if "--pretend" in opts: |
| 1036 retval = 0 | 1038 retval = 0 |
| 1037 else: | 1039 else: |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 for db_pkg in final_db.match_pkgs(pkg): | 1259 for db_pkg in final_db.match_pkgs(pkg): |
| 1258 print "Adding %s to world" % db_pkg.cp | 1260 print "Adding %s to world" % db_pkg.cp |
| 1259 new_world_pkgs.append(db_pkg.cp) | 1261 new_world_pkgs.append(db_pkg.cp) |
| 1260 if new_world_pkgs: | 1262 if new_world_pkgs: |
| 1261 world_set.update(new_world_pkgs) | 1263 world_set.update(new_world_pkgs) |
| 1262 | 1264 |
| 1263 print "Done" | 1265 print "Done" |
| 1264 | 1266 |
| 1265 if __name__ == "__main__": | 1267 if __name__ == "__main__": |
| 1266 main() | 1268 main() |
| OLD | NEW |