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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 Args: | 917 Args: |
918 binhost_url: Base URL of remote packages (PORTAGE_BINHOST). | 918 binhost_url: Base URL of remote packages (PORTAGE_BINHOST). |
919 | 919 |
920 Returns: | 920 Returns: |
921 A dict mapping package identifiers to modification times. | 921 A dict mapping package identifiers to modification times. |
922 """ | 922 """ |
923 | 923 |
924 if not binhost_url: | 924 if not binhost_url: |
925 return {} | 925 return {} |
926 | 926 |
| 927 def retry_urlopen(url, tries=3): |
| 928 """Open the specified url, retrying if we run into network errors. |
| 929 |
| 930 We do not retry for HTTP errors. |
| 931 |
| 932 Args: |
| 933 url: The specified url. |
| 934 tries: The number of times to try. |
| 935 |
| 936 Returns: |
| 937 The result of urllib2.urlopen(url). |
| 938 """ |
| 939 for i in range(tries): |
| 940 try: |
| 941 return urllib2.urlopen(url) |
| 942 except urllib2.HTTPError as e: |
| 943 raise |
| 944 except urllib2.URLError as e: |
| 945 if i + 1 == tries: |
| 946 raise |
| 947 else: |
| 948 print "Cannot GET %s: %s" % (url, e) |
| 949 |
927 url = binhost_url + "/Packages" | 950 url = binhost_url + "/Packages" |
928 | |
929 prebuilt_pkgs = {} | |
930 try: | 951 try: |
931 f = urllib2.urlopen(url) | 952 f = retry_urlopen(url) |
932 except urllib2.HTTPError as e: | 953 except urllib2.HTTPError as e: |
933 if e.code == 404: | 954 if e.code == 404: |
934 return {} | 955 return {} |
935 else: | 956 else: |
936 raise | 957 raise |
| 958 prebuilt_pkgs = {} |
937 for line in f: | 959 for line in f: |
938 if line.startswith("CPV: "): | 960 if line.startswith("CPV: "): |
939 pkg = line.replace("CPV: ", "").rstrip() | 961 pkg = line.replace("CPV: ", "").rstrip() |
940 elif line.startswith("MTIME: "): | 962 elif line.startswith("MTIME: "): |
941 prebuilt_pkgs[pkg] = int(line[:-1].replace("MTIME: ", "")) | 963 prebuilt_pkgs[pkg] = int(line[:-1].replace("MTIME: ", "")) |
942 f.close() | 964 f.close() |
943 | 965 |
944 return prebuilt_pkgs | 966 return prebuilt_pkgs |
945 | 967 |
946 def LocalPackageDatabase(): | 968 def LocalPackageDatabase(): |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 else: | 1159 else: |
1138 for pkg in self.mandatory_source.copy(): | 1160 for pkg in self.mandatory_source.copy(): |
1139 for db_pkg in final_db.match_pkgs(pkg): | 1161 for db_pkg in final_db.match_pkgs(pkg): |
1140 MergeChildren(str(db_pkg.cpv), "mandatory_source") | 1162 MergeChildren(str(db_pkg.cpv), "mandatory_source") |
1141 | 1163 |
1142 cycles = FindCycles() | 1164 cycles = FindCycles() |
1143 if self.rebuild: | 1165 if self.rebuild: |
1144 local_pkgs = LocalPackageDatabase() | 1166 local_pkgs = LocalPackageDatabase() |
1145 remote_pkgs = {} | 1167 remote_pkgs = {} |
1146 if "--getbinpkg" in emerge.opts: | 1168 if "--getbinpkg" in emerge.opts: |
1147 remote_pkgs = RemotePackageDatabase(emerge.settings["PORTAGE_BINHOST"]
) | 1169 binhost = emerge.settings["PORTAGE_BINHOST"] |
| 1170 remote_pkgs = RemotePackageDatabase(binhost) |
1148 AutoRebuildDeps(local_pkgs, remote_pkgs, cycles) | 1171 AutoRebuildDeps(local_pkgs, remote_pkgs, cycles) |
1149 | 1172 |
1150 # We need to remove installed packages so that we can use the dependency | 1173 # We need to remove installed packages so that we can use the dependency |
1151 # ordering of the install process to show us what cycles to crack. Once | 1174 # ordering of the install process to show us what cycles to crack. Once |
1152 # we've done that, we also need to recalculate our list of cycles so that | 1175 # we've done that, we also need to recalculate our list of cycles so that |
1153 # we don't include the installed packages in our cycles. | 1176 # we don't include the installed packages in our cycles. |
1154 RemoveInstalledPackages() | 1177 RemoveInstalledPackages() |
1155 SanitizeTree() | 1178 SanitizeTree() |
1156 if deps_map: | 1179 if deps_map: |
1157 if "--usepkg" in emerge.opts: | 1180 if "--usepkg" in emerge.opts: |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1706 # If we already upgraded portage, we don't need to do so again. But we do | 1729 # If we already upgraded portage, we don't need to do so again. But we do |
1707 # need to upgrade the rest of the packages. So we'll go ahead and do that. | 1730 # need to upgrade the rest of the packages. So we'll go ahead and do that. |
1708 if portage_upgrade: | 1731 if portage_upgrade: |
1709 args = sys.argv[1:] + ["--nomerge=sys-apps/portage"] | 1732 args = sys.argv[1:] + ["--nomerge=sys-apps/portage"] |
1710 os.execvp(os.path.realpath(sys.argv[0]), args) | 1733 os.execvp(os.path.realpath(sys.argv[0]), args) |
1711 | 1734 |
1712 print "Done" | 1735 print "Done" |
1713 | 1736 |
1714 if __name__ == "__main__": | 1737 if __name__ == "__main__": |
1715 main() | 1738 main() |
OLD | NEW |