| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Script to build binutils for both i386 and AMD64 Linux architectures. | 6 # Script to build binutils for both i386 and AMD64 Linux architectures. |
| 7 # Must be run on an AMD64 supporting machine which has debootstrap and sudo | 7 # Must be run on an AMD64 supporting machine which has debootstrap and sudo |
| 8 # installed. | 8 # installed. |
| 9 # Uses Ubuntu Lucid chroots as build environment. | 9 # Uses Ubuntu Lucid chroots as build environment. |
| 10 | 10 |
| 11 set -e | 11 set -e |
| 12 | 12 |
| 13 if [ x"$(whoami)" = x"root" ]; then | 13 if [ x"$(whoami)" = x"root" ]; then |
| 14 echo "Script must not be run as root." | 14 echo "Script must not be run as root." |
| 15 exit 1 | 15 exit 1 |
| 16 fi | 16 fi |
| 17 sudo -v | 17 sudo -v |
| 18 | 18 |
| 19 OUTPUTDIR="${1:-$PWD/output-$(date +%Y%m%d-%H%M%S)}" | 19 OUTPUTDIR="${1:-$PWD/output-$(date +%Y%m%d-%H%M%S)}" |
| 20 if [ ! -d "$OUTPUTDIR" ]; then | 20 if [ ! -d "$OUTPUTDIR" ]; then |
| 21 mkdir -p "$OUTPUTDIR" | 21 mkdir -p "$OUTPUTDIR" |
| 22 fi | 22 fi |
| 23 | 23 |
| 24 # Download the source | 24 # Download the source |
| 25 VERSION=2.25 | 25 VERSION=2.26 |
| 26 wget -c http://ftp.gnu.org/gnu/binutils/binutils-$VERSION.tar.bz2 | 26 wget -c http://ftp.gnu.org/gnu/binutils/binutils-$VERSION.tar.bz2 |
| 27 | 27 |
| 28 # Verify the signature | 28 # Verify the signature |
| 29 wget -c -q http://ftp.gnu.org/gnu/binutils/binutils-$VERSION.tar.bz2.sig | 29 wget -c -q http://ftp.gnu.org/gnu/binutils/binutils-$VERSION.tar.bz2.sig |
| 30 if ! gpg --verify binutils-$VERSION.tar.bz2.sig; then | 30 if ! gpg --verify binutils-$VERSION.tar.bz2.sig; then |
| 31 echo "GPG Signature failed to verify." | 31 echo "GPG Signature failed to verify." |
| 32 echo "" | 32 echo "" |
| 33 echo "You may need to import the vendor GPG key with:" | 33 echo "You may need to import the vendor GPG key with:" |
| 34 echo "# gpg --keyserver pgp.mit.edu --recv-key 4AE55E93" | 34 echo "# gpg --keyserver pgp.mit.edu --recv-key 4AE55E93" |
| 35 exit 1 | 35 exit 1 |
| 36 fi | 36 fi |
| 37 | 37 |
| 38 if [ ! -d gperftools ]; then | 38 if [ ! -d gperftools ]; then |
| 39 git clone --branch gperftools-2.4 https://github.com/gperftools/gperftools | 39 git clone --branch gperftools-2.4 https://github.com/gperftools/gperftools |
| 40 fi | 40 fi |
| 41 | 41 |
| 42 # Extract the source | 42 # Extract the source |
| 43 rm -rf binutils-$VERSION | 43 rm -rf binutils-$VERSION |
| 44 tar jxf binutils-$VERSION.tar.bz2 | 44 tar jxf binutils-$VERSION.tar.bz2 |
| 45 | 45 |
| 46 # Patch the source | 46 # Patch the source |
| 47 ( | 47 ( |
| 48 cd binutils-$VERSION | 48 cd binutils-$VERSION |
| 49 echo "unlock-thin.patch" | |
| 50 echo "==================================" | |
| 51 patch -p1 < ../unlock-thin.patch | |
| 52 echo "----------------------------------" | |
| 53 echo | |
| 54 echo "plugin-dso-fix.patch" | |
| 55 echo "==================================" | |
| 56 patch -p1 < ../plugin-dso-fix.patch | |
| 57 echo "----------------------------------" | |
| 58 echo | |
| 59 echo "long-plt.patch" | 49 echo "long-plt.patch" |
| 60 echo "==================================" | 50 echo "==================================" |
| 61 patch -p1 < ../long-plt.patch | 51 patch -p1 < ../long-plt.patch |
| 62 echo "----------------------------------" | 52 echo "----------------------------------" |
| 63 echo | 53 echo |
| 54 echo "icf-rel.patch" |
| 55 echo "==================================" |
| 56 patch -p1 < ../icf-rel.patch |
| 57 echo "----------------------------------" |
| 58 echo |
| 64 ) | 59 ) |
| 65 | 60 |
| 66 for ARCH in i386 amd64; do | 61 for ARCH in i386 amd64; do |
| 67 if [ ! -d precise-chroot-$ARCH ]; then | 62 if [ ! -d precise-chroot-$ARCH ]; then |
| 68 # Refresh sudo credentials | 63 # Refresh sudo credentials |
| 69 sudo -v | 64 sudo -v |
| 70 | 65 |
| 71 # Create the chroot | 66 # Create the chroot |
| 72 echo "" | 67 echo "" |
| 73 echo "Building chroot for $ARCH" | 68 echo "Building chroot for $ARCH" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 95 | 90 |
| 96 # Do the build | 91 # Do the build |
| 97 PREFIX= | 92 PREFIX= |
| 98 case $ARCH in | 93 case $ARCH in |
| 99 i386) | 94 i386) |
| 100 PREFIX="setarch linux32" | 95 PREFIX="setarch linux32" |
| 101 ARCHNAME=i686-pc-linux-gnu | 96 ARCHNAME=i686-pc-linux-gnu |
| 102 ;; | 97 ;; |
| 103 amd64) | 98 amd64) |
| 104 PREFIX="setarch linux64" | 99 PREFIX="setarch linux64" |
| 105 ARCHNAME=x86_64-unknown-linux-gnu | 100 ARCHNAME=x86_64-pc-linux-gnu |
| 106 ;; | 101 ;; |
| 107 esac | 102 esac |
| 108 echo "" | 103 echo "" |
| 109 echo "Building binutils for $ARCH" | 104 echo "Building binutils for $ARCH" |
| 110 LOGFILE="$OUTPUTDIR/build-$ARCH.log" | 105 LOGFILE="$OUTPUTDIR/build-$ARCH.log" |
| 111 if ! sudo $PREFIX chroot precise-chroot-$ARCH /build/build-one.sh /build/binut
ils-$VERSION > $LOGFILE 2>&1; then | 106 if ! sudo $PREFIX chroot precise-chroot-$ARCH /build/build-one.sh /build/binut
ils-$VERSION > $LOGFILE 2>&1; then |
| 112 echo "Build failed! See $LOGFILE for details." | 107 echo "Build failed! See $LOGFILE for details." |
| 113 exit 1 | 108 exit 1 |
| 114 fi | 109 fi |
| 115 | 110 |
| 116 # Copy data out of the chroot | 111 # Copy data out of the chroot |
| 117 sudo chown -R $(whoami) "$BUILDDIR/output/" | 112 sudo chown -R $(whoami) "$BUILDDIR/output/" |
| 118 | 113 |
| 119 # Strip the output binaries | 114 # Strip the output binaries |
| 120 for i in "$BUILDDIR/output/$ARCHNAME/bin/*"; do | 115 strip "$BUILDDIR/output/$ARCHNAME/bin/"* |
| 121 strip $i | |
| 122 done | |
| 123 | 116 |
| 124 # Copy them out of the chroot | 117 # Copy them out of the chroot |
| 125 cp -a "$BUILDDIR/output/$ARCHNAME" "$OUTPUTDIR" | 118 cp -a "$BUILDDIR/output/$ARCHNAME" "$OUTPUTDIR" |
| 126 | 119 |
| 127 # Copy plugin header out of the chroot | 120 # Copy plugin header out of the chroot |
| 128 mkdir "$OUTPUTDIR/$ARCHNAME/include" | 121 mkdir "$OUTPUTDIR/$ARCHNAME/include" |
| 129 cp "$BUILDDIR/binutils-$VERSION/include/plugin-api.h" "$OUTPUTDIR/$ARCHNAME/in
clude/" | 122 cp "$BUILDDIR/binutils-$VERSION/include/plugin-api.h" "$OUTPUTDIR/$ARCHNAME/in
clude/" |
| 130 | 123 |
| 131 # Clean up chroot | 124 # Clean up chroot |
| 132 sudo rm -rf "$BUILDDIR" | 125 sudo rm -rf "$BUILDDIR" |
| 133 done | 126 done |
| 134 | 127 |
| 135 echo "Check you are happy with the binaries in" | 128 echo "Check you are happy with the binaries in" |
| 136 echo " $OUTPUTDIR" | 129 echo " $OUTPUTDIR" |
| 137 echo "Then" | 130 echo "Then" |
| 138 echo " * upload to Google Storage using the upload.sh script" | 131 echo " * upload to Google Storage using the upload.sh script" |
| 139 echo " * roll dependencies" | 132 echo " * roll dependencies" |
| OLD | NEW |