OLD | NEW |
---|---|
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright 2012 The Native Client Authors. All rights reserved. | 2 # Copyright 2012 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can | 3 # Use of this source code is governed by a BSD-style license that can |
4 # be found in the LICENSE file. | 4 # be found in the LICENSE file. |
5 # | 5 # |
6 #@ This script creates the mips trusted SDK. | 6 #@ This script creates the mips trusted SDK. |
7 #@ It must be run from the native_client directory. | 7 #@ It must be run from the native_client directory. |
8 | 8 |
9 # This script is intended to build a mipsel-linux-gnu cross compilation | |
10 # toolchain that runs on x86 linux and generates code for a little-endian, | |
11 # hard-float, mips32 target. | |
12 # | |
13 # It expects the host machine to have relatively recent versions of GMP (4.2.0 | |
14 # or later), MPFR (2.4.2), and MPC (0.8.1) in order to build the GCC. | |
15 # | |
16 # Common way to get those is: | |
17 # sudo apt-get install libmpfr-dev libmpc-dev libgmp3-dev | |
18 | |
9 ###################################################################### | 19 ###################################################################### |
10 # Config | 20 # Config |
11 ###################################################################### | 21 ###################################################################### |
12 | 22 |
13 set -o nounset | 23 set -o nounset |
14 set -o errexit | 24 set -o errexit |
25 set -o xtrace | |
15 | 26 |
16 readonly CS_URL=https://sourcery.mentor.com/sgpp/lite/mips/portal/package9761/pu blic/mips-linux-gnu/mips-2011.09-75-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2 | 27 readonly MAKE_OPTS="-j8" |
28 readonly ARCH="mips32" | |
29 | |
30 readonly GCC_URL="http://ftp.gnu.org/gnu/gcc/gcc-4.6.3/gcc-4.6.3.tar.bz2" | |
31 readonly GCC_SHA1SUM="ce317ca5c8185b58bc9300182b534608c578637f" | |
32 | |
33 readonly BINUTILS_URL="http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.bz2" | |
34 readonly BINUTILS_SHA1SUM="65b304a0b9a53a686ce50a01173d1f40f8efe404" | |
35 | |
36 readonly KERNEL_URL="http://www.linux-mips.org/pub/linux/mips/kernel/v2.6/linux- 2.6.38.4.tar.gz" | |
37 readonly KERNEL_SHA1SUM="377fa5cf5f1d0c396759b1c4d147330e7e5b6d7f" | |
38 | |
39 readonly GDB_URL="http://ftp.gnu.org/gnu/gdb/gdb-7.5.tar.bz2" | |
40 readonly GDB_SHA1SUM="79b61152813e5730fa670c89e5fc3c04b670b02c" | |
41 | |
42 readonly EGLIBC_SVN_URL="svn://svn.eglibc.org/branches/eglibc-2_14" | |
43 readonly EGLIBC_REVISION="20996" | |
17 | 44 |
18 readonly DOWNLOAD_QEMU_URL="http://download.savannah.gnu.org/releases/qemu/qemu- 0.12.5.tar.gz" | 45 readonly DOWNLOAD_QEMU_URL="http://download.savannah.gnu.org/releases/qemu/qemu- 0.12.5.tar.gz" |
19 | 46 |
20 readonly INSTALL_ROOT=$(pwd)/toolchain/linux_mips-trusted | 47 readonly INSTALL_ROOT=$(pwd)/toolchain/linux_mips-trusted |
21 | 48 |
22 readonly TMP=$(pwd)/toolchain/tmp/crosstool-trusted | 49 readonly TMP=$(pwd)/toolchain/tmp/crosstool-trusted |
23 | 50 |
51 readonly BUILD_DIR=${TMP}/build | |
52 | |
24 readonly PATCH_MIPS32=$(readlink -f ../third_party/qemu/qemu-0.12.5.patch_mips) | 53 readonly PATCH_MIPS32=$(readlink -f ../third_party/qemu/qemu-0.12.5.patch_mips) |
25 | 54 |
26 readonly CS_ROOT=${INSTALL_ROOT}/mips-release | 55 readonly JAIL_MIPS32=${INSTALL_ROOT}/sysroot |
27 | 56 |
28 readonly JAIL_MIPS32=${CS_ROOT}/mips-linux-gnu/libc/el | 57 # These are simple compiler wrappers to force 32bit builds. |
29 | |
30 readonly MAKE_OPTS="-j8" | |
31 # These are simple compiler wrappers to force 32bit builds | |
32 readonly CC32=$(readlink -f pnacl/scripts/mygcc32) | 58 readonly CC32=$(readlink -f pnacl/scripts/mygcc32) |
33 readonly CXX32=$(readlink -f pnacl/scripts/myg++32) | 59 readonly CXX32=$(readlink -f pnacl/scripts/myg++32) |
60 | |
34 ###################################################################### | 61 ###################################################################### |
35 # Helper | 62 # Helper |
36 ###################################################################### | 63 ###################################################################### |
37 | 64 |
38 Banner() { | 65 Banner() { |
39 echo "######################################################################" | 66 echo "######################################################################" |
40 echo $* | 67 echo $* |
41 echo "######################################################################" | 68 echo "######################################################################" |
42 } | 69 } |
43 | 70 |
44 SubBanner() { | 71 SubBanner() { |
45 echo "......................................................................" | 72 echo "......................................................................" |
46 echo $* | 73 echo $* |
47 echo "...................................................................." | 74 echo "......................................................................" |
48 } | 75 } |
49 | 76 |
50 Usage() { | 77 Usage() { |
51 echo | 78 echo |
52 echo "$0 trusted_sdk" | 79 echo "$0 trusted_sdk" |
53 echo | 80 echo |
54 echo "trusted_sdk - Build everything and package it" | 81 echo "trusted_sdk - Build everything and package it" |
55 echo | 82 echo |
56 } | 83 } |
57 | 84 |
58 DownloadOrCopy() { | 85 DownloadOrCopy() { |
robertm
2012/10/10 15:38:27
I think it would be clearer to have a separate fun
petarj
2012/10/11 00:44:06
Done.
| |
59 if [[ -f "$2" ]] ; then | 86 local url=${1} |
60 echo "$2 already in place" | 87 local filename="${TMP}/${url##*/}" |
61 elif [[ $1 =~ 'http://' || $1 =~ 'https://' ]] ; then | 88 local filetype="${url%%:*}" |
62 SubBanner "downloading from $1 -> $2" | 89 local checksum=${2} |
robertm
2012/10/10 15:38:27
we usually do not use ${} for single char vars but
petarj
2012/10/11 00:44:06
Done.
| |
63 wget $1 -O $2 | 90 local revision=${2} |
91 | |
92 if [ "${filename}" == "" ]; then | |
93 echo "Unknown error occured. Aborting." | |
94 exit 1 | |
95 fi | |
96 | |
97 if [ "${filetype}" == "svn" ]; then | |
98 SubBanner "checkout from ${url} -> ${filename}" | |
99 svn --force export -r ${revision} ${url} ${filename} | |
100 elif [[ "${filetype}" == "http" || ${filetype} == "https" ]] ; then | |
101 if [ ! -f "${filename}" ]; then | |
102 SubBanner "downloading from ${url} -> ${filename}" | |
103 wget ${url} -O ${filename} | |
104 fi | |
105 if [ "${checksum}" != "nochecksum" ]; then | |
106 CheckSHA1Sum ${filename} ${checksum} | |
107 fi | |
64 else | 108 else |
65 SubBanner "copying from $1" | 109 SubBanner "copying from ${url}" |
66 cp $1 $2 | 110 cp ${url} ${filename} |
67 fi | 111 fi |
68 } | 112 } |
69 | 113 |
114 CheckSHA1Sum() { | |
115 local calculated_checksum=`sha1sum ${filename} | cut -d ' ' -f 1` | |
robertm
2012/10/10 15:38:27
use $() instead of backticks
petarj
2012/10/11 00:44:06
Done.
| |
116 if [ "${calculated_checksum}" != "${checksum}" ]; then | |
117 echo "${filename} sha1sum failed. Deleting file and aborting." | |
118 rm -f ${filename} | |
119 exit 1 | |
120 fi | |
121 } | |
122 | |
70 ###################################################################### | 123 ###################################################################### |
71 # | 124 # |
72 ###################################################################### | 125 ###################################################################### |
73 | 126 |
74 # some sanity checks to make sure this script is run from the right place | 127 # some sanity checks to make sure this script is run from the right place |
75 # with the right tools | 128 # with the right tools. |
76 SanityCheck() { | 129 SanityCheck() { |
77 Banner "Sanity Checks" | 130 Banner "Sanity Checks" |
78 if [[ $(basename $(pwd)) != "native_client" ]] ; then | 131 if [[ $(basename $(pwd)) != "native_client" ]] ; then |
79 echo "ERROR: run this script from the native_client/ dir" | 132 echo "ERROR: run this script from the native_client/ dir" |
80 exit -1 | 133 exit -1 |
81 fi | 134 fi |
82 | 135 |
83 if ! mkdir -p "${INSTALL_ROOT}" ; then | 136 if ! mkdir -p "${INSTALL_ROOT}" ; then |
84 echo "ERROR: ${INSTALL_ROOT} can't be created." | 137 echo "ERROR: ${INSTALL_ROOT} can't be created." |
85 exit -1 | 138 exit -1 |
86 fi | 139 fi |
87 | 140 |
88 for tool in cleanlinks wget ; do | 141 for tool in cleanlinks wget ; do |
89 if ! which ${tool} ; then | 142 if ! which ${tool} ; then |
90 echo "Required binary $tool not found." | 143 echo "Required binary $tool not found." |
91 echo "Exiting." | 144 echo "Exiting." |
92 exit 1 | 145 exit 1 |
93 fi | 146 fi |
94 done | 147 done |
95 } | 148 } |
96 | 149 |
97 | 150 |
98 ClearInstallDir() { | 151 ClearInstallDir() { |
99 Banner "clearing dirs in ${INSTALL_ROOT}" | 152 Banner "clearing dirs in ${INSTALL_ROOT}" |
100 rm -rf ${INSTALL_ROOT}/* | 153 rm -rf ${INSTALL_ROOT}/* |
101 } | 154 } |
102 | 155 |
156 ClearBuildDir() { | |
157 Banner "clearing dirs in ${BUILD_DIR}" | |
158 rm -rf ${BUILD_DIR}/* | |
159 } | |
103 | 160 |
104 CreateTarBall() { | 161 CreateTarBall() { |
105 local tarball=$1 | 162 local tarball=$1 |
106 Banner "creating tar ball ${tarball}" | 163 Banner "creating tar ball ${tarball}" |
107 tar cfz ${tarball}-mips.tgz -C ${INSTALL_ROOT} . | 164 tar cfz ${tarball}-mips.tgz -C ${INSTALL_ROOT} . |
108 } | 165 } |
109 | 166 |
110 | 167 |
111 # try to keep the tarball small | 168 # Download the toolchain source tarballs or use a local copy when available. |
112 PruneDirs() { | 169 DownloadOrCopyAndInstallToolchain() { |
113 Banner "pruning code sourcery tree" | 170 Banner "Installing toolchain" |
114 SubBanner "Size before: $(du -msc ${CS_ROOT})" | |
115 rm -rf ${CS_ROOT}/share | |
116 rm -rf ${CS_ROOT}/mips-linux-gnu/lib/uclibc | |
117 rm -rf ${CS_ROOT}/mips-linux-gnu/lib/soft-float | |
118 rm -rf ${CS_ROOT}/mips-linux-gnu/lib/micromips | |
119 | 171 |
120 rm -rf ${CS_ROOT}/mips-linux-gnu/libc/uclibc | 172 local tarball="${TMP}/${BINUTILS_URL##*/}" |
121 rm -rf ${CS_ROOT}/mips-linux-gnu/libc/soft-float | 173 DownloadOrCopy ${BINUTILS_URL} ${BINUTILS_SHA1SUM} |
122 rm -rf ${CS_ROOT}/mips-linux-gnu/libc/micromips | 174 SubBanner "extracting from ${tarball}" |
175 tar jxf ${tarball} -C ${TMP} | |
123 | 176 |
124 rm -rf ${CS_ROOT}/lib/gcc/mips-linux-gnu/4.4.1/uclibc | 177 tarball="${TMP}/${GCC_URL##*/}" |
125 rm -rf ${CS_ROOT}/lib/gcc/mips-linux-gnu/4.4.1/soft-float | 178 DownloadOrCopy ${GCC_URL} ${GCC_SHA1SUM} |
126 rm -rf ${CS_ROOT}/lib/gcc/mips-linux-gnu/4.4.1/micromips | 179 SubBanner "extracting from ${tarball}" |
180 tar jxf ${tarball} -C ${TMP} | |
127 | 181 |
128 rm -rf ${CS_ROOT}/mips-linux-gnu/include/c++/4.4.1/mips-linux-gnu/uclibc | 182 tarball="${TMP}/${GDB_URL##*/}" |
129 rm -rf ${CS_ROOT}/mips-linux-gnu/include/c++/4.4.1/mips-linux-gnu/soft-float | 183 DownloadOrCopy ${GDB_URL} ${GDB_SHA1SUM} |
130 rm -rf ${CS_ROOT}/mips-linux-gnu/include/c++/4.4.1/mips-linux-gnu/micromips | 184 SubBanner "extracting from ${tarball}" |
185 tar jxf ${tarball} -C ${TMP} | |
131 | 186 |
132 SubBanner "Size after: $(du -msc ${CS_ROOT})" | 187 tarball="${TMP}/${KERNEL_URL##*/}" |
188 DownloadOrCopy ${KERNEL_URL} ${KERNEL_SHA1SUM} | |
189 SubBanner "extracting from ${tarball}" | |
190 tar zxf ${tarball} -C ${TMP} | |
191 | |
192 local eglibc_dir="${TMP}/${EGLIBC_SVN_URL##*/}" | |
193 DownloadOrCopy ${EGLIBC_SVN_URL} ${EGLIBC_REVISION} | |
194 | |
195 Banner "Preparing the code" | |
196 | |
197 cd ${TMP}/eglibc-2_14/libc/ && ln -s ../ports ports && cd - | |
robertm
2012/10/10 15:38:27
we do not use long chains of &&
for the "ln" case
petarj
2012/10/11 00:44:06
Done.
| |
198 cd ${TMP}/binutils-2.22/gas/config \ | |
robertm
2012/10/10 15:38:27
add a comment for this
petarj
2012/10/11 00:44:06
Done.
| |
199 && OLD_TEXT="as_warn_where (fragp->fr_file, fragp->fr_line, msg);" \ | |
200 && NEW_TEXT="as_warn_where (fragp->fr_file, fragp->fr_line, \"%s\", msg);" \ | |
201 && FILE_NAME="$PWD/tc-mips.c" \ | |
202 && sed -i "s/$OLD_TEXT/$NEW_TEXT/g" "$FILE_NAME" && cd - | |
203 | |
204 | |
205 Banner "Building toolchain" | |
206 | |
207 mkdir -p ${BUILD_DIR}/binutils/ | |
208 cd ${BUILD_DIR}/binutils/ | |
209 | |
210 ${TMP}/binutils-2.22/configure --prefix=${INSTALL_ROOT} \ | |
robertm
2012/10/10 15:38:27
arg alignment
petarj
2012/10/11 00:44:06
Done.
| |
211 --target=mipsel-linux-gnu \ | |
212 --with-sysroot=${JAIL_MIPS32} | |
213 | |
214 make ${MAKE_OPTS} all-binutils all-gas all-ld | |
215 make ${MAKE_OPTS} install-binutils install-gas install-ld | |
216 | |
217 | |
218 mkdir -p ${BUILD_DIR}/gcc/initial | |
219 cd ${BUILD_DIR}/gcc/initial | |
220 | |
221 ${TMP}/gcc-4.6.3/configure --prefix=${INSTALL_ROOT} --disable-libssp \ | |
robertm
2012/10/10 15:38:27
one arg per line is easier to read (optional)
petarj
2012/10/11 00:44:06
Done.
| |
222 --disable-libgomp --disable-libmudflap --disable-fixed-point \ | |
223 --disable-decimal-float --with-mips-plt --with-endian=little \ | |
224 --with-arch=${ARCH} --target=mipsel-linux-gnu --enable-languages=c \ | |
225 --with-newlib --without-headers --disable-shared --disable-threads \ | |
226 --disable-libquadmath --disable-libatomic | |
227 | |
228 make ${MAKE_OPTS} all | |
229 make ${MAKE_OPTS} install | |
230 | |
231 | |
232 cd ${TMP}/linux-2.6.38.4 | |
233 make headers_install ARCH=mips INSTALL_HDR_PATH=${JAIL_MIPS32}/usr | |
234 | |
235 export PATH=${INSTALL_ROOT}/bin:$PATH | |
robertm
2012/10/10 15:38:27
it may be better to not export them put just
pre
petarj
2012/10/11 00:44:06
Done.
| |
236 export BUILD_CC=gcc | |
237 export AR=mipsel-linux-gnu-ar | |
238 export RANLIB=mipsel-linux-gnu-ranlib | |
239 export CC=mipsel-linux-gnu-gcc | |
240 export CXX=mipsel-linux-gnu-g++ | |
241 mkdir -p ${BUILD_DIR}/eglibc/initial | |
242 cd ${BUILD_DIR}/eglibc/initial | |
243 | |
244 ${TMP}/eglibc-2_14/libc/configure --prefix=/usr --enable-add-ons \ | |
245 --with-headers=${JAIL_MIPS32}/usr/include --build=i686-pc-linux-gnu \ | |
246 --host=mipsel-linux-gnu --disable-profile --without-gd --without-cvs | |
247 | |
248 make ${MAKE_OPTS} install-headers install_root=${JAIL_MIPS32} install-bootstra p-headers=yes | |
robertm
2012/10/10 15:38:27
line length
petarj
2012/10/11 00:44:06
Done.
| |
249 mkdir -p ${JAIL_MIPS32}/usr/lib | |
250 | |
251 make csu/subdir_lib && cp csu/crt1.o csu/crti.o csu/crtn.o ${JAIL_MIPS32}/usr /lib | |
252 mipsel-linux-gnu-gcc -nostdlib -nostartfiles -shared -x c /dev/null \ | |
253 -o ${JAIL_MIPS32}/usr/lib/libc.so | |
254 | |
255 | |
256 unset BUILD_CC AR RANLIB CC CXX | |
robertm
2012/10/10 15:38:27
comment?
(may not be needed anymore if you follow
| |
257 mkdir -p ${BUILD_DIR}/gcc/intermediate | |
258 cd ${BUILD_DIR}/gcc/intermediate | |
259 | |
260 ${TMP}/gcc-4.6.3/configure --prefix=${INSTALL_ROOT} --disable-libssp \ | |
261 --disable-libgomp --disable-libmudflap --disable-fixed-point \ | |
262 --disable-decimal-float --with-mips-plt --with-endian=little \ | |
263 --with-arch=${ARCH} --target=mipsel-linux-gnu --enable-languages=c \ | |
264 --with-sysroot=${JAIL_MIPS32} --disable-libquadmath --disable-libatomic | |
265 | |
266 make ${MAKE_OPTS} all | |
267 make ${MAKE_OPTS} install | |
268 | |
269 | |
270 export BUILD_CC=gcc | |
robertm
2012/10/10 15:38:27
see above
petarj
2012/10/11 00:44:06
Done.
| |
271 export AR=mipsel-linux-gnu-ar | |
272 export RANLIB=mipsel-linux-gnu-ranlib | |
273 export CC=mipsel-linux-gnu-gcc | |
274 export CXX=mipsel-linux-gnu-g++ | |
275 mkdir -p ${BUILD_DIR}/eglibc/final | |
276 cd ${BUILD_DIR}/eglibc/final | |
277 | |
278 ${TMP}/eglibc-2_14/libc/configure --prefix=/usr --enable-add-ons \ | |
279 --with-headers=${JAIL_MIPS32}/usr/include --build=i686-pc-linux-gnu \ | |
280 --host=mipsel-linux-gnu --disable-profile --without-gd --without-cvs | |
281 | |
282 make ${MAKE_OPTS} all | |
283 make ${MAKE_OPTS} install install_root=${JAIL_MIPS32} | |
284 | |
285 | |
286 unset BUILD_CC AR RANLIB CC CXX | |
287 mkdir -p ${BUILD_DIR}/gcc/final | |
288 cd ${BUILD_DIR}/gcc/final | |
289 | |
290 ${TMP}/gcc-4.6.3/configure --prefix=${INSTALL_ROOT} --disable-libssp \ | |
291 --disable-libgomp --disable-libmudflap --disable-fixed-point \ | |
292 --disable-decimal-float --with-mips-plt --with-endian=little \ | |
293 --with-arch=${ARCH} --target=mipsel-linux-gnu --enable-__cxa_atexit \ | |
294 --with-sysroot=${JAIL_MIPS32} --enable-languages=c,c++ | |
295 | |
296 make ${MAKE_OPTS} all | |
297 make ${MAKE_OPTS} install | |
298 | |
299 | |
300 mkdir -p ${BUILD_DIR}/gdb/ | |
301 cd ${BUILD_DIR}/gdb/ | |
302 | |
303 ${TMP}/gdb-7.5/configure --prefix=${INSTALL_ROOT} --target=mipsel-linux-gnu | |
304 | |
305 make ${MAKE_OPTS} all-gdb | |
306 make ${MAKE_OPTS} install-gdb | |
307 | |
308 cd ${INSTALL_ROOT}/../.. | |
133 } | 309 } |
134 | 310 |
135 | 311 |
136 # Download the codesourcery tarball or use a local copy when available. | |
137 DownloadOrCopyAndInstallCodeSourceryTarball() { | |
138 Banner "Installing Codesourcery Toolchain" | |
139 local tarball="${TMP}/${CS_URL##*/}" | |
140 DownloadOrCopy ${CS_URL} ${tarball} | |
141 | |
142 SubBanner "Untaring ${INSTALL_ROOT}/${tarball}" | |
143 tar jxf ${tarball} -C ${INSTALL_ROOT} | |
144 | |
145 pushd ${INSTALL_ROOT} | |
146 mv mips-* mips-release | |
147 popd | |
148 } | |
149 | |
150 | |
151 InstallTrustedLinkerScript() { | 312 InstallTrustedLinkerScript() { |
152 local trusted_ld_script=${INSTALL_ROOT}/ld_script_mips_trusted | 313 local trusted_ld_script=${INSTALL_ROOT}/ld_script_mips_trusted |
153 # We are using the output of "ld --verbose" which contains | 314 # We are using the output of "ld --verbose" which contains |
154 # the linker script delimited by "=========". | 315 # the linker script delimited by "=========". |
155 # We are changing the image start address to 70000000 | 316 # We are changing the image start address to 70000000 |
156 # to move the sel_ldr and other images "out of the way" | 317 # to move the sel_ldr and other images "out of the way" |
157 Banner "installing trusted linker script to ${trusted_ld_script}" | 318 Banner "installing trusted linker script to ${trusted_ld_script}" |
158 | 319 |
159 ${CS_ROOT}/bin/mips-linux-gnu-ld --verbose |\ | 320 ${INSTALL_ROOT}/bin/mipsel-linux-gnu-ld --verbose |\ |
160 grep -A 10000 "=======" |\ | 321 grep -A 10000 "=======" |\ |
161 grep -v "=======" |\ | 322 grep -v "=======" |\ |
162 sed -e 's/0400000/70000000/g' > ${trusted_ld_script} | 323 sed -e 's/0400000/70000000/g' > ${trusted_ld_script} |
163 } | 324 } |
164 | 325 |
165 | 326 |
166 InstallMissingHeaders() { | |
167 Banner "installing openssl headers from local system" | |
168 cp -r /usr/include/openssl ${JAIL_MIPS32}/usr/include/ | |
169 } | |
170 | |
171 | |
172 MissingSharedLibCleanup() { | |
173 Banner "Cleanup dangling symlinks" | |
174 } | |
175 | |
176 # ---------------------------------------------------------------------- | 327 # ---------------------------------------------------------------------- |
177 # mips32 deb files to complete our code sourcery jail | 328 # mips32 deb files to complete our code sourcery jail |
178 # ---------------------------------------------------------------------- | 329 # ---------------------------------------------------------------------- |
179 | 330 |
180 readonly REPO_DEBIAN=http://ftp.debian.org/debian | 331 readonly REPO_DEBIAN=http://ftp.debian.org/debian |
181 readonly MIPS32_PACKAGES=${REPO_DEBIAN}/dists/squeeze/main/binary-mipsel/Package s.bz2 | 332 readonly MIPS32_PACKAGES=${REPO_DEBIAN}/dists/squeeze/main/binary-mipsel/Package s.bz2 |
182 | 333 |
183 readonly TMP_PACKAGELIST_MIPS32=${TMP}/../packagelist_mipsel.tmp | 334 readonly TMP_PACKAGELIST_MIPS32=${TMP}/../packagelist_mipsel.tmp |
184 | 335 |
185 # These are good enough for native client | 336 # These are good enough for native client. |
186 readonly BASE_PACKAGES="\ | 337 readonly BASE_PACKAGES="\ |
187 libssl0.9.8 \ | 338 libssl0.9.8 \ |
188 libssl-dev \ | 339 libssl-dev \ |
189 libx11-6 \ | 340 libx11-6 \ |
190 libx11-dev \ | 341 libx11-dev \ |
191 x11proto-core-dev \ | 342 x11proto-core-dev \ |
192 libxt6 \ | 343 libxt6 \ |
193 libxt-dev \ | 344 libxt-dev \ |
194 zlib1g \ | 345 zlib1g \ |
195 zlib1g-dev \ | 346 zlib1g-dev \ |
(...skipping 12 matching lines...) Expand all Loading... | |
208 libxcb-shm0 \ | 359 libxcb-shm0 \ |
209 libxcb-shm0-dev \ | 360 libxcb-shm0-dev \ |
210 libxdmcp6 \ | 361 libxdmcp6 \ |
211 libxdmcp-dev \ | 362 libxdmcp-dev \ |
212 libxss1 \ | 363 libxss1 \ |
213 libxss-dev" | 364 libxss-dev" |
214 | 365 |
215 GeneratePackageLists() { | 366 GeneratePackageLists() { |
216 Banner "generating package lists for mips32" | 367 Banner "generating package lists for mips32" |
217 echo -n > ${TMP_PACKAGELIST_MIPS32} | 368 echo -n > ${TMP_PACKAGELIST_MIPS32} |
218 DownloadOrCopy ${MIPS32_PACKAGES} ${TMP}/../Packages_mipsel.bz2 | 369 DownloadOrCopy ${MIPS32_PACKAGES} nochecksum |
219 bzcat ${TMP}/../Packages_mipsel.bz2\ | 370 bzcat ${TMP}/Packages.bz2\ |
220 | egrep '^(Package:|Filename:)' > ${TMP}/../Packages_mipsel | 371 | egrep '^(Package:|Filename:)' > ${TMP}/Packages_mipsel |
221 for pkg in ${BASE_PACKAGES} ; do | 372 for pkg in ${BASE_PACKAGES} ; do |
222 grep -A 1 "${pkg}\$" ${TMP}/../Packages_mipsel\ | 373 grep -A 1 "${pkg}\$" ${TMP}/Packages_mipsel\ |
223 | egrep -o "pool/.*" >> ${TMP_PACKAGELIST_MIPS32} | 374 | egrep -o "pool/.*" >> ${TMP_PACKAGELIST_MIPS32} |
224 done | 375 done |
225 } | 376 } |
226 | 377 |
227 InstallMissingLibraries() { | 378 InstallMissingLibraries() { |
228 readonly DEP_FILES_NEEDED_MIPS32=$(cat ${TMP_PACKAGELIST_MIPS32}) | 379 readonly DEP_FILES_NEEDED_MIPS32=$(cat ${TMP_PACKAGELIST_MIPS32}) |
229 for file in ${DEP_FILES_NEEDED_MIPS32} ; do | 380 for file in ${DEP_FILES_NEEDED_MIPS32} ; do |
230 local package="${TMP}/${file##*/}" | 381 local package="${TMP}/${file##*/}" |
231 Banner "installing ${file}" | 382 Banner "installing ${file}" |
232 DownloadOrCopy ${REPO_DEBIAN}/${file} ${package} | 383 DownloadOrCopy ${REPO_DEBIAN}/${file} nochecksum |
233 SubBanner "extracting to ${JAIL_MIPS32}" | 384 SubBanner "extracting to ${JAIL_MIPS32}" |
234 dpkg --fsys-tarfile ${package}\ | 385 dpkg --fsys-tarfile ${package}\ |
235 | tar -xvf - --exclude=./usr/share -C ${JAIL_MIPS32} | 386 | tar -xvf - --exclude=./usr/share -C ${JAIL_MIPS32} |
236 done | 387 done |
237 | 388 |
238 Banner "some cleanup" | 389 Banner "some cleanup" |
239 | 390 |
240 pushd ${JAIL_MIPS32}/usr/lib/ | 391 pushd ${JAIL_MIPS32}/usr/lib/ |
241 cleanlinks > /dev/null 2> /dev/null | 392 cleanlinks > /dev/null 2> /dev/null |
242 FixLibs | 393 FixLibs |
(...skipping 13 matching lines...) Expand all Loading... | |
256 ln -s ../../lib/libdl.so.2 libdl.so | 407 ln -s ../../lib/libdl.so.2 libdl.so |
257 | 408 |
258 rm -f librt.so | 409 rm -f librt.so |
259 ln -s ../../lib/librt.so.1 librt.so | 410 ln -s ../../lib/librt.so.1 librt.so |
260 | 411 |
261 rm -f libpcre.so | 412 rm -f libpcre.so |
262 ln -s ../../lib/libpcre.so.3 libpcre.so | 413 ln -s ../../lib/libpcre.so.3 libpcre.so |
263 | 414 |
264 rm -f libresolv.so | 415 rm -f libresolv.so |
265 ln -s ../../lib/libresolv.so.2 libresolv.so | 416 ln -s ../../lib/libresolv.so.2 libresolv.so |
266 | |
267 echo "OUTPUT_FORMAT(elf32-tradlittlemips)" > libc.so | |
268 echo "GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld.so.1 ) )" >> libc.so | |
269 | |
270 echo "OUTPUT_FORMAT(elf32-tradlittlemips)" > libpthread.so | |
271 echo "GROUP ( libpthread.so.0 libpthread_nonshared.a )" >> libpthread.so | |
272 } | 417 } |
273 | 418 |
274 BuildAndInstallQemu() { | 419 BuildAndInstallQemu() { |
275 local saved_dir=$(pwd) | 420 local saved_dir=$(pwd) |
276 local tmpdir="${TMP}/qemu-mips.nacl" | 421 local tmpdir="${TMP}/qemu-mips.nacl" |
277 local tarball="qemu-0.12.5.tar.gz" | 422 local tarball="qemu-0.12.5.tar.gz" |
278 Banner "Building qemu in ${tmpdir}" | 423 Banner "Building qemu in ${tmpdir}" |
279 rm -rf ${tmpdir} | 424 rm -rf ${tmpdir} |
280 mkdir ${tmpdir} | 425 mkdir ${tmpdir} |
281 cd ${tmpdir} | 426 cd ${tmpdir} |
(...skipping 26 matching lines...) Expand all Loading... | |
308 SubBanner "Make" | 453 SubBanner "Make" |
309 env -i PATH=/usr/bin/:/bin \ | 454 env -i PATH=/usr/bin/:/bin \ |
310 make MAKE_OPTS=${MAKE_OPTS} | 455 make MAKE_OPTS=${MAKE_OPTS} |
311 | 456 |
312 SubBanner "Install" | 457 SubBanner "Install" |
313 cp mipsel-linux-user/qemu-mipsel ${INSTALL_ROOT}/qemu-mips32 | 458 cp mipsel-linux-user/qemu-mipsel ${INSTALL_ROOT}/qemu-mips32 |
314 cd ${saved_dir} | 459 cd ${saved_dir} |
315 cp tools/trusted_cross_toolchains/qemu_tool_mips32.sh ${INSTALL_ROOT} | 460 cp tools/trusted_cross_toolchains/qemu_tool_mips32.sh ${INSTALL_ROOT} |
316 ln -sf qemu_tool_mips32.sh ${INSTALL_ROOT}/run_under_qemu_mips32 | 461 ln -sf qemu_tool_mips32.sh ${INSTALL_ROOT}/run_under_qemu_mips32 |
317 } | 462 } |
463 | |
318 ###################################################################### | 464 ###################################################################### |
319 # Main | 465 # Main |
320 ###################################################################### | 466 ###################################################################### |
321 | 467 |
322 if [[ $# -eq 0 ]] ; then | 468 if [[ $# -eq 0 ]] ; then |
323 echo "you must specify a mode on the commandline:" | 469 echo "you must specify a mode on the commandline:" |
324 echo | 470 echo |
325 Usage | 471 Usage |
326 exit -1 | 472 exit -1 |
327 | 473 |
328 elif [[ $1 == "trusted_sdk" ]]; then | 474 elif [[ $1 == "trusted_sdk" ]]; then |
329 mkdir -p ${TMP} | 475 mkdir -p ${TMP} |
330 SanityCheck | 476 SanityCheck |
331 ClearInstallDir | 477 ClearInstallDir |
332 DownloadOrCopyAndInstallCodeSourceryTarball | 478 ClearBuildDir |
333 PruneDirs | 479 DownloadOrCopyAndInstallToolchain |
334 GeneratePackageLists | 480 GeneratePackageLists |
335 InstallMissingHeaders | |
336 InstallMissingLibraries | 481 InstallMissingLibraries |
337 MissingSharedLibCleanup | |
338 InstallTrustedLinkerScript | 482 InstallTrustedLinkerScript |
339 BuildAndInstallQemu | 483 BuildAndInstallQemu |
340 CreateTarBall $1 | 484 CreateTarBall $1 |
341 | 485 |
342 else | 486 else |
343 Usage | 487 Usage |
344 exit -1 | 488 exit -1 |
345 | 489 |
346 fi | 490 fi |
347 | 491 |
OLD | NEW |