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.24 |
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 | 38 |
39 if [ ! -d binutils-$VERSION ]; then | 39 if [ ! -d binutils-$VERSION ]; then |
40 # Extract the source | 40 # Extract the source |
41 tar jxf binutils-$VERSION.tar.bz2 | 41 tar jxf binutils-$VERSION.tar.bz2 |
42 | 42 |
43 # Patch the source | 43 # Patch the source |
44 ( | 44 ( |
45 cd binutils-$VERSION | 45 cd binutils-$VERSION |
46 echo "unlock-thin.patch" | 46 patch -p1 < ../ehframe-race.patch |
47 echo "==================================" | |
48 patch -p1 < ../unlock-thin.patch | 47 patch -p1 < ../unlock-thin.patch |
49 echo "----------------------------------" | |
50 echo | |
51 echo "plugin-dso-fix.patch" | |
52 echo "==================================" | |
53 patch -p1 < ../plugin-dso-fix.patch | 48 patch -p1 < ../plugin-dso-fix.patch |
54 echo "----------------------------------" | |
55 echo | |
56 ) | 49 ) |
57 fi | 50 fi |
58 | 51 |
59 for ARCH in i386 amd64; do | 52 for ARCH in i386 amd64; do |
60 if [ ! -d precise-chroot-$ARCH ]; then | 53 if [ ! -d lucid-chroot-$ARCH ]; then |
61 # Refresh sudo credentials | 54 # Refresh sudo credentials |
62 sudo -v | 55 sudo -v |
63 | 56 |
64 # Create the chroot | 57 # Create the chroot |
65 echo "" | 58 echo "" |
66 echo "Building chroot for $ARCH" | 59 echo "Building chroot for $ARCH" |
67 echo "=============================" | 60 echo "=============================" |
68 sudo debootstrap \ | 61 sudo debootstrap \ |
69 --arch=$ARCH \ | 62 --arch=$ARCH \ |
70 --include=build-essential,flex,bison \ | 63 --include=build-essential,flex,bison \ |
71 precise precise-chroot-$ARCH | 64 lucid lucid-chroot-$ARCH |
72 echo "=============================" | 65 echo "=============================" |
73 fi | 66 fi |
74 | 67 |
75 BUILDDIR=precise-chroot-$ARCH/build | 68 BUILDDIR=lucid-chroot-$ARCH/build |
76 | 69 |
77 # Clean up any previous failed build attempts inside chroot | 70 # Clean up any previous failed build attempts inside chroot |
78 if [ -d "$BUILDDIR" ]; then | 71 if [ -d "$BUILDDIR" ]; then |
79 sudo rm -rf "$BUILDDIR" | 72 sudo rm -rf "$BUILDDIR" |
80 fi | 73 fi |
81 | 74 |
82 # Copy data into the chroot | 75 # Copy data into the chroot |
83 sudo mkdir -p "$BUILDDIR" | 76 sudo mkdir -p "$BUILDDIR" |
84 sudo cp -a binutils-$VERSION "$BUILDDIR" | 77 sudo cp -a binutils-$VERSION "$BUILDDIR" |
85 sudo cp -a build-one.sh "$BUILDDIR" | 78 sudo cp -a build-one.sh "$BUILDDIR" |
86 | 79 |
87 # Do the build | 80 # Do the build |
88 PREFIX= | 81 PREFIX= |
89 case $ARCH in | 82 case $ARCH in |
90 i386) | 83 i386) |
91 PREFIX="setarch linux32" | 84 PREFIX="setarch linux32" |
92 ARCHNAME=i686-pc-linux-gnu | 85 ARCHNAME=i686-pc-linux-gnu |
93 ;; | 86 ;; |
94 amd64) | 87 amd64) |
95 PREFIX="setarch linux64" | 88 PREFIX="setarch linux64" |
96 ARCHNAME=x86_64-unknown-linux-gnu | 89 ARCHNAME=x86_64-unknown-linux-gnu |
97 ;; | 90 ;; |
98 esac | 91 esac |
99 echo "" | 92 echo "" |
100 echo "Building binutils for $ARCH" | 93 echo "Building binutils for $ARCH" |
101 LOGFILE="$OUTPUTDIR/build-$ARCH.log" | 94 LOGFILE="$OUTPUTDIR/build-$ARCH.log" |
102 if ! sudo $PREFIX chroot precise-chroot-$ARCH /build/build-one.sh /build/binut
ils-$VERSION > $LOGFILE 2>&1; then | 95 if ! sudo $PREFIX chroot lucid-chroot-$ARCH /build/build-one.sh /build/binutil
s-$VERSION > $LOGFILE 2>&1; then |
103 echo "Build failed! See $LOGFILE for details." | 96 echo "Build failed! See $LOGFILE for details." |
104 exit 1 | 97 exit 1 |
105 fi | 98 fi |
106 | 99 |
107 # Copy data out of the chroot | 100 # Copy data out of the chroot |
108 sudo chown -R $(whoami) "$BUILDDIR/output/" | 101 sudo chown -R $(whoami) "$BUILDDIR/output/" |
109 | 102 |
110 # Strip the output binaries | 103 # Strip the output binaries |
111 for i in "$BUILDDIR/output/$ARCHNAME/bin/*"; do | 104 for i in "$BUILDDIR/output/$ARCHNAME/bin/*"; do |
112 strip $i | 105 strip $i |
113 done | 106 done |
114 | 107 |
115 # Copy them out of the chroot | 108 # Copy them out of the chroot |
116 cp -a "$BUILDDIR/output/$ARCHNAME" "$OUTPUTDIR" | 109 cp -a "$BUILDDIR/output/$ARCHNAME" "$OUTPUTDIR" |
117 | 110 |
118 # Copy plugin header out of the chroot | 111 # Copy plugin header out of the chroot |
119 mkdir "$OUTPUTDIR/$ARCHNAME/include" | 112 mkdir "$OUTPUTDIR/$ARCHNAME/include" |
120 cp "$BUILDDIR/binutils-$VERSION/include/plugin-api.h" "$OUTPUTDIR/$ARCHNAME/in
clude/" | 113 cp "$BUILDDIR/binutils-$VERSION/include/plugin-api.h" "$OUTPUTDIR/$ARCHNAME/in
clude/" |
121 | 114 |
122 # Clean up chroot | 115 # Clean up chroot |
123 sudo rm -rf "$BUILDDIR" | 116 sudo rm -rf "$BUILDDIR" |
124 done | 117 done |
125 | 118 |
126 echo "Check you are happy with the binaries in" | 119 echo "Check you are happy with the binaries in" |
127 echo " $OUTPUTDIR" | 120 echo " $OUTPUTDIR" |
128 echo "Then" | 121 echo "Then" |
129 echo " * upload to Google Storage using the upload.sh script" | 122 echo " * upload to Google Storage using the upload.sh script" |
130 echo " * roll dependencies" | 123 echo " * roll dependencies" |
OLD | NEW |