Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: platform_tools/barelinux/bin/arm64_download

Issue 239243005: arm64_download script waits for VM to boot before finishing. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 set -e
epoger 2014/04/15 19:33:06 Note that "set -e" can have its pitfalls. See htt
10
9 usage() { 11 usage() {
10 cat >&2 <<EOF 12 cat >&2 <<EOF
11 arm64_download - this script downloads the Linaro's ARMv8 Aarch64 13 arm64_download - this script downloads the Linaro's ARMv8 Aarch64
12 toolchain and minimal embedded Linux system as well as ARM's 14 toolchain and minimal embedded Linux system as well as ARM's
13 foundation model. The required files are mirrored on Google Cloud. 15 foundation model. The required files are mirrored on Google Cloud.
14 16
15 If the files are already located in the working directory, the 17 If the files are already located in the working directory, the
16 download can be skipped if the checksums match. 18 download can be skipped if the checksums match.
17 19
18 The script then starts a emulated Arm64 Linux system in the 20 The script then starts a emulated Arm64 Linux system in the
19 background. After the boot is complete, you can SSH into the system 21 background. After the boot is complete, you can SSH into the system
20 at port 8022 via user@localhost. The SSH key will be downloaded into 22 at port 8022 via user@localhost. The SSH key will be downloaded into
21 the working directery as well. 23 the working directery as well.
22 24
23 Requires gsutil, xz, tar, and gunzip. 25 Requires gsutil, xz, tar, md5sum, and gunzip.
24 26
25 Usage: 27 Usage:
26 $0 WORKING_DIRECTORY 28 $0 WORKING_DIRECTORY
27 ssh-add WORKING_DIRECTORY/key 29 ssh-add WORKING_DIRECTORY/key
28 ...wait... 30 ...wait...
29 ssh -p 8022 user@localhost 31 ssh -p 8022 user@localhost
30 EOF 32 EOF
31 return 1 33 return 1
32 } 34 }
33 35
34 try() {
35 # print an error on nonzero return code
36 "$@"
37 local ret=$?
38 if [ $ret != 0 ] ; then
39 echo "'$@' failed and returned ${ret}." >&2
40 return $ret
41 fi
42 }
43
44 download_necessary_software_to_dir() ( 36 download_necessary_software_to_dir() (
37 echo 'Downloading necessary software.'
45 cd "$1" 38 cd "$1"
46 local location="chromium-skia-gm/arm64env" 39 local location="chromium-skia-gm/arm64env"
47 try gsutil cp "gs://${location}/md5sum.txt" . || return 40 gsutil cp "gs://${location}/md5sum.txt" . 2> /dev/null
48 if md5sum -c --quiet "md5sum.txt"; then 41 if ! md5sum -c --quiet "md5sum.txt"; then
49 return 0 42 gsutil cp "gs://${location}/*" .
50 fi 43 fi
51 try gsutil cp "gs://${location}/*" . || return 44 echo 'Done.'
52 ) 45 )
53 46
54 install_compiler() { 47 install_compiler() {
55 local working_dir="$1" 48 local working_dir="$1"
56 local toolchain="gcc-linaro-aarch64-linux-gnu-4.8-2013.12_linux" 49 local toolchain="gcc-linaro-aarch64-linux-gnu-4.8-2013.12_linux"
57 ( 50 (
58 try cd "$working_dir" || return 51 cd "$working_dir"
59 try test -f "${toolchain}.tar.xz" || return 52 test -f "${toolchain}.tar.xz"
60 try xz --decompress --stdout < "${toolchain}.tar.xz" | \ 53 xz --decompress --stdout < "${toolchain}.tar.xz" | \
61 try tar xf - || return 54 tar xf -
62 ) 55 )
63 local dir="${working_dir}/${toolchain}" 56 local dir="${working_dir}/${toolchain}"
64 try test -d "$dir" || return 57 test -d "$dir"
65 try test -x "${dir}/bin/aarch64-linux-gnu-gcc" || return 58 test -x "${dir}/bin/aarch64-linux-gnu-gcc"
66 try test -x "${dir}/bin/aarch64-linux-gnu-g++" || return 59 test -x "${dir}/bin/aarch64-linux-gnu-g++"
67 } 60 }
68 61
69 install_runtime() { 62 install_runtime() {
70 local working_dir="$1" 63 local working_dir="$1"
71 64
72 local firmware='img-foundation.axf' 65 local firmware='img-foundation.axf'
73 local rootfs='vexpress64-openembedded_lamp-armv8-gcc-4.8_20131215-557' 66 local rootfs='vexpress64-openembedded_lamp-armv8-gcc-4.8_20131215-557'
74 local compressed_rootfs="${rootfs}.img.CLEAN_AND_CONFIGURED.xz" 67 local compressed_rootfs="${rootfs}.img.CLEAN_AND_CONFIGURED.xz"
75 local compressed_foundation_model='FM000-KT-00035-r0p8-52rel06.tgz' 68 local compressed_foundation_model='FM000-KT-00035-r0p8-52rel06.tgz'
76 local keyfile='CLEAN_AND_CONFIGURED_key' 69 local keyfile='CLEAN_AND_CONFIGURED_key'
77 70
78 try cp "${working_dir}/$firmware" "${working_dir}/firmware" || return 71 echo 'Installing runtime files.'
72 cp "${working_dir}/$firmware" "${working_dir}/firmware"
79 73
80 try xz --decompress --stdout \ 74 xz --decompress --stdout \
81 < "${working_dir}/${compressed_rootfs}" \ 75 < "${working_dir}/${compressed_rootfs}" \
82 > "${working_dir}/rootfs" || return 76 > "${working_dir}/rootfs"
83 try test -f "${working_dir}/rootfs" || return 77 test -f "${working_dir}/rootfs"
84 78
85 ( 79 (
86 try cd "$working_dir" || return 80 cd "$working_dir"
87 try test -f "$compressed_foundation_model" || return 81 test -f "$compressed_foundation_model"
88 try gunzip -c "$compressed_foundation_model" | try tar xf - || return 82 gunzip -c "$compressed_foundation_model" | tar xf -
89 try test -d "Foundation_v8pkg" || return # Assert. 83 test -d "Foundation_v8pkg" # Assert.
90 ) 84 )
91 85
92 try cp "${working_dir}/${keyfile}" "${working_dir}/key" || return 86 cp "${working_dir}/${keyfile}" "${working_dir}/key"
93 chmod 'go=' "${working_dir}/key" 87 chmod 'go=' "${working_dir}/key"
88 echo 'Done.'
94 } 89 }
95 90
96 start_arm64_image() { 91 start_arm64_image() {
97 local working_dir="$1" 92 local working_dir="$1"
98 local foundation_dir="${working_dir}/Foundation_v8pkg" 93 local foundation_dir="${working_dir}/Foundation_v8pkg"
99 local foundation="${foundation_dir}/models/Linux64_GCC-4.1/Foundation_v8" 94 local foundation="${foundation_dir}/models/Linux64_GCC-4.1/Foundation_v8"
100 local firmware="${working_dir}/firmware" 95 local firmware="${working_dir}/firmware"
101 local rootfs="${working_dir}/rootfs" 96 local rootfs="${working_dir}/rootfs"
102 97
103 try test -d "$foundation_dir" || return 98 test -d "$foundation_dir"
104 try test -x "$foundation" || return 99 test -x "$foundation"
105 try test -f "$firmware" || return 100 test -f "$firmware"
106 try test -f "$rootfs" || return 101 test -f "$rootfs"
107 102
108 for PID in $(ps -o 'pid=' -C 'Foundation_v8') ; do 103 for PID in $(ps -o 'pid=' -C 'Foundation_v8') ; do
109 kill $PID 104 kill $PID
110 done 105 done
111 106
112 DISPLAY='' nohup \ 107 DISPLAY='' nohup \
113 "$foundation" \ 108 "$foundation" \
114 --image="${firmware}" \ 109 --image="${firmware}" \
115 --cores=4 \ 110 --cores=4 \
116 --block-device="${rootfs}" \ 111 --block-device="${rootfs}" \
117 --network="nat" \ 112 --network="nat" \
118 --network-nat-subnet="192.168.31.0/24" \ 113 --network-nat-subnet="192.168.31.0/24" \
119 --network-nat-ports="8022=22" \ 114 --network-nat-ports="8022=22" \
120 > /dev/null 2>&1 & 115 > /dev/null 2>&1 &
116 echo 'Waiting for foundation model to boot...'
117 while ! ssh -i "${working_dir}/key" \
118 -o NoHostAuthenticationForLocalhost=yes \
119 -p 8022 user@localhost true 2> /dev/null; do
120 sleep 5 ;
121 done
121 echo 'Listening to SSH on port 8022.' 122 echo 'Listening to SSH on port 8022.'
122 } 123 }
123 124
124 arm64_download() { 125 arm64_download() {
125 local working_directory="$1" 126 local working_directory="$1"
126 try mkdir -p "$working_directory" || return 127 mkdir -p "$working_directory"
127 128
128 try download_necessary_software_to_dir "$working_directory" || return 129 download_necessary_software_to_dir "$working_directory"
129 130
130 try install_compiler "$working_directory" || return 131 install_compiler "$working_directory"
131 132
132 try install_runtime "$working_directory" || return 133 install_runtime "$working_directory"
133 134
134 try start_arm64_image "$working_directory" || return 135 start_arm64_image "$working_directory"
135
136 try start_arm64_image \
137 "$working_directory" \
138 || return
139 } 136 }
140 137
141 for command in gsutil xz tar md5sum gunzip; do 138 for command in gsutil xz tar md5sum gunzip; do
142 try command -v "$command" > /dev/null || usage || exit 139 command -v "$command" > /dev/null || usage
143 done 140 done
144 141
145 if [ -z "$1" ] ; then 142 if [ -z "$1" ] ; then
146 usage || exit 143 usage
147 fi 144 fi
148 try arm64_download "$1" 145
146 arm64_download "$1"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698