media/webrtc/trunk/build/install-build-deps.sh

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/webrtc/trunk/build/install-build-deps.sh	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,414 @@
     1.4 +#!/bin/bash -e
     1.5 +
     1.6 +# Copyright (c) 2012 The Chromium Authors. All rights reserved.
     1.7 +# Use of this source code is governed by a BSD-style license that can be
     1.8 +# found in the LICENSE file.
     1.9 +
    1.10 +# Script to install everything needed to build chromium (well, ideally, anyway)
    1.11 +# See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions
    1.12 +# and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit
    1.13 +
    1.14 +usage() {
    1.15 +  echo "Usage: $0 [--options]"
    1.16 +  echo "Options:"
    1.17 +  echo "--[no-]syms: enable or disable installation of debugging symbols"
    1.18 +  echo "--[no-]lib32: enable or disable installation of 32 bit libraries"
    1.19 +  echo "--no-prompt: silently select standard options/defaults"
    1.20 +  echo "Script will prompt interactively if options not given."
    1.21 +  exit 1
    1.22 +}
    1.23 +
    1.24 +while test "$1" != ""
    1.25 +do
    1.26 +  case "$1" in
    1.27 +  --syms)                   do_inst_syms=1;;
    1.28 +  --no-syms)                do_inst_syms=0;;
    1.29 +  --lib32)                  do_inst_lib32=1;;
    1.30 +  --no-lib32)               do_inst_lib32=0;;
    1.31 +  --no-prompt)              do_default=1
    1.32 +                            do_quietly="-qq --assume-yes"
    1.33 +    ;;
    1.34 +  *) usage;;
    1.35 +  esac
    1.36 +  shift
    1.37 +done
    1.38 +
    1.39 +if ! egrep -q \
    1.40 +    'Ubuntu (10\.04|10\.10|11\.04|11\.10|12\.04|lucid|maverick|natty|oneiric|precise)' \
    1.41 +    /etc/issue; then
    1.42 +  echo "Only Ubuntu 10.04 (lucid) through 12.04 (precise) are currently" \
    1.43 +      "supported" >&2
    1.44 +  exit 1
    1.45 +fi
    1.46 +
    1.47 +if ! uname -m | egrep -q "i686|x86_64"; then
    1.48 +  echo "Only x86 architectures are currently supported" >&2
    1.49 +  exit
    1.50 +fi
    1.51 +
    1.52 +if [ "x$(id -u)" != x0 ]; then
    1.53 +  echo "Running as non-root user."
    1.54 +  echo "You might have to enter your password one or more times for 'sudo'."
    1.55 +  echo
    1.56 +fi
    1.57 +
    1.58 +# Packages needed for chromeos only
    1.59 +chromeos_dev_list="libbluetooth-dev libpulse-dev"
    1.60 +
    1.61 +# Packages need for development
    1.62 +dev_list="apache2.2-bin bison curl elfutils fakeroot flex g++ gperf
    1.63 +          language-pack-fr libapache2-mod-php5 libasound2-dev libbz2-dev
    1.64 +          libcairo2-dev libcups2-dev libcurl4-gnutls-dev libdbus-glib-1-dev
    1.65 +          libelf-dev libgconf2-dev libgl1-mesa-dev libglib2.0-dev
    1.66 +          libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev
    1.67 +          libkrb5-dev libnspr4-dev libnss3-dev libpam0g-dev libsctp-dev
    1.68 +          libsqlite3-dev libssl-dev libudev-dev libwww-perl libxslt1-dev
    1.69 +          libxss-dev libxt-dev libxtst-dev mesa-common-dev patch
    1.70 +          perl php5-cgi pkg-config python python-cherrypy3 python-dev
    1.71 +          python-psutil rpm ruby subversion ttf-dejavu-core ttf-indic-fonts
    1.72 +          ttf-kochi-gothic ttf-kochi-mincho ttf-thai-tlwg wdiff git-core
    1.73 +          $chromeos_dev_list"
    1.74 +
    1.75 +# 64-bit systems need a minimum set of 32-bit compat packages for the pre-built
    1.76 +# NaCl binaries. These are always needed, regardless of whether or not we want
    1.77 +# the full 32-bit "cross-compile" support (--lib32).
    1.78 +if [ "$(uname -m)" = "x86_64" ]; then
    1.79 +  dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6"
    1.80 +fi
    1.81 +
    1.82 +# Run-time libraries required by chromeos only
    1.83 +chromeos_lib_list="libpulse0 libbz2-1.0 libcurl4-gnutls-dev"
    1.84 +
    1.85 +# Full list of required run-time libraries
    1.86 +lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcups2 libdbus-glib-1-2
    1.87 +          libexpat1 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0
    1.88 +          libgtk2.0-0 libpam0g libpango1.0-0 libpcre3 libpixman-1-0
    1.89 +          libpng12-0 libstdc++6 libsqlite3-0 libudev0 libx11-6 libxau6 libxcb1
    1.90 +          libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3
    1.91 +          libxi6 libxinerama1 libxrandr2 libxrender1 libxtst6 zlib1g
    1.92 +          $chromeos_lib_list"
    1.93 +
    1.94 +# Debugging symbols for all of the run-time libraries
    1.95 +dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libdbus-glib-1-2-dbg
    1.96 +          libfontconfig1-dbg libglib2.0-0-dbg libgtk2.0-0-dbg
    1.97 +          libpango1.0-0-dbg libpcre3-dbg libpixman-1-0-dbg
    1.98 +          libsqlite3-0-dbg
    1.99 +          libx11-6-dbg libxau6-dbg libxcb1-dbg libxcomposite1-dbg
   1.100 +          libxcursor1-dbg libxdamage1-dbg libxdmcp6-dbg libxext6-dbg
   1.101 +          libxfixes3-dbg libxi6-dbg libxinerama1-dbg libxrandr2-dbg
   1.102 +          libxrender1-dbg libxtst6-dbg zlib1g-dbg"
   1.103 +
   1.104 +# Plugin lists needed for tests.
   1.105 +plugin_list="flashplugin-installer"
   1.106 +
   1.107 +# Some package names have changed over time
   1.108 +if apt-cache show ttf-mscorefonts-installer >/dev/null 2>&1; then
   1.109 +  dev_list="${dev_list} ttf-mscorefonts-installer"
   1.110 +else
   1.111 +  dev_list="${dev_list} msttcorefonts"
   1.112 +fi
   1.113 +if apt-cache show libnspr4-dbg >/dev/null 2>&1; then
   1.114 +  dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg"
   1.115 +  lib_list="${lib_list} libnspr4 libnss3"
   1.116 +else
   1.117 +  dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg"
   1.118 +  lib_list="${lib_list} libnspr4-0d libnss3-1d"
   1.119 +fi
   1.120 +if apt-cache show libjpeg-dev >/dev/null 2>&1; then
   1.121 + dev_list="${dev_list} libjpeg-dev"
   1.122 +else
   1.123 + dev_list="${dev_list} libjpeg62-dev"
   1.124 +fi
   1.125 +
   1.126 +# Some packages are only needed, if the distribution actually supports
   1.127 +# installing them.
   1.128 +if apt-cache show appmenu-gtk >/dev/null 2>&1; then
   1.129 +  lib_list="$lib_list appmenu-gtk"
   1.130 +fi
   1.131 +
   1.132 +# Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is
   1.133 +# accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has
   1.134 +# been provided to yes_no(), the function also accepts RETURN as a user input.
   1.135 +# The parameter specifies the exit code that should be returned in that case.
   1.136 +# The function will echo the user's selection followed by a newline character.
   1.137 +# Users can abort the function by pressing CTRL-C. This will call "exit 1".
   1.138 +yes_no() {
   1.139 +  if [ 0 -ne "${do_default-0}" ] ; then
   1.140 +    return $1
   1.141 +  fi
   1.142 +  local c
   1.143 +  while :; do
   1.144 +    c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
   1.145 +         stty -echo iuclc -icanon 2>/dev/null
   1.146 +         dd count=1 bs=1 2>/dev/null | od -An -tx1)"
   1.147 +    case "$c" in
   1.148 +      " 0a") if [ -n "$1" ]; then
   1.149 +               [ $1 -eq 0 ] && echo "Y" || echo "N"
   1.150 +               return $1
   1.151 +             fi
   1.152 +             ;;
   1.153 +      " 79") echo "Y"
   1.154 +             return 0
   1.155 +             ;;
   1.156 +      " 6e") echo "N"
   1.157 +             return 1
   1.158 +             ;;
   1.159 +      "")    echo "Aborted" >&2
   1.160 +             exit 1
   1.161 +             ;;
   1.162 +      *)     # The user pressed an unrecognized key. As we are not echoing
   1.163 +             # any incorrect user input, alert the user by ringing the bell.
   1.164 +             (tput bel) 2>/dev/null
   1.165 +             ;;
   1.166 +    esac
   1.167 +  done
   1.168 +}
   1.169 +
   1.170 +if test "$do_inst_syms" = ""
   1.171 +then
   1.172 +  echo "This script installs all tools and libraries needed to build Chromium."
   1.173 +  echo ""
   1.174 +  echo "For most of the libraries, it can also install debugging symbols, which"
   1.175 +  echo "will allow you to debug code in the system libraries. Most developers"
   1.176 +  echo "won't need these symbols."
   1.177 +  echo -n "Do you want me to install them for you (y/N) "
   1.178 +  if yes_no 1; then
   1.179 +    do_inst_syms=1
   1.180 +  fi
   1.181 +fi
   1.182 +if test "$do_inst_syms" = "1"; then
   1.183 +  echo "Installing debugging symbols."
   1.184 +else
   1.185 +  echo "Skipping installation of debugging symbols."
   1.186 +  dbg_list=
   1.187 +fi
   1.188 +
   1.189 +sudo apt-get update
   1.190 +
   1.191 +# We initially run "apt-get" with the --reinstall option and parse its output.
   1.192 +# This way, we can find all the packages that need to be newly installed
   1.193 +# without accidentally promoting any packages from "auto" to "manual".
   1.194 +# We then re-run "apt-get" with just the list of missing packages.
   1.195 +echo "Finding missing packages..."
   1.196 +packages="${dev_list} ${lib_list} ${dbg_list} ${plugin_list}"
   1.197 +# Intentionally leaving $packages unquoted so it's more readable.
   1.198 +echo "Packages required: " $packages
   1.199 +echo
   1.200 +new_list_cmd="sudo apt-get install --reinstall $(echo $packages)"
   1.201 +if new_list="$(yes n | LANG=C $new_list_cmd)"; then
   1.202 +  # We probably never hit this following line.
   1.203 +  echo "No missing packages, and the packages are up-to-date."
   1.204 +elif [ $? -eq 1 ]; then
   1.205 +  # We expect apt-get to have exit status of 1.
   1.206 +  # This indicates that we cancelled the install with "yes n|".
   1.207 +  new_list=$(echo "$new_list" |
   1.208 +    sed -e '1,/The following NEW packages will be installed:/d;s/^  //;t;d')
   1.209 +  new_list=$(echo "$new_list" | sed 's/ *$//')
   1.210 +  if [ -z "$new_list" ] ; then
   1.211 +    echo "No missing packages, and the packages are up-to-date."
   1.212 +  else
   1.213 +    echo "Installing missing packages: $new_list."
   1.214 +    sudo apt-get install ${do_quietly-} ${new_list}
   1.215 +  fi
   1.216 +  echo
   1.217 +else
   1.218 +  # An apt-get exit status of 100 indicates that a real error has occurred.
   1.219 +
   1.220 +  # I am intentionally leaving out the '"'s around new_list_cmd,
   1.221 +  # as this makes it easier to cut and paste the output
   1.222 +  echo "The following command failed: " ${new_list_cmd}
   1.223 +  echo
   1.224 +  echo "It produces the following output:"
   1.225 +  yes n | $new_list_cmd || true
   1.226 +  echo
   1.227 +  echo "You will have to install the above packages yourself."
   1.228 +  echo
   1.229 +  exit 100
   1.230 +fi
   1.231 +
   1.232 +# Install 32bit backwards compatibility support for 64bit systems
   1.233 +if [ "$(uname -m)" = "x86_64" ]; then
   1.234 +  if test "$do_inst_lib32" = ""
   1.235 +  then
   1.236 +    echo "We no longer recommend that you use this script to install"
   1.237 +    echo "32bit libraries on a 64bit system. Instead, consider using"
   1.238 +    echo "the install-chroot.sh script to help you set up a 32bit"
   1.239 +    echo "environment for building and testing 32bit versions of Chrome."
   1.240 +    echo
   1.241 +    echo "If you nonetheless want to try installing 32bit libraries"
   1.242 +    echo "directly, you can do so by explicitly passing the --lib32"
   1.243 +    echo "option to install-build-deps.sh."
   1.244 +  fi
   1.245 +  if test "$do_inst_lib32" != "1"
   1.246 +  then
   1.247 +    echo "Exiting without installing any 32bit libraries."
   1.248 +    exit 0
   1.249 +  fi
   1.250 +
   1.251 +  echo "N.B. the code for installing 32bit libraries on a 64bit"
   1.252 +  echo "     system is no longer actively maintained and might"
   1.253 +  echo "     not work with modern versions of Ubuntu or Debian."
   1.254 +  echo
   1.255 +
   1.256 +  # Standard 32bit compatibility libraries
   1.257 +  echo "First, installing the limited existing 32-bit support..."
   1.258 +  cmp_list="ia32-libs lib32asound2-dev lib32stdc++6 lib32z1
   1.259 +            lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib"
   1.260 +  if [ -n "`apt-cache search lib32readline-gplv2-dev 2>/dev/null`" ]; then
   1.261 +    cmp_list="${cmp_list} lib32readline-gplv2-dev"
   1.262 +  else
   1.263 +    cmp_list="${cmp_list} lib32readline5-dev"
   1.264 +  fi
   1.265 +  sudo apt-get install ${do_quietly-} $cmp_list
   1.266 +
   1.267 +  tmp=/tmp/install-32bit.$$
   1.268 +  trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT
   1.269 +  mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial"
   1.270 +  touch "${tmp}/status"
   1.271 +
   1.272 +  [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/"
   1.273 +  cat >>"${tmp}/apt/apt.conf" <<EOF
   1.274 +        Apt::Architecture "i386";
   1.275 +        Dir::Cache "${tmp}/cache";
   1.276 +        Dir::Cache::Archives "${tmp}/";
   1.277 +        Dir::State::Lists "${tmp}/apt/lists/";
   1.278 +        Dir::State::status "${tmp}/status";
   1.279 +EOF
   1.280 +
   1.281 +  # Download 32bit packages
   1.282 +  echo "Computing list of available 32bit packages..."
   1.283 +  sudo apt-get -c="${tmp}/apt/apt.conf" update
   1.284 +
   1.285 +  echo "Downloading available 32bit packages..."
   1.286 +  sudo apt-get -c="${tmp}/apt/apt.conf" \
   1.287 +          --yes --download-only --force-yes --reinstall install \
   1.288 +          ${lib_list} ${dbg_list}
   1.289 +
   1.290 +  # Open packages, remove everything that is not a library, move the
   1.291 +  # library to a lib32 directory and package everything as a *.deb file.
   1.292 +  echo "Repackaging and installing 32bit packages for use on 64bit systems..."
   1.293 +  for i in ${lib_list} ${dbg_list}; do
   1.294 +    orig="$(echo "${tmp}/${i}"_*_i386.deb)"
   1.295 +    compat="$(echo "${orig}" |
   1.296 +              sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')"
   1.297 +    rm -rf "${tmp}/staging"
   1.298 +    msg="$(fakeroot -u sh -exc '
   1.299 +      # Unpack 32bit Debian archive
   1.300 +      umask 022
   1.301 +      mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN"
   1.302 +      cd "'"${tmp}"'/staging"
   1.303 +      ar x "'${orig}'"
   1.304 +      tar zCfx dpkg data.tar.gz
   1.305 +      tar zCfx dpkg/DEBIAN control.tar.gz
   1.306 +
   1.307 +      # Create a posix extended regular expression fragment that will
   1.308 +      # recognize the includes which have changed. Should be rare,
   1.309 +      # will almost always be empty.
   1.310 +      includes=`sed -n -e "s/^[0-9a-z]*  //g" \
   1.311 +                       -e "\,usr/include/,p" dpkg/DEBIAN/md5sums |
   1.312 +                  xargs -n 1 -I FILE /bin/sh -c \
   1.313 +                    "cmp -s dpkg/FILE /FILE || echo FILE" |
   1.314 +                  tr "\n" "|" |
   1.315 +                  sed -e "s,|$,,"`
   1.316 +
   1.317 +      # If empty, set it to not match anything.
   1.318 +      test -z "$includes" && includes="^//"
   1.319 +
   1.320 +      # Turn the conflicts into an extended RE for removal from the
   1.321 +      # Provides line.
   1.322 +      conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \
   1.323 +                   dpkg/DEBIAN/control`
   1.324 +
   1.325 +      # Rename package, change architecture, remove conflicts and dependencies
   1.326 +      sed -r -i                              \
   1.327 +          -e "/Package/s/$/-ia32/"           \
   1.328 +          -e "/Architecture/s/:.*$/: amd64/" \
   1.329 +          -e "/Depends/s/:.*/: ia32-libs/"   \
   1.330 +          -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1"   \
   1.331 +          -e "/Recommends/d"                 \
   1.332 +          -e "/Conflicts/d"                  \
   1.333 +        dpkg/DEBIAN/control
   1.334 +
   1.335 +      # Only keep files that live in "lib" directories or the includes
   1.336 +      # that have changed.
   1.337 +      sed -r -i                                                               \
   1.338 +          -e "/\/lib64\//d" -e "/\/.?bin\//d"                                 \
   1.339 +          -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g"   \
   1.340 +          -e "s, lib/, lib32/,g"                                              \
   1.341 +          -e "s,/lib/,/lib32/,g"                                              \
   1.342 +          -e "t;d"                                                            \
   1.343 +          -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug," \
   1.344 +        dpkg/DEBIAN/md5sums
   1.345 +
   1.346 +      # Re-run ldconfig after installation/removal
   1.347 +      { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \
   1.348 +        >dpkg/DEBIAN/postinst
   1.349 +      { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \
   1.350 +        >dpkg/DEBIAN/postrm
   1.351 +      chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm
   1.352 +
   1.353 +      # Remove any other control files
   1.354 +      find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \
   1.355 +                       -name postinst -o -name postrm ")" -o -print |
   1.356 +        xargs -r rm -rf
   1.357 +
   1.358 +      # Remove any files/dirs that live outside of "lib" directories,
   1.359 +      # or are not in our list of changed includes.
   1.360 +      find dpkg -mindepth 1 -regextype posix-extended \
   1.361 +          "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \
   1.362 +          -prune -o -print | tac |
   1.363 +        xargs -r -n 1 sh -c "rm \$0 2>/dev/null || rmdir \$0 2>/dev/null || : "
   1.364 +      find dpkg -name lib64 -o -name bin -o -name "?bin" |
   1.365 +        tac | xargs -r rm -rf
   1.366 +
   1.367 +      # Remove any symbolic links that were broken by the above steps.
   1.368 +      find -L dpkg -type l -print | tac | xargs -r rm -rf
   1.369 +
   1.370 +      # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32
   1.371 +      # That is where gdb looks for them.
   1.372 +      find dpkg -type d -o -path "*/lib/*" -print |
   1.373 +        xargs -r -n 1 sh -c "
   1.374 +          i=\$(echo \"\${0}\" |
   1.375 +               sed -e s,/lib/,/lib32/,g \
   1.376 +               -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,);
   1.377 +          mkdir -p \"\${i%/*}\";
   1.378 +          mv \"\${0}\" \"\${i}\""
   1.379 +
   1.380 +      # Rename include to include32.
   1.381 +      [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32"
   1.382 +
   1.383 +      # Prune any empty directories
   1.384 +      find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || :
   1.385 +
   1.386 +      # Create our own Debian package
   1.387 +      cd ..
   1.388 +      dpkg --build staging/dpkg .' 2>&1)"
   1.389 +    compat="$(eval echo $(echo "${compat}" |
   1.390 +                          sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))"
   1.391 +    [ -r "${compat}" ] || {
   1.392 +      echo "${msg}" >&2
   1.393 +      echo "Failed to build new Debian archive!" >&2
   1.394 +      exit 1
   1.395 +    }
   1.396 +
   1.397 +    msg="$(sudo dpkg -i "${compat}" 2>&1)" && {
   1.398 +        echo "Installed ${compat##*/}"
   1.399 +      } || {
   1.400 +        # echo "${msg}" >&2
   1.401 +        echo "Skipped ${compat##*/}"
   1.402 +      }
   1.403 +  done
   1.404 +
   1.405 +  # Add symbolic links for developing 32bit code
   1.406 +  echo "Adding missing symbolic links, enabling 32bit code development..."
   1.407 +  for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* |
   1.408 +             sed -e 's/[.]so[.][0-9].*/.so/' |
   1.409 +             sort -u); do
   1.410 +    [ "x${i##*/}" = "xld-linux.so" ] && continue
   1.411 +    [ -r "$i" ] && continue
   1.412 +    j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' |
   1.413 +         sort -n | tail -n 1)"
   1.414 +    [ -r "$i.$j" ] || continue
   1.415 +    sudo ln -s "${i##*/}.$j" "$i"
   1.416 +  done
   1.417 +fi

mercurial