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

Side by Side Diff: build/install-build-deps.sh

Issue 10166023: Add a --no-prompt flag to install quietly. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Change option name to make it means less and 'do' more. Created 8 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 | Annotate | Revision Log
« 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/bash -e 1 #!/bin/bash -e
2 2
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # Script to install everything needed to build chromium (well, ideally, anyway) 7 # Script to install everything needed to build chromium (well, ideally, anyway)
8 # See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions 8 # See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions
9 # and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit 9 # and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit
10 10
11 usage() { 11 usage() {
12 echo "Usage: $0 [--options]" 12 echo "Usage: $0 [--options]"
13 echo "Options:" 13 echo "Options:"
14 echo "--[no-]syms: enable or disable installation of debugging symbols" 14 echo "--[no-]syms: enable or disable installation of debugging symbols"
15 echo "--[no-]lib32: enable or disable installation of 32 bit libraries" 15 echo "--[no-]lib32: enable or disable installation of 32 bit libraries"
16 echo "--no-prompt: silently select standard options/defaults"
16 echo "Script will prompt interactively if options not given." 17 echo "Script will prompt interactively if options not given."
17 exit 1 18 exit 1
18 } 19 }
19 20
20 while test "$1" != "" 21 while test "$1" != ""
21 do 22 do
22 case "$1" in 23 case "$1" in
23 --syms) do_inst_syms=1;; 24 --syms) do_inst_syms=1;;
24 --no-syms) do_inst_syms=0;; 25 --no-syms) do_inst_syms=0;;
25 --lib32) do_inst_lib32=1;; 26 --lib32) do_inst_lib32=1;;
26 --no-lib32) do_inst_lib32=0;; 27 --no-lib32) do_inst_lib32=0;;
28 --no-prompt) do_default=1
29 do_inst_syms=${do_inst_syms-0}
30 do_inst_lib32=${do_inst_lib32-0}
cmp 2012/04/21 23:49:26 Hi Peter, I still think lines 29-30 should be rem
31 do_quietly="-qq --assume-yes"
32 ;;
27 *) usage;; 33 *) usage;;
28 esac 34 esac
29 shift 35 shift
30 done 36 done
31 37
32 if ! egrep -q \ 38 if ! egrep -q \
33 'Ubuntu (10\.04|10\.10|11\.04|11\.10|12\.04|lucid|maverick|natty|oneiric|pre cise)' \ 39 'Ubuntu (10\.04|10\.10|11\.04|11\.10|12\.04|lucid|maverick|natty|oneiric|pre cise)' \
34 /etc/issue; then 40 /etc/issue; then
35 echo "Only Ubuntu 10.04 (lucid) through 12.04 (precise) are currently" \ 41 echo "Only Ubuntu 10.04 (lucid) through 12.04 (precise) are currently" \
36 "supported" >&2 42 "supported" >&2
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 lib_list="$lib_list appmenu-gtk" 121 lib_list="$lib_list appmenu-gtk"
116 fi 122 fi
117 123
118 # Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is 124 # Waits for the user to press 'Y' or 'N'. Either uppercase of lowercase is
119 # accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has 125 # accepted. Returns 0 for 'Y' and 1 for 'N'. If an optional parameter has
120 # been provided to yes_no(), the function also accepts RETURN as a user input. 126 # been provided to yes_no(), the function also accepts RETURN as a user input.
121 # The parameter specifies the exit code that should be returned in that case. 127 # The parameter specifies the exit code that should be returned in that case.
122 # The function will echo the user's selection followed by a newline character. 128 # The function will echo the user's selection followed by a newline character.
123 # Users can abort the function by pressing CTRL-C. This will call "exit 1". 129 # Users can abort the function by pressing CTRL-C. This will call "exit 1".
124 yes_no() { 130 yes_no() {
131 if [ 0 -ne "${do_default-0}" ] ; then
132 return $1
133 fi
125 local c 134 local c
126 while :; do 135 while :; do
127 c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT 136 c="$(trap 'stty echo -iuclc icanon 2>/dev/null' EXIT INT TERM QUIT
128 stty -echo iuclc -icanon 2>/dev/null 137 stty -echo iuclc -icanon 2>/dev/null
129 dd count=1 bs=1 2>/dev/null | od -An -tx1)" 138 dd count=1 bs=1 2>/dev/null | od -An -tx1)"
130 case "$c" in 139 case "$c" in
131 " 0a") if [ -n "$1" ]; then 140 " 0a") if [ -n "$1" ]; then
132 [ $1 -eq 0 ] && echo "Y" || echo "N" 141 [ $1 -eq 0 ] && echo "Y" || echo "N"
133 return $1 142 return $1
134 fi 143 fi
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 182
174 # We initially run "apt-get" with the --reinstall option and parse its output. 183 # We initially run "apt-get" with the --reinstall option and parse its output.
175 # This way, we can find all the packages that need to be newly installed 184 # This way, we can find all the packages that need to be newly installed
176 # without accidentally promoting any packages from "auto" to "manual". 185 # without accidentally promoting any packages from "auto" to "manual".
177 # We then re-run "apt-get" with just the list of missing packages. 186 # We then re-run "apt-get" with just the list of missing packages.
178 echo "Finding missing packages..." 187 echo "Finding missing packages..."
179 packages="${dev_list} ${lib_list} ${dbg_list} ${plugin_list}" 188 packages="${dev_list} ${lib_list} ${dbg_list} ${plugin_list}"
180 # Intentionally leaving $packages unquoted so it's more readable. 189 # Intentionally leaving $packages unquoted so it's more readable.
181 echo "Packages required: " $packages 190 echo "Packages required: " $packages
182 echo 191 echo
183 new_list_cmd="sudo apt-get install --reinstall $(echo $packages)" 192 new_list_cmd="sudo apt-get install --reinstall ${do_quietly-} $(echo $packages)"
184 if new_list="$(yes n | LANG=C $new_list_cmd)"; then 193 if new_list="$(yes n | LANG=C $new_list_cmd)"; then
185 # We probably never hit this following line. 194 # We probably never hit this following line.
186 echo "No missing packages, and the packages are up-to-date." 195 echo "No missing packages, and the packages are up-to-date."
187 elif [ $? -eq 1 ]; then 196 elif [ $? -eq 1 ]; then
188 # We expect apt-get to have exit status of 1. 197 # We expect apt-get to have exit status of 1.
189 # This indicates that we cancelled the install with "yes n|". 198 # This indicates that we cancelled the install with "yes n|".
190 new_list=$(echo "$new_list" | 199 new_list=$(echo "$new_list" |
191 sed -e '1,/The following NEW packages will be installed:/d;s/^ //;t;d') 200 sed -e '1,/The following NEW packages will be installed:/d;s/^ //;t;d')
192 new_list=$(echo "$new_list" | sed 's/ *$//') 201 new_list=$(echo "$new_list" | sed 's/ *$//')
193 if [ -z "$new_list" ] ; then 202 if [ -z "$new_list" ] ; then
194 echo "No missing packages, and the packages are up-to-date." 203 echo "No missing packages, and the packages are up-to-date."
195 else 204 else
196 echo "Installing missing packages: $new_list." 205 echo "Installing missing packages: $new_list."
197 sudo apt-get install ${new_list} 206 sudo apt-get install ${do_quietly-} ${new_list}
198 fi 207 fi
199 echo 208 echo
200 else 209 else
201 # An apt-get exit status of 100 indicates that a real error has occurred. 210 # An apt-get exit status of 100 indicates that a real error has occurred.
202 211
203 # I am intentionally leaving out the '"'s around new_list_cmd, 212 # I am intentionally leaving out the '"'s around new_list_cmd,
204 # as this makes it easier to cut and paste the output 213 # as this makes it easier to cut and paste the output
205 echo "The following command failed: " ${new_list_cmd} 214 echo "The following command failed: " ${new_list_cmd}
206 echo 215 echo
207 echo "It produces the following output:" 216 echo "It produces the following output:"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 sed -e 's/[.]so[.][0-9].*/.so/' | 400 sed -e 's/[.]so[.][0-9].*/.so/' |
392 sort -u); do 401 sort -u); do
393 [ "x${i##*/}" = "xld-linux.so" ] && continue 402 [ "x${i##*/}" = "xld-linux.so" ] && continue
394 [ -r "$i" ] && continue 403 [ -r "$i" ] && continue
395 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' | 404 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' |
396 sort -n | tail -n 1)" 405 sort -n | tail -n 1)"
397 [ -r "$i.$j" ] || continue 406 [ -r "$i.$j" ] || continue
398 sudo ln -s "${i##*/}.$j" "$i" 407 sudo ln -s "${i##*/}.$j" "$i"
399 done 408 done
400 fi 409 fi
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