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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 url: The specified url. | 741 url: The specified url. |
742 tries: The number of times to try. | 742 tries: The number of times to try. |
743 | 743 |
744 Returns: | 744 Returns: |
745 The result of urllib2.urlopen(url). | 745 The result of urllib2.urlopen(url). |
746 """ | 746 """ |
747 for i in range(tries): | 747 for i in range(tries): |
748 try: | 748 try: |
749 return urllib2.urlopen(url) | 749 return urllib2.urlopen(url) |
750 except urllib2.HTTPError as e: | 750 except urllib2.HTTPError as e: |
| 751 print "Cannot GET %s: %s" % (url, str(e)) |
751 if i + 1 >= tries or e.code < 500: | 752 if i + 1 >= tries or e.code < 500: |
752 raise | 753 raise |
753 else: | |
754 print "Cannot GET %s: %s" % (url, str(e)) | |
755 except urllib2.URLError as e: | 754 except urllib2.URLError as e: |
| 755 print "Cannot GET %s: %s" % (url, str(e)) |
756 if i + 1 >= tries: | 756 if i + 1 >= tries: |
757 raise | 757 raise |
758 else: | |
759 print "Cannot GET %s: %s" % (url, str(e)) | |
760 print "Sleeping for 10 seconds before retrying..." | 758 print "Sleeping for 10 seconds before retrying..." |
761 time.sleep(10) | 759 time.sleep(10) |
762 | 760 |
763 url = os.path.join(binhost_url, "Packages") | 761 url = os.path.join(binhost_url, "Packages") |
764 try: | 762 try: |
765 f = retry_urlopen(url) | 763 f = retry_urlopen(url) |
766 except urllib2.HTTPError as e: | 764 except urllib2.HTTPError as e: |
767 if e.code == 404: | 765 if e.code == 404: |
768 return {} | 766 return {} |
769 else: | 767 else: |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1828 print "Starting fast-emerge." | 1826 print "Starting fast-emerge." |
1829 print " Building package %s on %s" % (cmdline_packages, | 1827 print " Building package %s on %s" % (cmdline_packages, |
1830 deps.board or "root") | 1828 deps.board or "root") |
1831 if nomerge_packages: | 1829 if nomerge_packages: |
1832 print " Skipping package %s on %s" % (nomerge_packages, | 1830 print " Skipping package %s on %s" % (nomerge_packages, |
1833 deps.board or "root") | 1831 deps.board or "root") |
1834 | 1832 |
1835 remote_pkgs = {} | 1833 remote_pkgs = {} |
1836 if "--getbinpkg" in emerge.opts: | 1834 if "--getbinpkg" in emerge.opts: |
1837 binhost = emerge.settings["PORTAGE_BINHOST"] | 1835 binhost = emerge.settings["PORTAGE_BINHOST"] |
1838 remote_pkgs = deps.RemotePackageDatabase(binhost) | 1836 try: |
| 1837 remote_pkgs = deps.RemotePackageDatabase(binhost) |
| 1838 except (urllib2.HTTPError, urllib2.URLError): |
| 1839 print "Cannot resolve binhost. Building from source..." |
| 1840 del emerge.opts["--getbinpkg"] |
1839 | 1841 |
1840 deps_tree, deps_info = deps.GenDependencyTree(remote_pkgs) | 1842 deps_tree, deps_info = deps.GenDependencyTree(remote_pkgs) |
1841 | 1843 |
1842 # You want me to be verbose? I'll give you two trees! Twice as much value. | 1844 # You want me to be verbose? I'll give you two trees! Twice as much value. |
1843 if "--tree" in emerge.opts and "--verbose" in emerge.opts: | 1845 if "--tree" in emerge.opts and "--verbose" in emerge.opts: |
1844 deps.PrintTree(deps_tree) | 1846 deps.PrintTree(deps_tree) |
1845 | 1847 |
1846 deps_graph = deps.GenDependencyGraph(deps_tree, deps_info, remote_pkgs) | 1848 deps_graph = deps.GenDependencyGraph(deps_tree, deps_info, remote_pkgs) |
1847 | 1849 |
1848 # OK, time to print out our progress so far. | 1850 # OK, time to print out our progress so far. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1892 # need to upgrade the rest of the packages. So we'll go ahead and do that. | 1894 # need to upgrade the rest of the packages. So we'll go ahead and do that. |
1893 if portage_upgrade: | 1895 if portage_upgrade: |
1894 args = sys.argv[1:] + ["--nomerge=sys-apps/portage"] | 1896 args = sys.argv[1:] + ["--nomerge=sys-apps/portage"] |
1895 os.execvp(os.path.realpath(sys.argv[0]), args) | 1897 os.execvp(os.path.realpath(sys.argv[0]), args) |
1896 | 1898 |
1897 print "Done" | 1899 print "Done" |
1898 sys.exit(0) | 1900 sys.exit(0) |
1899 | 1901 |
1900 if __name__ == "__main__": | 1902 if __name__ == "__main__": |
1901 main() | 1903 main() |
OLD | NEW |