Chromium Code Reviews| Index: user_tools/linux/recovery.sh |
| diff --git a/user_tools/linux/recovery.sh b/user_tools/linux/recovery.sh |
| index f5c2fae0b8f10d8e5b6f27a899b3301972ed4492..d1e07c622afd4d87af1aaeb75dff26d2611427b0 100755 |
| --- a/user_tools/linux/recovery.sh |
| +++ b/user_tools/linux/recovery.sh |
| @@ -113,7 +113,7 @@ require_utils() { |
| local tool |
| local tmp |
| - external='cat cut dd grep ls mkdir mount readlink sed sync tr umount unzip wc' |
| + external='cat cut dd grep ls mkdir mount readlink sed sync umount unzip wc' |
|
scottz
2010/12/09 01:47:25
md5sum openssl sha1sum
I assume you leave wget/cu
Bill Richardson
2010/12/09 17:34:29
Yes, just below.
scottz
2010/12/09 18:04:27
Ahh I missed that :)
On 2010/12/09 17:34:29, Bil
|
| if [ -z "$WORKDIR" ]; then |
| external="$external mktemp" |
| fi |
| @@ -231,13 +231,13 @@ compute_checksum() { |
| if [ "$CHECK" = "openssl" ]; then |
| openssl md5 < "$filename" |
| else |
| - $CHECK "$tarball" | cut -d' ' -f1 |
| + $CHECK "$zipfile" | cut -d' ' -f1 |
| fi |
| } |
| ############################################################################## |
| -# Helper functions to handle the config file and image tarball. |
| +# Helper functions to handle the config file and image zipfile. |
| # Each paragraph in the config file should describe a new image. Let's make |
| # sure it follows all the rules. This scans the config file and returns success |
| @@ -248,9 +248,10 @@ good_config() { |
| local line |
| local key |
| local val |
| - local display_name |
| + local name |
| local file |
| - local size |
| + local zipfilesize |
| + local filesize |
| local url |
| local md5 |
| local sha1 |
| @@ -259,9 +260,10 @@ good_config() { |
| local count |
| local line_num |
| - display_name= |
| + name= |
| file= |
| - size= |
| + zipfilesize= |
| + filesize= |
| url= |
| md5= |
| sha1= |
| @@ -298,12 +300,12 @@ good_config() { |
| fi |
| case $key in |
| - display_name) |
| - if [ -n "$display_name" ]; then |
| + name) |
| + if [ -n "$name" ]; then |
| DEBUG "duplicate $key" |
| errors=yes |
| fi |
| - display_name="$val" |
| + name="$val" |
| ;; |
| file) |
| if [ -n "$file" ]; then |
| @@ -312,12 +314,19 @@ good_config() { |
| fi |
| file="$val" |
| ;; |
| - size) |
| - if [ -n "$size" ]; then |
| + zipfilesize) |
| + if [ -n "$zipfilesize" ]; then |
| DEBUG "duplicate $key" |
| errors=yes |
| fi |
| - size="$val" |
| + zipfilesize="$val" |
| + ;; |
| + filesize) |
| + if [ -n "$filesize" ]; then |
| + DEBUG "duplicate $key" |
| + errors=yes |
| + fi |
| + filesize="$val" |
| ;; |
| url) |
| url="$val" |
| @@ -334,16 +343,20 @@ good_config() { |
| end_lines="$end_lines $line_num" |
| count=$(( count + 1)) |
| - if [ -z "$display_name" ]; then |
| - DEBUG "image $count is missing display_name" |
| + if [ -z "$name" ]; then |
| + DEBUG "image $count is missing name" |
| errors=yes |
| fi |
| if [ -z "$file" ]; then |
| DEBUG "image $count is missing file" |
| errors=yes |
| fi |
| - if [ -z "$size" ]; then |
| - DEBUG "image $count is missing size" |
| + if [ -z "$zipfilesize" ]; then |
| + DEBUG "image $count is missing zipfilesize" |
| + errors=yes |
| + fi |
| + if [ -z "$filesize" ]; then |
| + DEBUG "image $count is missing filesize" |
| errors=yes |
| fi |
| if [ -z "$url" ]; then |
| @@ -360,9 +373,10 @@ good_config() { |
| fi |
| # Prepare for next stanza |
| - display_name= |
| + name= |
| file= |
| - size= |
| + zipfilesize= |
| + filesize= |
| url= |
| md5= |
| sha1= |
| @@ -403,13 +417,13 @@ choose_image() { |
| echo "0 - <quit>" |
| # NOTE: making assumptions about the order of lines in each stanza! |
| while read line; do |
| - if echo "$line" | grep -q '^display_name='; then |
| + if echo "$line" | grep -q '^name='; then |
| echo |
| count=$(( count + 1 )) |
| - echo "$line" | sed "s/display_name=/$count - /" |
| + echo "$line" | sed "s/name=/$count - /" |
| elif echo "$line" | grep -q '^channel='; then |
| echo "$line" | sed 's/channel=/ channel: /' |
| - elif echo "$line" | grep -q '^hwid=[^*]'; then |
| + elif echo "$line" | grep -q '^hwid='; then |
| echo "$line" | sed 's/hwid=/ HWID: /' |
| fi |
| done < "$config" |
| @@ -448,17 +462,19 @@ fetch_image() { |
| local key |
| local val |
| local file |
| - local size |
| + local zipfilesize |
| + local filesize |
| local url |
| local md5 |
| local sha1 |
| local line_num |
| - local tarball |
| + local zipfile |
| local err |
| local sum |
| file= |
| - size= |
| + zipfilesize= |
| + filesize= |
| url= |
| md5= |
| sha1= |
| @@ -489,8 +505,11 @@ fetch_image() { |
| file) |
| file="$val" |
| ;; |
| - size) |
| - size="$val" |
| + zipfilesize) |
| + zipfilesize="$val" |
| + ;; |
| + filesize) |
| + filesize="$val" |
| ;; |
| md5) |
| md5="$val" |
| @@ -504,10 +523,10 @@ fetch_image() { |
| # We've already got one (it's very nice). |
| continue; |
| fi |
| - warn "Downloading image tarball from $val" |
| + warn "Downloading image zipfile from $val" |
| warn "" |
| - tarball=${val##*/} |
| - if fetch_url "$val" "$tarball" "resumeok"; then |
| + zipfile=${val##*/} |
| + if fetch_url "$val" "$zipfile" "resumeok"; then |
| # Got it. |
| url="$val" |
| fi |
| @@ -517,16 +536,16 @@ fetch_image() { |
| done < "$config" |
| if [ -z "$url" ]; then |
| - DEBUG "couldn't fetch tarball" |
| + DEBUG "couldn't fetch zipfile" |
| return 1 |
| fi |
| - # Verify the tarball |
| - if ! ls -l "$tarball" | grep -q "$size"; then |
| - DEBUG "size is wrong" |
| + # Verify the zipfile |
| + if ! ls -l "$zipfile" | grep -q "$zipfilesize"; then |
| + DEBUG "zipfilesize is wrong" |
| return 1 |
| fi |
| - sum=$(compute_checksum "$tarball") |
| + sum=$(compute_checksum "$zipfile") |
| DEBUG "checksum is $sum" |
| if [ "$CHECKTYPE" = "md5" ] && [ "$sum" != "$md5" ]; then |
| DEBUG "wrong $CHECK" |
| @@ -537,10 +556,15 @@ fetch_image() { |
| fi |
| # Unpack the file |
| - warn "Unpacking the tarball" |
| + warn "Unpacking the zipfile" |
| rm -f "$file" |
| - if ! unzip "$tarball" "$file"; then |
| - DEBUG "Can't unpack the tarball" |
| + if ! unzip "$zipfile" "$file"; then |
| + DEBUG "Can't unpack the zipfile" |
| + return 1 |
| + fi |
| + |
| + if ! ls -l "$file" | grep -q "$filesize"; then |
| + DEBUG "unpacked filesize is wrong" |
| return 1 |
| fi |
| @@ -719,9 +743,9 @@ warn "Downloading config file from $CONFIGURL" |
| fetch_url "$CONFIGURL" "$tmpfile" || \ |
| gfatal "Unable to download the config file" |
| -# Un-DOS-ify the config file and separate the version info from the images |
| -tr -d '\015' < "$tmpfile" | grep '^recovery_tool' > "$version" |
| -tr -d '\015' < "$tmpfile" | grep -v '^#' | grep -v '^recovery_tool' > "$config" |
| +# Separate the version info from the images |
| +grep '^recovery_tool' "$tmpfile" > "$version" |
| +grep -v '^#' "$tmpfile" | grep -v '^recovery_tool' > "$config" |
| # Add one empty line to the config file to terminate the last stanza |
| echo >> "$config" |
|
scottz
2010/12/09 01:47:25
Is there a reason to not make this be part of the
Bill Richardson
2010/12/09 17:34:29
No. The first example didn't have it, and here at
|