blob: 552264a77a955f96beea5bdd1c3d0374c0e1d897 [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]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 \
[email protected]1a0f64a2011-05-20 17:53:55132 'Ubuntu (10\.04|10\.10|11\.04|lucid|maverick|natty)' \
[email protected]a51551d2010-07-15 22:59:48133 /etc/issue; then
[email protected]1a0f64a2011-05-20 17:53:55134 echo "Only Ubuntu 10.04 (lucid) through 11.04 (natty) are currently" \
[email protected]a51551d2010-07-15 22:59:48135 "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]1a0f64a2011-05-20 17:53:55154dev_list="apache2.2-bin bison fakeroot flex g++ gperf libapache2-mod-php5
155 libasound2-dev libbz2-dev libcairo2-dev
156 libdbus-glib-1-dev libgconf2-dev
[email protected]4da8fad2011-04-11 18:42:42157 libgl1-mesa-dev libglu1-mesa-dev libglib2.0-dev libgnome-keyring-dev
158 libgtk2.0-dev libjpeg62-dev libnspr4-dev libnss3-dev libpam0g-dev
159 libsctp-dev libsqlite3-dev libxslt1-dev libxss-dev libxtst-dev
160 mesa-common-dev msttcorefonts patch perl php5-cgi pkg-config python
161 python-dev rpm subversion ttf-dejavu-core ttf-kochi-gothic
[email protected]ccd3f342011-05-03 18:21:48162 ttf-kochi-mincho wdiff libcurl4-gnutls-dev ttf-indic-fonts
163 ttf-thai-tlwg
[email protected]9dc4bed2010-11-04 19:23:30164 $chromeos_dev_list"
[email protected]fdc6bf52010-06-07 22:01:57165
166# Run-time libraries required by chromeos only
[email protected]34799f9d2010-07-08 17:51:33167chromeos_lib_list="libpulse0 libbz2-1.0 libcurl4-gnutls-dev"
[email protected]e041ed12009-03-10 16:43:01168
169# Full list of required run-time libraries
[email protected]e3212ba2010-03-11 15:27:24170lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libdbus-glib-1-2 libexpat1
[email protected]ce940f02010-06-07 22:34:40171 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0 libgtk2.0-0
[email protected]1a0f64a2011-05-20 17:53:55172 libpam0g libpango1.0-0 libpcre3 libpixman-1-0
[email protected]fd11101b2011-02-16 04:46:46173 libpng12-0 libstdc++6 libsqlite3-0 libx11-6 libxau6 libxcb1
174 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3
175 libxi6 libxinerama1 libxrandr2 libxrender1 libxtst6 zlib1g
[email protected]9dc4bed2010-11-04 19:23:30176 $chromeos_lib_list"
[email protected]e041ed12009-03-10 16:43:01177
178# Debugging symbols for all of the run-time libraries
[email protected]84421462010-03-11 17:20:25179dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg
[email protected]1a0f64a2011-05-20 17:53:55180 libfontconfig1-dbg libglib2.0-0-dbg libgtk2.0-0-dbg
181 libpango1.0-0-dbg libpcre3-dbg libpixman-1-0-dbg
[email protected]b944e322011-05-18 20:01:35182 libsqlite3-0-dbg
[email protected]e759c4b2010-03-10 19:04:58183 libx11-6-dbg libxau6-dbg libxcb1-dbg libxcomposite1-dbg
[email protected]e041ed12009-03-10 16:43:01184 libxcursor1-dbg libxdamage1-dbg libxdmcp6-dbg libxext6-dbg
185 libxfixes3-dbg libxi6-dbg libxinerama1-dbg libxrandr2-dbg
[email protected]9dc4bed2010-11-04 19:23:30186 libxrender1-dbg libxtst6-dbg zlib1g-dbg"
[email protected]e041ed12009-03-10 16:43:01187
[email protected]1a0f64a2011-05-20 17:53:55188# Some NSS packages were renamed in Natty.
189if egrep -q 'Ubuntu (10\.04|10\.10)' /etc/issue; then
190 dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg"
191 lib_list="${lib_list} libnspr4-0d libnss3-1d"
[email protected]cd03d822010-05-13 21:11:20192else
[email protected]1a0f64a2011-05-20 17:53:55193 dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg"
194 lib_list="${lib_list} libnspr4 libnss3"
[email protected]4da8fad2011-04-11 18:42:42195fi
196
[email protected]8ada8c52009-03-10 21:53:08197# Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is
198# accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has
199# been provided to yes_no(), the function also accepts RETURN as a user input.
200# The parameter specifies the exit code that should be returned in that case.
201# The function will echo the user's selection followed by a newline character.
202# Users can abort the function by pressing CTRL-C. This will call "exit 1".
203yes_no() {
204 local c
205 while :; do
206 c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
207 stty -echo iuclc -icanon 2>/dev/null
208 dd count=1 bs=1 2>/dev/null | od -An -tx1)"
209 case "$c" in
210 " 0a") if [ -n "$1" ]; then
211 [ $1 -eq 0 ] && echo "Y" || echo "N"
212 return $1
213 fi
214 ;;
215 " 79") echo "Y"
216 return 0
217 ;;
218 " 6e") echo "N"
219 return 1
220 ;;
221 "") echo "Aborted" >&2
222 exit 1
223 ;;
224 *) # The user pressed an unrecognized key. As we are not echoing
225 # any incorrect user input, alert the user by ringing the bell.
226 (tput bel) 2>/dev/null
227 ;;
228 esac
229 done
230}
231
[email protected]1eae2bfb2010-01-26 18:17:53232if test "$do_inst_syms" = ""
233then
234 echo "This script installs all tools and libraries needed to build Chromium."
235 echo ""
236 echo "For most of the libraries, it can also install debugging symbols, which"
237 echo "will allow you to debug code in the system libraries. Most developers"
238 echo "won't need these symbols."
239 echo -n "Do you want me to install them for you (y/N) "
240 if yes_no 1; then
241 do_inst_syms=1
242 fi
243fi
244if test "$do_inst_syms" = "1"; then
[email protected]8ada8c52009-03-10 21:53:08245 echo "Installing debugging symbols."
246else
247 echo "Skipping installation of debugging symbols."
248 dbg_list=
249fi
250
[email protected]e041ed12009-03-10 16:43:01251sudo apt-get update
252
253# We initially run "apt-get" with the --reinstall option and parse its output.
254# This way, we can find all the packages that need to be newly installed
255# without accidentally promoting any packages from "auto" to "manual".
256# We then re-run "apt-get" with just the list of missing packages.
257echo "Finding missing packages..."
[email protected]12de04f2009-08-11 17:30:48258packages="${dev_list} ${lib_list} ${dbg_list}"
[email protected]b6e064522009-08-10 18:47:51259# Intentially leaving $packages unquoted so it's more readable.
260echo "Packages required: " $packages
261echo
[email protected]79a9d2962009-08-06 21:10:58262new_list_cmd="sudo apt-get install --reinstall $(echo $packages)"
[email protected]b62f11e72010-05-03 17:20:45263if new_list="$(yes n | LANG=C $new_list_cmd)"; then
[email protected]b6e064522009-08-10 18:47:51264 # We probably never hit this following line.
[email protected]79a9d2962009-08-06 21:10:58265 echo "No missing packages, and the packages are up-to-date."
[email protected]b62f11e72010-05-03 17:20:45266elif [ $? -eq 1 ]; then
[email protected]79a9d2962009-08-06 21:10:58267 # We expect apt-get to have exit status of 1.
268 # This indicates that we canceled the install with "yes n|".
[email protected]b6e064522009-08-10 18:47:51269 new_list=$(echo "$new_list" |
[email protected]79a9d2962009-08-06 21:10:58270 sed -e '1,/The following NEW packages will be installed:/d;s/^ //;t;d')
[email protected]b6e064522009-08-10 18:47:51271 new_list=$(echo "$new_list" | sed 's/ *$//')
272 if [ -z "$new_list" ] ; then
273 echo "No missing packages, and the packages are up-to-date."
274 else
275 echo "Installing missing packages: $new_list."
276 sudo apt-get install ${new_list}
277 fi
278 echo
[email protected]79a9d2962009-08-06 21:10:58279else
280 # An apt-get exit status of 100 indicates that a real error has occurred.
[email protected]e041ed12009-03-10 16:43:01281
[email protected]79a9d2962009-08-06 21:10:58282 # I am intentionally leaving out the '"'s around new_list_cmd,
283 # as this makes it easier to cut and paste the output
[email protected]79a9d2962009-08-06 21:10:58284 echo "The following command failed: " ${new_list_cmd}
285 echo
286 echo "It produces the following output:"
287 yes n | $new_list_cmd || true
288 echo
289 echo "You will have to install the above packages yourself."
290 echo
291 exit 100
292fi
[email protected]e041ed12009-03-10 16:43:01293
[email protected]b62f11e72010-05-03 17:20:45294# Some operating systems already ship gold (on recent Debian and
295# Ubuntu you can do "apt-get install binutils-gold" to get it), but
[email protected]ae0637b2010-06-30 17:07:56296# older releases didn't. Additionally, gold 2.20 (included in Ubuntu
[email protected]b4ce3c22d2011-02-23 21:30:17297# Lucid) makes binaries that just segfault, and 2.20.1 does not support
298# --map-whole-files.
[email protected]ae0637b2010-06-30 17:07:56299# So install from source if we don't have a good version.
[email protected]c87aa982009-06-11 17:44:04300
301case `ld --version` in
[email protected]b4ce3c22d2011-02-23 21:30:17302*gold*2.2[1-9].*) ;;
[email protected]c87aa982009-06-11 17:44:04303* )
[email protected]1eae2bfb2010-01-26 18:17:53304 if test "$do_inst_gold" = ""
305 then
306 echo "Gold is a new linker that links Chrome 5x faster than ld."
307 echo "Don't use it if you need to link other apps (e.g. valgrind, wine)"
308 echo -n "REPLACE SYSTEM LINKER ld with gold and back up ld? (y/N) "
309 if yes_no 1; then
310 do_inst_gold=1
311 fi
312 fi
313 if test "$do_inst_gold" = "1"
314 then
[email protected]ae0637b2010-06-30 17:07:56315 # If the system provides a good version of gold, just install it.
[email protected]b4ce3c22d2011-02-23 21:30:17316 if apt-cache show binutils-gold | grep -Eq 'Version: 2.2[1-9].*'; then
[email protected]f95691682009-11-17 05:19:56317 echo "Installing binutils-gold. Backing up ld as ld.single."
318 sudo apt-get install binutils-gold
319 else
320 # FIXME: avoid installing as /usr/bin/ld
321 echo "Building binutils. Backing up ld as ld.orig."
322 install_gold || exit 99
323 fi
[email protected]c87aa982009-06-11 17:44:04324 else
325 echo "Not installing gold."
326 fi
327esac
328
[email protected]e041ed12009-03-10 16:43:01329# Install 32bit backwards compatibility support for 64bit systems
[email protected]b6e064522009-08-10 18:47:51330if [ "$(uname -m)" = "x86_64" ]; then
[email protected]1eae2bfb2010-01-26 18:17:53331 if test "$do_inst_lib32" = ""
332 then
333 echo "Installing 32bit libraries not already provided by the system"
334 echo
[email protected]b62f11e72010-05-03 17:20:45335 echo "This is only needed to build a 32-bit Chrome on your 64-bit system."
336 echo
[email protected]1eae2bfb2010-01-26 18:17:53337 echo "While we only need to install a relatively small number of library"
338 echo "files, we temporarily need to download a lot of large *.deb packages"
339 echo "that contain these files. We will create new *.deb packages that"
340 echo "include just the 32bit libraries. These files will then be found on"
341 echo "your system in places like /lib32, /usr/lib32, /usr/lib/debug/lib32,"
342 echo "/usr/lib/debug/usr/lib32. If you ever need to uninstall these files,"
343 echo "look for packages named *-ia32.deb."
344 echo "Do you want me to download all packages needed to build new 32bit"
345 echo -n "package files (Y/n) "
[email protected]628b7ca2010-01-28 02:44:26346 if yes_no 0; then
[email protected]1eae2bfb2010-01-26 18:17:53347 do_inst_lib32=1
348 fi
349 fi
350 if test "$do_inst_lib32" != "1"
351 then
[email protected]8ada8c52009-03-10 21:53:08352 echo "Exiting without installing any 32bit libraries."
353 exit 0
354 fi
[email protected]b62f11e72010-05-03 17:20:45355
356 # Standard 32bit compatibility libraries
357 echo "First, installing the limited existing 32-bit support..."
358 cmp_list="ia32-libs lib32asound2-dev lib32readline5-dev lib32stdc++6 lib32z1
359 lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib"
[email protected]a81e44e12010-05-17 21:16:53360 sudo apt-get install $cmp_list
[email protected]b62f11e72010-05-03 17:20:45361
[email protected]e041ed12009-03-10 16:43:01362 tmp=/tmp/install-32bit.$$
363 trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT
364 mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial"
365 touch "${tmp}/status"
366
367 [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/"
[email protected]b6e064522009-08-10 18:47:51368 cat >>"${tmp}/apt/apt.conf" <<EOF
[email protected]79a9d2962009-08-06 21:10:58369 Apt::Architecture "i386";
370 Dir::Cache "${tmp}/cache";
371 Dir::Cache::Archives "${tmp}/";
372 Dir::State::Lists "${tmp}/apt/lists/";
373 Dir::State::status "${tmp}/status";
[email protected]b6e064522009-08-10 18:47:51374EOF
[email protected]1bf2ac972009-06-30 23:57:48375
[email protected]e041ed12009-03-10 16:43:01376 # Download 32bit packages
377 echo "Computing list of available 32bit packages..."
[email protected]a81e44e12010-05-17 21:16:53378 sudo apt-get -c="${tmp}/apt/apt.conf" update
[email protected]e041ed12009-03-10 16:43:01379
380 echo "Downloading available 32bit packages..."
[email protected]a81e44e12010-05-17 21:16:53381 sudo apt-get -c="${tmp}/apt/apt.conf" \
382 --yes --download-only --force-yes --reinstall install \
[email protected]e041ed12009-03-10 16:43:01383 ${lib_list} ${dbg_list}
384
385 # Open packages, remove everything that is not a library, move the
386 # library to a lib32 directory and package everything as a *.deb file.
387 echo "Repackaging and installing 32bit packages for use on 64bit systems..."
388 for i in ${lib_list} ${dbg_list}; do
389 orig="$(echo "${tmp}/${i}"_*_i386.deb)"
390 compat="$(echo "${orig}" |
391 sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')"
392 rm -rf "${tmp}/staging"
393 msg="$(fakeroot -u sh -exc '
394 # Unpack 32bit Debian archive
395 umask 022
396 mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN"
397 cd "'"${tmp}"'/staging"
398 ar x "'${orig}'"
399 tar zCfx dpkg data.tar.gz
400 tar zCfx dpkg/DEBIAN control.tar.gz
401
[email protected]34799f9d2010-07-08 17:51:33402 # Create a posix extended regular expression fragment that will
403 # recognize the includes which have changed. Should be rare,
404 # will almost always be empty.
405 includes=`sed -n -e "s/^[0-9a-z]* //g" \
406 -e "\,usr/include/,p" dpkg/DEBIAN/md5sums |
407 xargs -n 1 -I FILE /bin/sh -c \
408 "cmp -s dpkg/FILE /FILE || echo FILE" |
409 tr "\n" "|" |
410 sed -e "s,|$,,"`
[email protected]e041ed12009-03-10 16:43:01411
[email protected]34799f9d2010-07-08 17:51:33412 # If empty, set it to not match anything.
413 test -z "$includes" && includes="^//"
414
415 # Turn the conflicts into an extended RE for removal from the
416 # Provides line.
417 conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \
418 dpkg/DEBIAN/control`
419
420 # Rename package, change architecture, remove conflicts and dependencies
421 sed -r -i \
422 -e "/Package/s/$/-ia32/" \
423 -e "/Architecture/s/:.*$/: amd64/" \
424 -e "/Depends/s/:.*/: ia32-libs/" \
425 -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1" \
426 -e "/Recommends/d" \
427 -e "/Conflicts/d" \
428 dpkg/DEBIAN/control
429
430 # Only keep files that live in "lib" directories or the includes
431 # that have changed.
432 sed -r -i \
433 -e "/\/lib64\//d" -e "/\/.?bin\//d" \
434 -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g" \
435 -e "s, lib/, lib32/,g" \
436 -e "s,/lib/,/lib32/,g" \
437 -e "t;d" \
438 -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug," \
439 dpkg/DEBIAN/md5sums
[email protected]e041ed12009-03-10 16:43:01440
441 # Re-run ldconfig after installation/removal
442 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \
443 >dpkg/DEBIAN/postinst
444 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \
445 >dpkg/DEBIAN/postrm
446 chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm
447
448 # Remove any other control files
449 find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \
450 -name postinst -o -name postrm ")" -o -print |
451 xargs -r rm -rf
452
[email protected]34799f9d2010-07-08 17:51:33453 # Remove any files/dirs that live outside of "lib" directories,
454 # or are not in our list of changed includes.
455 find dpkg -mindepth 1 -regextype posix-extended \
456 "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \
457 -prune -o -print | tac |
458 xargs -r -n 1 sh -c "rm \$0 2>/dev/null || rmdir \$0 2>/dev/null || : "
[email protected]e041ed12009-03-10 16:43:01459 find dpkg -name lib64 -o -name bin -o -name "?bin" |
460 tac | xargs -r rm -rf
461
[email protected]34799f9d2010-07-08 17:51:33462 # Remove any symbolic links that were broken by the above steps.
463 find -L dpkg -type l -print | tac | xargs -r rm -rf
464
[email protected]e041ed12009-03-10 16:43:01465 # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32
466 # That is where gdb looks for them.
467 find dpkg -type d -o -path "*/lib/*" -print |
468 xargs -r -n 1 sh -c "
469 i=\$(echo \"\${0}\" |
470 sed -e s,/lib/,/lib32/,g \
471 -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,);
472 mkdir -p \"\${i%/*}\";
473 mv \"\${0}\" \"\${i}\""
474
[email protected]34799f9d2010-07-08 17:51:33475 # Rename include to include32.
476 [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32"
477
[email protected]e041ed12009-03-10 16:43:01478 # Prune any empty directories
479 find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || :
480
481 # Create our own Debian package
482 cd ..
483 dpkg --build staging/dpkg .' 2>&1)"
484 compat="$(eval echo $(echo "${compat}" |
485 sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))"
486 [ -r "${compat}" ] || {
487 echo "${msg}" >&2
488 echo "Failed to build new Debian archive!" >&2
489 exit 1
490 }
491
492 msg="$(sudo dpkg -i "${compat}" 2>&1)" && {
493 echo "Installed ${compat##*/}"
494 } || {
495 # echo "${msg}" >&2
496 echo "Skipped ${compat##*/}"
497 }
498 done
499
500 # Add symbolic links for developing 32bit code
501 echo "Adding missing symbolic links, enabling 32bit code development..."
502 for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* |
503 sed -e 's/[.]so[.][0-9].*/.so/' |
504 sort -u); do
505 [ "x${i##*/}" = "xld-linux.so" ] && continue
506 [ -r "$i" ] && continue
507 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' |
508 sort -n | tail -n 1)"
509 [ -r "$i.$j" ] || continue
510 sudo ln -s "${i##*/}.$j" "$i"
511 done
512fi