OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium 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 """Downloads, builds (with instrumentation) and installs shared libraries.""" | 6 """Downloads, builds (with instrumentation) and installs shared libraries.""" |
7 | 7 |
8 import argparse | 8 import argparse |
9 import os | 9 import os |
10 import platform | 10 import platform |
| 11 import re |
11 import shlex | 12 import shlex |
12 import shutil | 13 import shutil |
13 import subprocess | 14 import subprocess |
14 import sys | 15 import sys |
15 | 16 |
16 class ScopedChangeDirectory(object): | 17 class ScopedChangeDirectory(object): |
17 """Changes current working directory and restores it back automatically.""" | 18 """Changes current working directory and restores it back automatically.""" |
18 | 19 |
19 def __init__(self, path): | 20 def __init__(self, path): |
20 self.path = path | 21 self.path = path |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 ] | 163 ] |
163 shell_call('make -j%s install %s' % | 164 shell_call('make -j%s install %s' % |
164 (parsed_arguments.jobs, ' '.join(install_args)), | 165 (parsed_arguments.jobs, ' '.join(install_args)), |
165 parsed_arguments.verbose, environment) | 166 parsed_arguments.verbose, environment) |
166 | 167 |
167 | 168 |
168 def libpci3_make_install(parsed_arguments, environment, install_prefix): | 169 def libpci3_make_install(parsed_arguments, environment, install_prefix): |
169 # pciutils doesn't have a configure script | 170 # pciutils doesn't have a configure script |
170 # This build script follows debian/rules. | 171 # This build script follows debian/rules. |
171 | 172 |
| 173 # Find out the package version. We'll use this when creating symlinks. |
| 174 dir_name = os.path.split(os.getcwd())[-1] |
| 175 match = re.match('pciutils-(\d+\.\d+\.\d+)', dir_name) |
| 176 if match is None: |
| 177 raise Exception( |
| 178 'Unable to guess libpci3 version from directory name: %s' % dir_name) |
| 179 version = match.group(1) |
| 180 |
172 # `make install' will create a "$(DESTDIR)-udeb" directory alongside destdir. | 181 # `make install' will create a "$(DESTDIR)-udeb" directory alongside destdir. |
173 # We don't want that in our product dir, so we use an intermediate directory. | 182 # We don't want that in our product dir, so we use an intermediate directory. |
174 destdir = '%s/debian/pciutils' % os.getcwd() | 183 destdir = '%s/debian/pciutils' % os.getcwd() |
175 make_args = [ | 184 make_args = [ |
176 '%s="%s"' % (name, environment[name]) | 185 '%s="%s"' % (name, environment[name]) |
177 for name in['CC', 'CXX', 'CFLAGS', 'CXXFLAGS', 'LDFLAGS']] | 186 for name in['CC', 'CXX', 'CFLAGS', 'CXXFLAGS', 'LDFLAGS']] |
178 make_args.append('SHARED=yes') | 187 make_args.append('SHARED=yes') |
| 188 # pciutils-3.2.1 (Trusty) fails to build due to unresolved libkmod symbols. |
| 189 # The binary package has no dependencies on libkmod, so it looks like it was |
| 190 # actually built without libkmod support. |
| 191 make_args.append('LIBKMOD=no') |
179 paths = [ | 192 paths = [ |
180 'LIBDIR=/lib/', | 193 'LIBDIR=/lib/', |
181 'PREFIX=/usr', | 194 'PREFIX=/usr', |
182 'SBINDIR=/usr/bin', | 195 'SBINDIR=/usr/bin', |
183 'IDSDIR=/usr/share/misc', | 196 'IDSDIR=/usr/share/misc', |
184 ] | 197 ] |
185 install_args = ['DESTDIR=%s' % destdir] | 198 install_args = ['DESTDIR=%s' % destdir] |
186 run_shell_commands([ | 199 run_shell_commands([ |
187 'mkdir -p %s-udeb/usr/bin' % destdir, | 200 'mkdir -p %s-udeb/usr/bin' % destdir, |
188 'make -j%s %s' % (parsed_arguments.jobs, ' '.join(make_args + paths)), | 201 'make -j%s %s' % (parsed_arguments.jobs, ' '.join(make_args + paths)), |
189 'make -j%s %s install' % ( | 202 'make -j%s %s install' % ( |
190 parsed_arguments.jobs, | 203 parsed_arguments.jobs, |
191 ' '.join(install_args + paths))], | 204 ' '.join(install_args + paths))], |
192 parsed_arguments.verbose, environment) | 205 parsed_arguments.verbose, environment) |
193 # Now move the contents of the temporary destdir to their final place. | 206 # Now move the contents of the temporary destdir to their final place. |
194 run_shell_commands([ | 207 run_shell_commands([ |
195 'cp %s/* %s/ -rd' % (destdir, install_prefix), | 208 'cp %s/* %s/ -rd' % (destdir, install_prefix), |
196 'install -m 644 lib/libpci.so* %s/lib/' % install_prefix, | 209 'install -m 644 lib/libpci.so* %s/lib/' % install_prefix, |
197 'ln -sf libpci.so.3.1.8 %s/lib/libpci.so.3' % install_prefix], | 210 'ln -sf libpci.so.%s %s/lib/libpci.so.3' % (version, install_prefix)], |
198 parsed_arguments.verbose, environment) | 211 parsed_arguments.verbose, environment) |
199 | 212 |
200 | 213 |
201 def build_and_install(parsed_arguments, environment, install_prefix): | 214 def build_and_install(parsed_arguments, environment, install_prefix): |
202 if parsed_arguments.build_method == 'destdir': | 215 if parsed_arguments.build_method == 'destdir': |
203 destdir_configure_make_install( | 216 destdir_configure_make_install( |
204 parsed_arguments, environment, install_prefix) | 217 parsed_arguments, environment, install_prefix) |
205 elif parsed_arguments.build_method == 'custom_nss': | 218 elif parsed_arguments.build_method == 'custom_nss': |
206 nss_make_and_copy(parsed_arguments, environment, install_prefix) | 219 nss_make_and_copy(parsed_arguments, environment, install_prefix) |
207 elif parsed_arguments.build_method == 'custom_libcap': | 220 elif parsed_arguments.build_method == 'custom_libcap': |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 os.chdir(get_script_absolute_path()) | 374 os.chdir(get_script_absolute_path()) |
362 # Ensure all build dependencies are installed. | 375 # Ensure all build dependencies are installed. |
363 if parsed_arguments.check_build_deps: | 376 if parsed_arguments.check_build_deps: |
364 check_package_build_dependencies(parsed_arguments.package) | 377 check_package_build_dependencies(parsed_arguments.package) |
365 | 378 |
366 download_build_install(parsed_arguments) | 379 download_build_install(parsed_arguments) |
367 | 380 |
368 | 381 |
369 if __name__ == '__main__': | 382 if __name__ == '__main__': |
370 main() | 383 main() |
OLD | NEW |