OLD | NEW |
(Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 # |
| 5 # This script should not be run directly but sourced by the other |
| 6 # scripts (e.g. sysroot-creator-trusty.sh). Its up to the parent scripts |
| 7 # to define certain environment variables: e.g. |
| 8 # DISTRO=ubuntu |
| 9 # DIST=trusty |
| 10 # APT_REPO=http://archive.ubuntu.com/ubuntu |
| 11 # KEYRING_FILE=/usr/share/keyrings/ubuntu-archive-keyring.gpg |
| 12 # DEBIAN_PACKAGES="gcc libz libssl" |
| 13 |
| 14 #@ This script builds a Debian sysroot images for building Google Chrome. |
| 15 #@ |
| 16 #@ Generally this script is invoked as: |
| 17 #@ sysroot-creator-<flavour>.sh <mode> <args>* |
| 18 #@ Available modes are shown below. |
| 19 #@ |
| 20 #@ List of modes: |
| 21 |
| 22 ###################################################################### |
| 23 # Config |
| 24 ###################################################################### |
| 25 |
| 26 set -o nounset |
| 27 set -o errexit |
| 28 |
| 29 SCRIPT_DIR=$(cd $(dirname $0) && pwd) |
| 30 |
| 31 if [ -z "${DIST:-}" ]; then |
| 32 echo "error: DIST not defined" |
| 33 exit 1 |
| 34 fi |
| 35 |
| 36 if [ -z "${APT_REPO:-}" ]; then |
| 37 echo "error: APT_REPO not defined" |
| 38 exit 1 |
| 39 fi |
| 40 |
| 41 if [ -z "${KEYRING_FILE:-}" ]; then |
| 42 echo "error: KEYRING_FILE not defined" |
| 43 exit 1 |
| 44 fi |
| 45 |
| 46 if [ -z "${DEBIAN_PACKAGES:-}" ]; then |
| 47 echo "error: DEBIAN_PACKAGES not defined" |
| 48 exit 1 |
| 49 fi |
| 50 |
| 51 readonly REPO_BASEDIR="${APT_REPO}/dists/${DIST}" |
| 52 |
| 53 readonly REQUIRED_TOOLS="wget" |
| 54 |
| 55 ###################################################################### |
| 56 # Package Config |
| 57 ###################################################################### |
| 58 |
| 59 readonly RELEASE_FILE="Release" |
| 60 readonly RELEASE_FILE_GPG="Release.gpg" |
| 61 readonly RELEASE_LIST="${REPO_BASEDIR}/${RELEASE_FILE}" |
| 62 readonly RELEASE_LIST_GPG="${REPO_BASEDIR}/${RELEASE_FILE_GPG}" |
| 63 readonly PACKAGE_FILE_AMD64="main/binary-amd64/Packages.bz2" |
| 64 readonly PACKAGE_FILE_I386="main/binary-i386/Packages.bz2" |
| 65 readonly PACKAGE_FILE_ARM="main/binary-armhf/Packages.bz2" |
| 66 readonly PACKAGE_FILE_MIPS="main/binary-mipsel/Packages.bz2" |
| 67 readonly PACKAGE_LIST_AMD64="${REPO_BASEDIR}/${PACKAGE_FILE_AMD64}" |
| 68 readonly PACKAGE_LIST_I386="${REPO_BASEDIR}/${PACKAGE_FILE_I386}" |
| 69 readonly PACKAGE_LIST_ARM="${REPO_BASEDIR}/${PACKAGE_FILE_ARM}" |
| 70 readonly PACKAGE_LIST_MIPS="${REPO_BASEDIR}/${PACKAGE_FILE_MIPS}" |
| 71 |
| 72 readonly DEBIAN_DEP_LIST_AMD64="packagelist.${DIST}.amd64" |
| 73 readonly DEBIAN_DEP_LIST_I386="packagelist.${DIST}.i386" |
| 74 readonly DEBIAN_DEP_LIST_ARM="packagelist.${DIST}.arm" |
| 75 readonly DEBIAN_DEP_LIST_MIPS="packagelist.${DIST}.mipsel" |
| 76 |
| 77 ###################################################################### |
| 78 # Helper |
| 79 ###################################################################### |
| 80 |
| 81 Banner() { |
| 82 echo "######################################################################" |
| 83 echo $* |
| 84 echo "######################################################################" |
| 85 } |
| 86 |
| 87 |
| 88 SubBanner() { |
| 89 echo "----------------------------------------------------------------------" |
| 90 echo $* |
| 91 echo "----------------------------------------------------------------------" |
| 92 } |
| 93 |
| 94 |
| 95 Usage() { |
| 96 egrep "^#@" "${BASH_SOURCE[0]}" | cut --bytes=3- |
| 97 } |
| 98 |
| 99 |
| 100 DownloadOrCopy() { |
| 101 if [ -f "$2" ] ; then |
| 102 echo "$2 already in place" |
| 103 return |
| 104 fi |
| 105 |
| 106 HTTP=0 |
| 107 echo "$1" | grep -qs ^http:// && HTTP=1 |
| 108 if [ "$HTTP" = "1" ]; then |
| 109 SubBanner "downloading from $1 -> $2" |
| 110 wget "$1" -O "${2}.partial" |
| 111 mv "${2}.partial" $2 |
| 112 else |
| 113 SubBanner "copying from $1" |
| 114 cp "$1" "$2" |
| 115 fi |
| 116 } |
| 117 |
| 118 |
| 119 SetEnvironmentVariables() { |
| 120 ARCH="" |
| 121 echo $1 | grep -qs Amd64$ && ARCH=AMD64 |
| 122 if [ -z "$ARCH" ]; then |
| 123 echo $1 | grep -qs I386$ && ARCH=I386 |
| 124 fi |
| 125 if [ -z "$ARCH" ]; then |
| 126 echo $1 | grep -qs Mips$ && ARCH=MIPS |
| 127 fi |
| 128 if [ -z "$ARCH" ]; then |
| 129 echo $1 | grep -qs ARM$ && ARCH=ARM |
| 130 fi |
| 131 if [ -z "${ARCH}" ]; then |
| 132 echo "ERROR: Unable to determine architecture based on: $1" |
| 133 exit 1 |
| 134 fi |
| 135 ARCH_LOWER=$(echo $ARCH | tr '[:upper:]' '[:lower:]') |
| 136 } |
| 137 |
| 138 |
| 139 # some sanity checks to make sure this script is run from the right place |
| 140 # with the right tools |
| 141 SanityCheck() { |
| 142 Banner "Sanity Checks" |
| 143 |
| 144 local chrome_dir=$(cd "${SCRIPT_DIR}/../../../.." && pwd) |
| 145 BUILD_DIR="${chrome_dir}/out/sysroot-build/${DIST}" |
| 146 mkdir -p ${BUILD_DIR} |
| 147 echo "Using build directory: ${BUILD_DIR}" |
| 148 |
| 149 for tool in ${REQUIRED_TOOLS} ; do |
| 150 if ! which ${tool} > /dev/null ; then |
| 151 echo "Required binary $tool not found." |
| 152 echo "Exiting." |
| 153 exit 1 |
| 154 fi |
| 155 done |
| 156 |
| 157 # This is where the staging sysroot is. |
| 158 INSTALL_ROOT="${BUILD_DIR}/${DIST}_${ARCH_LOWER}_staging" |
| 159 TARBALL="${BUILD_DIR}/${DISTRO}_${DIST}_${ARCH_LOWER}_sysroot.tgz" |
| 160 |
| 161 if ! mkdir -p "${INSTALL_ROOT}" ; then |
| 162 echo "ERROR: ${INSTALL_ROOT} can't be created." |
| 163 exit 1 |
| 164 fi |
| 165 } |
| 166 |
| 167 |
| 168 ChangeDirectory() { |
| 169 # Change directory to where this script is. |
| 170 cd ${SCRIPT_DIR} |
| 171 } |
| 172 |
| 173 |
| 174 ClearInstallDir() { |
| 175 Banner "Clearing dirs in ${INSTALL_ROOT}" |
| 176 rm -rf ${INSTALL_ROOT}/* |
| 177 } |
| 178 |
| 179 |
| 180 CreateTarBall() { |
| 181 Banner "Creating tarball ${TARBALL}" |
| 182 tar zcf ${TARBALL} -C ${INSTALL_ROOT} . |
| 183 } |
| 184 |
| 185 ExtractPackageBz2() { |
| 186 bzcat "$1" | egrep '^(Package:|Filename:|SHA256:) ' > "$2" |
| 187 } |
| 188 |
| 189 GeneratePackageListAmd64() { |
| 190 local output_file="$1" |
| 191 local package_list="${BUILD_DIR}/Packages.${DIST}_amd64.bz2" |
| 192 local tmp_package_list="${BUILD_DIR}/Packages.${DIST}_amd64" |
| 193 DownloadOrCopy "${PACKAGE_LIST_AMD64}" "${package_list}" |
| 194 VerifyPackageListing "${PACKAGE_FILE_AMD64}" "${package_list}" |
| 195 ExtractPackageBz2 "$package_list" "$tmp_package_list" |
| 196 GeneratePackageList "$tmp_package_list" "$output_file" "${DEBIAN_PACKAGES} |
| 197 ${DEBIAN_PACKAGES_X86}" |
| 198 } |
| 199 |
| 200 GeneratePackageListI386() { |
| 201 local output_file="$1" |
| 202 local package_list="${BUILD_DIR}/Packages.${DIST}_i386.bz2" |
| 203 local tmp_package_list="${BUILD_DIR}/Packages.${DIST}_amd64" |
| 204 DownloadOrCopy "${PACKAGE_LIST_I386}" "${package_list}" |
| 205 VerifyPackageListing "${PACKAGE_FILE_I386}" "${package_list}" |
| 206 ExtractPackageBz2 "$package_list" "$tmp_package_list" |
| 207 GeneratePackageList "$tmp_package_list" "$output_file" "${DEBIAN_PACKAGES} |
| 208 ${DEBIAN_PACKAGES_X86}" |
| 209 } |
| 210 |
| 211 GeneratePackageListARM() { |
| 212 local output_file="$1" |
| 213 local package_list="${BUILD_DIR}/Packages.${DIST}_arm.bz2" |
| 214 local tmp_package_list="${BUILD_DIR}/Packages.${DIST}_arm" |
| 215 DownloadOrCopy "${PACKAGE_LIST_ARM}" "${package_list}" |
| 216 VerifyPackageListing "${PACKAGE_FILE_ARM}" "${package_list}" |
| 217 ExtractPackageBz2 "$package_list" "$tmp_package_list" |
| 218 GeneratePackageList "$tmp_package_list" "$output_file" "${DEBIAN_PACKAGES}" |
| 219 } |
| 220 |
| 221 GeneratePackageListMips() { |
| 222 local output_file="$1" |
| 223 local package_list="${BUILD_DIR}/Packages.${DIST}_mips.bz2" |
| 224 local tmp_package_list="${BUILD_DIR}/Packages.${DIST}_mips" |
| 225 DownloadOrCopy "${PACKAGE_LIST_MIPS}" "${package_list}" |
| 226 VerifyPackageListing "${PACKAGE_FILE_MIPS}" "${package_list}" |
| 227 ExtractPackageBz2 "$package_list" "$tmp_package_list" |
| 228 GeneratePackageList "$tmp_package_list" "$output_file" "${DEBIAN_PACKAGES}" |
| 229 } |
| 230 |
| 231 StripChecksumsFromPackageList() { |
| 232 local package_file="$1" |
| 233 sed -i 's/ [a-f0-9]\{64\}$//' "$package_file" |
| 234 } |
| 235 |
| 236 VerifyPackageFilesMatch() { |
| 237 local downloaded_package_file="$1" |
| 238 local stored_package_file="$2" |
| 239 diff -u "$downloaded_package_file" "$stored_package_file" |
| 240 if [ "$?" -ne "0" ]; then |
| 241 echo "ERROR: downloaded package files does not match $2." |
| 242 echo "You may need to run UpdatePackageLists." |
| 243 exit 1 |
| 244 fi |
| 245 } |
| 246 |
| 247 ###################################################################### |
| 248 # |
| 249 ###################################################################### |
| 250 |
| 251 HacksAndPatchesAmd64() { |
| 252 Banner "Misc Hacks & Patches" |
| 253 # these are linker scripts with absolute pathnames in them |
| 254 # which we rewrite here |
| 255 lscripts="${INSTALL_ROOT}/usr/lib/x86_64-linux-gnu/libpthread.so \ |
| 256 ${INSTALL_ROOT}/usr/lib/x86_64-linux-gnu/libc.so" |
| 257 |
| 258 # Rewrite linker scripts |
| 259 sed -i -e 's|/usr/lib/x86_64-linux-gnu/||g' ${lscripts} |
| 260 sed -i -e 's|/lib/x86_64-linux-gnu/||g' ${lscripts} |
| 261 |
| 262 # This is for chrome's ./build/linux/pkg-config-wrapper |
| 263 # which overwrites PKG_CONFIG_PATH internally |
| 264 SubBanner "Package Configs Symlink" |
| 265 mkdir -p ${INSTALL_ROOT}/usr/share |
| 266 ln -s ../lib/x86_64-linux-gnu/pkgconfig ${INSTALL_ROOT}/usr/share/pkgconfig |
| 267 |
| 268 SubBanner "Adding an additional ld.conf include" |
| 269 LD_SO_HACK_CONF="${INSTALL_ROOT}/etc/ld.so.conf.d/zz_hack.conf" |
| 270 echo /usr/lib/gcc/x86_64-linux-gnu/4.6 > "$LD_SO_HACK_CONF" |
| 271 echo /usr/lib >> "$LD_SO_HACK_CONF" |
| 272 } |
| 273 |
| 274 |
| 275 HacksAndPatchesI386() { |
| 276 Banner "Misc Hacks & Patches" |
| 277 # these are linker scripts with absolute pathnames in them |
| 278 # which we rewrite here |
| 279 lscripts="${INSTALL_ROOT}/usr/lib/i386-linux-gnu/libpthread.so \ |
| 280 ${INSTALL_ROOT}/usr/lib/i386-linux-gnu/libc.so" |
| 281 |
| 282 # Rewrite linker scripts |
| 283 sed -i -e 's|/usr/lib/i386-linux-gnu/||g' ${lscripts} |
| 284 sed -i -e 's|/lib/i386-linux-gnu/||g' ${lscripts} |
| 285 |
| 286 # This is for chrome's ./build/linux/pkg-config-wrapper |
| 287 # which overwrites PKG_CONFIG_PATH internally |
| 288 SubBanner "Package Configs Symlink" |
| 289 mkdir -p ${INSTALL_ROOT}/usr/share |
| 290 ln -s ../lib/i386-linux-gnu/pkgconfig ${INSTALL_ROOT}/usr/share/pkgconfig |
| 291 |
| 292 SubBanner "Adding an additional ld.conf include" |
| 293 LD_SO_HACK_CONF="${INSTALL_ROOT}/etc/ld.so.conf.d/zz_hack.conf" |
| 294 echo /usr/lib/gcc/i486-linux-gnu/4.6 > "$LD_SO_HACK_CONF" |
| 295 echo /usr/lib >> "$LD_SO_HACK_CONF" |
| 296 } |
| 297 |
| 298 |
| 299 HacksAndPatchesARM() { |
| 300 Banner "Misc Hacks & Patches" |
| 301 # these are linker scripts with absolute pathnames in them |
| 302 # which we rewrite here |
| 303 lscripts="${INSTALL_ROOT}/usr/lib/arm-linux-gnueabihf/libpthread.so \ |
| 304 ${INSTALL_ROOT}/usr/lib/arm-linux-gnueabihf/libc.so" |
| 305 |
| 306 # Rewrite linker scripts |
| 307 sed -i -e 's|/usr/lib/arm-linux-gnueabihf/||g' ${lscripts} |
| 308 sed -i -e 's|/lib/arm-linux-gnueabihf/||g' ${lscripts} |
| 309 |
| 310 # This is for chrome's ./build/linux/pkg-config-wrapper |
| 311 # which overwrites PKG_CONFIG_PATH internally |
| 312 SubBanner "Package Configs Symlink" |
| 313 mkdir -p ${INSTALL_ROOT}/usr/share |
| 314 ln -s ../lib/arm-linux-gnueabihf/pkgconfig ${INSTALL_ROOT}/usr/share/pkgconfig |
| 315 } |
| 316 |
| 317 |
| 318 HacksAndPatchesMips() { |
| 319 Banner "Misc Hacks & Patches" |
| 320 # these are linker scripts with absolute pathnames in them |
| 321 # which we rewrite here |
| 322 lscripts="${INSTALL_ROOT}/usr/lib/mipsel-linux-gnu/libpthread.so \ |
| 323 ${INSTALL_ROOT}/usr/lib/mipsel-linux-gnu/libc.so" |
| 324 |
| 325 # Rewrite linker scripts |
| 326 sed -i -e 's|/usr/lib/mipsel-linux-gnu/||g' ${lscripts} |
| 327 sed -i -e 's|/lib/mipsel-linux-gnu/||g' ${lscripts} |
| 328 |
| 329 # This is for chrome's ./build/linux/pkg-config-wrapper |
| 330 # which overwrites PKG_CONFIG_PATH internally |
| 331 SubBanner "Package Configs Symlink" |
| 332 mkdir -p ${INSTALL_ROOT}/usr/share |
| 333 ln -s ../lib/mipsel-linux-gnu/pkgconfig ${INSTALL_ROOT}/usr/share/pkgconfig |
| 334 } |
| 335 |
| 336 |
| 337 InstallIntoSysroot() { |
| 338 Banner "Install Libs And Headers Into Jail" |
| 339 |
| 340 mkdir -p ${BUILD_DIR}/debian-packages |
| 341 mkdir -p ${INSTALL_ROOT} |
| 342 while (( "$#" )); do |
| 343 local file="$1" |
| 344 local package="${BUILD_DIR}/debian-packages/${file##*/}" |
| 345 shift |
| 346 local sha256sum="$1" |
| 347 shift |
| 348 if [ "${#sha256sum}" -ne "64" ]; then |
| 349 echo "Bad sha256sum from package list" |
| 350 exit 1 |
| 351 fi |
| 352 |
| 353 Banner "Installing ${file}" |
| 354 DownloadOrCopy ${APT_REPO}/pool/${file} ${package} |
| 355 if [ ! -s "${package}" ] ; then |
| 356 echo |
| 357 echo "ERROR: bad package ${package}" |
| 358 exit 1 |
| 359 fi |
| 360 echo "${sha256sum} ${package}" | sha256sum --quiet -c |
| 361 |
| 362 SubBanner "Extracting to ${INSTALL_ROOT}" |
| 363 dpkg --fsys-tarfile ${package}\ |
| 364 | tar -xf - --exclude=./usr/share -C ${INSTALL_ROOT} |
| 365 done |
| 366 } |
| 367 |
| 368 |
| 369 CleanupJailSymlinks() { |
| 370 Banner "Jail symlink cleanup" |
| 371 |
| 372 SAVEDPWD=$(pwd) |
| 373 cd ${INSTALL_ROOT} |
| 374 local libdirs="lib usr/lib" |
| 375 if [ "${ARCH}" != "MIPS" ]; then |
| 376 libdirs+=" lib64" |
| 377 fi |
| 378 find $libdirs -type l -printf '%p %l\n' | while read link target; do |
| 379 # skip links with non-absolute paths |
| 380 echo "${target}" | grep -qs ^/ || continue |
| 381 echo "${link}: ${target}" |
| 382 case "${link}" in |
| 383 usr/lib/gcc/x86_64-linux-gnu/4.*/* | usr/lib/gcc/i486-linux-gnu/4.*/* | \ |
| 384 usr/lib/gcc/arm-linux-gnueabihf/4.*/* | \ |
| 385 usr/lib/gcc/mipsel-linux-gnu/4.*/*) |
| 386 # Relativize the symlink. |
| 387 ln -snfv "../../../../..${target}" "${link}" |
| 388 ;; |
| 389 usr/lib/x86_64-linux-gnu/* | usr/lib/i386-linux-gnu/* | \ |
| 390 usr/lib/arm-linux-gnueabihf/* | usr/lib/mipsel-linux-gnu/* ) |
| 391 # Relativize the symlink. |
| 392 ln -snfv "../../..${target}" "${link}" |
| 393 ;; |
| 394 usr/lib/*) |
| 395 # Relativize the symlink. |
| 396 ln -snfv "../..${target}" "${link}" |
| 397 ;; |
| 398 lib64/* | lib/*) |
| 399 # Relativize the symlink. |
| 400 ln -snfv "..${target}" "${link}" |
| 401 ;; |
| 402 esac |
| 403 done |
| 404 |
| 405 find $libdirs -type l -printf '%p %l\n' | while read link target; do |
| 406 # Make sure we catch new bad links. |
| 407 if [ ! -r "${link}" ]; then |
| 408 echo "ERROR: FOUND BAD LINK ${link}" |
| 409 ls -l ${link} |
| 410 exit 1 |
| 411 fi |
| 412 done |
| 413 cd "$SAVEDPWD" |
| 414 } |
| 415 |
| 416 #@ |
| 417 #@ BuildSysrootAmd64 |
| 418 #@ |
| 419 #@ Build everything and package it |
| 420 BuildSysrootAmd64() { |
| 421 ClearInstallDir |
| 422 local package_file="$BUILD_DIR/package_with_sha256sum_amd64" |
| 423 GeneratePackageListAmd64 "$package_file" |
| 424 local files_and_sha256sums="$(cat ${package_file})" |
| 425 StripChecksumsFromPackageList "$package_file" |
| 426 VerifyPackageFilesMatch "$package_file" "$DEBIAN_DEP_LIST_AMD64" |
| 427 InstallIntoSysroot ${files_and_sha256sums} |
| 428 CleanupJailSymlinks |
| 429 HacksAndPatchesAmd64 |
| 430 CreateTarBall |
| 431 } |
| 432 |
| 433 #@ |
| 434 #@ BuildSysrootI386 |
| 435 #@ |
| 436 #@ Build everything and package it |
| 437 BuildSysrootI386() { |
| 438 ClearInstallDir |
| 439 local package_file="$BUILD_DIR/package_with_sha256sum_i386" |
| 440 GeneratePackageListI386 "$package_file" |
| 441 local files_and_sha256sums="$(cat ${package_file})" |
| 442 StripChecksumsFromPackageList "$package_file" |
| 443 VerifyPackageFilesMatch "$package_file" "$DEBIAN_DEP_LIST_I386" |
| 444 InstallIntoSysroot ${files_and_sha256sums} |
| 445 CleanupJailSymlinks |
| 446 HacksAndPatchesI386 |
| 447 CreateTarBall |
| 448 } |
| 449 |
| 450 #@ |
| 451 #@ BuildSysrootARM |
| 452 #@ |
| 453 #@ Build everything and package it |
| 454 BuildSysrootARM() { |
| 455 ClearInstallDir |
| 456 local package_file="$BUILD_DIR/package_with_sha256sum_arm" |
| 457 GeneratePackageListARM "$package_file" |
| 458 local files_and_sha256sums="$(cat ${package_file})" |
| 459 StripChecksumsFromPackageList "$package_file" |
| 460 VerifyPackageFilesMatch "$package_file" "$DEBIAN_DEP_LIST_ARM" |
| 461 APT_REPO=${APR_REPO_ARM:=$APT_REPO} |
| 462 InstallIntoSysroot ${files_and_sha256sums} |
| 463 CleanupJailSymlinks |
| 464 HacksAndPatchesARM |
| 465 CreateTarBall |
| 466 } |
| 467 |
| 468 #@ |
| 469 #@ BuildSysrootMips |
| 470 #@ |
| 471 #@ Build everything and package it |
| 472 BuildSysrootMips() { |
| 473 ClearInstallDir |
| 474 local package_file="$BUILD_DIR/package_with_sha256sum_arm" |
| 475 GeneratePackageListMips "$package_file" |
| 476 local files_and_sha256sums="$(cat ${package_file})" |
| 477 StripChecksumsFromPackageList "$package_file" |
| 478 VerifyPackageFilesMatch "$package_file" "$DEBIAN_DEP_LIST_MIPS" |
| 479 APT_REPO=${APR_REPO_MIPS:=$APT_REPO} |
| 480 InstallIntoSysroot ${files_and_sha256sums} |
| 481 CleanupJailSymlinks |
| 482 HacksAndPatchesMips |
| 483 CreateTarBall |
| 484 } |
| 485 |
| 486 #@ |
| 487 #@ BuildSysrootAll |
| 488 #@ |
| 489 #@ Build sysroot images for all architectures |
| 490 BuildSysrootAll() { |
| 491 RunCommand BuildSysrootAmd64 |
| 492 RunCommand BuildSysrootI386 |
| 493 RunCommand BuildSysrootARM |
| 494 RunCommand BuildSysrootMips |
| 495 } |
| 496 |
| 497 UploadSysroot() { |
| 498 local rev=$1 |
| 499 if [ -z "${rev}" ]; then |
| 500 echo "Please specify a revision to upload at." |
| 501 exit 1 |
| 502 fi |
| 503 set -x |
| 504 gsutil cp -a public-read "${TARBALL}" \ |
| 505 "gs://chrome-linux-sysroot/toolchain/$rev/" |
| 506 set +x |
| 507 } |
| 508 |
| 509 #@ |
| 510 #@ UploadSysrootAmd64 <revision> |
| 511 #@ |
| 512 UploadSysrootAmd64() { |
| 513 UploadSysroot "$@" |
| 514 } |
| 515 |
| 516 #@ |
| 517 #@ UploadSysrootI386 <revision> |
| 518 #@ |
| 519 UploadSysrootI386() { |
| 520 UploadSysroot "$@" |
| 521 } |
| 522 |
| 523 #@ |
| 524 #@ UploadSysrootARM <revision> |
| 525 #@ |
| 526 UploadSysrootARM() { |
| 527 UploadSysroot "$@" |
| 528 } |
| 529 |
| 530 #@ |
| 531 #@ UploadSysrootMips <revision> |
| 532 #@ |
| 533 UploadSysrootMips() { |
| 534 UploadSysroot "$@" |
| 535 } |
| 536 |
| 537 #@ |
| 538 #@ UploadSysrootAll <revision> |
| 539 #@ |
| 540 #@ Upload sysroot image for all architectures |
| 541 UploadSysrootAll() { |
| 542 RunCommand UploadSysrootAmd64 "$@" |
| 543 RunCommand UploadSysrootI386 "$@" |
| 544 RunCommand UploadSysrootARM "$@" |
| 545 RunCommand UploadSysrootMips "$@" |
| 546 } |
| 547 |
| 548 # |
| 549 # CheckForDebianGPGKeyring |
| 550 # |
| 551 # Make sure the Debian GPG keys exist. Otherwise print a helpful message. |
| 552 # |
| 553 CheckForDebianGPGKeyring() { |
| 554 if [ ! -e "$KEYRING_FILE" ]; then |
| 555 echo "Debian GPG keys missing. Install the debian-archive-keyring package." |
| 556 exit 1 |
| 557 fi |
| 558 } |
| 559 |
| 560 # |
| 561 # VerifyPackageListing |
| 562 # |
| 563 # Verifies the downloaded Packages.bz2 file has the right checksums. |
| 564 # |
| 565 VerifyPackageListing() { |
| 566 local file_path=$1 |
| 567 local output_file=$2 |
| 568 local release_file="${BUILD_DIR}/${RELEASE_FILE}" |
| 569 local release_file_gpg="${BUILD_DIR}/${RELEASE_FILE_GPG}" |
| 570 local tmp_keyring_file="${BUILD_DIR}/keyring.gpg" |
| 571 |
| 572 CheckForDebianGPGKeyring |
| 573 |
| 574 DownloadOrCopy ${RELEASE_LIST} ${release_file} |
| 575 DownloadOrCopy ${RELEASE_LIST_GPG} ${release_file_gpg} |
| 576 echo "Verifying: ${release_file} with ${release_file_gpg}" |
| 577 cp "${KEYRING_FILE}" "${tmp_keyring_file}" |
| 578 gpg --primary-keyring "${tmp_keyring_file}" --recv-keys 2B90D010 |
| 579 gpgv --keyring "${tmp_keyring_file}" "${release_file_gpg}" "${release_file}" |
| 580 |
| 581 echo "Verifying: ${output_file}" |
| 582 local checksums=$(grep ${file_path} ${release_file} | cut -d " " -f 2) |
| 583 local sha256sum=$(echo ${checksums} | cut -d " " -f 3) |
| 584 |
| 585 if [ "${#sha256sum}" -ne "64" ]; then |
| 586 echo "Bad sha256sum from ${RELEASE_LIST}" |
| 587 exit 1 |
| 588 fi |
| 589 |
| 590 echo "${sha256sum} ${output_file}" | sha256sum --quiet -c |
| 591 } |
| 592 |
| 593 # |
| 594 # GeneratePackageList |
| 595 # |
| 596 # Looks up package names in ${BUILD_DIR}/Packages and write list of URLs |
| 597 # to output file. |
| 598 # |
| 599 GeneratePackageList() { |
| 600 local input_file="$1" |
| 601 local output_file="$2" |
| 602 echo "Updating: ${output_file} from ${input_file}" |
| 603 /bin/rm -f "${output_file}" |
| 604 shift |
| 605 shift |
| 606 for pkg in $@ ; do |
| 607 local pkg_full=$(grep -A 1 " ${pkg}\$" "$input_file" | \ |
| 608 egrep -o "pool/.*") |
| 609 if [ -z "${pkg_full}" ]; then |
| 610 echo "ERROR: missing package: $pkg" |
| 611 exit 1 |
| 612 fi |
| 613 local pkg_nopool=$(echo "$pkg_full" | sed "s/^pool\///") |
| 614 local sha256sum=$(grep -A 4 " ${pkg}\$" "$input_file" | \ |
| 615 grep ^SHA256: | sed 's/^SHA256: //') |
| 616 if [ "${#sha256sum}" -ne "64" ]; then |
| 617 echo "Bad sha256sum from Packages" |
| 618 exit 1 |
| 619 fi |
| 620 echo $pkg_nopool $sha256sum >> "$output_file" |
| 621 done |
| 622 # sort -o does an in-place sort of this file |
| 623 sort "$output_file" -o "$output_file" |
| 624 } |
| 625 |
| 626 #@ |
| 627 #@ UpdatePackageListsAmd64 |
| 628 #@ |
| 629 #@ Regenerate the package lists such that they contain an up-to-date |
| 630 #@ list of URLs within the Debian archive. (For amd64) |
| 631 UpdatePackageListsAmd64() { |
| 632 GeneratePackageListAmd64 "$DEBIAN_DEP_LIST_AMD64" |
| 633 StripChecksumsFromPackageList "$DEBIAN_DEP_LIST_AMD64" |
| 634 } |
| 635 |
| 636 #@ |
| 637 #@ UpdatePackageListsI386 |
| 638 #@ |
| 639 #@ Regenerate the package lists such that they contain an up-to-date |
| 640 #@ list of URLs within the Debian archive. (For i386) |
| 641 UpdatePackageListsI386() { |
| 642 GeneratePackageListI386 "$DEBIAN_DEP_LIST_I386" |
| 643 StripChecksumsFromPackageList "$DEBIAN_DEP_LIST_I386" |
| 644 } |
| 645 |
| 646 #@ |
| 647 #@ UpdatePackageListsARM |
| 648 #@ |
| 649 #@ Regenerate the package lists such that they contain an up-to-date |
| 650 #@ list of URLs within the Debian archive. (For arm) |
| 651 UpdatePackageListsARM() { |
| 652 GeneratePackageListARM "$DEBIAN_DEP_LIST_ARM" |
| 653 StripChecksumsFromPackageList "$DEBIAN_DEP_LIST_ARM" |
| 654 } |
| 655 |
| 656 #@ |
| 657 #@ UpdatePackageListsMips |
| 658 #@ |
| 659 #@ Regenerate the package lists such that they contain an up-to-date |
| 660 #@ list of URLs within the Debian archive. (For arm) |
| 661 UpdatePackageListsMips() { |
| 662 GeneratePackageListMips "$DEBIAN_DEP_LIST_MIPS" |
| 663 StripChecksumsFromPackageList "$DEBIAN_DEP_LIST_MIPS" |
| 664 } |
| 665 |
| 666 #@ |
| 667 #@ UpdatePackageListsAll |
| 668 #@ |
| 669 #@ Regenerate the package lists for all architectures. |
| 670 UpdatePackageListsAll() { |
| 671 RunCommand UpdatePackageListsAmd64 |
| 672 RunCommand UpdatePackageListsI386 |
| 673 RunCommand UpdatePackageListsARM |
| 674 RunCommand UpdatePackageListsMips |
| 675 } |
| 676 |
| 677 RunCommand() { |
| 678 SetEnvironmentVariables "$1" |
| 679 SanityCheck |
| 680 "$@" |
| 681 } |
| 682 |
| 683 if [ $# -eq 0 ] ; then |
| 684 echo "ERROR: you must specify a mode on the commandline" |
| 685 echo |
| 686 Usage |
| 687 exit 1 |
| 688 elif [ "$(type -t $1)" != "function" ]; then |
| 689 echo "ERROR: unknown function '$1'." >&2 |
| 690 echo "For help, try:" |
| 691 echo " $0 help" |
| 692 exit 1 |
| 693 else |
| 694 ChangeDirectory |
| 695 if echo $1 | grep -qs "All$"; then |
| 696 "$@" |
| 697 else |
| 698 RunCommand "$@" |
| 699 fi |
| 700 fi |
OLD | NEW |