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.util import Trace, Log, Warn | 7 from naclports.util import Log, Warn, LogVerbose |
8 from naclports.error import Error | 8 from naclports.error import Error |
9 from naclports import configuration, pkg_info, util | 9 from naclports import configuration, pkg_info, util |
10 | 10 |
11 EXTRA_KEYS = ['BUILD_CONFIG', 'BUILD_ARCH', 'BUILD_TOOLCHAIN', | 11 EXTRA_KEYS = ['BUILD_CONFIG', 'BUILD_ARCH', 'BUILD_TOOLCHAIN', |
12 'BUILD_SDK_VERSION', 'BUILD_NACLPORTS_REVISION'] | 12 'BUILD_SDK_VERSION', 'BUILD_NACLPORTS_REVISION'] |
13 | 13 |
14 | 14 |
15 def RemoveEmptyDirs(dirname): | 15 def RemoveEmptyDirs(dirname): |
16 """Recursively remove a directoy and its parents if they are empty.""" | 16 """Recursively remove a directoy and its parents if they are empty.""" |
17 while not os.listdir(dirname): | 17 while not os.listdir(dirname): |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 with open(self.GetListFile()) as f: | 153 with open(self.GetListFile()) as f: |
154 for line in f: | 154 for line in f: |
155 yield line.strip() | 155 yield line.strip() |
156 | 156 |
157 def DoUninstall(self): | 157 def DoUninstall(self): |
158 with util.InstallLock(self.config): | 158 with util.InstallLock(self.config): |
159 RemoveFile(self.GetInstallStamp()) | 159 RemoveFile(self.GetInstallStamp()) |
160 | 160 |
161 root = util.GetInstallRoot(self.config) | 161 root = util.GetInstallRoot(self.config) |
162 for filename in self.Files(): | 162 for filename in self.Files(): |
163 filename = os.path.join(root, filename) | 163 fullname = os.path.join(root, filename) |
164 if not os.path.lexists(filename): | 164 if not os.path.lexists(fullname): |
165 Warn('File not found while uninstalling: %s' % filename) | 165 Warn('File not found while uninstalling: %s' % fullname) |
166 continue | 166 continue |
167 Trace('rm %s' % filename) | 167 LogVerbose('uninstall: %s' % filename) |
168 RemoveFile(filename) | 168 RemoveFile(fullname) |
169 | 169 |
170 RemoveFile(self.GetListFile()) | 170 RemoveFile(self.GetListFile()) |
171 | 171 |
172 | 172 |
173 def InstalledPackageIterator(config): | 173 def InstalledPackageIterator(config): |
174 stamp_root = util.GetInstallStampRoot(config) | 174 stamp_root = util.GetInstallStampRoot(config) |
175 if not os.path.exists(stamp_root): | 175 if not os.path.exists(stamp_root): |
176 return | 176 return |
177 | 177 |
178 for filename in os.listdir(stamp_root): | 178 for filename in os.listdir(stamp_root): |
179 if os.path.splitext(filename)[1] != '.info': | 179 if os.path.splitext(filename)[1] != '.info': |
180 continue | 180 continue |
181 yield InstalledPackage(os.path.join(stamp_root, filename)) | 181 yield InstalledPackage(os.path.join(stamp_root, filename)) |
182 | 182 |
183 | 183 |
184 def CreateInstalledPackage(package_name, config=None): | 184 def CreateInstalledPackage(package_name, config=None): |
185 stamp_root = util.GetInstallStampRoot(config) | 185 stamp_root = util.GetInstallStampRoot(config) |
186 info_file = os.path.join(stamp_root, package_name + '.info') | 186 info_file = os.path.join(stamp_root, package_name + '.info') |
187 if not os.path.exists(info_file): | 187 if not os.path.exists(info_file): |
188 raise Error('package not installed: %s [%s]' % (package_name, config)) | 188 raise Error('package not installed: %s [%s]' % (package_name, config)) |
189 return InstalledPackage(info_file) | 189 return InstalledPackage(info_file) |
OLD | NEW |