blob: 7908608365a55ff9079a4e991c35866e70c6effb [file] [log] [blame]
[email protected]e041ed12009-03-10 16:43:011#!/bin/bash -e
2
[email protected]4da8fad2011-04-11 18:42:423# Copyright (c) 2011 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"
15 echo "--[no-]gold: enable or disable installation of gold linker"
16 echo "--[no-]lib32: enable or disable installation of 32 bit libraries"
17 echo "Script will prompt interactively if options not given."
18 exit 1
19}
20
21while test "$1" != ""
22do
23 case "$1" in
24 --syms) do_inst_syms=1;;
25 --no-syms) do_inst_syms=0;;
26 --gold) do_inst_gold=1;;
27 --no-gold) do_inst_gold=0;;
28 --lib32) do_inst_lib32=1;;
29 --no-lib32) do_inst_lib32=0;;
30 *) usage;;
31 esac
32 shift
33done
34
[email protected]c87aa982009-06-11 17:44:0435install_gold() {
36 # Gold is optional; it's a faster replacement for ld,
37 # and makes life on 2GB machines much more pleasant.
38
[email protected]b62f11e72010-05-03 17:20:4539 # First make sure root can access this directory, as that's tripped
40 # up some folks.
[email protected]1bf2ac972009-06-30 23:57:4841 if sudo touch xyz.$$
42 then
43 sudo rm xyz.$$
44 else
45 echo root cannot write to the current directory, not installing gold
46 return
47 fi
48
[email protected]42276a972011-07-08 20:31:5749 BINUTILS=binutils-2.21.1
[email protected]c87aa982009-06-11 17:44:0450 BINUTILS_URL=http://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.bz2
[email protected]2e2b3a32011-07-09 00:04:2651 BINUTILS_SHA1=f188490772cc902ec44a76545887bff60dbfa22d
[email protected]c87aa982009-06-11 17:44:0452
53 test -f $BINUTILS.tar.bz2 || wget $BINUTILS_URL
[email protected]d42915d42009-11-18 10:36:4654 if test "`sha1sum $BINUTILS.tar.bz2|cut -d' ' -f1`" != "$BINUTILS_SHA1"
[email protected]c87aa982009-06-11 17:44:0455 then
56 echo Bad sha1sum for $BINUTILS.tar.bz2
57 exit 1
58 fi
[email protected]0b53eb02009-09-23 22:22:4759
[email protected]c87aa982009-06-11 17:44:0460 tar -xjvf $BINUTILS.tar.bz2
61 cd $BINUTILS
[email protected]b4ce3c22d2011-02-23 21:30:1762 ./configure --prefix=/usr/local/gold --enable-gold --enable-threads
[email protected]80e0c6302011-02-11 22:11:3163 make maybe-all-binutils maybe-all-gold -j4
64 if sudo make maybe-install-binutils maybe-install-gold
[email protected]1bf2ac972009-06-30 23:57:4865 then
66 # Still need to figure out graceful way of pointing gyp to use
67 # /usr/local/gold/bin/ld without requiring him to set environment
68 # variables. That will go into bootstrap-linux.sh when it's ready.
69 echo "Installing gold as /usr/bin/ld."
70 echo "To uninstall, do 'cd /usr/bin; sudo rm ld; sudo mv ld.orig ld'"
[email protected]803c45c52009-11-18 10:58:0071 test -f /usr/bin/ld && test ! -f /usr/bin/ld.orig && \
72 sudo mv /usr/bin/ld /usr/bin/ld.orig
[email protected]b2e24bd2009-09-10 17:45:3973 sudo strip /usr/local/gold/bin/ld
[email protected]1bf2ac972009-06-30 23:57:4874 sudo ln -fs /usr/local/gold/bin/ld /usr/bin/ld.gold
75 sudo ln -fs /usr/bin/ld.gold /usr/bin/ld
76 else
77 echo "make install failed, not installing gold"
78 fi
[email protected]c87aa982009-06-11 17:44:0479}
80
[email protected]a51551d2010-07-15 22:59:4881if ! egrep -q \
[email protected]1a0f64a2011-05-20 17:53:5582 'Ubuntu (10\.04|10\.10|11\.04|lucid|maverick|natty)' \
[email protected]a51551d2010-07-15 22:59:4883 /etc/issue; then
[email protected]1a0f64a2011-05-20 17:53:5584 echo "Only Ubuntu 10.04 (lucid) through 11.04 (natty) are currently" \
[email protected]a51551d2010-07-15 22:59:4885 "supported" >&2
[email protected]cf1df402008-10-31 21:45:3086 exit 1
87fi
[email protected]cf1df402008-10-31 21:45:3088
[email protected]e041ed12009-03-10 16:43:0189if ! uname -m | egrep -q "i686|x86_64"; then
90 echo "Only x86 architectures are currently supported" >&2
91 exit
92fi
93
94if [ "x$(id -u)" != x0 ]; then
95 echo "Running as non-root user."
96 echo "You might have to enter your password one or more times for 'sudo'."
[email protected]8ada8c52009-03-10 21:53:0897 echo
[email protected]e041ed12009-03-10 16:43:0198fi
99
[email protected]fdc6bf52010-06-07 22:01:57100# Packages needed for chromeos only
101chromeos_dev_list="libpulse-dev"
102
[email protected]e041ed12009-03-10 16:43:01103# Packages need for development
[email protected]12440af82011-06-16 19:54:19104dev_list="apache2.2-bin bison fakeroot flex g++ gperf language-pack-fr
105 libapache2-mod-php5 libasound2-dev libbz2-dev libcairo2-dev
106 libcups2-dev libdbus-glib-1-dev libgconf2-dev
[email protected]4da8fad2011-04-11 18:42:42107 libgl1-mesa-dev libglu1-mesa-dev libglib2.0-dev libgnome-keyring-dev
[email protected]b4887d42011-08-23 21:46:30108 libgtk2.0-dev libjpeg62-dev libkrb5-dev libnspr4-dev libnss3-dev
109 libpam0g-dev libsctp-dev libsqlite3-dev libxslt1-dev libxss-dev
110 libxtst-dev mesa-common-dev msttcorefonts patch perl libwww-perl
111 php5-cgi pkg-config python python-dev rpm subversion ttf-dejavu-core
[email protected]2635e752011-07-08 21:27:29112 ttf-kochi-gothic ttf-kochi-mincho wdiff libcurl4-gnutls-dev
113 ttf-indic-fonts ttf-thai-tlwg
[email protected]9dc4bed2010-11-04 19:23:30114 $chromeos_dev_list"
[email protected]fdc6bf52010-06-07 22:01:57115
116# Run-time libraries required by chromeos only
[email protected]34799f9d2010-07-08 17:51:33117chromeos_lib_list="libpulse0 libbz2-1.0 libcurl4-gnutls-dev"
[email protected]e041ed12009-03-10 16:43:01118
119# Full list of required run-time libraries
[email protected]a9259a52011-05-21 01:05:22120lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcups2 libdbus-glib-1-2
121 libexpat1 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0
122 libgtk2.0-0 libpam0g libpango1.0-0 libpcre3 libpixman-1-0
[email protected]fd11101b2011-02-16 04:46:46123 libpng12-0 libstdc++6 libsqlite3-0 libx11-6 libxau6 libxcb1
124 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3
125 libxi6 libxinerama1 libxrandr2 libxrender1 libxtst6 zlib1g
[email protected]9dc4bed2010-11-04 19:23:30126 $chromeos_lib_list"
[email protected]e041ed12009-03-10 16:43:01127
128# Debugging symbols for all of the run-time libraries
[email protected]84421462010-03-11 17:20:25129dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg
[email protected]1a0f64a2011-05-20 17:53:55130 libfontconfig1-dbg libglib2.0-0-dbg libgtk2.0-0-dbg
131 libpango1.0-0-dbg libpcre3-dbg libpixman-1-0-dbg
[email protected]b944e322011-05-18 20:01:35132 libsqlite3-0-dbg
[email protected]e759c4b2010-03-10 19:04:58133 libx11-6-dbg libxau6-dbg libxcb1-dbg libxcomposite1-dbg
[email protected]e041ed12009-03-10 16:43:01134 libxcursor1-dbg libxdamage1-dbg libxdmcp6-dbg libxext6-dbg
135 libxfixes3-dbg libxi6-dbg libxinerama1-dbg libxrandr2-dbg
[email protected]9dc4bed2010-11-04 19:23:30136 libxrender1-dbg libxtst6-dbg zlib1g-dbg"
[email protected]e041ed12009-03-10 16:43:01137
[email protected]31a605532011-08-23 22:27:35138# Plugin lists needed for tests.
139plugin_list="flashplugin-installer"
140
[email protected]1a0f64a2011-05-20 17:53:55141# Some NSS packages were renamed in Natty.
142if egrep -q 'Ubuntu (10\.04|10\.10)' /etc/issue; then
143 dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg"
144 lib_list="${lib_list} libnspr4-0d libnss3-1d"
[email protected]cd03d822010-05-13 21:11:20145else
[email protected]1a0f64a2011-05-20 17:53:55146 dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg"
147 lib_list="${lib_list} libnspr4 libnss3"
[email protected]4da8fad2011-04-11 18:42:42148fi
149
[email protected]8ada8c52009-03-10 21:53:08150# Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is
151# accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has
152# been provided to yes_no(), the function also accepts RETURN as a user input.
153# The parameter specifies the exit code that should be returned in that case.
154# The function will echo the user's selection followed by a newline character.
155# Users can abort the function by pressing CTRL-C. This will call "exit 1".
156yes_no() {
157 local c
158 while :; do
159 c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
160 stty -echo iuclc -icanon 2>/dev/null
161 dd count=1 bs=1 2>/dev/null | od -An -tx1)"
162 case "$c" in
163 " 0a") if [ -n "$1" ]; then
164 [ $1 -eq 0 ] && echo "Y" || echo "N"
165 return $1
166 fi
167 ;;
168 " 79") echo "Y"
169 return 0
170 ;;
171 " 6e") echo "N"
172 return 1
173 ;;
174 "") echo "Aborted" >&2
175 exit 1
176 ;;
177 *) # The user pressed an unrecognized key. As we are not echoing
178 # any incorrect user input, alert the user by ringing the bell.
179 (tput bel) 2>/dev/null
180 ;;
181 esac
182 done
183}
184
[email protected]1eae2bfb2010-01-26 18:17:53185if test "$do_inst_syms" = ""
186then
187 echo "This script installs all tools and libraries needed to build Chromium."
188 echo ""
189 echo "For most of the libraries, it can also install debugging symbols, which"
190 echo "will allow you to debug code in the system libraries. Most developers"
191 echo "won't need these symbols."
192 echo -n "Do you want me to install them for you (y/N) "
193 if yes_no 1; then
194 do_inst_syms=1
195 fi
196fi
197if test "$do_inst_syms" = "1"; then
[email protected]8ada8c52009-03-10 21:53:08198 echo "Installing debugging symbols."
199else
200 echo "Skipping installation of debugging symbols."
201 dbg_list=
202fi
203
[email protected]e041ed12009-03-10 16:43:01204sudo apt-get update
205
206# We initially run "apt-get" with the --reinstall option and parse its output.
207# This way, we can find all the packages that need to be newly installed
208# without accidentally promoting any packages from "auto" to "manual".
209# We then re-run "apt-get" with just the list of missing packages.
210echo "Finding missing packages..."
[email protected]31a605532011-08-23 22:27:35211packages="${dev_list} ${lib_list} ${dbg_list} ${plugin_list}"
[email protected]b6e064522009-08-10 18:47:51212# Intentially leaving $packages unquoted so it's more readable.
213echo "Packages required: " $packages
214echo
[email protected]79a9d2962009-08-06 21:10:58215new_list_cmd="sudo apt-get install --reinstall $(echo $packages)"
[email protected]b62f11e72010-05-03 17:20:45216if new_list="$(yes n | LANG=C $new_list_cmd)"; then
[email protected]b6e064522009-08-10 18:47:51217 # We probably never hit this following line.
[email protected]79a9d2962009-08-06 21:10:58218 echo "No missing packages, and the packages are up-to-date."
[email protected]b62f11e72010-05-03 17:20:45219elif [ $? -eq 1 ]; then
[email protected]79a9d2962009-08-06 21:10:58220 # We expect apt-get to have exit status of 1.
221 # This indicates that we canceled the install with "yes n|".
[email protected]b6e064522009-08-10 18:47:51222 new_list=$(echo "$new_list" |
[email protected]79a9d2962009-08-06 21:10:58223 sed -e '1,/The following NEW packages will be installed:/d;s/^ //;t;d')
[email protected]b6e064522009-08-10 18:47:51224 new_list=$(echo "$new_list" | sed 's/ *$//')
225 if [ -z "$new_list" ] ; then
226 echo "No missing packages, and the packages are up-to-date."
227 else
228 echo "Installing missing packages: $new_list."
229 sudo apt-get install ${new_list}
230 fi
231 echo
[email protected]79a9d2962009-08-06 21:10:58232else
233 # An apt-get exit status of 100 indicates that a real error has occurred.
[email protected]e041ed12009-03-10 16:43:01234
[email protected]79a9d2962009-08-06 21:10:58235 # I am intentionally leaving out the '"'s around new_list_cmd,
236 # as this makes it easier to cut and paste the output
[email protected]79a9d2962009-08-06 21:10:58237 echo "The following command failed: " ${new_list_cmd}
238 echo
239 echo "It produces the following output:"
240 yes n | $new_list_cmd || true
241 echo
242 echo "You will have to install the above packages yourself."
243 echo
244 exit 100
245fi
[email protected]e041ed12009-03-10 16:43:01246
[email protected]b62f11e72010-05-03 17:20:45247# Some operating systems already ship gold (on recent Debian and
248# Ubuntu you can do "apt-get install binutils-gold" to get it), but
[email protected]ae0637b2010-06-30 17:07:56249# older releases didn't. Additionally, gold 2.20 (included in Ubuntu
[email protected]b4ce3c22d2011-02-23 21:30:17250# Lucid) makes binaries that just segfault, and 2.20.1 does not support
251# --map-whole-files.
[email protected]ae0637b2010-06-30 17:07:56252# So install from source if we don't have a good version.
[email protected]c87aa982009-06-11 17:44:04253
254case `ld --version` in
[email protected]b4ce3c22d2011-02-23 21:30:17255*gold*2.2[1-9].*) ;;
[email protected]c87aa982009-06-11 17:44:04256* )
[email protected]1eae2bfb2010-01-26 18:17:53257 if test "$do_inst_gold" = ""
258 then
259 echo "Gold is a new linker that links Chrome 5x faster than ld."
260 echo "Don't use it if you need to link other apps (e.g. valgrind, wine)"
261 echo -n "REPLACE SYSTEM LINKER ld with gold and back up ld? (y/N) "
262 if yes_no 1; then
263 do_inst_gold=1
264 fi
265 fi
266 if test "$do_inst_gold" = "1"
267 then
[email protected]ae0637b2010-06-30 17:07:56268 # If the system provides a good version of gold, just install it.
[email protected]b4ce3c22d2011-02-23 21:30:17269 if apt-cache show binutils-gold | grep -Eq 'Version: 2.2[1-9].*'; then
[email protected]f95691682009-11-17 05:19:56270 echo "Installing binutils-gold. Backing up ld as ld.single."
271 sudo apt-get install binutils-gold
272 else
273 # FIXME: avoid installing as /usr/bin/ld
274 echo "Building binutils. Backing up ld as ld.orig."
275 install_gold || exit 99
276 fi
[email protected]c87aa982009-06-11 17:44:04277 else
278 echo "Not installing gold."
279 fi
280esac
281
[email protected]e041ed12009-03-10 16:43:01282# Install 32bit backwards compatibility support for 64bit systems
[email protected]b6e064522009-08-10 18:47:51283if [ "$(uname -m)" = "x86_64" ]; then
[email protected]1eae2bfb2010-01-26 18:17:53284 if test "$do_inst_lib32" = ""
285 then
286 echo "Installing 32bit libraries not already provided by the system"
287 echo
[email protected]b62f11e72010-05-03 17:20:45288 echo "This is only needed to build a 32-bit Chrome on your 64-bit system."
289 echo
[email protected]1eae2bfb2010-01-26 18:17:53290 echo "While we only need to install a relatively small number of library"
291 echo "files, we temporarily need to download a lot of large *.deb packages"
292 echo "that contain these files. We will create new *.deb packages that"
293 echo "include just the 32bit libraries. These files will then be found on"
294 echo "your system in places like /lib32, /usr/lib32, /usr/lib/debug/lib32,"
295 echo "/usr/lib/debug/usr/lib32. If you ever need to uninstall these files,"
296 echo "look for packages named *-ia32.deb."
297 echo "Do you want me to download all packages needed to build new 32bit"
298 echo -n "package files (Y/n) "
[email protected]628b7ca2010-01-28 02:44:26299 if yes_no 0; then
[email protected]1eae2bfb2010-01-26 18:17:53300 do_inst_lib32=1
301 fi
302 fi
303 if test "$do_inst_lib32" != "1"
304 then
[email protected]8ada8c52009-03-10 21:53:08305 echo "Exiting without installing any 32bit libraries."
306 exit 0
307 fi
[email protected]b62f11e72010-05-03 17:20:45308
309 # Standard 32bit compatibility libraries
310 echo "First, installing the limited existing 32-bit support..."
311 cmp_list="ia32-libs lib32asound2-dev lib32readline5-dev lib32stdc++6 lib32z1
312 lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib"
[email protected]a81e44e12010-05-17 21:16:53313 sudo apt-get install $cmp_list
[email protected]b62f11e72010-05-03 17:20:45314
[email protected]e041ed12009-03-10 16:43:01315 tmp=/tmp/install-32bit.$$
316 trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT
317 mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial"
318 touch "${tmp}/status"
319
320 [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/"
[email protected]b6e064522009-08-10 18:47:51321 cat >>"${tmp}/apt/apt.conf" <<EOF
[email protected]79a9d2962009-08-06 21:10:58322 Apt::Architecture "i386";
323 Dir::Cache "${tmp}/cache";
324 Dir::Cache::Archives "${tmp}/";
325 Dir::State::Lists "${tmp}/apt/lists/";
326 Dir::State::status "${tmp}/status";
[email protected]b6e064522009-08-10 18:47:51327EOF
[email protected]1bf2ac972009-06-30 23:57:48328
[email protected]e041ed12009-03-10 16:43:01329 # Download 32bit packages
330 echo "Computing list of available 32bit packages..."
[email protected]a81e44e12010-05-17 21:16:53331 sudo apt-get -c="${tmp}/apt/apt.conf" update
[email protected]e041ed12009-03-10 16:43:01332
333 echo "Downloading available 32bit packages..."
[email protected]a81e44e12010-05-17 21:16:53334 sudo apt-get -c="${tmp}/apt/apt.conf" \
335 --yes --download-only --force-yes --reinstall install \
[email protected]e041ed12009-03-10 16:43:01336 ${lib_list} ${dbg_list}
337
338 # Open packages, remove everything that is not a library, move the
339 # library to a lib32 directory and package everything as a *.deb file.
340 echo "Repackaging and installing 32bit packages for use on 64bit systems..."
341 for i in ${lib_list} ${dbg_list}; do
342 orig="$(echo "${tmp}/${i}"_*_i386.deb)"
343 compat="$(echo "${orig}" |
344 sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')"
345 rm -rf "${tmp}/staging"
346 msg="$(fakeroot -u sh -exc '
347 # Unpack 32bit Debian archive
348 umask 022
349 mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN"
350 cd "'"${tmp}"'/staging"
351 ar x "'${orig}'"
352 tar zCfx dpkg data.tar.gz
353 tar zCfx dpkg/DEBIAN control.tar.gz
354
[email protected]34799f9d2010-07-08 17:51:33355 # Create a posix extended regular expression fragment that will
356 # recognize the includes which have changed. Should be rare,
357 # will almost always be empty.
358 includes=`sed -n -e "s/^[0-9a-z]* //g" \
359 -e "\,usr/include/,p" dpkg/DEBIAN/md5sums |
360 xargs -n 1 -I FILE /bin/sh -c \
361 "cmp -s dpkg/FILE /FILE || echo FILE" |
362 tr "\n" "|" |
363 sed -e "s,|$,,"`
[email protected]e041ed12009-03-10 16:43:01364
[email protected]34799f9d2010-07-08 17:51:33365 # If empty, set it to not match anything.
366 test -z "$includes" && includes="^//"
367
368 # Turn the conflicts into an extended RE for removal from the
369 # Provides line.
370 conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \
371 dpkg/DEBIAN/control`
372
373 # Rename package, change architecture, remove conflicts and dependencies
374 sed -r -i \
375 -e "/Package/s/$/-ia32/" \
376 -e "/Architecture/s/:.*$/: amd64/" \
377 -e "/Depends/s/:.*/: ia32-libs/" \
378 -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1" \
379 -e "/Recommends/d" \
380 -e "/Conflicts/d" \
381 dpkg/DEBIAN/control
382
383 # Only keep files that live in "lib" directories or the includes
384 # that have changed.
385 sed -r -i \
386 -e "/\/lib64\//d" -e "/\/.?bin\//d" \
387 -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g" \
388 -e "s, lib/, lib32/,g" \
389 -e "s,/lib/,/lib32/,g" \
390 -e "t;d" \
391 -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug," \
392 dpkg/DEBIAN/md5sums
[email protected]e041ed12009-03-10 16:43:01393
394 # Re-run ldconfig after installation/removal
395 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \
396 >dpkg/DEBIAN/postinst
397 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \
398 >dpkg/DEBIAN/postrm
399 chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm
400
401 # Remove any other control files
402 find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \
403 -name postinst -o -name postrm ")" -o -print |
404 xargs -r rm -rf
405
[email protected]34799f9d2010-07-08 17:51:33406 # Remove any files/dirs that live outside of "lib" directories,
407 # or are not in our list of changed includes.
408 find dpkg -mindepth 1 -regextype posix-extended \
409 "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \
410 -prune -o -print | tac |
411 xargs -r -n 1 sh -c "rm \$0 2>/dev/null || rmdir \$0 2>/dev/null || : "
[email protected]e041ed12009-03-10 16:43:01412 find dpkg -name lib64 -o -name bin -o -name "?bin" |
413 tac | xargs -r rm -rf
414
[email protected]34799f9d2010-07-08 17:51:33415 # Remove any symbolic links that were broken by the above steps.
416 find -L dpkg -type l -print | tac | xargs -r rm -rf
417
[email protected]e041ed12009-03-10 16:43:01418 # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32
419 # That is where gdb looks for them.
420 find dpkg -type d -o -path "*/lib/*" -print |
421 xargs -r -n 1 sh -c "
422 i=\$(echo \"\${0}\" |
423 sed -e s,/lib/,/lib32/,g \
424 -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,);
425 mkdir -p \"\${i%/*}\";
426 mv \"\${0}\" \"\${i}\""
427
[email protected]34799f9d2010-07-08 17:51:33428 # Rename include to include32.
429 [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32"
430
[email protected]e041ed12009-03-10 16:43:01431 # Prune any empty directories
432 find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || :
433
434 # Create our own Debian package
435 cd ..
436 dpkg --build staging/dpkg .' 2>&1)"
437 compat="$(eval echo $(echo "${compat}" |
438 sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))"
439 [ -r "${compat}" ] || {
440 echo "${msg}" >&2
441 echo "Failed to build new Debian archive!" >&2
442 exit 1
443 }
444
445 msg="$(sudo dpkg -i "${compat}" 2>&1)" && {
446 echo "Installed ${compat##*/}"
447 } || {
448 # echo "${msg}" >&2
449 echo "Skipped ${compat##*/}"
450 }
451 done
452
453 # Add symbolic links for developing 32bit code
454 echo "Adding missing symbolic links, enabling 32bit code development..."
455 for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* |
456 sed -e 's/[.]so[.][0-9].*/.so/' |
457 sort -u); do
458 [ "x${i##*/}" = "xld-linux.so" ] && continue
459 [ -r "$i" ] && continue
460 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' |
461 sort -n | tail -n 1)"
462 [ -r "$i.$j" ] || continue
463 sudo ln -s "${i##*/}.$j" "$i"
464 done
465fi