OLD | NEW |
1 # Copyright (c) 2014 The Native Client Authors. All rights reserved. | 1 # Copyright (c) 2014 The Native Client Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os | 5 import os |
6 | 6 |
7 from naclports import configuration, binary_package, package, util, paths | 7 from naclports import configuration, binary_package, package, util, paths |
8 from naclports import pkg_info, error | 8 from naclports import pkg_info, error |
9 | 9 |
10 DEFAULT_INDEX = os.path.join(paths.NACLPORTS_ROOT, 'lib', 'prebuilt.txt') | 10 DEFAULT_INDEX = os.path.join(paths.NACLPORTS_ROOT, 'lib', 'prebuilt.txt') |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return (package_name, config) in self.packages | 77 return (package_name, config) in self.packages |
78 | 78 |
79 def Installable(self, package_name, config): | 79 def Installable(self, package_name, config): |
80 """Returns True if the index contains the given package and it is | 80 """Returns True if the index contains the given package and it is |
81 installable in the currently configured SDK.""" | 81 installable in the currently configured SDK.""" |
82 info = self.packages.get((package_name, config)) | 82 info = self.packages.get((package_name, config)) |
83 if not info: | 83 if not info: |
84 return False | 84 return False |
85 version = util.GetSDKVersion() | 85 version = util.GetSDKVersion() |
86 if info['BUILD_SDK_VERSION'] != version: | 86 if info['BUILD_SDK_VERSION'] != version: |
87 util.Trace('Prebuilt package was built with different SDK version: ' | 87 util.LogVerbose('Prebuilt package was built with different SDK version: ' |
88 '%s vs %s' % (info['BUILD_SDK_VERSION'], version)) | 88 '%s vs %s' % (info['BUILD_SDK_VERSION'], version)) |
89 return False | 89 return False |
90 return True | 90 return True |
91 | 91 |
92 def Download(self, package_name, config): | 92 def Download(self, package_name, config): |
93 if not os.path.exists(PREBUILT_ROOT): | 93 if not os.path.exists(PREBUILT_ROOT): |
94 util.Makedirs(PREBUILT_ROOT) | 94 util.Makedirs(PREBUILT_ROOT) |
95 info = self.packages[(package_name, config)] | 95 info = self.packages[(package_name, config)] |
96 filename = os.path.join(PREBUILT_ROOT, os.path.basename(info['BIN_URL'])) | 96 filename = os.path.join(PREBUILT_ROOT, os.path.basename(info['BIN_URL'])) |
97 if os.path.exists(filename): | 97 if os.path.exists(filename): |
98 try: | 98 try: |
(...skipping 14 matching lines...) Expand all Loading... |
113 info = pkg_info.ParsePkgInfo(info_files, self.filename, | 113 info = pkg_info.ParsePkgInfo(info_files, self.filename, |
114 self.valid_keys, self.required_keys) | 114 self.valid_keys, self.required_keys) |
115 debug = info['BUILD_CONFIG'] == 'debug' | 115 debug = info['BUILD_CONFIG'] == 'debug' |
116 config = configuration.Configuration(info['BUILD_ARCH'], | 116 config = configuration.Configuration(info['BUILD_ARCH'], |
117 info['BUILD_TOOLCHAIN'], | 117 info['BUILD_TOOLCHAIN'], |
118 debug) | 118 debug) |
119 key = (info['NAME'], config) | 119 key = (info['NAME'], config) |
120 if key in self.packages: | 120 if key in self.packages: |
121 error.Error('package index contains duplicate: %s' % str(key)) | 121 error.Error('package index contains duplicate: %s' % str(key)) |
122 self.packages[key] = info | 122 self.packages[key] = info |
OLD | NEW |