[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 1 | #!/bin/bash -e |
| 2 | |
[email protected] | aac39c9 | 2012-02-08 18:39:53 | [diff] [blame^] | 3 | # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | e46cdae | 2009-08-25 20:59:27 | [diff] [blame] | 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] | cf1df40 | 2008-10-31 21:45:30 | [diff] [blame] | 7 | # Script to install everything needed to build chromium (well, ideally, anyway) |
[email protected] | 592ea8ca | 2008-11-03 19:47:36 | [diff] [blame] | 8 | # See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions |
| 9 | # and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit |
[email protected] | cf1df40 | 2008-10-31 21:45:30 | [diff] [blame] | 10 | |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 11 | usage() { |
| 12 | echo "Usage: $0 [--options]" |
| 13 | echo "Options:" |
| 14 | echo "--[no-]syms: enable or disable installation of debugging symbols" |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 15 | echo "--[no-]lib32: enable or disable installation of 32 bit libraries" |
| 16 | echo "Script will prompt interactively if options not given." |
| 17 | exit 1 |
| 18 | } |
| 19 | |
| 20 | while test "$1" != "" |
| 21 | do |
| 22 | case "$1" in |
[email protected] | ce77464 | 2011-09-12 23:21:39 | [diff] [blame] | 23 | --syms) do_inst_syms=1;; |
| 24 | --no-syms) do_inst_syms=0;; |
[email protected] | ce77464 | 2011-09-12 23:21:39 | [diff] [blame] | 25 | --lib32) do_inst_lib32=1;; |
| 26 | --no-lib32) do_inst_lib32=0;; |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 27 | *) usage;; |
| 28 | esac |
| 29 | shift |
| 30 | done |
| 31 | |
[email protected] | a51551d | 2010-07-15 22:59:48 | [diff] [blame] | 32 | if ! egrep -q \ |
[email protected] | e345f66f | 2011-10-17 20:52:16 | [diff] [blame] | 33 | 'Ubuntu (10\.04|10\.10|11\.04|11\.10|lucid|maverick|natty|oneiric)' \ |
[email protected] | a51551d | 2010-07-15 22:59:48 | [diff] [blame] | 34 | /etc/issue; then |
[email protected] | e345f66f | 2011-10-17 20:52:16 | [diff] [blame] | 35 | echo "Only Ubuntu 10.04 (lucid) through 11.10 (oneiric) are currently" \ |
[email protected] | a51551d | 2010-07-15 22:59:48 | [diff] [blame] | 36 | "supported" >&2 |
[email protected] | cf1df40 | 2008-10-31 21:45:30 | [diff] [blame] | 37 | exit 1 |
| 38 | fi |
[email protected] | cf1df40 | 2008-10-31 21:45:30 | [diff] [blame] | 39 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 40 | if ! uname -m | egrep -q "i686|x86_64"; then |
| 41 | echo "Only x86 architectures are currently supported" >&2 |
| 42 | exit |
| 43 | fi |
| 44 | |
| 45 | if [ "x$(id -u)" != x0 ]; then |
| 46 | echo "Running as non-root user." |
| 47 | echo "You might have to enter your password one or more times for 'sudo'." |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 48 | echo |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 49 | fi |
| 50 | |
[email protected] | fdc6bf5 | 2010-06-07 22:01:57 | [diff] [blame] | 51 | # Packages needed for chromeos only |
| 52 | chromeos_dev_list="libpulse-dev" |
| 53 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 54 | # Packages need for development |
[email protected] | 041d14a | 2011-12-13 01:42:48 | [diff] [blame] | 55 | dev_list="apache2.2-bin bison curl elfutils fakeroot flex g++ gperf |
| 56 | language-pack-fr libapache2-mod-php5 libasound2-dev libbz2-dev |
| 57 | libcairo2-dev libcups2-dev libcurl4-gnutls-dev libdbus-glib-1-dev |
| 58 | libelf-dev libgconf2-dev libgl1-mesa-dev libglib2.0-dev |
| 59 | libglu1-mesa-dev libgnome-keyring-dev libgtk2.0-dev libjpeg62-dev |
| 60 | libkrb5-dev libnspr4-dev libnss3-dev libpam0g-dev libsctp-dev |
[email protected] | 6de217b7 | 2011-12-17 03:36:32 | [diff] [blame] | 61 | libsqlite3-dev libssl-dev libudev-dev libwww-perl libxslt1-dev |
| 62 | libxss-dev libxt-dev libxtst-dev mesa-common-dev msttcorefonts patch |
| 63 | perl php5-cgi pkg-config python python-cherrypy3 python-dev |
| 64 | python-psutil rpm ruby subversion ttf-dejavu-core ttf-indic-fonts |
| 65 | ttf-kochi-gothic ttf-kochi-mincho ttf-thai-tlwg wdiff |
[email protected] | 9dc4bed | 2010-11-04 19:23:30 | [diff] [blame] | 66 | $chromeos_dev_list" |
[email protected] | fdc6bf5 | 2010-06-07 22:01:57 | [diff] [blame] | 67 | |
| 68 | # Run-time libraries required by chromeos only |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 69 | chromeos_lib_list="libpulse0 libbz2-1.0 libcurl4-gnutls-dev" |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 70 | |
| 71 | # Full list of required run-time libraries |
[email protected] | a9259a5 | 2011-05-21 01:05:22 | [diff] [blame] | 72 | lib_list="libatk1.0-0 libc6 libasound2 libcairo2 libcups2 libdbus-glib-1-2 |
| 73 | libexpat1 libfontconfig1 libfreetype6 libglib2.0-0 libgnome-keyring0 |
| 74 | libgtk2.0-0 libpam0g libpango1.0-0 libpcre3 libpixman-1-0 |
[email protected] | 6de217b7 | 2011-12-17 03:36:32 | [diff] [blame] | 75 | libpng12-0 libstdc++6 libsqlite3-0 libudev0 libx11-6 libxau6 libxcb1 |
[email protected] | fd11101b | 2011-02-16 04:46:46 | [diff] [blame] | 76 | libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 |
| 77 | libxi6 libxinerama1 libxrandr2 libxrender1 libxtst6 zlib1g |
[email protected] | 9dc4bed | 2010-11-04 19:23:30 | [diff] [blame] | 78 | $chromeos_lib_list" |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 79 | |
| 80 | # Debugging symbols for all of the run-time libraries |
[email protected] | f3307aa | 2011-10-21 22:52:38 | [diff] [blame] | 81 | dbg_list="libatk1.0-dbg libc6-dbg libcairo2-dbg libdbus-glib-1-2-dbg |
[email protected] | 1a0f64a | 2011-05-20 17:53:55 | [diff] [blame] | 82 | libfontconfig1-dbg libglib2.0-0-dbg libgtk2.0-0-dbg |
| 83 | libpango1.0-0-dbg libpcre3-dbg libpixman-1-0-dbg |
[email protected] | b944e32 | 2011-05-18 20:01:35 | [diff] [blame] | 84 | libsqlite3-0-dbg |
[email protected] | e759c4b | 2010-03-10 19:04:58 | [diff] [blame] | 85 | libx11-6-dbg libxau6-dbg libxcb1-dbg libxcomposite1-dbg |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 86 | libxcursor1-dbg libxdamage1-dbg libxdmcp6-dbg libxext6-dbg |
| 87 | libxfixes3-dbg libxi6-dbg libxinerama1-dbg libxrandr2-dbg |
[email protected] | 9dc4bed | 2010-11-04 19:23:30 | [diff] [blame] | 88 | libxrender1-dbg libxtst6-dbg zlib1g-dbg" |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 89 | |
[email protected] | 31a60553 | 2011-08-23 22:27:35 | [diff] [blame] | 90 | # Plugin lists needed for tests. |
| 91 | plugin_list="flashplugin-installer" |
| 92 | |
[email protected] | 1a0f64a | 2011-05-20 17:53:55 | [diff] [blame] | 93 | # Some NSS packages were renamed in Natty. |
| 94 | if egrep -q 'Ubuntu (10\.04|10\.10)' /etc/issue; then |
| 95 | dbg_list="${dbg_list} libnspr4-0d-dbg libnss3-1d-dbg" |
| 96 | lib_list="${lib_list} libnspr4-0d libnss3-1d" |
[email protected] | cd03d82 | 2010-05-13 21:11:20 | [diff] [blame] | 97 | else |
[email protected] | 1a0f64a | 2011-05-20 17:53:55 | [diff] [blame] | 98 | dbg_list="${dbg_list} libnspr4-dbg libnss3-dbg" |
| 99 | lib_list="${lib_list} libnspr4 libnss3" |
[email protected] | 4da8fad | 2011-04-11 18:42:42 | [diff] [blame] | 100 | fi |
| 101 | |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 102 | # Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is |
| 103 | # accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has |
| 104 | # been provided to yes_no(), the function also accepts RETURN as a user input. |
| 105 | # The parameter specifies the exit code that should be returned in that case. |
| 106 | # The function will echo the user's selection followed by a newline character. |
| 107 | # Users can abort the function by pressing CTRL-C. This will call "exit 1". |
| 108 | yes_no() { |
| 109 | local c |
| 110 | while :; do |
| 111 | c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT |
| 112 | stty -echo iuclc -icanon 2>/dev/null |
| 113 | dd count=1 bs=1 2>/dev/null | od -An -tx1)" |
| 114 | case "$c" in |
| 115 | " 0a") if [ -n "$1" ]; then |
| 116 | [ $1 -eq 0 ] && echo "Y" || echo "N" |
| 117 | return $1 |
| 118 | fi |
| 119 | ;; |
| 120 | " 79") echo "Y" |
| 121 | return 0 |
| 122 | ;; |
| 123 | " 6e") echo "N" |
| 124 | return 1 |
| 125 | ;; |
| 126 | "") echo "Aborted" >&2 |
| 127 | exit 1 |
| 128 | ;; |
| 129 | *) # The user pressed an unrecognized key. As we are not echoing |
| 130 | # any incorrect user input, alert the user by ringing the bell. |
| 131 | (tput bel) 2>/dev/null |
| 132 | ;; |
| 133 | esac |
| 134 | done |
| 135 | } |
| 136 | |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 137 | if test "$do_inst_syms" = "" |
| 138 | then |
| 139 | echo "This script installs all tools and libraries needed to build Chromium." |
| 140 | echo "" |
| 141 | echo "For most of the libraries, it can also install debugging symbols, which" |
| 142 | echo "will allow you to debug code in the system libraries. Most developers" |
| 143 | echo "won't need these symbols." |
| 144 | echo -n "Do you want me to install them for you (y/N) " |
| 145 | if yes_no 1; then |
| 146 | do_inst_syms=1 |
| 147 | fi |
| 148 | fi |
| 149 | if test "$do_inst_syms" = "1"; then |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 150 | echo "Installing debugging symbols." |
| 151 | else |
| 152 | echo "Skipping installation of debugging symbols." |
| 153 | dbg_list= |
| 154 | fi |
| 155 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 156 | sudo apt-get update |
| 157 | |
| 158 | # We initially run "apt-get" with the --reinstall option and parse its output. |
| 159 | # This way, we can find all the packages that need to be newly installed |
| 160 | # without accidentally promoting any packages from "auto" to "manual". |
| 161 | # We then re-run "apt-get" with just the list of missing packages. |
| 162 | echo "Finding missing packages..." |
[email protected] | 31a60553 | 2011-08-23 22:27:35 | [diff] [blame] | 163 | packages="${dev_list} ${lib_list} ${dbg_list} ${plugin_list}" |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 164 | # Intentially leaving $packages unquoted so it's more readable. |
| 165 | echo "Packages required: " $packages |
| 166 | echo |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 167 | new_list_cmd="sudo apt-get install --reinstall $(echo $packages)" |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 168 | if new_list="$(yes n | LANG=C $new_list_cmd)"; then |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 169 | # We probably never hit this following line. |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 170 | echo "No missing packages, and the packages are up-to-date." |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 171 | elif [ $? -eq 1 ]; then |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 172 | # We expect apt-get to have exit status of 1. |
| 173 | # This indicates that we canceled the install with "yes n|". |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 174 | new_list=$(echo "$new_list" | |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 175 | sed -e '1,/The following NEW packages will be installed:/d;s/^ //;t;d') |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 176 | new_list=$(echo "$new_list" | sed 's/ *$//') |
| 177 | if [ -z "$new_list" ] ; then |
| 178 | echo "No missing packages, and the packages are up-to-date." |
| 179 | else |
| 180 | echo "Installing missing packages: $new_list." |
| 181 | sudo apt-get install ${new_list} |
| 182 | fi |
| 183 | echo |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 184 | else |
| 185 | # An apt-get exit status of 100 indicates that a real error has occurred. |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 186 | |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 187 | # I am intentionally leaving out the '"'s around new_list_cmd, |
| 188 | # as this makes it easier to cut and paste the output |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 189 | echo "The following command failed: " ${new_list_cmd} |
| 190 | echo |
| 191 | echo "It produces the following output:" |
| 192 | yes n | $new_list_cmd || true |
| 193 | echo |
| 194 | echo "You will have to install the above packages yourself." |
| 195 | echo |
| 196 | exit 100 |
| 197 | fi |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 198 | |
| 199 | # Install 32bit backwards compatibility support for 64bit systems |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 200 | if [ "$(uname -m)" = "x86_64" ]; then |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 201 | if test "$do_inst_lib32" = "" |
| 202 | then |
| 203 | echo "Installing 32bit libraries not already provided by the system" |
| 204 | echo |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 205 | echo "This is only needed to build a 32-bit Chrome on your 64-bit system." |
| 206 | echo |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 207 | echo "While we only need to install a relatively small number of library" |
| 208 | echo "files, we temporarily need to download a lot of large *.deb packages" |
| 209 | echo "that contain these files. We will create new *.deb packages that" |
| 210 | echo "include just the 32bit libraries. These files will then be found on" |
| 211 | echo "your system in places like /lib32, /usr/lib32, /usr/lib/debug/lib32," |
| 212 | echo "/usr/lib/debug/usr/lib32. If you ever need to uninstall these files," |
| 213 | echo "look for packages named *-ia32.deb." |
| 214 | echo "Do you want me to download all packages needed to build new 32bit" |
[email protected] | 0813754 | 2011-09-23 21:35:18 | [diff] [blame] | 215 | echo -n "package files (y/N) " |
| 216 | if yes_no 1; then |
[email protected] | 1eae2bfb | 2010-01-26 18:17:53 | [diff] [blame] | 217 | do_inst_lib32=1 |
| 218 | fi |
| 219 | fi |
| 220 | if test "$do_inst_lib32" != "1" |
| 221 | then |
[email protected] | 8ada8c5 | 2009-03-10 21:53:08 | [diff] [blame] | 222 | echo "Exiting without installing any 32bit libraries." |
| 223 | exit 0 |
| 224 | fi |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 225 | |
| 226 | # Standard 32bit compatibility libraries |
| 227 | echo "First, installing the limited existing 32-bit support..." |
[email protected] | 7cf14b37 | 2011-12-08 18:32:52 | [diff] [blame] | 228 | cmp_list="ia32-libs lib32asound2-dev lib32stdc++6 lib32z1 |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 229 | lib32z1-dev libc6-dev-i386 libc6-i386 g++-multilib" |
[email protected] | 7cf14b37 | 2011-12-08 18:32:52 | [diff] [blame] | 230 | if [ -n "`apt-cache search lib32readline-gplv2-dev 2>/dev/null`" ]; then |
| 231 | cmp_list="${cmp_list} lib32readline-gplv2-dev" |
| 232 | else |
| 233 | cmp_list="${cmp_list} lib32readline5-dev" |
| 234 | fi |
[email protected] | a81e44e1 | 2010-05-17 21:16:53 | [diff] [blame] | 235 | sudo apt-get install $cmp_list |
[email protected] | b62f11e7 | 2010-05-03 17:20:45 | [diff] [blame] | 236 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 237 | tmp=/tmp/install-32bit.$$ |
| 238 | trap 'rm -rf "${tmp}"' EXIT INT TERM QUIT |
| 239 | mkdir -p "${tmp}/apt/lists/partial" "${tmp}/cache" "${tmp}/partial" |
| 240 | touch "${tmp}/status" |
| 241 | |
| 242 | [ -r /etc/apt/apt.conf ] && cp /etc/apt/apt.conf "${tmp}/apt/" |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 243 | cat >>"${tmp}/apt/apt.conf" <<EOF |
[email protected] | 79a9d296 | 2009-08-06 21:10:58 | [diff] [blame] | 244 | Apt::Architecture "i386"; |
| 245 | Dir::Cache "${tmp}/cache"; |
| 246 | Dir::Cache::Archives "${tmp}/"; |
| 247 | Dir::State::Lists "${tmp}/apt/lists/"; |
| 248 | Dir::State::status "${tmp}/status"; |
[email protected] | b6e06452 | 2009-08-10 18:47:51 | [diff] [blame] | 249 | EOF |
[email protected] | 1bf2ac97 | 2009-06-30 23:57:48 | [diff] [blame] | 250 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 251 | # Download 32bit packages |
| 252 | echo "Computing list of available 32bit packages..." |
[email protected] | a81e44e1 | 2010-05-17 21:16:53 | [diff] [blame] | 253 | sudo apt-get -c="${tmp}/apt/apt.conf" update |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 254 | |
| 255 | echo "Downloading available 32bit packages..." |
[email protected] | a81e44e1 | 2010-05-17 21:16:53 | [diff] [blame] | 256 | sudo apt-get -c="${tmp}/apt/apt.conf" \ |
| 257 | --yes --download-only --force-yes --reinstall install \ |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 258 | ${lib_list} ${dbg_list} |
| 259 | |
| 260 | # Open packages, remove everything that is not a library, move the |
| 261 | # library to a lib32 directory and package everything as a *.deb file. |
| 262 | echo "Repackaging and installing 32bit packages for use on 64bit systems..." |
| 263 | for i in ${lib_list} ${dbg_list}; do |
| 264 | orig="$(echo "${tmp}/${i}"_*_i386.deb)" |
| 265 | compat="$(echo "${orig}" | |
| 266 | sed -e 's,\(_[^_/]*_\)i386\(.deb\),-ia32\1amd64\2,')" |
| 267 | rm -rf "${tmp}/staging" |
| 268 | msg="$(fakeroot -u sh -exc ' |
| 269 | # Unpack 32bit Debian archive |
| 270 | umask 022 |
| 271 | mkdir -p "'"${tmp}"'/staging/dpkg/DEBIAN" |
| 272 | cd "'"${tmp}"'/staging" |
| 273 | ar x "'${orig}'" |
| 274 | tar zCfx dpkg data.tar.gz |
| 275 | tar zCfx dpkg/DEBIAN control.tar.gz |
| 276 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 277 | # Create a posix extended regular expression fragment that will |
| 278 | # recognize the includes which have changed. Should be rare, |
| 279 | # will almost always be empty. |
| 280 | includes=`sed -n -e "s/^[0-9a-z]* //g" \ |
| 281 | -e "\,usr/include/,p" dpkg/DEBIAN/md5sums | |
| 282 | xargs -n 1 -I FILE /bin/sh -c \ |
| 283 | "cmp -s dpkg/FILE /FILE || echo FILE" | |
| 284 | tr "\n" "|" | |
| 285 | sed -e "s,|$,,"` |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 286 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 287 | # If empty, set it to not match anything. |
| 288 | test -z "$includes" && includes="^//" |
| 289 | |
| 290 | # Turn the conflicts into an extended RE for removal from the |
| 291 | # Provides line. |
| 292 | conflicts=`sed -n -e "/Conflicts/s/Conflicts: *//;T;s/, */|/g;p" \ |
| 293 | dpkg/DEBIAN/control` |
| 294 | |
| 295 | # Rename package, change architecture, remove conflicts and dependencies |
| 296 | sed -r -i \ |
| 297 | -e "/Package/s/$/-ia32/" \ |
| 298 | -e "/Architecture/s/:.*$/: amd64/" \ |
| 299 | -e "/Depends/s/:.*/: ia32-libs/" \ |
| 300 | -e "/Provides/s/($conflicts)(, *)?//g;T1;s/, *$//;:1" \ |
| 301 | -e "/Recommends/d" \ |
| 302 | -e "/Conflicts/d" \ |
| 303 | dpkg/DEBIAN/control |
| 304 | |
| 305 | # Only keep files that live in "lib" directories or the includes |
| 306 | # that have changed. |
| 307 | sed -r -i \ |
| 308 | -e "/\/lib64\//d" -e "/\/.?bin\//d" \ |
| 309 | -e "\,$includes,s,[ /]include/,&32/,g;s,include/32/,include32/,g" \ |
| 310 | -e "s, lib/, lib32/,g" \ |
| 311 | -e "s,/lib/,/lib32/,g" \ |
| 312 | -e "t;d" \ |
| 313 | -e "\,^/usr/lib32/debug\(.*/lib32\),s,^/usr/lib32/debug,/usr/lib/debug," \ |
| 314 | dpkg/DEBIAN/md5sums |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 315 | |
| 316 | # Re-run ldconfig after installation/removal |
| 317 | { echo "#!/bin/sh"; echo "[ \"x\$1\" = xconfigure ]&&ldconfig||:"; } \ |
| 318 | >dpkg/DEBIAN/postinst |
| 319 | { echo "#!/bin/sh"; echo "[ \"x\$1\" = xremove ]&&ldconfig||:"; } \ |
| 320 | >dpkg/DEBIAN/postrm |
| 321 | chmod 755 dpkg/DEBIAN/postinst dpkg/DEBIAN/postrm |
| 322 | |
| 323 | # Remove any other control files |
| 324 | find dpkg/DEBIAN -mindepth 1 "(" -name control -o -name md5sums -o \ |
| 325 | -name postinst -o -name postrm ")" -o -print | |
| 326 | xargs -r rm -rf |
| 327 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 328 | # Remove any files/dirs that live outside of "lib" directories, |
| 329 | # or are not in our list of changed includes. |
| 330 | find dpkg -mindepth 1 -regextype posix-extended \ |
| 331 | "(" -name DEBIAN -o -name lib -o -regex "dpkg/($includes)" ")" \ |
| 332 | -prune -o -print | tac | |
| 333 | xargs -r -n 1 sh -c "rm \$0 2>/dev/null || rmdir \$0 2>/dev/null || : " |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 334 | find dpkg -name lib64 -o -name bin -o -name "?bin" | |
| 335 | tac | xargs -r rm -rf |
| 336 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 337 | # Remove any symbolic links that were broken by the above steps. |
| 338 | find -L dpkg -type l -print | tac | xargs -r rm -rf |
| 339 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 340 | # Rename lib to lib32, but keep debug symbols in /usr/lib/debug/usr/lib32 |
| 341 | # That is where gdb looks for them. |
| 342 | find dpkg -type d -o -path "*/lib/*" -print | |
| 343 | xargs -r -n 1 sh -c " |
| 344 | i=\$(echo \"\${0}\" | |
| 345 | sed -e s,/lib/,/lib32/,g \ |
| 346 | -e s,/usr/lib32/debug\\\\\(.*/lib32\\\\\),/usr/lib/debug\\\\1,); |
| 347 | mkdir -p \"\${i%/*}\"; |
| 348 | mv \"\${0}\" \"\${i}\"" |
| 349 | |
[email protected] | 34799f9d | 2010-07-08 17:51:33 | [diff] [blame] | 350 | # Rename include to include32. |
| 351 | [ -d "dpkg/usr/include" ] && mv "dpkg/usr/include" "dpkg/usr/include32" |
| 352 | |
[email protected] | e041ed1 | 2009-03-10 16:43:01 | [diff] [blame] | 353 | # Prune any empty directories |
| 354 | find dpkg -type d | tac | xargs -r -n 1 rmdir 2>/dev/null || : |
| 355 | |
| 356 | # Create our own Debian package |
| 357 | cd .. |
| 358 | dpkg --build staging/dpkg .' 2>&1)" |
| 359 | compat="$(eval echo $(echo "${compat}" | |
| 360 | sed -e 's,_[^_/]*_amd64.deb,_*_amd64.deb,'))" |
| 361 | [ -r "${compat}" ] || { |
| 362 | echo "${msg}" >&2 |
| 363 | echo "Failed to build new Debian archive!" >&2 |
| 364 | exit 1 |
| 365 | } |
| 366 | |
| 367 | msg="$(sudo dpkg -i "${compat}" 2>&1)" && { |
| 368 | echo "Installed ${compat##*/}" |
| 369 | } || { |
| 370 | # echo "${msg}" >&2 |
| 371 | echo "Skipped ${compat##*/}" |
| 372 | } |
| 373 | done |
| 374 | |
| 375 | # Add symbolic links for developing 32bit code |
| 376 | echo "Adding missing symbolic links, enabling 32bit code development..." |
| 377 | for i in $(find /lib32 /usr/lib32 -maxdepth 1 -name \*.so.\* | |
| 378 | sed -e 's/[.]so[.][0-9].*/.so/' | |
| 379 | sort -u); do |
| 380 | [ "x${i##*/}" = "xld-linux.so" ] && continue |
| 381 | [ -r "$i" ] && continue |
| 382 | j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' | |
| 383 | sort -n | tail -n 1)" |
| 384 | [ -r "$i.$j" ] || continue |
| 385 | sudo ln -s "${i##*/}.$j" "$i" |
| 386 | done |
| 387 | fi |