blob: 757c54520fa219cd385b06e4c2cdefed120a718f [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]bd29cdd2013-02-22 03:49:2017 echo "--[no-]chromeos-fonts: enable or disable installation of Chrome OS"\
18 "fonts"
[email protected]e2544ed42012-04-23 04:48:3119 echo "--no-prompt: silently select standard options/defaults"
[email protected]1eae2bfb2010-01-26 18:17:5320 echo "Script will prompt interactively if options not given."
21 exit 1
22}
23
24while test "$1" != ""
25do
26 case "$1" in
[email protected]ce774642011-09-12 23:21:3927 --syms) do_inst_syms=1;;
28 --no-syms) do_inst_syms=0;;
[email protected]ce774642011-09-12 23:21:3929 --lib32) do_inst_lib32=1;;
30 --no-lib32) do_inst_lib32=0;;
[email protected]f2826b6a2012-11-15 01:06:2631 --arm) do_inst_arm=1;;
32 --no-arm) do_inst_arm=0;;
[email protected]bd29cdd2013-02-22 03:49:2033 --chromeos-fonts) do_inst_chromeos_fonts=1;;
34 --no-chromeos-fonts) do_inst_chromeos_fonts=0;;
[email protected]e2544ed42012-04-23 04:48:3135 --no-prompt) do_default=1
36 do_quietly="-qq --assume-yes"
37 ;;
[email protected]fe63a022013-01-15 22:11:4738 --unsupported) do_unsupported=1;;
[email protected]1eae2bfb2010-01-26 18:17:5339 *) usage;;
40 esac
41 shift
42done
43
[email protected]c7492db62013-01-08 07:18:2444ubuntu_versions="10\.04|10\.10|11\.04|11\.10|12\.04|12\.10"
45ubuntu_codenames="lucid|maverick|natty|oneiric|precise|quantal"
[email protected]fe63a022013-01-15 22:11:4746ubuntu_issue="Ubuntu ($ubuntu_versions|$ubuntu_codenames)"
47# GCEL is an Ubuntu-derived VM image used on Google Compute Engine; /etc/issue
48# doesn't contain a version number so just trust that the user knows what
49# they're doing.
50gcel_issue="^GCEL"
[email protected]f2826b6a2012-11-15 01:06:2651
[email protected]fe63a022013-01-15 22:11:4752if [ 0 -eq "${do_unsupported-0}" ] ; then
53 if ! egrep -q "($ubuntu_issue|$gcel_issue)" /etc/issue; then
54 echo "ERROR: Only Ubuntu 10.04 (lucid) through 12.10 (quantal) are"\
55 "currently supported" >&2
56 exit 1
57 fi
[email protected]cf1df402008-10-31 21:45:3058
[email protected]fe63a022013-01-15 22:11:4759 if ! uname -m | egrep -q "i686|x86_64"; then
60 echo "Only x86 architectures are currently supported" >&2
61 exit
62 fi
[email protected]e041ed12009-03-10 16:43:0163fi
64
65if [ "x$(id -u)" != x0 ]; then
66 echo "Running as non-root user."
67 echo "You might have to enter your password one or more times for 'sudo'."
[email protected]8ada8c52009-03-10 21:53:0868 echo
[email protected]e041ed12009-03-10 16:43:0169fi
70
[email protected]fdc6bf52010-06-07 22:01:5771# Packages needed for chromeos only
[email protected]a76ae552013-03-07 17:07:4772chromeos_dev_list="libbluetooth-dev"
[email protected]fdc6bf52010-06-07 22:01:5773
[email protected]e041ed12009-03-10 16:43:0174# Packages need for development
[email protected]041d14a2011-12-13 01:42:4875dev_list="apache2.2-bin bison curl elfutils fakeroot flex g++ gperf
76 language-pack-fr libapache2-mod-php5 libasound2-dev libbz2-dev
[email protected]6ffd19f352012-10-23 02:00:4177 libcairo2-dev libcups2-dev libcurl4-gnutls-dev libelf-dev
78 libgconf2-dev libgl1-mesa-dev libglib2.0-dev libglu1-mesa-dev
[email protected]831c6bc2012-12-11 23:58:2079 libgnome-keyring-dev libgtk2.0-dev libkrb5-dev libnspr4-dev
[email protected]a76ae552013-03-07 17:07:4780 libnss3-dev libpam0g-dev libpci-dev libpulse-dev libsctp-dev
81 libspeechd-dev libsqlite3-dev libssl-dev libudev-dev libwww-perl
82 libxslt1-dev libxss-dev libxt-dev libxtst-dev mesa-common-dev
83 metacity patch perl php5-cgi pkg-config python python-cherrypy3
84 python-dev python-psutil rpm ruby subversion ttf-dejavu-core
85 ttf-indic-fonts ttf-kochi-gothic ttf-kochi-mincho ttf-thai-tlwg
86 wdiff git-core
[email protected]8190b882012-12-05 19:40:3487 $chromeos_dev_list"
[email protected]fdc6bf52010-06-07 22:01:5788
[email protected]f16aabf2012-08-15 21:00:1489# 64-bit systems need a minimum set of 32-bit compat packages for the pre-built
[email protected]d93d68b12012-10-15 06:39:5390# NaCl binaries. These are always needed, regardless of whether or not we want
[email protected]f16aabf2012-08-15 21:00:1491# the full 32-bit "cross-compile" support (--lib32).
92if [ "$(uname -m)" = "x86_64" ]; then
[email protected]d93d68b12012-10-15 06:39:5393 dev_list="${dev_list} libc6-i386 lib32gcc1 lib32stdc++6"
[email protected]f16aabf2012-08-15 21:00:1494fi
95
[email protected]fdc6bf52010-06-07 22:01:5796# Run-time libraries required by chromeos only
[email protected]34799f9d2010-07-08 17:51:3397chromeos_lib_list="libpulse0 libbz2-1.0 libcurl4-gnutls-dev"
[email protected]e041ed12009-03-10 16:43:0198
99# Full list of required run-time libraries
[email protected]6ffd19f352012-10-23 02:00:41100lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcups2 libexpat1
101 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0
[email protected]ca3a1d262012-10-30 22:33:20102 libgtk2.0-0 libpam0g libpango1.0-0 libpci3 libpcre3 libpixman-1-0
[email protected]8190b882012-12-05 19:40:34103 libpng12-0 libspeechd2 libstdc++6 libsqlite3-0 libudev0 libx11-6
104 libxau6 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6
105 libxext6 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1
106 libxtst6 zlib1g $chromeos_lib_list"
[email protected]e041ed12009-03-10 16:43:01107
108# Debugging symbols for all of the run-time libraries
[email protected]6ffd19f352012-10-23 02:00:41109dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libfontconfig1-dbg
110 libglib2.0-0-dbg libgtk2.0-0-dbg libpango1.0-0-dbg libpcre3-dbg
111 libpixman-1-0-dbg libsqlite3-0-dbg libx11-6-dbg libxau6-dbg
112 libxcb1-dbg libxcomposite1-dbg libxcursor1-dbg libxdamage1-dbg
113 libxdmcp6-dbg libxext6-dbg libxfixes3-dbg libxi6-dbg libxinerama1-dbg
114 libxrandr2-dbg libxrender1-dbg libxtst6-dbg zlib1g-dbg"
[email protected]e041ed12009-03-10 16:43:01115
[email protected]f2826b6a2012-11-15 01:06:26116# arm cross toolchain packages needed to build chrome on arm
117arm_list="libc6-armel-cross libc6-dev-armel-cross libgcc1-armel-cross
118 libgomp1-armel-cross linux-libc-dev-armel-cross
119 libgcc1-dbg-armel-cross libgomp1-dbg-armel-cross
120 binutils-arm-linux-gnueabi cpp-arm-linux-gnueabi
121 gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
[email protected]9f28a9cf2012-12-17 23:31:40122 libmudflap0-dbg-armel-cross"
[email protected]f2826b6a2012-11-15 01:06:26123
[email protected]31a605532011-08-23 22:27:35124
[email protected]757c2962012-03-15 19:05:18125# Some package names have changed over time
[email protected]b11411c2012-03-21 22:09:41126if apt-cache show ttf-mscorefonts-installer >/dev/null 2>&1; then
[email protected]757c2962012-03-15 19:05:18127 dev_list="${dev_list} ttf-mscorefonts-installer"
[email protected]b11411c2012-03-21 22:09:41128else
129 dev_list="${dev_list} msttcorefonts"
[email protected]757c2962012-03-15 19:05:18130fi
[email protected]b11411c2012-03-21 22:09:41131if apt-cache show libnspr4-dbg >/dev/null 2>&1; then
[email protected]1a0f64a2011-05-20 17:53:55132 dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg"
133 lib_list="${lib_list} libnspr4 libnss3"
[email protected]757c2962012-03-15 19:05:18134else
135 dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg"
136 lib_list="${lib_list} libnspr4-0d libnss3-1d"
137fi
[email protected]b11411c2012-03-21 22:09:41138if apt-cache show libjpeg-dev >/dev/null 2>&1; then
139 dev_list="${dev_list} libjpeg-dev"
140else
141 dev_list="${dev_list} libjpeg62-dev"
142fi
[email protected]757c2962012-03-15 19:05:18143
144# Some packages are only needed, if the distribution actually supports
145# installing them.
[email protected]b11411c2012-03-21 22:09:41146if apt-cache show appmenu-gtk >/dev/null 2>&1; then
[email protected]757c2962012-03-15 19:05:18147 lib_list="$lib_list appmenu-gtk"
[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() {
[email protected]e2544ed42012-04-23 04:48:31157 if [ 0 -ne "${do_default-0}" ] ; then
158 return $1
159 fi
[email protected]8ada8c52009-03-10 21:53:08160 local c
161 while :; do
162 c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
163 stty -echo iuclc -icanon 2>/dev/null
164 dd count=1 bs=1 2>/dev/null | od -An -tx1)"
165 case "$c" in
166 " 0a") if [ -n "$1" ]; then
167 [ $1 -eq 0 ] && echo "Y" || echo "N"
168 return $1
169 fi
170 ;;
171 " 79") echo "Y"
172 return 0
173 ;;
174 " 6e") echo "N"
175 return 1
176 ;;
177 "") echo "Aborted" >&2
178 exit 1
179 ;;
180 *) # The user pressed an unrecognized key. As we are not echoing
181 # any incorrect user input, alert the user by ringing the bell.
182 (tput bel) 2>/dev/null
183 ;;
184 esac
185 done
186}
187
[email protected]1eae2bfb2010-01-26 18:17:53188if test "$do_inst_syms" = ""
189then
190 echo "This script installs all tools and libraries needed to build Chromium."
191 echo ""
192 echo "For most of the libraries, it can also install debugging symbols, which"
193 echo "will allow you to debug code in the system libraries. Most developers"
194 echo "won't need these symbols."
195 echo -n "Do you want me to install them for you (y/N) "
196 if yes_no 1; then
197 do_inst_syms=1
198 fi
199fi
200if test "$do_inst_syms" = "1"; then
[email protected]8ada8c52009-03-10 21:53:08201 echo "Installing debugging symbols."
202else
203 echo "Skipping installation of debugging symbols."
204 dbg_list=
205fi
206
[email protected]bd29cdd2013-02-22 03:49:20207# Install the Chrome OS default fonts.
208if test "$do_inst_chromeos_fonts" != "0"; then
[email protected]1c480ab62013-04-05 03:52:15209 echo
[email protected]bd29cdd2013-02-22 03:49:20210 echo "Installing Chrome OS fonts."
211 dir=`echo $0 | sed -r -e 's/\/[^/]+$//'`
[email protected]1c480ab62013-04-05 03:52:15212 if ! sudo $dir/linux/install-chromeos-fonts.py; then
213 echo "ERROR: The installation of the Chrome OS default fonts failed."
214 if [ `stat -f -c %T $dir` == "nfs" ]; then
215 echo "The reason is that your repo is installed on a remote file system."
216 else
217 echo "This is expected if your repo is installed on a remote file system."
218 fi
219 echo "It is recommended to install your repo on a local file system."
220 echo "You can skip the installation of the Chrome OS default founts with"
221 echo "the command line option: --no-chromeos-fonts."
222 exit 1
223 fi
[email protected]bd29cdd2013-02-22 03:49:20224else
225 echo "Skipping installation of Chrome OS fonts."
226fi
227
[email protected]9f28a9cf2012-12-17 23:31:40228# When cross building for arm on 64-bit systems the host binaries
229# that are part of v8 need to be compiled with -m32 which means
230# that basic multilib support is needed.
231if [ "$(uname -m)" = "x86_64" ]; then
232 arm_list="$arm_list g++-multilib"
233fi
234
[email protected]f2826b6a2012-11-15 01:06:26235if test "$do_inst_arm" = "1"; then
236 . /etc/lsb-release
237 if test "$DISTRIB_CODENAME" != "precise"; then
238 echo "ERROR: Installing the ARM cross toolchain is only available on" \
239 "Ubuntu precise." >&2
240 exit 1
241 fi
242 echo "Installing ARM cross toolchain."
243else
244 echo "Skipping installation of ARM cross toolchain."
245 arm_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]061de65b2013-03-05 02:25:23255packages="${dev_list} ${lib_list} ${dbg_list} ${arm_list}"
[email protected]757c2962012-03-15 19:05:18256# Intentionally leaving $packages unquoted so it's more readable.
[email protected]b6e064522009-08-10 18:47:51257echo "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.
[email protected]757c2962012-03-15 19:05:18265 # This indicates that we cancelled 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."
[email protected]e2544ed42012-04-23 04:48:31273 sudo apt-get install ${do_quietly-} ${new_list}
[email protected]b6e064522009-08-10 18:47:51274 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
291# Install 32bit backwards compatibility support for 64bit systems
[email protected]b6e064522009-08-10 18:47:51292if [ "$(uname -m)" = "x86_64" ]; then
[email protected]1eae2bfb2010-01-26 18:17:53293 if test "$do_inst_lib32" != "1"
294 then
[email protected]4a242bea2012-11-07 19:31:52295 echo "NOTE: If you were expecting the option to install 32bit libs,"
296 echo "please run with the --lib32 flag."
297 echo
298 echo "Installation complete."
[email protected]8ada8c52009-03-10 21:53:08299 exit 0
300 fi
[email protected]b62f11e72010-05-03 17:20:45301
[email protected]4a242bea2012-11-07 19:31:52302 echo "WARNING"
[email protected]e76a3632012-03-15 20:56:27303 echo
[email protected]4a242bea2012-11-07 19:31:52304 echo "We no longer recommend that you use this script to install"
305 echo "32bit libraries on a 64bit system. Instead, consider using the"
306 echo "install-chroot.sh script to help you set up a 32bit environment"
307 echo "for building and testing 32bit versions of Chrome."
308 echo
309 echo "The code for installing 32bit libraries on a 64bit system is"
310 echo "unmaintained and might not work with modern versions of Ubuntu"
311 echo "or Debian."
312 echo
313 echo -n "Are you sure you want to proceed (y/N) "
314 if yes_no 1; then
315 do_inst_lib32=1
316 fi
317 if test "$do_inst_lib32" != "1"
[email protected]796c3522012-11-07 22:56:35318 then
[email protected]4a242bea2012-11-07 19:31:52319 exit 0
320 fi
[email protected]e76a3632012-03-15 20:56:27321
[email protected]b62f11e72010-05-03 17:20:45322 # Standard 32bit compatibility libraries
323 echo "First, installing the limited existing 32-bit support..."
[email protected]7cf14b372011-12-08 18:32:52324 cmp_list="ia32-libs lib32asound2-dev lib32stdc++6 lib32z1
[email protected]b62f11e72010-05-03 17:20:45325 lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib"
[email protected]7cf14b372011-12-08 18:32:52326 if [ -n "`apt-cache search lib32readline-gplv2-dev 2>/dev/null`" ]; then
327 cmp_list="${cmp_list} lib32readline-gplv2-dev"
328 else
329 cmp_list="${cmp_list} lib32readline5-dev"
330 fi
[email protected]221569d32012-05-20 04:55:48331 sudo apt-get install ${do_quietly-} $cmp_list
[email protected]b62f11e72010-05-03 17:20:45332
[email protected]e041ed12009-03-10 16:43:01333 tmp=/tmp/install-32bit.$$
334 trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT
335 mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial"
336 touch "${tmp}/status"
337
338 [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/"
[email protected]b6e064522009-08-10 18:47:51339 cat >>"${tmp}/apt/apt.conf" <<EOF
[email protected]79a9d2962009-08-06 21:10:58340 Apt::Architecture "i386";
341 Dir::Cache "${tmp}/cache";
342 Dir::Cache::Archives "${tmp}/";
343 Dir::State::Lists "${tmp}/apt/lists/";
344 Dir::State::status "${tmp}/status";
[email protected]b6e064522009-08-10 18:47:51345EOF
[email protected]1bf2ac972009-06-30 23:57:48346
[email protected]e041ed12009-03-10 16:43:01347 # Download 32bit packages
348 echo "Computing list of available 32bit packages..."
[email protected]a81e44e12010-05-17 21:16:53349 sudo apt-get -c="${tmp}/apt/apt.conf" update
[email protected]e041ed12009-03-10 16:43:01350
351 echo "Downloading available 32bit packages..."
[email protected]a81e44e12010-05-17 21:16:53352 sudo apt-get -c="${tmp}/apt/apt.conf" \
353 --yes --download-only --force-yes --reinstall install \
[email protected]e041ed12009-03-10 16:43:01354 ${lib_list} ${dbg_list}
355
356 # Open packages, remove everything that is not a library, move the
357 # library to a lib32 directory and package everything as a *.deb file.
358 echo "Repackaging and installing 32bit packages for use on 64bit systems..."
359 for i in ${lib_list} ${dbg_list}; do
360 orig="$(echo "${tmp}/${i}"_*_i386.deb)"
361 compat="$(echo "${orig}" |
362 sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')"
363 rm -rf "${tmp}/staging"
364 msg="$(fakeroot -u sh -exc '
365 # Unpack 32bit Debian archive
366 umask 022
367 mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN"
368 cd "'"${tmp}"'/staging"
369 ar x "'${orig}'"
[email protected]55d1d7532013-03-19 03:06:45370 tar Cfx dpkg data.tar*
[email protected]e041ed12009-03-10 16:43:01371 tar zCfx dpkg/DEBIAN control.tar.gz
372
[email protected]34799f9d2010-07-08 17:51:33373 # Create a posix extended regular expression fragment that will
374 # recognize the includes which have changed. Should be rare,
375 # will almost always be empty.
376 includes=`sed -n -e "s/^[0-9a-z]* //g" \
377 -e "\,usr/include/,p" dpkg/DEBIAN/md5sums |
378 xargs -n 1 -I FILE /bin/sh -c \
379 "cmp -s dpkg/FILE /FILE || echo FILE" |
380 tr "\n" "|" |
381 sed -e "s,|$,,"`
[email protected]e041ed12009-03-10 16:43:01382
[email protected]34799f9d2010-07-08 17:51:33383 # If empty, set it to not match anything.
384 test -z "$includes" && includes="^//"
385
386 # Turn the conflicts into an extended RE for removal from the
387 # Provides line.
388 conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \
389 dpkg/DEBIAN/control`
390
391 # Rename package, change architecture, remove conflicts and dependencies
392 sed -r -i \
393 -e "/Package/s/$/-ia32/" \
394 -e "/Architecture/s/:.*$/: amd64/" \
395 -e "/Depends/s/:.*/: ia32-libs/" \
396 -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1" \
397 -e "/Recommends/d" \
398 -e "/Conflicts/d" \
399 dpkg/DEBIAN/control
400
401 # Only keep files that live in "lib" directories or the includes
402 # that have changed.
403 sed -r -i \
404 -e "/\/lib64\//d" -e "/\/.?bin\//d" \
405 -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g" \
406 -e "s, lib/, lib32/,g" \
407 -e "s,/lib/,/lib32/,g" \
408 -e "t;d" \
409 -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug," \
410 dpkg/DEBIAN/md5sums
[email protected]e041ed12009-03-10 16:43:01411
412 # Re-run ldconfig after installation/removal
413 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \
414 >dpkg/DEBIAN/postinst
415 { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \
416 >dpkg/DEBIAN/postrm
417 chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm
418
419 # Remove any other control files
420 find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \
421 -name postinst -o -name postrm ")" -o -print |
422 xargs -r rm -rf
423
[email protected]34799f9d2010-07-08 17:51:33424 # Remove any files/dirs that live outside of "lib" directories,
425 # or are not in our list of changed includes.
426 find dpkg -mindepth 1 -regextype posix-extended \
427 "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \
428 -prune -o -print | tac |
429 xargs -r -n 1 sh -c "rm \$0 2>/dev/null || rmdir \$0 2>/dev/null || : "
[email protected]e041ed12009-03-10 16:43:01430 find dpkg -name lib64 -o -name bin -o -name "?bin" |
431 tac | xargs -r rm -rf
432
[email protected]34799f9d2010-07-08 17:51:33433 # Remove any symbolic links that were broken by the above steps.
434 find -L dpkg -type l -print | tac | xargs -r rm -rf
435
[email protected]e041ed12009-03-10 16:43:01436 # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32
437 # That is where gdb looks for them.
438 find dpkg -type d -o -path "*/lib/*" -print |
439 xargs -r -n 1 sh -c "
440 i=\$(echo \"\${0}\" |
441 sed -e s,/lib/,/lib32/,g \
442 -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,);
443 mkdir -p \"\${i%/*}\";
444 mv \"\${0}\" \"\${i}\""
445
[email protected]34799f9d2010-07-08 17:51:33446 # Rename include to include32.
447 [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32"
448
[email protected]e041ed12009-03-10 16:43:01449 # Prune any empty directories
450 find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || :
451
452 # Create our own Debian package
453 cd ..
454 dpkg --build staging/dpkg .' 2>&1)"
455 compat="$(eval echo $(echo "${compat}" |
456 sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))"
457 [ -r "${compat}" ] || {
458 echo "${msg}" >&2
459 echo "Failed to build new Debian archive!" >&2
460 exit 1
461 }
462
463 msg="$(sudo dpkg -i "${compat}" 2>&1)" && {
464 echo "Installed ${compat##*/}"
465 } || {
466 # echo "${msg}" >&2
467 echo "Skipped ${compat##*/}"
468 }
469 done
470
471 # Add symbolic links for developing 32bit code
472 echo "Adding missing symbolic links, enabling 32bit code development..."
473 for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* |
474 sed -e 's/[.]so[.][0-9].*/.so/' |
475 sort -u); do
476 [ "x${i##*/}" = "xld-linux.so" ] && continue
477 [ -r "$i" ] && continue
478 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' |
479 sort -n | tail -n 1)"
480 [ -r "$i.$j" ] || continue
481 sudo ln -s "${i##*/}.$j" "$i"
482 done
483fi