| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 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 __author__ = 'nsanders@chromium.org (Nick Sanders)' | 6 __author__ = 'nsanders@chromium.org (Nick Sanders)' |
| 7 | 7 |
| 8 import common, os, re | 8 import common, os, re |
| 9 from autotest_lib.client.bin import utils | 9 from autotest_lib.client.bin import utils |
| 10 | 10 |
| 11 version = 1 | 11 version = 1 |
| 12 | 12 |
| 13 def target_is_x86(): | 13 def target_is_x86_pie(): |
| 14 result = utils.system_output('${CC} -dumpmachine', retain_output=True, | 14 result = utils.system_output('${CC} -dumpmachine', retain_output=True, |
| 15 ignore_status=True) | 15 ignore_status=True) |
| 16 x86_pattern = re.compile(r"^i.86.*") | 16 x86_pattern = re.compile(r"^i.86.*") |
| 17 return x86_pattern.match(result) | 17 if not x86_pattern.match(result): |
| 18 return False |
| 19 result = utils.system_output('${CC} -dumpspecs', retain_output=True, |
| 20 ignore_status=True) |
| 21 if result.find('!nopie:') == -1: |
| 22 return False |
| 23 return True |
| 18 | 24 |
| 19 | 25 |
| 20 def setup(tarball, topdir): | 26 def setup(tarball, topdir): |
| 21 srcdir = os.path.join(topdir, 'src') | 27 srcdir = os.path.join(topdir, 'src') |
| 22 utils.extract_tarball_to_dir(tarball, srcdir) | 28 utils.extract_tarball_to_dir(tarball, srcdir) |
| 23 # 'Add' arm support. | 29 # 'Add' arm support. |
| 24 os.chdir(srcdir) | 30 os.chdir(srcdir) |
| 25 utils.system('patch -p0 < ../iotools.arm.patch') | 31 utils.system('patch -p0 < ../iotools.arm.patch') |
| 26 # TODO(fes): Remove this if there is a better way to detect that we are | 32 if target_is_x86_pie(): |
| 27 # in a hardened build (or if this later properly picks up the | |
| 28 # -nopie flag from portage) | |
| 29 if os.path.exists('/etc/hardened') and target_is_x86(): | |
| 30 utils.system('patch -p0 < ../iotools.nopie.patch') | 33 utils.system('patch -p0 < ../iotools.nopie.patch') |
| 31 | 34 |
| 32 utils.system('CROSS_COMPILE=${CTARGET_default}- make') | 35 utils.system('CROSS_COMPILE=${CTARGET_default}- make') |
| 33 utils.system('cp iotools %s' % topdir) | 36 utils.system('cp iotools %s' % topdir) |
| 34 os.chdir(topdir) | 37 os.chdir(topdir) |
| 35 | 38 |
| 36 | 39 |
| 37 # The source is grabbed from | 40 # The source is grabbed from |
| 38 # http://iotools.googlecode.com/files/iotools-1.2.tar.gz | 41 # http://iotools.googlecode.com/files/iotools-1.2.tar.gz |
| 39 pwd = os.getcwd() | 42 pwd = os.getcwd() |
| 40 tarball = os.path.join(pwd, 'iotools-1.2.tar.gz') | 43 tarball = os.path.join(pwd, 'iotools-1.2.tar.gz') |
| 41 utils.update_version(pwd+'/src', False, version, setup, tarball, pwd) | 44 utils.update_version(pwd+'/src', False, version, setup, tarball, pwd) |
| OLD | NEW |