~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to src/third_party/v8/tools/android-run.py

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# Copyright 2012 the V8 project authors. All rights reserved.
 
4
# Redistribution and use in source and binary forms, with or without
 
5
# modification, are permitted provided that the following conditions are
 
6
# met:
 
7
#
 
8
#     * Redistributions of source code must retain the above copyright
 
9
#       notice, this list of conditions and the following disclaimer.
 
10
#     * Redistributions in binary form must reproduce the above
 
11
#       copyright notice, this list of conditions and the following
 
12
#       disclaimer in the documentation and/or other materials provided
 
13
#       with the distribution.
 
14
#     * Neither the name of Google Inc. nor the names of its
 
15
#       contributors may be used to endorse or promote products derived
 
16
#       from this software without specific prior written permission.
 
17
#
 
18
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
19
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
20
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
21
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
22
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
23
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
24
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
25
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
26
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
27
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
28
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
29
 
 
30
# This script executes the passed command line on Android device
 
31
# using 'adb shell' command. Unfortunately, 'adb shell' always
 
32
# returns exit code 0, ignoring the exit code of executed command.
 
33
# Since we need to return non-zero exit code if the command failed,
 
34
# we augment the passed command line with exit code checking statement
 
35
# and output special error string in case of non-zero exit code.
 
36
# Then we parse the output of 'adb shell' and look for that error string.
 
37
 
 
38
import os
 
39
from os.path import join, dirname, abspath
 
40
import subprocess
 
41
import sys
 
42
import tempfile
 
43
 
 
44
def Check(output, errors):
 
45
  failed = any([s.startswith('/system/bin/sh:') or s.startswith('ANDROID')
 
46
                for s in output.split('\n')])
 
47
  return 1 if failed else 0
 
48
 
 
49
def Execute(cmdline):
 
50
  (fd_out, outname) = tempfile.mkstemp()
 
51
  (fd_err, errname) = tempfile.mkstemp()
 
52
  process = subprocess.Popen(
 
53
    args=cmdline,
 
54
    shell=True,
 
55
    stdout=fd_out,
 
56
    stderr=fd_err,
 
57
  )
 
58
  exit_code = process.wait()
 
59
  os.close(fd_out)
 
60
  os.close(fd_err)
 
61
  output = file(outname).read()
 
62
  errors = file(errname).read()
 
63
  os.unlink(outname)
 
64
  os.unlink(errname)
 
65
  sys.stdout.write(output)
 
66
  sys.stderr.write(errors)
 
67
  return exit_code or Check(output, errors)
 
68
 
 
69
def Escape(arg):
 
70
  def ShouldEscape():
 
71
    for x in arg:
 
72
      if not x.isalnum() and x != '-' and x != '_':
 
73
        return True
 
74
    return False
 
75
 
 
76
  return arg if not ShouldEscape() else '"%s"' % (arg.replace('"', '\\"'))
 
77
 
 
78
def WriteToTemporaryFile(data):
 
79
  (fd, fname) = tempfile.mkstemp()
 
80
  os.close(fd)
 
81
  tmp_file = open(fname, "w")
 
82
  tmp_file.write(data)
 
83
  tmp_file.close()
 
84
  return fname
 
85
 
 
86
def Main():
 
87
  if (len(sys.argv) == 1):
 
88
    print("Usage: %s <command-to-run-on-device>" % sys.argv[0])
 
89
    return 1
 
90
  workspace = abspath(join(dirname(sys.argv[0]), '..'))
 
91
  android_workspace = os.getenv("ANDROID_V8", "/data/local/v8")
 
92
  args = [Escape(arg) for arg in sys.argv[1:]]
 
93
  script = (" ".join(args) + "\n"
 
94
            "case $? in\n"
 
95
            "  0) ;;\n"
 
96
            "  *) echo \"ANDROID: Error returned by test\";;\n"
 
97
            "esac\n")
 
98
  script = script.replace(workspace, android_workspace)
 
99
  script_file = WriteToTemporaryFile(script)
 
100
  android_script_file = android_workspace + "/" + script_file
 
101
  command =  ("adb push '%s' %s;" % (script_file, android_script_file) +
 
102
              "adb shell 'sh %s';" % android_script_file +
 
103
              "adb shell 'rm %s'" % android_script_file)
 
104
  error_code = Execute(command)
 
105
  os.unlink(script_file)
 
106
  return error_code
 
107
 
 
108
if __name__ == '__main__':
 
109
  sys.exit(Main())