| OLD | NEW |
| (Empty) |
| 1 #!/bin/sh | |
| 2 # | |
| 3 # Copyright (c) 2013 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 # | |
| 7 #@ This script builds a Debian Wheezy sysroot for building Google Chrome. | |
| 8 #@ | |
| 9 #@ Generally this script is invoked as: | |
| 10 #@ sysroot-creator-debian.wheezy.sh <mode> <args>* | |
| 11 #@ Available modes are shown below. | |
| 12 #@ | |
| 13 #@ List of modes: | |
| 14 | |
| 15 ###################################################################### | |
| 16 # Config | |
| 17 ###################################################################### | |
| 18 | |
| 19 set -o nounset | |
| 20 set -o errexit | |
| 21 | |
| 22 readonly SCRIPT_DIR=$(dirname $0) | |
| 23 | |
| 24 # This is where the staging sysroot is. | |
| 25 readonly INSTALL_ROOT_AMD64=$(pwd)/debian_wheezy_amd64_staging | |
| 26 readonly INSTALL_ROOT_I386=$(pwd)/debian_wheezy_i386_staging | |
| 27 readonly INSTALL_ROOT_ARM=$(pwd)/debian_wheezy_arm_staging | |
| 28 | |
| 29 readonly REQUIRED_TOOLS="wget" | |
| 30 | |
| 31 ###################################################################### | |
| 32 # Package Config | |
| 33 ###################################################################### | |
| 34 | |
| 35 # This is where we get all the debian packages from. | |
| 36 readonly DEBIAN_REPO=http://http.us.debian.org/debian | |
| 37 readonly REPO_BASEDIR="${DEBIAN_REPO}/dists/wheezy" | |
| 38 | |
| 39 readonly RELEASE_FILE="Release" | |
| 40 readonly RELEASE_FILE_GPG="Release.gpg" | |
| 41 readonly RELEASE_LIST="${REPO_BASEDIR}/${RELEASE_FILE}" | |
| 42 readonly RELEASE_LIST_GPG="${REPO_BASEDIR}/${RELEASE_FILE_GPG}" | |
| 43 readonly PACKAGE_FILE_AMD64="main/binary-amd64/Packages.bz2" | |
| 44 readonly PACKAGE_FILE_I386="main/binary-i386/Packages.bz2" | |
| 45 readonly PACKAGE_FILE_ARM="main/binary-armhf/Packages.bz2" | |
| 46 readonly PACKAGE_LIST_AMD64="${REPO_BASEDIR}/${PACKAGE_FILE_AMD64}" | |
| 47 readonly PACKAGE_LIST_I386="${REPO_BASEDIR}/${PACKAGE_FILE_I386}" | |
| 48 readonly PACKAGE_LIST_ARM="${REPO_BASEDIR}/${PACKAGE_FILE_ARM}" | |
| 49 | |
| 50 # Sysroot packages: these are the packages needed to build chrome. | |
| 51 # NOTE: When DEBIAN_PACKAGES is modified, the packagelist files must be updated | |
| 52 # by running this script in GeneratePackageList mode. | |
| 53 readonly DEBIAN_PACKAGES="\ | |
| 54 comerr-dev \ | |
| 55 gcc-4.6 \ | |
| 56 krb5-multidev \ | |
| 57 libasound2 \ | |
| 58 libasound2-dev \ | |
| 59 libatk1.0-0 \ | |
| 60 libatk1.0-dev \ | |
| 61 libavahi-client3 \ | |
| 62 libavahi-common3 \ | |
| 63 libc6 \ | |
| 64 libc6-dev \ | |
| 65 libcairo2 \ | |
| 66 libcairo2-dev \ | |
| 67 libcairo-gobject2 \ | |
| 68 libcairo-script-interpreter2 \ | |
| 69 libcap-dev \ | |
| 70 libcap2 \ | |
| 71 libcomerr2 \ | |
| 72 libcups2 \ | |
| 73 libcups2-dev \ | |
| 74 libdbus-1-3 \ | |
| 75 libdbus-1-dev \ | |
| 76 libdbus-glib-1-2 \ | |
| 77 libdrm2 \ | |
| 78 libelf1 \ | |
| 79 libelf-dev \ | |
| 80 libexif12 \ | |
| 81 libexif-dev \ | |
| 82 libexpat1 \ | |
| 83 libexpat1-dev \ | |
| 84 libffi5 \ | |
| 85 libfontconfig1 \ | |
| 86 libfontconfig1-dev \ | |
| 87 libfreetype6 \ | |
| 88 libfreetype6-dev \ | |
| 89 libgcc1 \ | |
| 90 libgcc1 \ | |
| 91 libgconf-2-4 \ | |
| 92 libgconf2-4 \ | |
| 93 libgconf2-dev \ | |
| 94 libgcrypt11 \ | |
| 95 libgcrypt11-dev \ | |
| 96 libgdk-pixbuf2.0-0 \ | |
| 97 libgdk-pixbuf2.0-dev \ | |
| 98 libgl1-mesa-dev \ | |
| 99 libgl1-mesa-glx \ | |
| 100 libglapi-mesa \ | |
| 101 libglib2.0-0 \ | |
| 102 libglib2.0-dev \ | |
| 103 libgnome-keyring0 \ | |
| 104 libgnome-keyring-dev \ | |
| 105 libgnutls26 \ | |
| 106 libgnutls-dev \ | |
| 107 libgnutls-openssl27 \ | |
| 108 libgnutlsxx27 \ | |
| 109 libgomp1 \ | |
| 110 libgpg-error0 \ | |
| 111 libgpg-error-dev \ | |
| 112 libgssapi-krb5-2 \ | |
| 113 libgssrpc4 \ | |
| 114 libgtk2.0-0 \ | |
| 115 libgtk2.0-dev \ | |
| 116 libk5crypto3 \ | |
| 117 libkadm5clnt-mit8 \ | |
| 118 libkadm5srv-mit8 \ | |
| 119 libkdb5-6 \ | |
| 120 libkeyutils1 \ | |
| 121 libkrb5-3 \ | |
| 122 libkrb5-dev \ | |
| 123 libkrb5support0 \ | |
| 124 libnspr4 \ | |
| 125 libnspr4-dev \ | |
| 126 libnss3 \ | |
| 127 libnss3-dev \ | |
| 128 libnss-db \ | |
| 129 liborbit2 \ | |
| 130 libp11-2 \ | |
| 131 libp11-kit0 \ | |
| 132 libpam0g \ | |
| 133 libpam0g-dev \ | |
| 134 libpango1.0-0 \ | |
| 135 libpango1.0-dev \ | |
| 136 libpci3 \ | |
| 137 libpci-dev \ | |
| 138 libpcre3 \ | |
| 139 libpcre3-dev \ | |
| 140 libpcrecpp0 \ | |
| 141 libpixman-1-0 \ | |
| 142 libpixman-1-dev \ | |
| 143 libpng12-0 \ | |
| 144 libpng12-dev \ | |
| 145 libpulse0 \ | |
| 146 libpulse-dev \ | |
| 147 libpulse-mainloop-glib0 \ | |
| 148 libselinux1 \ | |
| 149 libspeechd2 \ | |
| 150 libspeechd-dev \ | |
| 151 libssl1.0.0 \ | |
| 152 libssl-dev \ | |
| 153 libstdc++6 \ | |
| 154 libstdc++6-4.6-dev \ | |
| 155 libtasn1-3 \ | |
| 156 libudev0 \ | |
| 157 libudev-dev \ | |
| 158 libx11-6 \ | |
| 159 libx11-dev \ | |
| 160 libx11-xcb1 \ | |
| 161 libxau6 \ | |
| 162 libxau-dev \ | |
| 163 libxcb1 \ | |
| 164 libxcb1-dev \ | |
| 165 libxcb-glx0 \ | |
| 166 libxcb-render0 \ | |
| 167 libxcb-render0-dev \ | |
| 168 libxcb-shm0 \ | |
| 169 libxcb-shm0-dev \ | |
| 170 libxcomposite1 \ | |
| 171 libxcomposite-dev \ | |
| 172 libxcursor1 \ | |
| 173 libxcursor-dev \ | |
| 174 libxdamage1 \ | |
| 175 libxdamage-dev \ | |
| 176 libxdmcp6 \ | |
| 177 libxext6 \ | |
| 178 libxext-dev \ | |
| 179 libxfixes3 \ | |
| 180 libxfixes-dev \ | |
| 181 libxi6 \ | |
| 182 libxi-dev \ | |
| 183 libxinerama1 \ | |
| 184 libxinerama-dev \ | |
| 185 libxrandr2 \ | |
| 186 libxrandr-dev \ | |
| 187 libxrender1 \ | |
| 188 libxrender-dev \ | |
| 189 libxss1 \ | |
| 190 libxss-dev \ | |
| 191 libxt6 \ | |
| 192 libxt-dev \ | |
| 193 libxtst6 \ | |
| 194 libxtst-dev \ | |
| 195 libxxf86vm1 \ | |
| 196 linux-libc-dev \ | |
| 197 mesa-common-dev \ | |
| 198 speech-dispatcher \ | |
| 199 x11proto-composite-dev \ | |
| 200 x11proto-core-dev \ | |
| 201 x11proto-damage-dev \ | |
| 202 x11proto-fixes-dev \ | |
| 203 x11proto-input-dev \ | |
| 204 x11proto-kb-dev \ | |
| 205 x11proto-randr-dev \ | |
| 206 x11proto-record-dev \ | |
| 207 x11proto-render-dev \ | |
| 208 x11proto-scrnsaver-dev \ | |
| 209 x11proto-xext-dev \ | |
| 210 zlib1g \ | |
| 211 zlib1g-dev" | |
| 212 | |
| 213 DEBIAN_PACKAGES_X86="libquadmath0" | |
| 214 | |
| 215 readonly DEBIAN_DEP_LIST_AMD64="packagelist.debian.wheezy.amd64" | |
| 216 readonly DEBIAN_DEP_LIST_I386="packagelist.debian.wheezy.i386" | |
| 217 readonly DEBIAN_DEP_LIST_ARM="packagelist.debian.wheezy.arm" | |
| 218 | |
| 219 ###################################################################### | |
| 220 # Helper | |
| 221 ###################################################################### | |
| 222 | |
| 223 Banner() { | |
| 224 echo "######################################################################" | |
| 225 echo $* | |
| 226 echo "######################################################################" | |
| 227 } | |
| 228 | |
| 229 | |
| 230 SubBanner() { | |
| 231 echo "......................................................................" | |
| 232 echo $* | |
| 233 echo "......................................................................" | |
| 234 } | |
| 235 | |
| 236 | |
| 237 Usage() { | |
| 238 egrep "^#@" "$0" | cut --bytes=3- | |
| 239 } | |
| 240 | |
| 241 | |
| 242 DownloadOrCopy() { | |
| 243 if [ -f "$2" ] ; then | |
| 244 echo "$2 already in place" | |
| 245 return | |
| 246 fi | |
| 247 | |
| 248 HTTP=0 | |
| 249 echo "$1" | grep -qs ^http:// && HTTP=1 | |
| 250 if [ "$HTTP" = "1" ]; then | |
| 251 SubBanner "downloading from $1 -> $2" | |
| 252 wget "$1" -O "$2" | |
| 253 else | |
| 254 SubBanner "copying from $1" | |
| 255 cp "$1" "$2" | |
| 256 fi | |
| 257 } | |
| 258 | |
| 259 | |
| 260 SetEnvironmentVariables() { | |
| 261 ARCH="" | |
| 262 echo $1 | grep -qs Amd64$ && ARCH=AMD64 | |
| 263 if [ -z "$ARCH" ]; then | |
| 264 echo $1 | grep -qs I386$ && ARCH=I386 | |
| 265 fi | |
| 266 if [ -z "$ARCH" ]; then | |
| 267 echo $1 | grep -qs ARM$ && ARCH=ARM | |
| 268 fi | |
| 269 case "$ARCH" in | |
| 270 ARM) | |
| 271 INSTALL_ROOT="$INSTALL_ROOT_ARM"; | |
| 272 ;; | |
| 273 AMD64) | |
| 274 INSTALL_ROOT="$INSTALL_ROOT_AMD64"; | |
| 275 ;; | |
| 276 I386) | |
| 277 INSTALL_ROOT="$INSTALL_ROOT_I386"; | |
| 278 ;; | |
| 279 *) | |
| 280 echo "ERROR: Unexpected bad architecture." | |
| 281 exit 1 | |
| 282 ;; | |
| 283 esac | |
| 284 } | |
| 285 | |
| 286 Cleanup() { | |
| 287 echo "Cleaning: $TMP" | |
| 288 rm -rf "$TMP" | |
| 289 } | |
| 290 | |
| 291 # some sanity checks to make sure this script is run from the right place | |
| 292 # with the right tools | |
| 293 SanityCheck() { | |
| 294 Banner "Sanity Checks" | |
| 295 | |
| 296 if [ "$(basename $(pwd))" != "sysroot_scripts" ] ; then | |
| 297 echo -n "ERROR: run this script from " | |
| 298 echo "src/chrome/installer/linux/sysroot_scripts" | |
| 299 exit 1 | |
| 300 fi | |
| 301 | |
| 302 if ! mkdir -p "${INSTALL_ROOT}" ; then | |
| 303 echo "ERROR: ${INSTALL_ROOT} can't be created." | |
| 304 exit 1 | |
| 305 fi | |
| 306 | |
| 307 TMP=$(mktemp -q -t -d debian-wheezy-XXXXXX) | |
| 308 if [ -z "$TMP" ]; then | |
| 309 echo "ERROR: temp dir can't be created." | |
| 310 exit 1 | |
| 311 fi | |
| 312 trap Cleanup 0 | |
| 313 | |
| 314 for tool in ${REQUIRED_TOOLS} ; do | |
| 315 if ! which ${tool} ; then | |
| 316 echo "Required binary $tool not found." | |
| 317 echo "Exiting." | |
| 318 exit 1 | |
| 319 fi | |
| 320 done | |
| 321 } | |
| 322 | |
| 323 | |
| 324 ChangeDirectory() { | |
| 325 # Change directory to where this script is. | |
| 326 cd ${SCRIPT_DIR} | |
| 327 } | |
| 328 | |
| 329 | |
| 330 ClearInstallDir() { | |
| 331 Banner "Clearing dirs in ${INSTALL_ROOT}" | |
| 332 rm -rf ${INSTALL_ROOT}/* | |
| 333 } | |
| 334 | |
| 335 | |
| 336 CreateTarBall() { | |
| 337 local tarball=$1 | |
| 338 Banner "Creating tar ball ${tarball}" | |
| 339 tar zcf ${tarball} -C ${INSTALL_ROOT} . | |
| 340 } | |
| 341 | |
| 342 CheckBuildSysrootArgs() { | |
| 343 if [ "$#" -ne "1" ]; then | |
| 344 echo "ERROR: BuildSysroot commands only take 1 argument" | |
| 345 exit 1 | |
| 346 fi | |
| 347 | |
| 348 if [ -z "$1" ]; then | |
| 349 echo "ERROR: tarball name required" | |
| 350 exit 1 | |
| 351 fi | |
| 352 } | |
| 353 | |
| 354 ExtractPackageBz2() { | |
| 355 bzcat "$1" | egrep '^(Package:|Filename:|SHA256:) ' > "$2" | |
| 356 } | |
| 357 | |
| 358 GeneratePackageListAmd64() { | |
| 359 local output_file="$1" | |
| 360 local package_list="${TMP}/Packages.wheezy_amd64.bz2" | |
| 361 local tmp_package_list="${TMP}/Packages.wheezy_amd64" | |
| 362 DownloadOrCopy "${PACKAGE_LIST_AMD64}" "${package_list}" | |
| 363 VerifyPackageListing "${PACKAGE_FILE_AMD64}" "${package_list}" | |
| 364 ExtractPackageBz2 "$package_list" "$tmp_package_list" | |
| 365 | |
| 366 GeneratePackageList "$tmp_package_list" "$output_file" "${DEBIAN_PACKAGES} | |
| 367 ${DEBIAN_PACKAGES_X86}" | |
| 368 } | |
| 369 | |
| 370 GeneratePackageListI386() { | |
| 371 local output_file="$1" | |
| 372 local package_list="${TMP}/Packages.wheezy_i386.bz2" | |
| 373 local tmp_package_list="${TMP}/Packages.wheezy_amd64" | |
| 374 DownloadOrCopy "${PACKAGE_LIST_I386}" "${package_list}" | |
| 375 VerifyPackageListing "${PACKAGE_FILE_I386}" "${package_list}" | |
| 376 ExtractPackageBz2 "$package_list" "$tmp_package_list" | |
| 377 | |
| 378 GeneratePackageList "$tmp_package_list" "$output_file" "${DEBIAN_PACKAGES} | |
| 379 ${DEBIAN_PACKAGES_X86}" | |
| 380 } | |
| 381 | |
| 382 GeneratePackageListARM() { | |
| 383 local output_file="$1" | |
| 384 local package_list="${TMP}/Packages.wheezy_arm.bz2" | |
| 385 local tmp_package_list="${TMP}/Packages.wheezy_arm" | |
| 386 DownloadOrCopy "${PACKAGE_LIST_ARM}" "${package_list}" | |
| 387 VerifyPackageListing "${PACKAGE_FILE_ARM}" "${package_list}" | |
| 388 ExtractPackageBz2 "$package_list" "$tmp_package_list" | |
| 389 | |
| 390 GeneratePackageList "$tmp_package_list" "$output_file" "${DEBIAN_PACKAGES}" | |
| 391 } | |
| 392 | |
| 393 StripChecksumsFromPackageList() { | |
| 394 local package_file="$1" | |
| 395 sed -i 's/ [a-f0-9]\{64\}$//' "$package_file" | |
| 396 } | |
| 397 | |
| 398 VerifyPackageFilesMatch() { | |
| 399 local downloaded_package_file="$1" | |
| 400 local stored_package_file="$2" | |
| 401 diff -u "$downloaded_package_file" "$stored_package_file" | |
| 402 if [ "$?" -ne "0" ]; then | |
| 403 echo "ERROR: downloaded package files does not match $2." | |
| 404 echo "You may need to run UpdatePackageLists." | |
| 405 exit 1 | |
| 406 fi | |
| 407 } | |
| 408 | |
| 409 ###################################################################### | |
| 410 # | |
| 411 ###################################################################### | |
| 412 | |
| 413 HacksAndPatchesAmd64() { | |
| 414 Banner "Misc Hacks & Patches" | |
| 415 # these are linker scripts with absolute pathnames in them | |
| 416 # which we rewrite here | |
| 417 lscripts="${INSTALL_ROOT}/usr/lib/x86_64-linux-gnu/libpthread.so \ | |
| 418 ${INSTALL_ROOT}/usr/lib/x86_64-linux-gnu/libc.so" | |
| 419 | |
| 420 #SubBanner "Rewriting Linker Scripts" | |
| 421 sed -i -e 's|/usr/lib/x86_64-linux-gnu/||g' ${lscripts} | |
| 422 sed -i -e 's|/lib/x86_64-linux-gnu/||g' ${lscripts} | |
| 423 | |
| 424 # This is for chrome's ./build/linux/pkg-config-wrapper | |
| 425 # which overwrites PKG_CONFIG_PATH internally | |
| 426 SubBanner "Package Configs Symlink" | |
| 427 mkdir -p ${INSTALL_ROOT}/usr/share | |
| 428 ln -s ../lib/x86_64-linux-gnu/pkgconfig ${INSTALL_ROOT}/usr/share/pkgconfig | |
| 429 | |
| 430 SubBanner "Adding an additional ld.conf include" | |
| 431 LD_SO_HACK_CONF="${INSTALL_ROOT}/etc/ld.so.conf.d/zz_hack.conf" | |
| 432 echo /usr/lib/gcc/x86_64-linux-gnu/4.6 > "$LD_SO_HACK_CONF" | |
| 433 echo /usr/lib >> "$LD_SO_HACK_CONF" | |
| 434 } | |
| 435 | |
| 436 | |
| 437 HacksAndPatchesI386() { | |
| 438 Banner "Misc Hacks & Patches" | |
| 439 # these are linker scripts with absolute pathnames in them | |
| 440 # which we rewrite here | |
| 441 lscripts="${INSTALL_ROOT}/usr/lib/i386-linux-gnu/libpthread.so \ | |
| 442 ${INSTALL_ROOT}/usr/lib/i386-linux-gnu/libc.so" | |
| 443 | |
| 444 #SubBanner "Rewriting Linker Scripts" | |
| 445 sed -i -e 's|/usr/lib/i386-linux-gnu/||g' ${lscripts} | |
| 446 sed -i -e 's|/lib/i386-linux-gnu/||g' ${lscripts} | |
| 447 | |
| 448 # This is for chrome's ./build/linux/pkg-config-wrapper | |
| 449 # which overwrites PKG_CONFIG_PATH internally | |
| 450 SubBanner "Package Configs Symlink" | |
| 451 mkdir -p ${INSTALL_ROOT}/usr/share | |
| 452 ln -s ../lib/i386-linux-gnu/pkgconfig ${INSTALL_ROOT}/usr/share/pkgconfig | |
| 453 | |
| 454 SubBanner "Adding an additional ld.conf include" | |
| 455 LD_SO_HACK_CONF="${INSTALL_ROOT}/etc/ld.so.conf.d/zz_hack.conf" | |
| 456 echo /usr/lib/gcc/i486-linux-gnu/4.6 > "$LD_SO_HACK_CONF" | |
| 457 echo /usr/lib >> "$LD_SO_HACK_CONF" | |
| 458 } | |
| 459 | |
| 460 | |
| 461 HacksAndPatchesARM() { | |
| 462 Banner "Misc Hacks & Patches" | |
| 463 # these are linker scripts with absolute pathnames in them | |
| 464 # which we rewrite here | |
| 465 lscripts="${INSTALL_ROOT}/usr/lib/arm-linux-gnueabihf/libpthread.so \ | |
| 466 ${INSTALL_ROOT}/usr/lib/arm-linux-gnueabihf/libc.so" | |
| 467 | |
| 468 #SubBanner "Rewriting Linker Scripts" | |
| 469 sed -i -e 's|/usr/lib/arm-linux-gnueabihf/||g' ${lscripts} | |
| 470 sed -i -e 's|/lib/arm-linux-gnueabihf/||g' ${lscripts} | |
| 471 | |
| 472 # This is for chrome's ./build/linux/pkg-config-wrapper | |
| 473 # which overwrites PKG_CONFIG_PATH internally | |
| 474 SubBanner "Package Configs Symlink" | |
| 475 mkdir -p ${INSTALL_ROOT}/usr/share | |
| 476 ln -s ../lib/arm-linux-gnueabihf/pkgconfig ${INSTALL_ROOT}/usr/share/pkgconfig | |
| 477 } | |
| 478 | |
| 479 | |
| 480 InstallIntoSysroot() { | |
| 481 Banner "Install Libs And Headers Into Jail" | |
| 482 | |
| 483 mkdir -p ${TMP}/debian-packages | |
| 484 mkdir -p ${INSTALL_ROOT} | |
| 485 while (( "$#" )); do | |
| 486 local file="$1" | |
| 487 local package="${TMP}/debian-packages/${file##*/}" | |
| 488 shift | |
| 489 local sha256sum="$1" | |
| 490 shift | |
| 491 if [ "${#sha256sum}" -ne "64" ]; then | |
| 492 echo "Bad sha256sum from package list" | |
| 493 exit 1 | |
| 494 fi | |
| 495 | |
| 496 Banner "Installing ${file}" | |
| 497 DownloadOrCopy ${DEBIAN_REPO}/pool/${file} ${package} | |
| 498 if [ ! -s "${package}" ] ; then | |
| 499 echo | |
| 500 echo "ERROR: bad package ${package}" | |
| 501 exit 1 | |
| 502 fi | |
| 503 echo "${sha256sum} ${package}" | sha256sum --quiet -c | |
| 504 | |
| 505 SubBanner "Extracting to ${INSTALL_ROOT}" | |
| 506 dpkg --fsys-tarfile ${package}\ | |
| 507 | tar -xvf - --exclude=./usr/share -C ${INSTALL_ROOT} | |
| 508 done | |
| 509 } | |
| 510 | |
| 511 | |
| 512 CleanupJailSymlinks() { | |
| 513 Banner "Jail symlink cleanup" | |
| 514 | |
| 515 SAVEDPWD=$(pwd) | |
| 516 cd ${INSTALL_ROOT} | |
| 517 find lib lib64 usr/lib -type l -printf '%p %l\n' | while read link target; do | |
| 518 # skip links with non-absolute paths | |
| 519 echo "${target}" | grep -qs ^/ || continue | |
| 520 echo "${link}: ${target}" | |
| 521 case "${link}" in | |
| 522 usr/lib/gcc/x86_64-linux-gnu/4.*/* | usr/lib/gcc/i486-linux-gnu/4.*/* | \ | |
| 523 usr/lib/gcc/arm-linux-gnueabihf/4.*/*) | |
| 524 # Relativize the symlink. | |
| 525 ln -snfv "../../../../..${target}" "${link}" | |
| 526 ;; | |
| 527 usr/lib/x86_64-linux-gnu/* | usr/lib/i386-linux-gnu/* | \ | |
| 528 usr/lib/arm-linux-gnueabihf/*) | |
| 529 # Relativize the symlink. | |
| 530 ln -snfv "../../..${target}" "${link}" | |
| 531 ;; | |
| 532 usr/lib/*) | |
| 533 # Relativize the symlink. | |
| 534 ln -snfv "../..${target}" "${link}" | |
| 535 ;; | |
| 536 lib64/* | lib/*) | |
| 537 # Relativize the symlink. | |
| 538 ln -snfv "..${target}" "${link}" | |
| 539 ;; | |
| 540 esac | |
| 541 done | |
| 542 | |
| 543 find lib lib64 usr/lib -type l -printf '%p %l\n' | while read link target; do | |
| 544 # Make sure we catch new bad links. | |
| 545 if [ ! -r "${link}" ]; then | |
| 546 echo "ERROR: FOUND BAD LINK ${link}" | |
| 547 ls -l ${link} | |
| 548 exit 1 | |
| 549 fi | |
| 550 done | |
| 551 cd "$SAVEDPWD" | |
| 552 } | |
| 553 | |
| 554 #@ | |
| 555 #@ BuildSysrootAmd64 <tarball-name> | |
| 556 #@ | |
| 557 #@ Build everything and package it | |
| 558 BuildSysrootAmd64() { | |
| 559 CheckBuildSysrootArgs $@ | |
| 560 ClearInstallDir | |
| 561 local package_file="$TMP/package_with_sha256sum_amd64" | |
| 562 GeneratePackageListAmd64 "$package_file" | |
| 563 local files_and_sha256sums="$(cat ${package_file})" | |
| 564 StripChecksumsFromPackageList "$package_file" | |
| 565 VerifyPackageFilesMatch "$package_file" "$DEBIAN_DEP_LIST_AMD64" | |
| 566 InstallIntoSysroot "${files_and_sha256sums}" | |
| 567 CleanupJailSymlinks | |
| 568 HacksAndPatchesAmd64 | |
| 569 CreateTarBall "$1" | |
| 570 } | |
| 571 | |
| 572 #@ | |
| 573 #@ BuildSysrootI386 <tarball-name> | |
| 574 #@ | |
| 575 #@ Build everything and package it | |
| 576 BuildSysrootI386() { | |
| 577 CheckBuildSysrootArgs $@ | |
| 578 ClearInstallDir | |
| 579 local package_file="$TMP/package_with_sha256sum_i386" | |
| 580 GeneratePackageListI386 "$package_file" | |
| 581 local files_and_sha256sums="$(cat ${package_file})" | |
| 582 StripChecksumsFromPackageList "$package_file" | |
| 583 VerifyPackageFilesMatch "$package_file" "$DEBIAN_DEP_LIST_I386" | |
| 584 InstallIntoSysroot "${files_and_sha256sums}" | |
| 585 CleanupJailSymlinks | |
| 586 HacksAndPatchesI386 | |
| 587 CreateTarBall "$1" | |
| 588 } | |
| 589 | |
| 590 #@ | |
| 591 #@ BuildSysrootARM <tarball-name> | |
| 592 #@ | |
| 593 #@ Build everything and package it | |
| 594 BuildSysrootARM() { | |
| 595 CheckBuildSysrootArgs $@ | |
| 596 ClearInstallDir | |
| 597 local package_file="$TMP/package_with_sha256sum_arm" | |
| 598 GeneratePackageListARM "$package_file" | |
| 599 local files_and_sha256sums="$(cat ${package_file})" | |
| 600 StripChecksumsFromPackageList "$package_file" | |
| 601 VerifyPackageFilesMatch "$package_file" "$DEBIAN_DEP_LIST_ARM" | |
| 602 InstallIntoSysroot "${files_and_sha256sums}" | |
| 603 CleanupJailSymlinks | |
| 604 HacksAndPatchesARM | |
| 605 CreateTarBall "$1" | |
| 606 } | |
| 607 | |
| 608 # | |
| 609 # CheckForDebianGPGKeyring | |
| 610 # | |
| 611 # Make sure the Debian GPG keys exist. Otherwise print a helpful message. | |
| 612 # | |
| 613 CheckForDebianGPGKeyring() { | |
| 614 if [ ! -e "/usr/share/keyrings/debian-archive-keyring.gpg" ]; then | |
| 615 echo "Debian GPG keys missing. Install the debian-archive-keyring package." | |
| 616 exit 1 | |
| 617 fi | |
| 618 } | |
| 619 | |
| 620 # | |
| 621 # VerifyPackageListing | |
| 622 # | |
| 623 # Verifies the downloaded Packages.bz2 file has the right checksums. | |
| 624 # | |
| 625 VerifyPackageListing() { | |
| 626 local file_path=$1 | |
| 627 local output_file=$2 | |
| 628 local release_file="${TMP}/${RELEASE_FILE}" | |
| 629 local release_file_gpg="${TMP}/${RELEASE_FILE_GPG}" | |
| 630 | |
| 631 CheckForDebianGPGKeyring | |
| 632 | |
| 633 DownloadOrCopy ${RELEASE_LIST} ${release_file} | |
| 634 DownloadOrCopy ${RELEASE_LIST_GPG} ${release_file_gpg} | |
| 635 echo "Verifying: ${release_file} with ${release_file_gpg}" | |
| 636 gpgv --keyring /usr/share/keyrings/debian-archive-keyring.gpg \ | |
| 637 ${release_file_gpg} ${release_file} | |
| 638 | |
| 639 echo "Verifying: ${output_file}" | |
| 640 local checksums=$(grep ${file_path} ${release_file} | cut -d " " -f 2) | |
| 641 local sha256sum=$(echo ${checksums} | cut -d " " -f 3) | |
| 642 | |
| 643 if [ "${#sha256sum}" -ne "64" ]; then | |
| 644 echo "Bad sha256sum from ${RELEASE_LIST}" | |
| 645 exit 1 | |
| 646 fi | |
| 647 | |
| 648 echo "${sha256sum} ${output_file}" | sha256sum --quiet -c | |
| 649 } | |
| 650 | |
| 651 # | |
| 652 # GeneratePackageList | |
| 653 # | |
| 654 # Looks up package names in ${TMP}/Packages and write list of URLs | |
| 655 # to output file. | |
| 656 # | |
| 657 GeneratePackageList() { | |
| 658 local input_file="$1" | |
| 659 local output_file="$2" | |
| 660 echo "Updating: ${output_file} from ${input_file}" | |
| 661 /bin/rm -f "${output_file}" | |
| 662 shift | |
| 663 shift | |
| 664 for pkg in $@ ; do | |
| 665 local pkg_full=$(grep -A 1 " ${pkg}\$" "$input_file" | \ | |
| 666 egrep -o "pool/.*") | |
| 667 if [ -z "${pkg_full}" ]; then | |
| 668 echo "ERROR: missing package: $pkg" | |
| 669 exit 1 | |
| 670 fi | |
| 671 local pkg_nopool=$(echo "$pkg_full" | sed "s/^pool\///") | |
| 672 local sha256sum=$(grep -A 4 " ${pkg}\$" "$input_file" | \ | |
| 673 grep ^SHA256: | sed 's/^SHA256: //') | |
| 674 if [ "${#sha256sum}" -ne "64" ]; then | |
| 675 echo "Bad sha256sum from Packages" | |
| 676 exit 1 | |
| 677 fi | |
| 678 echo $pkg_nopool $sha256sum >> "$output_file" | |
| 679 done | |
| 680 # sort -o does an in-place sort of this file | |
| 681 sort "$output_file" -o "$output_file" | |
| 682 } | |
| 683 | |
| 684 #@ | |
| 685 #@ UpdatePackageListsAmd64 | |
| 686 #@ | |
| 687 #@ Regenerate the package lists such that they contain an up-to-date | |
| 688 #@ list of URLs within the Debian archive. (For amd64) | |
| 689 UpdatePackageListsAmd64() { | |
| 690 GeneratePackageListAmd64 "$DEBIAN_DEP_LIST_AMD64" | |
| 691 StripChecksumsFromPackageList "$DEBIAN_DEP_LIST_AMD64" | |
| 692 } | |
| 693 | |
| 694 #@ | |
| 695 #@ UpdatePackageListsI386 | |
| 696 #@ | |
| 697 #@ Regenerate the package lists such that they contain an up-to-date | |
| 698 #@ list of URLs within the Debian archive. (For i386) | |
| 699 UpdatePackageListsI386() { | |
| 700 GeneratePackageListI386 "$DEBIAN_DEP_LIST_I386" | |
| 701 StripChecksumsFromPackageList "$DEBIAN_DEP_LIST_I386" | |
| 702 } | |
| 703 | |
| 704 #@ | |
| 705 #@ UpdatePackageListsARM | |
| 706 #@ | |
| 707 #@ Regenerate the package lists such that they contain an up-to-date | |
| 708 #@ list of URLs within the Debian archive. (For arm) | |
| 709 UpdatePackageListsARM() { | |
| 710 GeneratePackageListARM "$DEBIAN_DEP_LIST_ARM" | |
| 711 StripChecksumsFromPackageList "$DEBIAN_DEP_LIST_ARM" | |
| 712 } | |
| 713 | |
| 714 if [ $# -eq 0 ] ; then | |
| 715 echo "ERROR: you must specify a mode on the commandline" | |
| 716 echo | |
| 717 Usage | |
| 718 exit 1 | |
| 719 elif [ "$(type -t $1)" != "function" ]; then | |
| 720 echo "ERROR: unknown function '$1'." >&2 | |
| 721 echo "For help, try:" | |
| 722 echo " $0 help" | |
| 723 exit 1 | |
| 724 else | |
| 725 ChangeDirectory | |
| 726 SetEnvironmentVariables "$1" | |
| 727 SanityCheck | |
| 728 "$@" | |
| 729 fi | |
| OLD | NEW |