OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that be | 3 # Use of this source code is governed by a BSD-style license that be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Small utility library of python functions used by the various package | 6 """Small utility library of python functions used by the various package |
7 installers. | 7 installers. |
8 """ | 8 """ |
9 | 9 |
10 import errno | 10 import errno |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 return shell_env | 73 return shell_env |
74 | 74 |
75 | 75 |
76 # Return a "normalized" path that will work with both hermetic cygwin and *nix | 76 # Return a "normalized" path that will work with both hermetic cygwin and *nix |
77 # shell environments. On *nix, this method just returns the original path; on | 77 # shell environments. On *nix, this method just returns the original path; on |
78 # Windows running hermetic cygwin, this alters the path. |abs_path| must be | 78 # Windows running hermetic cygwin, this alters the path. |abs_path| must be |
79 # a fully-qualified absolute path, on Windows it must include the drive letter. | 79 # a fully-qualified absolute path, on Windows it must include the drive letter. |
80 # |shell_env| describes the environment used by any subprocess (this is | 80 # |shell_env| describes the environment used by any subprocess (this is |
81 # normally obtained from GetShellEnvironment() | 81 # normally obtained from GetShellEnvironment() |
82 # TODO(dspringer,khim): make this work properly for hermetic cygwin (see bug | |
83 # http://code.google.com/p/nativeclient/issues/detail?id=1122) | |
84 def HermeticBuildPath(abs_path, shell_env): | 82 def HermeticBuildPath(abs_path, shell_env): |
85 if (sys.platform == 'win32'): | 83 if (sys.platform == 'win32'): |
86 return abs_path | 84 return abs_path.replace('\\', '\\\\') |
87 | 85 |
88 return abs_path | 86 return abs_path |
89 | 87 |
90 | 88 |
91 # patch version 2.6 doesn't work. Most of our Linux distros use patch 2.6. | 89 # patch version 2.6 doesn't work. Most of our Linux distros use patch 2.6. |
92 # Returns |True| if the version of patch is usable (that is, not version 2.6). | 90 # Returns |True| if the version of patch is usable (that is, not version 2.6). |
93 # |shell_env| is the enviromnent used to run the subprocesses like patch and | 91 # |shell_env| is the enviromnent used to run the subprocesses like patch and |
94 # sed. If |shell_env| is None, then os.environ is used. | 92 # sed. If |shell_env| is None, then os.environ is used. |
95 def CheckPatchVersion(shell_env=None): | 93 def CheckPatchVersion(shell_env=None): |
96 if shell_env is None: | 94 if shell_env is None: |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if m: | 173 if m: |
176 return int(m.group(1)) | 174 return int(m.group(1)) |
177 else: | 175 else: |
178 return 0 | 176 return 0 |
179 | 177 |
180 # Returns the version of native client based on the svn revision number. | 178 # Returns the version of native client based on the svn revision number. |
181 def VersionString(): | 179 def VersionString(): |
182 rev = SVNRevision() | 180 rev = SVNRevision() |
183 build_number = os.environ.get('BUILD_NUMBER', '0') | 181 build_number = os.environ.get('BUILD_NUMBER', '0') |
184 return 'native_client_sdk_0_1_%d_%s' % (rev, build_number) | 182 return 'native_client_sdk_0_1_%d_%s' % (rev, build_number) |
OLD | NEW |