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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 #!/bin/bash -e
michael@0 2
michael@0 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
michael@0 4 # Use of this source code is governed by a BSD-style license that can be
michael@0 5 # found in the LICENSE file.
michael@0 6
michael@0 7 # Script to install everything needed to build chromium (well, ideally, anyway)
michael@0 8 # See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions
michael@0 9 # and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit
michael@0 10
michael@0 11 usage() {
michael@0 12 echo "Usage: $0 [--options]"
michael@0 13 echo "Options:"
michael@0 14 echo "--[no-]syms: enable or disable installation of debugging symbols"
michael@0 15 echo "--[no-]lib32: enable or disable installation of 32 bit libraries"
michael@0 16 echo "--no-prompt: silently select standard options/defaults"
michael@0 17 echo "Script will prompt interactively if options not given."
michael@0 18 exit 1
michael@0 19 }
michael@0 20
michael@0 21 while test "$1" != ""
michael@0 22 do
michael@0 23 case "$1" in
michael@0 24 --syms) do_inst_syms=1;;
michael@0 25 --no-syms) do_inst_syms=0;;
michael@0 26 --lib32) do_inst_lib32=1;;
michael@0 27 --no-lib32) do_inst_lib32=0;;
michael@0 28 --no-prompt) do_default=1
michael@0 29 do_quietly="-qq --assume-yes"
michael@0 30 ;;
michael@0 31 *) usage;;
michael@0 32 esac
michael@0 33 shift
michael@0 34 done
michael@0 35
michael@0 36 if ! egrep -q \
michael@0 37 'Ubuntu (10\.04|10\.10|11\.04|11\.10|12\.04|lucid|maverick|natty|oneiric|precise)' \
michael@0 38 /etc/issue; then
michael@0 39 echo "Only Ubuntu 10.04 (lucid) through 12.04 (precise) are currently" \
michael@0 40 "supported" >&2
michael@0 41 exit 1
michael@0 42 fi
michael@0 43
michael@0 44 if ! uname -m | egrep -q "i686|x86_64"; then
michael@0 45 echo "Only x86 architectures are currently supported" >&2
michael@0 46 exit
michael@0 47 fi
michael@0 48
michael@0 49 if [ "x$(id -u)" != x0 ]; then
michael@0 50 echo "Running as non-root user."
michael@0 51 echo "You might have to enter your password one or more times for 'sudo'."
michael@0 52 echo
michael@0 53 fi
michael@0 54
michael@0 55 # Packages needed for chromeos only
michael@0 56 chromeos_dev_list="libbluetooth-dev libpulse-dev"
michael@0 57
michael@0 58 # Packages need for development
michael@0 59 dev_list="apache2.2-bin bison curl elfutils fakeroot flex g++ gperf
michael@0 60 language-pack-fr libapache2-mod-php5 libasound2-dev libbz2-dev
michael@0 61 libcairo2-dev libcups2-dev libcurl4-gnutls-dev libdbus-glib-1-dev
michael@0 62 libelf-dev libgconf2-dev libgl1-mesa-dev libglib2.0-dev
michael@0 63 libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev
michael@0 64 libkrb5-dev libnspr4-dev libnss3-dev libpam0g-dev libsctp-dev
michael@0 65 libsqlite3-dev libssl-dev libudev-dev libwww-perl libxslt1-dev
michael@0 66 libxss-dev libxt-dev libxtst-dev mesa-common-dev patch
michael@0 67 perl php5-cgi pkg-config python python-cherrypy3 python-dev
michael@0 68 python-psutil rpm ruby subversion ttf-dejavu-core ttf-indic-fonts
michael@0 69 ttf-kochi-gothic ttf-kochi-mincho ttf-thai-tlwg wdiff git-core
michael@0 70 $chromeos_dev_list"
michael@0 71
michael@0 72 # 64-bit systems need a minimum set of 32-bit compat packages for the pre-built
michael@0 73 # NaCl binaries. These are always needed, regardless of whether or not we want
michael@0 74 # the full 32-bit "cross-compile" support (--lib32).
michael@0 75 if [ "$(uname -m)" = "x86_64" ]; then
michael@0 76 dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6"
michael@0 77 fi
michael@0 78
michael@0 79 # Run-time libraries required by chromeos only
michael@0 80 chromeos_lib_list="libpulse0 libbz2-1.0 libcurl4-gnutls-dev"
michael@0 81
michael@0 82 # Full list of required run-time libraries
michael@0 83 lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcups2 libdbus-glib-1-2
michael@0 84 libexpat1 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0
michael@0 85 libgtk2.0-0 libpam0g libpango1.0-0 libpcre3 libpixman-1-0
michael@0 86 libpng12-0 libstdc++6 libsqlite3-0 libudev0 libx11-6 libxau6 libxcb1
michael@0 87 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3
michael@0 88 libxi6 libxinerama1 libxrandr2 libxrender1 libxtst6 zlib1g
michael@0 89 $chromeos_lib_list"
michael@0 90
michael@0 91 # Debugging symbols for all of the run-time libraries
michael@0 92 dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libdbus-glib-1-2-dbg
michael@0 93 libfontconfig1-dbg libglib2.0-0-dbg libgtk2.0-0-dbg
michael@0 94 libpango1.0-0-dbg libpcre3-dbg libpixman-1-0-dbg
michael@0 95 libsqlite3-0-dbg
michael@0 96 libx11-6-dbg libxau6-dbg libxcb1-dbg libxcomposite1-dbg
michael@0 97 libxcursor1-dbg libxdamage1-dbg libxdmcp6-dbg libxext6-dbg
michael@0 98 libxfixes3-dbg libxi6-dbg libxinerama1-dbg libxrandr2-dbg
michael@0 99 libxrender1-dbg libxtst6-dbg zlib1g-dbg"
michael@0 100
michael@0 101 # Plugin lists needed for tests.
michael@0 102 plugin_list="flashplugin-installer"
michael@0 103
michael@0 104 # Some package names have changed over time
michael@0 105 if apt-cache show ttf-mscorefonts-installer >/dev/null 2>&1; then
michael@0 106 dev_list="${dev_list} ttf-mscorefonts-installer"
michael@0 107 else
michael@0 108 dev_list="${dev_list} msttcorefonts"
michael@0 109 fi
michael@0 110 if apt-cache show libnspr4-dbg >/dev/null 2>&1; then
michael@0 111 dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg"
michael@0 112 lib_list="${lib_list} libnspr4 libnss3"
michael@0 113 else
michael@0 114 dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg"
michael@0 115 lib_list="${lib_list} libnspr4-0d libnss3-1d"
michael@0 116 fi
michael@0 117 if apt-cache show libjpeg-dev >/dev/null 2>&1; then
michael@0 118 dev_list="${dev_list} libjpeg-dev"
michael@0 119 else
michael@0 120 dev_list="${dev_list} libjpeg62-dev"
michael@0 121 fi
michael@0 122
michael@0 123 # Some packages are only needed, if the distribution actually supports
michael@0 124 # installing them.
michael@0 125 if apt-cache show appmenu-gtk >/dev/null 2>&1; then
michael@0 126 lib_list="$lib_list appmenu-gtk"
michael@0 127 fi
michael@0 128
michael@0 129 # Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is
michael@0 130 # accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has
michael@0 131 # been provided to yes_no(), the function also accepts RETURN as a user input.
michael@0 132 # The parameter specifies the exit code that should be returned in that case.
michael@0 133 # The function will echo the user's selection followed by a newline character.
michael@0 134 # Users can abort the function by pressing CTRL-C. This will call "exit 1".
michael@0 135 yes_no() {
michael@0 136 if [ 0 -ne "${do_default-0}" ] ; then
michael@0 137 return $1
michael@0 138 fi
michael@0 139 local c
michael@0 140 while :; do
michael@0 141 c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
michael@0 142 stty -echo iuclc -icanon 2>/dev/null
michael@0 143 dd count=1 bs=1 2>/dev/null | od -An -tx1)"
michael@0 144 case "$c" in
michael@0 145 " 0a") if [ -n "$1" ]; then
michael@0 146 [ $1 -eq 0 ] && echo "Y" || echo "N"
michael@0 147 return $1
michael@0 148 fi
michael@0 149 ;;
michael@0 150 " 79") echo "Y"
michael@0 151 return 0
michael@0 152 ;;
michael@0 153 " 6e") echo "N"
michael@0 154 return 1
michael@0 155 ;;
michael@0 156 "") echo "Aborted" >&2
michael@0 157 exit 1
michael@0 158 ;;
michael@0 159 *) # The user pressed an unrecognized key. As we are not echoing
michael@0 160 # any incorrect user input, alert the user by ringing the bell.
michael@0 161 (tput bel) 2>/dev/null
michael@0 162 ;;
michael@0 163 esac
michael@0 164 done
michael@0 165 }
michael@0 166
michael@0 167 if test "$do_inst_syms" = ""
michael@0 168 then
michael@0 169 echo "This script installs all tools and libraries needed to build Chromium."
michael@0 170 echo ""
michael@0 171 echo "For most of the libraries, it can also install debugging symbols, which"
michael@0 172 echo "will allow you to debug code in the system libraries. Most developers"
michael@0 173 echo "won't need these symbols."
michael@0 174 echo -n "Do you want me to install them for you (y/N) "
michael@0 175 if yes_no 1; then
michael@0 176 do_inst_syms=1
michael@0 177 fi
michael@0 178 fi
michael@0 179 if test "$do_inst_syms" = "1"; then
michael@0 180 echo "Installing debugging symbols."
michael@0 181 else
michael@0 182 echo "Skipping installation of debugging symbols."
michael@0 183 dbg_list=
michael@0 184 fi
michael@0 185
michael@0 186 sudo apt-get update
michael@0 187
michael@0 188 # We initially run "apt-get" with the --reinstall option and parse its output.
michael@0 189 # This way, we can find all the packages that need to be newly installed
michael@0 190 # without accidentally promoting any packages from "auto" to "manual".
michael@0 191 # We then re-run "apt-get" with just the list of missing packages.
michael@0 192 echo "Finding missing packages..."
michael@0 193 packages="${dev_list} ${lib_list} ${dbg_list} ${plugin_list}"
michael@0 194 # Intentionally leaving $packages unquoted so it's more readable.
michael@0 195 echo "Packages required: " $packages
michael@0 196 echo
michael@0 197 new_list_cmd="sudo apt-get install --reinstall $(echo $packages)"
michael@0 198 if new_list="$(yes n | LANG=C $new_list_cmd)"; then
michael@0 199 # We probably never hit this following line.
michael@0 200 echo "No missing packages, and the packages are up-to-date."
michael@0 201 elif [ $? -eq 1 ]; then
michael@0 202 # We expect apt-get to have exit status of 1.
michael@0 203 # This indicates that we cancelled the install with "yes n|".
michael@0 204 new_list=$(echo "$new_list" |
michael@0 205 sed -e '1,/The following NEW packages will be installed:/d;s/^ //;t;d')
michael@0 206 new_list=$(echo "$new_list" | sed 's/ *$//')
michael@0 207 if [ -z "$new_list" ] ; then
michael@0 208 echo "No missing packages, and the packages are up-to-date."
michael@0 209 else
michael@0 210 echo "Installing missing packages: $new_list."
michael@0 211 sudo apt-get install ${do_quietly-} ${new_list}
michael@0 212 fi
michael@0 213 echo
michael@0 214 else
michael@0 215 # An apt-get exit status of 100 indicates that a real error has occurred.
michael@0 216
michael@0 217 # I am intentionally leaving out the '"'s around new_list_cmd,
michael@0 218 # as this makes it easier to cut and paste the output
michael@0 219 echo "The following command failed: " ${new_list_cmd}
michael@0 220 echo
michael@0 221 echo "It produces the following output:"
michael@0 222 yes n | $new_list_cmd || true
michael@0 223 echo
michael@0 224 echo "You will have to install the above packages yourself."
michael@0 225 echo
michael@0 226 exit 100
michael@0 227 fi
michael@0 228
michael@0 229 # Install 32bit backwards compatibility support for 64bit systems
michael@0 230 if [ "$(uname -m)" = "x86_64" ]; then
michael@0 231 if test "$do_inst_lib32" = ""
michael@0 232 then
michael@0 233 echo "We no longer recommend that you use this script to install"
michael@0 234 echo "32bit libraries on a 64bit system. Instead, consider using"
michael@0 235 echo "the install-chroot.sh script to help you set up a 32bit"
michael@0 236 echo "environment for building and testing 32bit versions of Chrome."
michael@0 237 echo
michael@0 238 echo "If you nonetheless want to try installing 32bit libraries"
michael@0 239 echo "directly, you can do so by explicitly passing the --lib32"
michael@0 240 echo "option to install-build-deps.sh."
michael@0 241 fi
michael@0 242 if test "$do_inst_lib32" != "1"
michael@0 243 then
michael@0 244 echo "Exiting without installing any 32bit libraries."
michael@0 245 exit 0
michael@0 246 fi
michael@0 247
michael@0 248 echo "N.B. the code for installing 32bit libraries on a 64bit"
michael@0 249 echo " system is no longer actively maintained and might"
michael@0 250 echo " not work with modern versions of Ubuntu or Debian."
michael@0 251 echo
michael@0 252
michael@0 253 # Standard 32bit compatibility libraries
michael@0 254 echo "First, installing the limited existing 32-bit support..."
michael@0 255 cmp_list="ia32-libs lib32asound2-dev lib32stdc++6 lib32z1
michael@0 256 lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib"
michael@0 257 if [ -n "`apt-cache search lib32readline-gplv2-dev 2>/dev/null`" ]; then
michael@0 258 cmp_list="${cmp_list} lib32readline-gplv2-dev"
michael@0 259 else
michael@0 260 cmp_list="${cmp_list} lib32readline5-dev"
michael@0 261 fi
michael@0 262 sudo apt-get install ${do_quietly-} $cmp_list
michael@0 263
michael@0 264 tmp=/tmp/install-32bit.$$
michael@0 265 trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT
michael@0 266 mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial"
michael@0 267 touch "${tmp}/status"
michael@0 268
michael@0 269 [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/"
michael@0 270 cat >>"${tmp}/apt/apt.conf" <<EOF
michael@0 271 Apt::Architecture "i386";
michael@0 272 Dir::Cache "${tmp}/cache";
michael@0 273 Dir::Cache::Archives "${tmp}/";
michael@0 274 Dir::State::Lists "${tmp}/apt/lists/";
michael@0 275 Dir::State::status "${tmp}/status";
michael@0 276 EOF
michael@0 277
michael@0 278 # Download 32bit packages
michael@0 279 echo "Computing list of available 32bit packages..."
michael@0 280 sudo apt-get -c="${tmp}/apt/apt.conf" update
michael@0 281
michael@0 282 echo "Downloading available 32bit packages..."
michael@0 283 sudo apt-get -c="${tmp}/apt/apt.conf" \
michael@0 284 --yes --download-only --force-yes --reinstall install \
michael@0 285 ${lib_list} ${dbg_list}
michael@0 286
michael@0 287 # Open packages, remove everything that is not a library, move the
michael@0 288 # library to a lib32 directory and package everything as a *.deb file.
michael@0 289 echo "Repackaging and installing 32bit packages for use on 64bit systems..."
michael@0 290 for i in ${lib_list} ${dbg_list}; do
michael@0 291 orig="$(echo "${tmp}/${i}"_*_i386.deb)"
michael@0 292 compat="$(echo "${orig}" |
michael@0 293 sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')"
michael@0 294 rm -rf "${tmp}/staging"
michael@0 295 msg="$(fakeroot -u sh -exc '
michael@0 296 # Unpack 32bit Debian archive
michael@0 297 umask 022
michael@0 298 mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN"
michael@0 299 cd "'"${tmp}"'/staging"
michael@0 300 ar x "'${orig}'"
michael@0 301 tar zCfx dpkg data.tar.gz
michael@0 302 tar zCfx dpkg/DEBIAN control.tar.gz
michael@0 303
michael@0 304 # Create a posix extended regular expression fragment that will
michael@0 305 # recognize the includes which have changed. Should be rare,
michael@0 306 # will almost always be empty.
michael@0 307 includes=`sed -n -e "s/^[0-9a-z]* //g" \
michael@0 308 -e "\,usr/include/,p" dpkg/DEBIAN/md5sums |
michael@0 309 xargs -n 1 -I FILE /bin/sh -c \
michael@0 310 "cmp -s dpkg/FILE /FILE || echo FILE" |
michael@0 311 tr "\n" "|" |
michael@0 312 sed -e "s,|$,,"`
michael@0 313
michael@0 314 # If empty, set it to not match anything.
michael@0 315 test -z "$includes" && includes="^//"
michael@0 316
michael@0 317 # Turn the conflicts into an extended RE for removal from the
michael@0 318 # Provides line.
michael@0 319 conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \
michael@0 320 dpkg/DEBIAN/control`
michael@0 321
michael@0 322 # Rename package, change architecture, remove conflicts and dependencies
michael@0 323 sed -r -i \
michael@0 324 -e "/Package/s/$/-ia32/" \
michael@0 325 -e "/Architecture/s/:.*$/: amd64/" \
michael@0 326 -e "/Depends/s/:.*/: ia32-libs/" \
michael@0 327 -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1" \
michael@0 328 -e "/Recommends/d" \
michael@0 329 -e "/Conflicts/d" \
michael@0 330 dpkg/DEBIAN/control
michael@0 331
michael@0 332 # Only keep files that live in "lib" directories or the includes
michael@0 333 # that have changed.
michael@0 334 sed -r -i \
michael@0 335 -e "/\/lib64\//d" -e "/\/.?bin\//d" \
michael@0 336 -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g" \
michael@0 337 -e "s, lib/, lib32/,g" \
michael@0 338 -e "s,/lib/,/lib32/,g" \
michael@0 339 -e "t;d" \
michael@0 340 -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug," \
michael@0 341 dpkg/DEBIAN/md5sums
michael@0 342
michael@0 343 # Re-run ldconfig after installation/removal
michael@0 344 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \
michael@0 345 >dpkg/DEBIAN/postinst
michael@0 346 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \
michael@0 347 >dpkg/DEBIAN/postrm
michael@0 348 chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm
michael@0 349
michael@0 350 # Remove any other control files
michael@0 351 find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \
michael@0 352 -name postinst -o -name postrm ")" -o -print |
michael@0 353 xargs -r rm -rf
michael@0 354
michael@0 355 # Remove any files/dirs that live outside of "lib" directories,
michael@0 356 # or are not in our list of changed includes.
michael@0 357 find dpkg -mindepth 1 -regextype posix-extended \
michael@0 358 "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \
michael@0 359 -prune -o -print | tac |
michael@0 360 xargs -r -n 1 sh -c "rm \$0 2>/dev/null || rmdir \$0 2>/dev/null || : "
michael@0 361 find dpkg -name lib64 -o -name bin -o -name "?bin" |
michael@0 362 tac | xargs -r rm -rf
michael@0 363
michael@0 364 # Remove any symbolic links that were broken by the above steps.
michael@0 365 find -L dpkg -type l -print | tac | xargs -r rm -rf
michael@0 366
michael@0 367 # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32
michael@0 368 # That is where gdb looks for them.
michael@0 369 find dpkg -type d -o -path "*/lib/*" -print |
michael@0 370 xargs -r -n 1 sh -c "
michael@0 371 i=\$(echo \"\${0}\" |
michael@0 372 sed -e s,/lib/,/lib32/,g \
michael@0 373 -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,);
michael@0 374 mkdir -p \"\${i%/*}\";
michael@0 375 mv \"\${0}\" \"\${i}\""
michael@0 376
michael@0 377 # Rename include to include32.
michael@0 378 [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32"
michael@0 379
michael@0 380 # Prune any empty directories
michael@0 381 find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || :
michael@0 382
michael@0 383 # Create our own Debian package
michael@0 384 cd ..
michael@0 385 dpkg --build staging/dpkg .' 2>&1)"
michael@0 386 compat="$(eval echo $(echo "${compat}" |
michael@0 387 sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))"
michael@0 388 [ -r "${compat}" ] || {
michael@0 389 echo "${msg}" >&2
michael@0 390 echo "Failed to build new Debian archive!" >&2
michael@0 391 exit 1
michael@0 392 }
michael@0 393
michael@0 394 msg="$(sudo dpkg -i "${compat}" 2>&1)" && {
michael@0 395 echo "Installed ${compat##*/}"
michael@0 396 } || {
michael@0 397 # echo "${msg}" >&2
michael@0 398 echo "Skipped ${compat##*/}"
michael@0 399 }
michael@0 400 done
michael@0 401
michael@0 402 # Add symbolic links for developing 32bit code
michael@0 403 echo "Adding missing symbolic links, enabling 32bit code development..."
michael@0 404 for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* |
michael@0 405 sed -e 's/[.]so[.][0-9].*/.so/' |
michael@0 406 sort -u); do
michael@0 407 [ "x${i##*/}" = "xld-linux.so" ] && continue
michael@0 408 [ -r "$i" ] && continue
michael@0 409 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' |
michael@0 410 sort -n | tail -n 1)"
michael@0 411 [ -r "$i.$j" ] || continue
michael@0 412 sudo ln -s "${i##*/}.$j" "$i"
michael@0 413 done
michael@0 414 fi

mercurial