blob: fb3833e67a1e8d4359cd2d791516167b0bf17ece [file] [log] [blame]
[email protected]e041ed12009-03-10 16:43:011#!/bin/bash -e
2
[email protected]aac39c92012-02-08 18:39:533# Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]e46cdae2009-08-25 20:59:274# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
[email protected]cf1df402008-10-31 21:45:307# Script to install everything needed to build chromium (well, ideally, anyway)
[email protected]592ea8ca2008-11-03 19:47:368# See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions
9# and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit
[email protected]cf1df402008-10-31 21:45:3010
[email protected]1eae2bfb2010-01-26 18:17:5311usage() {
12 echo "Usage: $0 [--options]"
13 echo "Options:"
14 echo "--[no-]syms: enable or disable installation of debugging symbols"
[email protected]1eae2bfb2010-01-26 18:17:5315 echo "--[no-]lib32: enable or disable installation of 32 bit libraries"
[email protected]f2826b6a2012-11-15 01:06:2616 echo "--[no-]arm: enable or disable installation of arm cross toolchain"
[email protected]e2544ed42012-04-23 04:48:3117 echo "--no-prompt: silently select standard options/defaults"
[email protected]1eae2bfb2010-01-26 18:17:5318 echo "Script will prompt interactively if options not given."
19 exit 1
20}
21
22while test "$1" != ""
23do
24 case "$1" in
[email protected]ce774642011-09-12 23:21:3925 --syms) do_inst_syms=1;;
26 --no-syms) do_inst_syms=0;;
[email protected]ce774642011-09-12 23:21:3927 --lib32) do_inst_lib32=1;;
28 --no-lib32) do_inst_lib32=0;;
[email protected]f2826b6a2012-11-15 01:06:2629 --arm) do_inst_arm=1;;
30 --no-arm) do_inst_arm=0;;
[email protected]e2544ed42012-04-23 04:48:3131 --no-prompt) do_default=1
32 do_quietly="-qq --assume-yes"
33 ;;
[email protected]1eae2bfb2010-01-26 18:17:5334 *) usage;;
35 esac
36 shift
37done
38
[email protected]f2826b6a2012-11-15 01:06:2639ubuntu_versions="10\.04|10\.10|11\.04|11\.10|12\.04"
40ubuntu_codenames="lucid|maverick|natty|oneiric|precise"
41
42if ! egrep -q "Ubuntu ($ubuntu_versions|$ubuntu_codenames)" /etc/issue; then
43 echo "ERROR: Only Ubuntu 10.04 (lucid) through 12.04 (precise) are currently"\
[email protected]a51551d2010-07-15 22:59:4844 "supported" >&2
[email protected]cf1df402008-10-31 21:45:3045 exit 1
46fi
[email protected]cf1df402008-10-31 21:45:3047
[email protected]e041ed12009-03-10 16:43:0148if ! uname -m | egrep -q "i686|x86_64"; then
49 echo "Only x86 architectures are currently supported" >&2
50 exit
51fi
52
53if [ "x$(id -u)" != x0 ]; then
54 echo "Running as non-root user."
55 echo "You might have to enter your password one or more times for 'sudo'."
[email protected]8ada8c52009-03-10 21:53:0856 echo
[email protected]e041ed12009-03-10 16:43:0157fi
58
[email protected]fdc6bf52010-06-07 22:01:5759# Packages needed for chromeos only
[email protected]e8626b92012-04-20 18:06:1860chromeos_dev_list="libbluetooth-dev libpulse-dev"
[email protected]fdc6bf52010-06-07 22:01:5761
[email protected]e041ed12009-03-10 16:43:0162# Packages need for development
[email protected]041d14a2011-12-13 01:42:4863dev_list="apache2.2-bin bison curl elfutils fakeroot flex g++ gperf
64 language-pack-fr libapache2-mod-php5 libasound2-dev libbz2-dev
[email protected]6ffd19f352012-10-23 02:00:4165 libcairo2-dev libcups2-dev libcurl4-gnutls-dev libelf-dev
66 libgconf2-dev libgl1-mesa-dev libglib2.0-dev libglu1-mesa-dev
[email protected]58622c22012-11-09 02:01:5567 libgnome-keyring-dev libgtk2.0-dev libwebkit-dev libkrb5-dev
68 libnspr4-dev libnss3-dev libpam0g-dev libpci-dev libsctp-dev
69 libsqlite3-dev libssl-dev libudev-dev libwww-perl libxslt1-dev
70 libxss-dev libxt-dev libxtst-dev mesa-common-dev patch perl php5-cgi
71 pkg-config python python-cherrypy3 python-dev python-psutil rpm ruby
72 subversion ttf-dejavu-core ttf-indic-fonts ttf-kochi-gothic
73 ttf-kochi-mincho ttf-thai-tlwg wdiff git-core $chromeos_dev_list"
[email protected]fdc6bf52010-06-07 22:01:5774
[email protected]f16aabf2012-08-15 21:00:1475# 64-bit systems need a minimum set of 32-bit compat packages for the pre-built
[email protected]d93d68b12012-10-15 06:39:5376# NaCl binaries. These are always needed, regardless of whether or not we want
[email protected]f16aabf2012-08-15 21:00:1477# the full 32-bit "cross-compile" support (--lib32).
78if [ "$(uname -m)" = "x86_64" ]; then
[email protected]d93d68b12012-10-15 06:39:5379 dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6"
[email protected]f16aabf2012-08-15 21:00:1480fi
81
[email protected]fdc6bf52010-06-07 22:01:5782# Run-time libraries required by chromeos only
[email protected]34799f9d2010-07-08 17:51:3383chromeos_lib_list="libpulse0 libbz2-1.0 libcurl4-gnutls-dev"
[email protected]e041ed12009-03-10 16:43:0184
85# Full list of required run-time libraries
[email protected]6ffd19f352012-10-23 02:00:4186lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcups2 libexpat1
87 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0
[email protected]ca3a1d262012-10-30 22:33:2088 libgtk2.0-0 libpam0g libpango1.0-0 libpci3 libpcre3 libpixman-1-0
[email protected]6de217b72011-12-17 03:36:3289 libpng12-0 libstdc++6 libsqlite3-0 libudev0 libx11-6 libxau6 libxcb1
[email protected]fd11101b2011-02-16 04:46:4690 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3
91 libxi6 libxinerama1 libxrandr2 libxrender1 libxtst6 zlib1g
[email protected]9dc4bed2010-11-04 19:23:3092 $chromeos_lib_list"
[email protected]e041ed12009-03-10 16:43:0193
94# Debugging symbols for all of the run-time libraries
[email protected]6ffd19f352012-10-23 02:00:4195dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libfontconfig1-dbg
96 libglib2.0-0-dbg libgtk2.0-0-dbg libpango1.0-0-dbg libpcre3-dbg
97 libpixman-1-0-dbg libsqlite3-0-dbg libx11-6-dbg libxau6-dbg
98 libxcb1-dbg libxcomposite1-dbg libxcursor1-dbg libxdamage1-dbg
99 libxdmcp6-dbg libxext6-dbg libxfixes3-dbg libxi6-dbg libxinerama1-dbg
100 libxrandr2-dbg libxrender1-dbg libxtst6-dbg zlib1g-dbg"
[email protected]e041ed12009-03-10 16:43:01101
[email protected]f2826b6a2012-11-15 01:06:26102# arm cross toolchain packages needed to build chrome on arm
103arm_list="libc6-armel-cross libc6-dev-armel-cross libgcc1-armel-cross
104 libgomp1-armel-cross linux-libc-dev-armel-cross
105 libgcc1-dbg-armel-cross libgomp1-dbg-armel-cross
106 binutils-arm-linux-gnueabi cpp-arm-linux-gnueabi
107 gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
108 cpp-4.5-arm-linux-gnueabi gcc-4.5-arm-linux-gnueabi
109 g++-4.5-arm-linux-gnueabi libmudflap0-dbg-armel-cross"
110
[email protected]31a605532011-08-23 22:27:35111# Plugin lists needed for tests.
112plugin_list="flashplugin-installer"
113
[email protected]757c2962012-03-15 19:05:18114# Some package names have changed over time
[email protected]b11411c2012-03-21 22:09:41115if apt-cache show ttf-mscorefonts-installer >/dev/null 2>&1; then
[email protected]757c2962012-03-15 19:05:18116 dev_list="${dev_list} ttf-mscorefonts-installer"
[email protected]b11411c2012-03-21 22:09:41117else
118 dev_list="${dev_list} msttcorefonts"
[email protected]757c2962012-03-15 19:05:18119fi
[email protected]b11411c2012-03-21 22:09:41120if apt-cache show libnspr4-dbg >/dev/null 2>&1; then
[email protected]1a0f64a2011-05-20 17:53:55121 dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg"
122 lib_list="${lib_list} libnspr4 libnss3"
[email protected]757c2962012-03-15 19:05:18123else
124 dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg"
125 lib_list="${lib_list} libnspr4-0d libnss3-1d"
126fi
[email protected]b11411c2012-03-21 22:09:41127if apt-cache show libjpeg-dev >/dev/null 2>&1; then
128 dev_list="${dev_list} libjpeg-dev"
129else
130 dev_list="${dev_list} libjpeg62-dev"
131fi
[email protected]757c2962012-03-15 19:05:18132
133# Some packages are only needed, if the distribution actually supports
134# installing them.
[email protected]b11411c2012-03-21 22:09:41135if apt-cache show appmenu-gtk >/dev/null 2>&1; then
[email protected]757c2962012-03-15 19:05:18136 lib_list="$lib_list appmenu-gtk"
[email protected]4da8fad2011-04-11 18:42:42137fi
138
[email protected]8ada8c52009-03-10 21:53:08139# Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is
140# accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has
141# been provided to yes_no(), the function also accepts RETURN as a user input.
142# The parameter specifies the exit code that should be returned in that case.
143# The function will echo the user's selection followed by a newline character.
144# Users can abort the function by pressing CTRL-C. This will call "exit 1".
145yes_no() {
[email protected]e2544ed42012-04-23 04:48:31146 if [ 0 -ne "${do_default-0}" ] ; then
147 return $1
148 fi
[email protected]8ada8c52009-03-10 21:53:08149 local c
150 while :; do
151 c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
152 stty -echo iuclc -icanon 2>/dev/null
153 dd count=1 bs=1 2>/dev/null | od -An -tx1)"
154 case "$c" in
155 " 0a") if [ -n "$1" ]; then
156 [ $1 -eq 0 ] && echo "Y" || echo "N"
157 return $1
158 fi
159 ;;
160 " 79") echo "Y"
161 return 0
162 ;;
163 " 6e") echo "N"
164 return 1
165 ;;
166 "") echo "Aborted" >&2
167 exit 1
168 ;;
169 *) # The user pressed an unrecognized key. As we are not echoing
170 # any incorrect user input, alert the user by ringing the bell.
171 (tput bel) 2>/dev/null
172 ;;
173 esac
174 done
175}
176
[email protected]1eae2bfb2010-01-26 18:17:53177if test "$do_inst_syms" = ""
178then
179 echo "This script installs all tools and libraries needed to build Chromium."
180 echo ""
181 echo "For most of the libraries, it can also install debugging symbols, which"
182 echo "will allow you to debug code in the system libraries. Most developers"
183 echo "won't need these symbols."
184 echo -n "Do you want me to install them for you (y/N) "
185 if yes_no 1; then
186 do_inst_syms=1
187 fi
188fi
189if test "$do_inst_syms" = "1"; then
[email protected]8ada8c52009-03-10 21:53:08190 echo "Installing debugging symbols."
191else
192 echo "Skipping installation of debugging symbols."
193 dbg_list=
194fi
195
[email protected]f2826b6a2012-11-15 01:06:26196if test "$do_inst_arm" = "1"; then
197 . /etc/lsb-release
198 if test "$DISTRIB_CODENAME" != "precise"; then
199 echo "ERROR: Installing the ARM cross toolchain is only available on" \
200 "Ubuntu precise." >&2
201 exit 1
202 fi
203 echo "Installing ARM cross toolchain."
204else
205 echo "Skipping installation of ARM cross toolchain."
206 arm_list=
207fi
208
[email protected]e041ed12009-03-10 16:43:01209sudo apt-get update
210
211# We initially run "apt-get" with the --reinstall option and parse its output.
212# This way, we can find all the packages that need to be newly installed
213# without accidentally promoting any packages from "auto" to "manual".
214# We then re-run "apt-get" with just the list of missing packages.
215echo "Finding missing packages..."
[email protected]f2826b6a2012-11-15 01:06:26216packages="${dev_list} ${lib_list} ${dbg_list} ${plugin_list} ${arm_list}"
[email protected]757c2962012-03-15 19:05:18217# Intentionally leaving $packages unquoted so it's more readable.
[email protected]b6e064522009-08-10 18:47:51218echo "Packages required: " $packages
219echo
[email protected]79a9d2962009-08-06 21:10:58220new_list_cmd="sudo apt-get install --reinstall $(echo $packages)"
[email protected]b62f11e72010-05-03 17:20:45221if new_list="$(yes n | LANG=C $new_list_cmd)"; then
[email protected]b6e064522009-08-10 18:47:51222 # We probably never hit this following line.
[email protected]79a9d2962009-08-06 21:10:58223 echo "No missing packages, and the packages are up-to-date."
[email protected]b62f11e72010-05-03 17:20:45224elif [ $? -eq 1 ]; then
[email protected]79a9d2962009-08-06 21:10:58225 # We expect apt-get to have exit status of 1.
[email protected]757c2962012-03-15 19:05:18226 # This indicates that we cancelled the install with "yes n|".
[email protected]b6e064522009-08-10 18:47:51227 new_list=$(echo "$new_list" |
[email protected]79a9d2962009-08-06 21:10:58228 sed -e '1,/The following NEW packages will be installed:/d;s/^ //;t;d')
[email protected]b6e064522009-08-10 18:47:51229 new_list=$(echo "$new_list" | sed 's/ *$//')
230 if [ -z "$new_list" ] ; then
231 echo "No missing packages, and the packages are up-to-date."
232 else
233 echo "Installing missing packages: $new_list."
[email protected]e2544ed42012-04-23 04:48:31234 sudo apt-get install ${do_quietly-} ${new_list}
[email protected]b6e064522009-08-10 18:47:51235 fi
236 echo
[email protected]79a9d2962009-08-06 21:10:58237else
238 # An apt-get exit status of 100 indicates that a real error has occurred.
[email protected]e041ed12009-03-10 16:43:01239
[email protected]79a9d2962009-08-06 21:10:58240 # I am intentionally leaving out the '"'s around new_list_cmd,
241 # as this makes it easier to cut and paste the output
[email protected]79a9d2962009-08-06 21:10:58242 echo "The following command failed: " ${new_list_cmd}
243 echo
244 echo "It produces the following output:"
245 yes n | $new_list_cmd || true
246 echo
247 echo "You will have to install the above packages yourself."
248 echo
249 exit 100
250fi
[email protected]e041ed12009-03-10 16:43:01251
252# Install 32bit backwards compatibility support for 64bit systems
[email protected]b6e064522009-08-10 18:47:51253if [ "$(uname -m)" = "x86_64" ]; then
[email protected]1eae2bfb2010-01-26 18:17:53254 if test "$do_inst_lib32" != "1"
255 then
[email protected]4a242bea2012-11-07 19:31:52256 echo "NOTE: If you were expecting the option to install 32bit libs,"
257 echo "please run with the --lib32 flag."
258 echo
259 echo "Installation complete."
[email protected]8ada8c52009-03-10 21:53:08260 exit 0
261 fi
[email protected]b62f11e72010-05-03 17:20:45262
[email protected]4a242bea2012-11-07 19:31:52263 echo "WARNING"
[email protected]e76a3632012-03-15 20:56:27264 echo
[email protected]4a242bea2012-11-07 19:31:52265 echo "We no longer recommend that you use this script to install"
266 echo "32bit libraries on a 64bit system. Instead, consider using the"
267 echo "install-chroot.sh script to help you set up a 32bit environment"
268 echo "for building and testing 32bit versions of Chrome."
269 echo
270 echo "The code for installing 32bit libraries on a 64bit system is"
271 echo "unmaintained and might not work with modern versions of Ubuntu"
272 echo "or Debian."
273 echo
274 echo -n "Are you sure you want to proceed (y/N) "
275 if yes_no 1; then
276 do_inst_lib32=1
277 fi
278 if test "$do_inst_lib32" != "1"
[email protected]796c3522012-11-07 22:56:35279 then
[email protected]4a242bea2012-11-07 19:31:52280 exit 0
281 fi
[email protected]e76a3632012-03-15 20:56:27282
[email protected]b62f11e72010-05-03 17:20:45283 # Standard 32bit compatibility libraries
284 echo "First, installing the limited existing 32-bit support..."
[email protected]7cf14b372011-12-08 18:32:52285 cmp_list="ia32-libs lib32asound2-dev lib32stdc++6 lib32z1
[email protected]b62f11e72010-05-03 17:20:45286 lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib"
[email protected]7cf14b372011-12-08 18:32:52287 if [ -n "`apt-cache search lib32readline-gplv2-dev 2>/dev/null`" ]; then
288 cmp_list="${cmp_list} lib32readline-gplv2-dev"
289 else
290 cmp_list="${cmp_list} lib32readline5-dev"
291 fi
[email protected]221569d32012-05-20 04:55:48292 sudo apt-get install ${do_quietly-} $cmp_list
[email protected]b62f11e72010-05-03 17:20:45293
[email protected]e041ed12009-03-10 16:43:01294 tmp=/tmp/install-32bit.$$
295 trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT
296 mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial"
297 touch "${tmp}/status"
298
299 [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/"
[email protected]b6e064522009-08-10 18:47:51300 cat >>"${tmp}/apt/apt.conf" <<EOF
[email protected]79a9d2962009-08-06 21:10:58301 Apt::Architecture "i386";
302 Dir::Cache "${tmp}/cache";
303 Dir::Cache::Archives "${tmp}/";
304 Dir::State::Lists "${tmp}/apt/lists/";
305 Dir::State::status "${tmp}/status";
[email protected]b6e064522009-08-10 18:47:51306EOF
[email protected]1bf2ac972009-06-30 23:57:48307
[email protected]e041ed12009-03-10 16:43:01308 # Download 32bit packages
309 echo "Computing list of available 32bit packages..."
[email protected]a81e44e12010-05-17 21:16:53310 sudo apt-get -c="${tmp}/apt/apt.conf" update
[email protected]e041ed12009-03-10 16:43:01311
312 echo "Downloading available 32bit packages..."
[email protected]a81e44e12010-05-17 21:16:53313 sudo apt-get -c="${tmp}/apt/apt.conf" \
314 --yes --download-only --force-yes --reinstall install \
[email protected]e041ed12009-03-10 16:43:01315 ${lib_list} ${dbg_list}
316
317 # Open packages, remove everything that is not a library, move the
318 # library to a lib32 directory and package everything as a *.deb file.
319 echo "Repackaging and installing 32bit packages for use on 64bit systems..."
320 for i in ${lib_list} ${dbg_list}; do
321 orig="$(echo "${tmp}/${i}"_*_i386.deb)"
322 compat="$(echo "${orig}" |
323 sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')"
324 rm -rf "${tmp}/staging"
325 msg="$(fakeroot -u sh -exc '
326 # Unpack 32bit Debian archive
327 umask 022
328 mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN"
329 cd "'"${tmp}"'/staging"
330 ar x "'${orig}'"
331 tar zCfx dpkg data.tar.gz
332 tar zCfx dpkg/DEBIAN control.tar.gz
333
[email protected]34799f9d2010-07-08 17:51:33334 # Create a posix extended regular expression fragment that will
335 # recognize the includes which have changed. Should be rare,
336 # will almost always be empty.
337 includes=`sed -n -e "s/^[0-9a-z]* //g" \
338 -e "\,usr/include/,p" dpkg/DEBIAN/md5sums |
339 xargs -n 1 -I FILE /bin/sh -c \
340 "cmp -s dpkg/FILE /FILE || echo FILE" |
341 tr "\n" "|" |
342 sed -e "s,|$,,"`
[email protected]e041ed12009-03-10 16:43:01343
[email protected]34799f9d2010-07-08 17:51:33344 # If empty, set it to not match anything.
345 test -z "$includes" && includes="^//"
346
347 # Turn the conflicts into an extended RE for removal from the
348 # Provides line.
349 conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \
350 dpkg/DEBIAN/control`
351
352 # Rename package, change architecture, remove conflicts and dependencies
353 sed -r -i \
354 -e "/Package/s/$/-ia32/" \
355 -e "/Architecture/s/:.*$/: amd64/" \
356 -e "/Depends/s/:.*/: ia32-libs/" \
357 -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1" \
358 -e "/Recommends/d" \
359 -e "/Conflicts/d" \
360 dpkg/DEBIAN/control
361
362 # Only keep files that live in "lib" directories or the includes
363 # that have changed.
364 sed -r -i \
365 -e "/\/lib64\//d" -e "/\/.?bin\//d" \
366 -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g" \
367 -e "s, lib/, lib32/,g" \
368 -e "s,/lib/,/lib32/,g" \
369 -e "t;d" \
370 -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug," \
371 dpkg/DEBIAN/md5sums
[email protected]e041ed12009-03-10 16:43:01372
373 # Re-run ldconfig after installation/removal
374 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \
375 >dpkg/DEBIAN/postinst
376 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \
377 >dpkg/DEBIAN/postrm
378 chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm
379
380 # Remove any other control files
381 find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \
382 -name postinst -o -name postrm ")" -o -print |
383 xargs -r rm -rf
384
[email protected]34799f9d2010-07-08 17:51:33385 # Remove any files/dirs that live outside of "lib" directories,
386 # or are not in our list of changed includes.
387 find dpkg -mindepth 1 -regextype posix-extended \
388 "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \
389 -prune -o -print | tac |
390 xargs -r -n 1 sh -c "rm \$0 2>/dev/null || rmdir \$0 2>/dev/null || : "
[email protected]e041ed12009-03-10 16:43:01391 find dpkg -name lib64 -o -name bin -o -name "?bin" |
392 tac | xargs -r rm -rf
393
[email protected]34799f9d2010-07-08 17:51:33394 # Remove any symbolic links that were broken by the above steps.
395 find -L dpkg -type l -print | tac | xargs -r rm -rf
396
[email protected]e041ed12009-03-10 16:43:01397 # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32
398 # That is where gdb looks for them.
399 find dpkg -type d -o -path "*/lib/*" -print |
400 xargs -r -n 1 sh -c "
401 i=\$(echo \"\${0}\" |
402 sed -e s,/lib/,/lib32/,g \
403 -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,);
404 mkdir -p \"\${i%/*}\";
405 mv \"\${0}\" \"\${i}\""
406
[email protected]34799f9d2010-07-08 17:51:33407 # Rename include to include32.
408 [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32"
409
[email protected]e041ed12009-03-10 16:43:01410 # Prune any empty directories
411 find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || :
412
413 # Create our own Debian package
414 cd ..
415 dpkg --build staging/dpkg .' 2>&1)"
416 compat="$(eval echo $(echo "${compat}" |
417 sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))"
418 [ -r "${compat}" ] || {
419 echo "${msg}" >&2
420 echo "Failed to build new Debian archive!" >&2
421 exit 1
422 }
423
424 msg="$(sudo dpkg -i "${compat}" 2>&1)" && {
425 echo "Installed ${compat##*/}"
426 } || {
427 # echo "${msg}" >&2
428 echo "Skipped ${compat##*/}"
429 }
430 done
431
432 # Add symbolic links for developing 32bit code
433 echo "Adding missing symbolic links, enabling 32bit code development..."
434 for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* |
435 sed -e 's/[.]so[.][0-9].*/.so/' |
436 sort -u); do
437 [ "x${i##*/}" = "xld-linux.so" ] && continue
438 [ -r "$i" ] && continue
439 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' |
440 sort -n | tail -n 1)"
441 [ -r "$i.$j" ] || continue
442 sudo ln -s "${i##*/}.$j" "$i"
443 done
444fi