| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 | 2 |
| 3 # Copyright 2014 Google Inc. | 3 # Copyright 2014 Google Inc. |
| 4 # | 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
| 7 | 7 |
| 8 | 8 |
| 9 usage() { | 9 usage() { |
| 10 cat >&2 <<EOF | 10 cat >&2 <<EOF |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 try() { | 34 try() { |
| 35 # print an error on nonzero return code | 35 # print an error on nonzero return code |
| 36 "$@" | 36 "$@" |
| 37 local ret=$? | 37 local ret=$? |
| 38 if [ $ret != 0 ] ; then | 38 if [ $ret != 0 ] ; then |
| 39 echo "'$@' failed and returned ${ret}." >&2 | 39 echo "'$@' failed and returned ${ret}." >&2 |
| 40 return $ret | 40 return $ret |
| 41 fi | 41 fi |
| 42 } | 42 } |
| 43 | 43 |
| 44 gsutil_check_get() { | 44 download_necessary_software_to_dir() ( |
| 45 local gurl="$1" | 45 cd "$1" |
| 46 local file="$2" | 46 local location="chromium-skia-gm/arm64env" |
| 47 if ! [ -f "$file" ] || \ | 47 try gsutil cp "gs://${location}/md5sum.txt" . || return |
| 48 [ "$(gsutil ls -L "$gurl" | sed -n 's/\W*Hash (md5):\W*//p')" \ | 48 if md5sum -c --quiet "md5sum.txt"; then |
| 49 != "$(md5sum < "$file" | sed 's/\W*-//')" ] ; then | 49 return 0 |
| 50 try gsutil cp "$gurl" "$file" || return | |
| 51 fi | 50 fi |
| 52 } | 51 try gsutil cp "gs://${location}/*" . || return |
| 52 ) |
| 53 | 53 |
| 54 download_compiler() { | 54 install_compiler() { |
| 55 local working_dir="$1" | 55 local working_dir="$1" |
| 56 local location="$2" | 56 local toolchain="gcc-linaro-aarch64-linux-gnu-4.8-2013.12_linux" |
| 57 local toolchain="$3" | |
| 58 | |
| 59 try cd "$working_dir" || return | |
| 60 | |
| 61 try gsutil_check_get "gs://${location}/${toolchain}.tar.xz" \ | |
| 62 "${working_dir}/${toolchain}.tar.xz" || return | |
| 63 ( | 57 ( |
| 64 cd "$working_dir" | 58 try cd "$working_dir" || return |
| 65 xz --decompress --stdout < "${toolchain}.tar.xz" | tar xf - | 59 try test -f "${toolchain}.tar.xz" || return |
| 60 try xz --decompress --stdout < "${toolchain}.tar.xz" | \ |
| 61 try tar xf - || return |
| 66 ) | 62 ) |
| 67 local dir="${working_dir}/${toolchain}" | 63 local dir="${working_dir}/${toolchain}" |
| 68 try test -d "$dir" || return | 64 try test -d "$dir" || return |
| 69 try test -x "${dir}/bin/aarch64-linux-gnu-gcc" || return | 65 try test -x "${dir}/bin/aarch64-linux-gnu-gcc" || return |
| 70 try test -x "${dir}/bin/aarch64-linux-gnu-g++" || return | 66 try test -x "${dir}/bin/aarch64-linux-gnu-g++" || return |
| 71 } | 67 } |
| 72 | 68 |
| 73 download_runtime() { | 69 install_runtime() { |
| 74 local working_dir="$1" | 70 local working_dir="$1" |
| 75 local location="$2" | |
| 76 local firmware="$3" | |
| 77 local compressed_rootfs="$4" | |
| 78 local compressed_foundation_model="$5" | |
| 79 local keyfile="$6" | |
| 80 | 71 |
| 81 try gsutil_check_get "gs://${location}/${firmware}" \ | 72 local firmware='img-foundation.axf' |
| 82 "${working_dir}/firmware" || return | 73 local rootfs='vexpress64-openembedded_lamp-armv8-gcc-4.8_20131215-557' |
| 74 local compressed_rootfs="${rootfs}.img.CLEAN_AND_CONFIGURED.xz" |
| 75 local compressed_foundation_model='FM000-KT-00035-r0p8-52rel06.tgz' |
| 76 local keyfile='CLEAN_AND_CONFIGURED_key' |
| 83 | 77 |
| 84 try gsutil_check_get "gs://${location}/${compressed_rootfs}" \ | 78 try cp "${working_dir}/$firmware" "${working_dir}/firmware" || return |
| 85 "${working_dir}/${compressed_rootfs}" || return | |
| 86 | 79 |
| 87 try xz --decompress --stdout \ | 80 try xz --decompress --stdout \ |
| 88 < "${working_dir}/${compressed_rootfs}" \ | 81 < "${working_dir}/${compressed_rootfs}" \ |
| 89 > "${working_dir}/rootfs" || return | 82 > "${working_dir}/rootfs" || return |
| 90 try test -f "${working_dir}/rootfs" || return | 83 try test -f "${working_dir}/rootfs" || return |
| 91 | 84 |
| 92 try gsutil_check_get "gs://${location}/${compressed_foundation_model}" \ | |
| 93 "${working_dir}/${compressed_foundation_model}" || return | |
| 94 ( | 85 ( |
| 95 try cd "$working_dir" || return | 86 try cd "$working_dir" || return |
| 87 try test -f "$compressed_foundation_model" || return |
| 96 try gunzip -c "$compressed_foundation_model" | try tar xf - || return | 88 try gunzip -c "$compressed_foundation_model" | try tar xf - || return |
| 97 try test -d "Foundation_v8pkg" || return # Assert. | 89 try test -d "Foundation_v8pkg" || return # Assert. |
| 98 ) | 90 ) |
| 99 | 91 |
| 100 try gsutil_check_get "gs://${location}/${keyfile}" \ | 92 try cp "${working_dir}/${keyfile}" "${working_dir}/key" || return |
| 101 "${working_dir}/key" || return | 93 chmod 'go=' "${working_dir}/key" |
| 102 chmod go= "${working_dir}/key" | |
| 103 } | 94 } |
| 104 | 95 |
| 105 start_arm64_image() { | 96 start_arm64_image() { |
| 106 local working_dir="$1" | 97 local working_dir="$1" |
| 107 local foundation_dir="${working_dir}/Foundation_v8pkg" | 98 local foundation_dir="${working_dir}/Foundation_v8pkg" |
| 108 local foundation="${foundation_dir}/models/Linux64_GCC-4.1/Foundation_v8" | 99 local foundation="${foundation_dir}/models/Linux64_GCC-4.1/Foundation_v8" |
| 109 local firmware="${working_dir}/firmware" | 100 local firmware="${working_dir}/firmware" |
| 110 local rootfs="${working_dir}/rootfs" | 101 local rootfs="${working_dir}/rootfs" |
| 111 | 102 |
| 112 try test -d "$foundation_dir" || return | 103 try test -d "$foundation_dir" || return |
| (...skipping 12 matching lines...) Expand all Loading... |
| 125 --block-device="${rootfs}" \ | 116 --block-device="${rootfs}" \ |
| 126 --network="nat" \ | 117 --network="nat" \ |
| 127 --network-nat-subnet="192.168.31.0/24" \ | 118 --network-nat-subnet="192.168.31.0/24" \ |
| 128 --network-nat-ports="8022=22" \ | 119 --network-nat-ports="8022=22" \ |
| 129 > /dev/null 2>&1 & | 120 > /dev/null 2>&1 & |
| 130 echo 'Listening to SSH on port 8022.' | 121 echo 'Listening to SSH on port 8022.' |
| 131 } | 122 } |
| 132 | 123 |
| 133 arm64_download() { | 124 arm64_download() { |
| 134 local working_directory="$1" | 125 local working_directory="$1" |
| 135 local location="chromium-skia-gm/arm64env" | |
| 136 try mkdir -p "$working_directory" || return | 126 try mkdir -p "$working_directory" || return |
| 137 | 127 |
| 138 try download_compiler \ | 128 try download_necessary_software_to_dir "$working_directory" || return |
| 139 "$working_directory" \ | |
| 140 "$location" \ | |
| 141 'gcc-linaro-aarch64-linux-gnu-4.8-2013.12_linux' \ | |
| 142 || return | |
| 143 | 129 |
| 144 local rootfs='vexpress64-openembedded_lamp-armv8-gcc-4.8_20131215-557' | 130 try install_compiler "$working_directory" || return |
| 145 try download_runtime \ | 131 |
| 146 "$working_directory" \ | 132 try install_runtime "$working_directory" || return |
| 147 "$location" \ | 133 |
| 148 'img-foundation.axf' \ | 134 try start_arm64_image "$working_directory" || return |
| 149 "${rootfs}.img.CLEAN_AND_CONFIGURED.xz" \ | |
| 150 'FM000-KT-00035-r0p8-52rel06.tgz' \ | |
| 151 'CLEAN_AND_CONFIGURED_key' \ | |
| 152 || return | |
| 153 | 135 |
| 154 try start_arm64_image \ | 136 try start_arm64_image \ |
| 155 "$working_directory" \ | 137 "$working_directory" \ |
| 156 || return | 138 || return |
| 157 | |
| 158 } | 139 } |
| 159 | 140 |
| 160 for command in gsutil xz tar gunzip; do | 141 for command in gsutil xz tar md5sum gunzip; do |
| 161 try command -v "$command" > /dev/null || usage || exit | 142 try command -v "$command" > /dev/null || usage || exit |
| 162 done | 143 done |
| 163 | 144 |
| 164 if [ -z "$1" ] ; then | 145 if [ -z "$1" ] ; then |
| 165 usage || exit | 146 usage || exit |
| 166 fi | 147 fi |
| 167 try arm64_download "$1" || exit | 148 try arm64_download "$1" |
| OLD | NEW |