blob: 933ed251f0229380c4548083f9711942eb05623f [file] [log] [blame]
[email protected]e041ed12009-03-10 16:43:011#!/bin/bash -e
2
[email protected]e46cdae2009-08-25 20:59:273# Copyright (c) 2009 The Chromium Authors. All rights reserved.
4# 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]b4ce3c22d2011-02-23 21:30:1749 BINUTILS=binutils-2.21
[email protected]c87aa982009-06-11 17:44:0450 BINUTILS_URL=http://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.bz2
[email protected]b4ce3c22d2011-02-23 21:30:1751 BINUTILS_SHA1=ef93235588eb443e4c4a77f229a8d131bccaecc6
[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 patch -p1 <<EOF
63diff -u -r1.103 -r1.103.2.1
64--- src/gold/object.h 2010/09/08 23:54:51 1.103
65+++ src/gold/object.h 2011/02/10 01:15:28 1.103.2.1
66@@ -1,6 +1,6 @@
67 // object.h -- support for an object file for linking in gold -*- C++ -*-
68
69-// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
70+// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
71 // Written by Ian Lance Taylor <iant@google.com>.
72
73 // This file is part of gold.
74@@ -2165,15 +2165,6 @@
75 Output_symtab_xindex*,
76 Output_symtab_xindex*);
77
78- // Clear the local symbol information.
79- void
80- clear_local_symbols()
81- {
82- this->local_values_.clear();
83- this->local_got_offsets_.clear();
84- this->local_plt_offsets_.clear();
85- }
86-
87 // Record a mapping from discarded section SHNDX to the corresponding
88 // kept section.
89 void
90diff -u -r1.60 -r1.60.2.1
91--- src/gold/reloc.cc 2010/10/14 22:10:22 1.60
92+++ src/gold/reloc.cc 2011/02/10 01:15:28 1.60.2.1
93@@ -1,6 +1,6 @@
94 // reloc.cc -- relocate input files for gold.
95
96-// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
97+// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
98 // Written by Ian Lance Taylor <iant@google.com>.
99
100 // This file is part of gold.
101@@ -685,9 +685,6 @@
102 // Write out the local symbols.
103 this->write_local_symbols(of, layout->sympool(), layout->dynpool(),
104 layout->symtab_xindex(), layout->dynsym_xindex());
105-
106- // We should no longer need the local symbol values.
107- this->clear_local_symbols();
108 }
109
110 // Sort a Read_multiple vector by file offset.
111EOF
112 ./configure --prefix=/usr/local/gold --enable-gold --enable-threads
[email protected]80e0c6302011-02-11 22:11:31113 make maybe-all-binutils maybe-all-gold -j4
114 if sudo make maybe-install-binutils maybe-install-gold
[email protected]1bf2ac972009-06-30 23:57:48115 then
116 # Still need to figure out graceful way of pointing gyp to use
117 # /usr/local/gold/bin/ld without requiring him to set environment
118 # variables. That will go into bootstrap-linux.sh when it's ready.
119 echo "Installing gold as /usr/bin/ld."
120 echo "To uninstall, do 'cd /usr/bin; sudo rm ld; sudo mv ld.orig ld'"
[email protected]803c45c52009-11-18 10:58:00121 test -f /usr/bin/ld && test ! -f /usr/bin/ld.orig && \
122 sudo mv /usr/bin/ld /usr/bin/ld.orig
[email protected]b2e24bd2009-09-10 17:45:39123 sudo strip /usr/local/gold/bin/ld
[email protected]1bf2ac972009-06-30 23:57:48124 sudo ln -fs /usr/local/gold/bin/ld /usr/bin/ld.gold
125 sudo ln -fs /usr/bin/ld.gold /usr/bin/ld
126 else
127 echo "make install failed, not installing gold"
128 fi
[email protected]c87aa982009-06-11 17:44:04129}
130
[email protected]a51551d2010-07-15 22:59:48131if ! egrep -q \
132 'Ubuntu (8\.04|8\.10|9\.04|9\.10|10\.04|10\.10|karmic|lucid|maverick)' \
133 /etc/issue; then
134 echo "Only Ubuntu 8.04 (hardy) through 10.10 (maverick) are currently" \
135 "supported" >&2
[email protected]cf1df402008-10-31 21:45:30136 exit 1
137fi
[email protected]cf1df402008-10-31 21:45:30138
[email protected]e041ed12009-03-10 16:43:01139if ! uname -m | egrep -q "i686|x86_64"; then
140 echo "Only x86 architectures are currently supported" >&2
141 exit
142fi
143
144if [ "x$(id -u)" != x0 ]; then
145 echo "Running as non-root user."
146 echo "You might have to enter your password one or more times for 'sudo'."
[email protected]8ada8c52009-03-10 21:53:08147 echo
[email protected]e041ed12009-03-10 16:43:01148fi
149
[email protected]fdc6bf52010-06-07 22:01:57150# Packages needed for chromeos only
151chromeos_dev_list="libpulse-dev"
152
[email protected]e041ed12009-03-10 16:43:01153# Packages need for development
[email protected]b62f11e72010-05-03 17:20:45154dev_list="apache2 bison fakeroot flex g++ gperf libapache2-mod-php5
[email protected]cd03d822010-05-13 21:11:20155 libasound2-dev libbz2-dev libcairo2-dev libdbus-glib-1-dev
156 libgconf2-dev libgl1-mesa-dev libglu1-mesa-dev libglib2.0-dev
[email protected]ce940f02010-06-07 22:34:40157 libgnome-keyring-dev libgtk2.0-dev libjpeg62-dev libnspr4-dev
[email protected]4f86f272011-04-07 18:07:29158 libnss3-dev libpam0g-dev libsctp-dev libsqlite3-dev libxslt1-dev
159 libxss-dev libxtst-dev lighttpd mesa-common-dev msttcorefonts patch
160 perl php5-cgi pkg-config python python-dev rpm subversion
161 ttf-dejavu-core ttf-kochi-gothic ttf-kochi-mincho wdiff
162 libcurl4-gnutls-dev
[email protected]9dc4bed2010-11-04 19:23:30163 $chromeos_dev_list"
[email protected]fdc6bf52010-06-07 22:01:57164
165# Run-time libraries required by chromeos only
[email protected]34799f9d2010-07-08 17:51:33166chromeos_lib_list="libpulse0 libbz2-1.0 libcurl4-gnutls-dev"
[email protected]e041ed12009-03-10 16:43:01167
168# Full list of required run-time libraries
[email protected]e3212ba2010-03-11 15:27:24169lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libdbus-glib-1-2 libexpat1
[email protected]ce940f02010-06-07 22:34:40170 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0 libgtk2.0-0
[email protected]fd11101b2011-02-16 04:46:46171 libnspr4-0d libnss3-1d libpam0g libpango1.0-0 libpcre3 libpixman-1-0
172 libpng12-0 libstdc++6 libsqlite3-0 libx11-6 libxau6 libxcb1
173 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3
174 libxi6 libxinerama1 libxrandr2 libxrender1 libxtst6 zlib1g
[email protected]9dc4bed2010-11-04 19:23:30175 $chromeos_lib_list"
[email protected]e041ed12009-03-10 16:43:01176
177# Debugging symbols for all of the run-time libraries
[email protected]84421462010-03-11 17:20:25178dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg
[email protected]e759c4b2010-03-10 19:04:58179 libfontconfig1-dbg libglib2.0-0-dbg libgtk2.0-0-dbg libnspr4-0d-dbg
180 libnss3-1d-dbg libpango1.0-0-dbg libpcre3-dbg libpixman-1-0-dbg
181 libx11-6-dbg libxau6-dbg libxcb1-dbg libxcomposite1-dbg
[email protected]e041ed12009-03-10 16:43:01182 libxcursor1-dbg libxdamage1-dbg libxdmcp6-dbg libxext6-dbg
183 libxfixes3-dbg libxi6-dbg libxinerama1-dbg libxrandr2-dbg
[email protected]9dc4bed2010-11-04 19:23:30184 libxrender1-dbg libxtst6-dbg zlib1g-dbg"
[email protected]e041ed12009-03-10 16:43:01185
[email protected]ce940f02010-06-07 22:34:40186# CUPS package changed its name from hardy to the next version. Include
[email protected]cd03d822010-05-13 21:11:20187# proper package here depending on the system.
[email protected]1437d242010-05-14 03:10:46188if egrep -q 'Ubuntu (8\.04|8\.10)' /etc/issue; then
[email protected]cd03d822010-05-13 21:11:20189 dev_list="${dev_list} libcupsys2-dev"
190else
191 dev_list="${dev_list} libcups2-dev"
192fi
193
[email protected]8ada8c52009-03-10 21:53:08194# Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is
195# accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has
196# been provided to yes_no(), the function also accepts RETURN as a user input.
197# The parameter specifies the exit code that should be returned in that case.
198# The function will echo the user's selection followed by a newline character.
199# Users can abort the function by pressing CTRL-C. This will call "exit 1".
200yes_no() {
201 local c
202 while :; do
203 c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
204 stty -echo iuclc -icanon 2>/dev/null
205 dd count=1 bs=1 2>/dev/null | od -An -tx1)"
206 case "$c" in
207 " 0a") if [ -n "$1" ]; then
208 [ $1 -eq 0 ] && echo "Y" || echo "N"
209 return $1
210 fi
211 ;;
212 " 79") echo "Y"
213 return 0
214 ;;
215 " 6e") echo "N"
216 return 1
217 ;;
218 "") echo "Aborted" >&2
219 exit 1
220 ;;
221 *) # The user pressed an unrecognized key. As we are not echoing
222 # any incorrect user input, alert the user by ringing the bell.
223 (tput bel) 2>/dev/null
224 ;;
225 esac
226 done
227}
228
[email protected]1eae2bfb2010-01-26 18:17:53229if test "$do_inst_syms" = ""
230then
231 echo "This script installs all tools and libraries needed to build Chromium."
232 echo ""
233 echo "For most of the libraries, it can also install debugging symbols, which"
234 echo "will allow you to debug code in the system libraries. Most developers"
235 echo "won't need these symbols."
236 echo -n "Do you want me to install them for you (y/N) "
237 if yes_no 1; then
238 do_inst_syms=1
239 fi
240fi
241if test "$do_inst_syms" = "1"; then
[email protected]8ada8c52009-03-10 21:53:08242 echo "Installing debugging symbols."
243else
244 echo "Skipping installation of debugging symbols."
245 dbg_list=
246fi
247
[email protected]e041ed12009-03-10 16:43:01248sudo apt-get update
249
250# We initially run "apt-get" with the --reinstall option and parse its output.
251# This way, we can find all the packages that need to be newly installed
252# without accidentally promoting any packages from "auto" to "manual".
253# We then re-run "apt-get" with just the list of missing packages.
254echo "Finding missing packages..."
[email protected]12de04f2009-08-11 17:30:48255packages="${dev_list} ${lib_list} ${dbg_list}"
[email protected]b6e064522009-08-10 18:47:51256# Intentially leaving $packages unquoted so it's more readable.
257echo "Packages required: " $packages
258echo
[email protected]79a9d2962009-08-06 21:10:58259new_list_cmd="sudo apt-get install --reinstall $(echo $packages)"
[email protected]b62f11e72010-05-03 17:20:45260if new_list="$(yes n | LANG=C $new_list_cmd)"; then
[email protected]b6e064522009-08-10 18:47:51261 # We probably never hit this following line.
[email protected]79a9d2962009-08-06 21:10:58262 echo "No missing packages, and the packages are up-to-date."
[email protected]b62f11e72010-05-03 17:20:45263elif [ $? -eq 1 ]; then
[email protected]79a9d2962009-08-06 21:10:58264 # We expect apt-get to have exit status of 1.
265 # This indicates that we canceled the install with "yes n|".
[email protected]b6e064522009-08-10 18:47:51266 new_list=$(echo "$new_list" |
[email protected]79a9d2962009-08-06 21:10:58267 sed -e '1,/The following NEW packages will be installed:/d;s/^ //;t;d')
[email protected]b6e064522009-08-10 18:47:51268 new_list=$(echo "$new_list" | sed 's/ *$//')
269 if [ -z "$new_list" ] ; then
270 echo "No missing packages, and the packages are up-to-date."
271 else
272 echo "Installing missing packages: $new_list."
273 sudo apt-get install ${new_list}
274 fi
275 echo
[email protected]79a9d2962009-08-06 21:10:58276else
277 # An apt-get exit status of 100 indicates that a real error has occurred.
[email protected]e041ed12009-03-10 16:43:01278
[email protected]79a9d2962009-08-06 21:10:58279 # I am intentionally leaving out the '"'s around new_list_cmd,
280 # as this makes it easier to cut and paste the output
[email protected]79a9d2962009-08-06 21:10:58281 echo "The following command failed: " ${new_list_cmd}
282 echo
283 echo "It produces the following output:"
284 yes n | $new_list_cmd || true
285 echo
286 echo "You will have to install the above packages yourself."
287 echo
288 exit 100
289fi
[email protected]e041ed12009-03-10 16:43:01290
[email protected]b62f11e72010-05-03 17:20:45291# Some operating systems already ship gold (on recent Debian and
292# Ubuntu you can do "apt-get install binutils-gold" to get it), but
[email protected]ae0637b2010-06-30 17:07:56293# older releases didn't. Additionally, gold 2.20 (included in Ubuntu
[email protected]b4ce3c22d2011-02-23 21:30:17294# Lucid) makes binaries that just segfault, and 2.20.1 does not support
295# --map-whole-files.
[email protected]ae0637b2010-06-30 17:07:56296# So install from source if we don't have a good version.
[email protected]c87aa982009-06-11 17:44:04297
298case `ld --version` in
[email protected]b4ce3c22d2011-02-23 21:30:17299*gold*2.2[1-9].*) ;;
[email protected]c87aa982009-06-11 17:44:04300* )
[email protected]1eae2bfb2010-01-26 18:17:53301 if test "$do_inst_gold" = ""
302 then
303 echo "Gold is a new linker that links Chrome 5x faster than ld."
304 echo "Don't use it if you need to link other apps (e.g. valgrind, wine)"
305 echo -n "REPLACE SYSTEM LINKER ld with gold and back up ld? (y/N) "
306 if yes_no 1; then
307 do_inst_gold=1
308 fi
309 fi
310 if test "$do_inst_gold" = "1"
311 then
[email protected]ae0637b2010-06-30 17:07:56312 # If the system provides a good version of gold, just install it.
[email protected]b4ce3c22d2011-02-23 21:30:17313 if apt-cache show binutils-gold | grep -Eq 'Version: 2.2[1-9].*'; then
[email protected]f95691682009-11-17 05:19:56314 echo "Installing binutils-gold. Backing up ld as ld.single."
315 sudo apt-get install binutils-gold
316 else
317 # FIXME: avoid installing as /usr/bin/ld
318 echo "Building binutils. Backing up ld as ld.orig."
319 install_gold || exit 99
320 fi
[email protected]c87aa982009-06-11 17:44:04321 else
322 echo "Not installing gold."
323 fi
324esac
325
[email protected]e041ed12009-03-10 16:43:01326# Install 32bit backwards compatibility support for 64bit systems
[email protected]b6e064522009-08-10 18:47:51327if [ "$(uname -m)" = "x86_64" ]; then
[email protected]1eae2bfb2010-01-26 18:17:53328 if test "$do_inst_lib32" = ""
329 then
330 echo "Installing 32bit libraries not already provided by the system"
331 echo
[email protected]b62f11e72010-05-03 17:20:45332 echo "This is only needed to build a 32-bit Chrome on your 64-bit system."
333 echo
[email protected]1eae2bfb2010-01-26 18:17:53334 echo "While we only need to install a relatively small number of library"
335 echo "files, we temporarily need to download a lot of large *.deb packages"
336 echo "that contain these files. We will create new *.deb packages that"
337 echo "include just the 32bit libraries. These files will then be found on"
338 echo "your system in places like /lib32, /usr/lib32, /usr/lib/debug/lib32,"
339 echo "/usr/lib/debug/usr/lib32. If you ever need to uninstall these files,"
340 echo "look for packages named *-ia32.deb."
341 echo "Do you want me to download all packages needed to build new 32bit"
342 echo -n "package files (Y/n) "
[email protected]628b7ca2010-01-28 02:44:26343 if yes_no 0; then
[email protected]1eae2bfb2010-01-26 18:17:53344 do_inst_lib32=1
345 fi
346 fi
347 if test "$do_inst_lib32" != "1"
348 then
[email protected]8ada8c52009-03-10 21:53:08349 echo "Exiting without installing any 32bit libraries."
350 exit 0
351 fi
[email protected]b62f11e72010-05-03 17:20:45352
353 # Standard 32bit compatibility libraries
354 echo "First, installing the limited existing 32-bit support..."
355 cmp_list="ia32-libs lib32asound2-dev lib32readline5-dev lib32stdc++6 lib32z1
356 lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib"
[email protected]a81e44e12010-05-17 21:16:53357 sudo apt-get install $cmp_list
[email protected]b62f11e72010-05-03 17:20:45358
[email protected]e041ed12009-03-10 16:43:01359 tmp=/tmp/install-32bit.$$
360 trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT
361 mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial"
362 touch "${tmp}/status"
363
364 [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/"
[email protected]b6e064522009-08-10 18:47:51365 cat >>"${tmp}/apt/apt.conf" <<EOF
[email protected]79a9d2962009-08-06 21:10:58366 Apt::Architecture "i386";
367 Dir::Cache "${tmp}/cache";
368 Dir::Cache::Archives "${tmp}/";
369 Dir::State::Lists "${tmp}/apt/lists/";
370 Dir::State::status "${tmp}/status";
[email protected]b6e064522009-08-10 18:47:51371EOF
[email protected]1bf2ac972009-06-30 23:57:48372
[email protected]e041ed12009-03-10 16:43:01373 # Download 32bit packages
374 echo "Computing list of available 32bit packages..."
[email protected]a81e44e12010-05-17 21:16:53375 sudo apt-get -c="${tmp}/apt/apt.conf" update
[email protected]e041ed12009-03-10 16:43:01376
377 echo "Downloading available 32bit packages..."
[email protected]a81e44e12010-05-17 21:16:53378 sudo apt-get -c="${tmp}/apt/apt.conf" \
379 --yes --download-only --force-yes --reinstall install \
[email protected]e041ed12009-03-10 16:43:01380 ${lib_list} ${dbg_list}
381
382 # Open packages, remove everything that is not a library, move the
383 # library to a lib32 directory and package everything as a *.deb file.
384 echo "Repackaging and installing 32bit packages for use on 64bit systems..."
385 for i in ${lib_list} ${dbg_list}; do
386 orig="$(echo "${tmp}/${i}"_*_i386.deb)"
387 compat="$(echo "${orig}" |
388 sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')"
389 rm -rf "${tmp}/staging"
390 msg="$(fakeroot -u sh -exc '
391 # Unpack 32bit Debian archive
392 umask 022
393 mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN"
394 cd "'"${tmp}"'/staging"
395 ar x "'${orig}'"
396 tar zCfx dpkg data.tar.gz
397 tar zCfx dpkg/DEBIAN control.tar.gz
398
[email protected]34799f9d2010-07-08 17:51:33399 # Create a posix extended regular expression fragment that will
400 # recognize the includes which have changed. Should be rare,
401 # will almost always be empty.
402 includes=`sed -n -e "s/^[0-9a-z]* //g" \
403 -e "\,usr/include/,p" dpkg/DEBIAN/md5sums |
404 xargs -n 1 -I FILE /bin/sh -c \
405 "cmp -s dpkg/FILE /FILE || echo FILE" |
406 tr "\n" "|" |
407 sed -e "s,|$,,"`
[email protected]e041ed12009-03-10 16:43:01408
[email protected]34799f9d2010-07-08 17:51:33409 # If empty, set it to not match anything.
410 test -z "$includes" && includes="^//"
411
412 # Turn the conflicts into an extended RE for removal from the
413 # Provides line.
414 conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \
415 dpkg/DEBIAN/control`
416
417 # Rename package, change architecture, remove conflicts and dependencies
418 sed -r -i \
419 -e "/Package/s/$/-ia32/" \
420 -e "/Architecture/s/:.*$/: amd64/" \
421 -e "/Depends/s/:.*/: ia32-libs/" \
422 -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1" \
423 -e "/Recommends/d" \
424 -e "/Conflicts/d" \
425 dpkg/DEBIAN/control
426
427 # Only keep files that live in "lib" directories or the includes
428 # that have changed.
429 sed -r -i \
430 -e "/\/lib64\//d" -e "/\/.?bin\//d" \
431 -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g" \
432 -e "s, lib/, lib32/,g" \
433 -e "s,/lib/,/lib32/,g" \
434 -e "t;d" \
435 -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug," \
436 dpkg/DEBIAN/md5sums
[email protected]e041ed12009-03-10 16:43:01437
438 # Re-run ldconfig after installation/removal
439 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \
440 >dpkg/DEBIAN/postinst
441 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \
442 >dpkg/DEBIAN/postrm
443 chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm
444
445 # Remove any other control files
446 find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \
447 -name postinst -o -name postrm ")" -o -print |
448 xargs -r rm -rf
449
[email protected]34799f9d2010-07-08 17:51:33450 # Remove any files/dirs that live outside of "lib" directories,
451 # or are not in our list of changed includes.
452 find dpkg -mindepth 1 -regextype posix-extended \
453 "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \
454 -prune -o -print | tac |
455 xargs -r -n 1 sh -c "rm \$0 2>/dev/null || rmdir \$0 2>/dev/null || : "
[email protected]e041ed12009-03-10 16:43:01456 find dpkg -name lib64 -o -name bin -o -name "?bin" |
457 tac | xargs -r rm -rf
458
[email protected]34799f9d2010-07-08 17:51:33459 # Remove any symbolic links that were broken by the above steps.
460 find -L dpkg -type l -print | tac | xargs -r rm -rf
461
[email protected]e041ed12009-03-10 16:43:01462 # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32
463 # That is where gdb looks for them.
464 find dpkg -type d -o -path "*/lib/*" -print |
465 xargs -r -n 1 sh -c "
466 i=\$(echo \"\${0}\" |
467 sed -e s,/lib/,/lib32/,g \
468 -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,);
469 mkdir -p \"\${i%/*}\";
470 mv \"\${0}\" \"\${i}\""
471
[email protected]34799f9d2010-07-08 17:51:33472 # Rename include to include32.
473 [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32"
474
[email protected]e041ed12009-03-10 16:43:01475 # Prune any empty directories
476 find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || :
477
478 # Create our own Debian package
479 cd ..
480 dpkg --build staging/dpkg .' 2>&1)"
481 compat="$(eval echo $(echo "${compat}" |
482 sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))"
483 [ -r "${compat}" ] || {
484 echo "${msg}" >&2
485 echo "Failed to build new Debian archive!" >&2
486 exit 1
487 }
488
489 msg="$(sudo dpkg -i "${compat}" 2>&1)" && {
490 echo "Installed ${compat##*/}"
491 } || {
492 # echo "${msg}" >&2
493 echo "Skipped ${compat##*/}"
494 }
495 done
496
497 # Add symbolic links for developing 32bit code
498 echo "Adding missing symbolic links, enabling 32bit code development..."
499 for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* |
500 sed -e 's/[.]so[.][0-9].*/.so/' |
501 sort -u); do
502 [ "x${i##*/}" = "xld-linux.so" ] && continue
503 [ -r "$i" ] && continue
504 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' |
505 sort -n | tail -n 1)"
506 [ -r "$i.$j" ] || continue
507 sudo ln -s "${i##*/}.$j" "$i"
508 done
509fi