Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / native_client / tools / linux.x86_64.prep.sh
1 #!/bin/bash
2 # Copyright (c) 2014 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 ##################################################################
7 #  Description: tool to examine an x86_64 linux system to look for
8 #  missing packages needed to develop for Native Client and help the
9 #  user to install any that are missing.  This makes many assumptions
10 #  about the linux distribution (Ubuntu) and version (Trusty Tahr) and
11 #  might not work for other distributions/versions.
12 ##################################################################
13
14 PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
15
16 umask=077
17 d=${TMPDIR:-/tmp}/nacl64.$$
18 if ! mkdir "$d" > /dev/null 2>&1
19 then
20   cat >&2 << EOF
21 Could not create safe temporary directory "$d".
22
23 ABORTING.
24 EOF
25   exit 1
26 fi
27 f="$d/x.c"
28 fout="$d/x"
29 trap 'rm -fr "$d"; exit' 0 1 2 3 15
30
31 function isRunningAsRoot() {
32   whoami | grep -q 'root'
33 }
34
35
36 function ensure_installed {
37   if ! [ -e "$1" ]
38   then
39     cat >&2 << EOF
40 ... you do not have $2.  Installing...
41 EOF
42     if apt-get -y install "$2" > /dev/null 2>&1
43     then
44       echo "... done" >&2
45     else
46       cat >&2 <<EOF
47 ... failed to install $2.
48
49 ABORTING
50 EOF
51       exit 1
52     fi
53   fi
54 }
55
56 if ! isRunningAsRoot
57 then
58   cat >&2 << \EOF
59 Not running as root, so cannot install libraries/links.
60 Note: you probably will need to copy this script to the local file system
61 (and off of NFS) in order to run this script as root.
62
63 ABORTING.
64 EOF
65   exit 1
66 fi
67
68 ensure_installed '/usr/lib/git-core/git-svn' 'git-svn'
69
70 if [ $(uname -m) != "x86_64" ]
71 then
72   cat << \EOF
73 You do not appear to be using an x86_64 system.  This rest of this script
74 is not required.
75 EOF
76   exit 0
77 fi
78
79 # libtinfo5 is needed by gdb
80 ensure_installed '/lib/i386-linux-gnu/libtinfo.so.5' 'libtinfo5:i386'
81 # glib is needed by qemu
82 ensure_installed '/lib/i386-linux-gnu/libglib-2.0.so.0' 'libglib2.0-0:i386'
83 # 32-bit libc headers and libraries
84 ensure_installed '/usr/include/i386-linux-gnu/asm/errno.h' 'linux-libc-dev:i386'