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

Side by Side Diff: user_tools/linux/recovery.sh

Issue 5516010: Use tr instead of sed to unDOSify the config file, so it works on Macs. (Closed) Base URL: http://git.chromium.org/git/vboot_reference.git@master
Patch Set: Created 10 years 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/sh 1 #!/bin/sh
2 # 2 #
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS 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 # This attempts to guide linux users through the process of putting a recovery 7 # This attempts to guide linux users through the process of putting a recovery
8 # image onto a removeable USB drive. 8 # image onto a removeable USB drive.
9 # 9 #
10 # We may not need root privileges if we have the right permissions. 10 # We may not need root privileges if we have the right permissions.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 # FETCH = name of utility used to download files from the web 97 # FETCH = name of utility used to download files from the web
98 # CHECK = command to invoke to generate checksums on a file 98 # CHECK = command to invoke to generate checksums on a file
99 # CHECKTYPE = type of checksum generated 99 # CHECKTYPE = type of checksum generated
100 # 100 #
101 require_utils() { 101 require_utils() {
102 local external 102 local external
103 local errors 103 local errors
104 local tool 104 local tool
105 local tmp 105 local tmp
106 106
107 external='cat cut dd grep ls mkdir mount readlink sed sync umount unzip wc' 107 external='cat cut dd grep ls mkdir mount readlink sed sync tr umount unzip wc'
108 if [ -z "$WORKDIR" ]; then 108 if [ -z "$WORKDIR" ]; then
109 external="$external mktemp" 109 external="$external mktemp"
110 fi 110 fi
111 errors= 111 errors=
112 112
113 for tool in $external ; do 113 for tool in $external ; do
114 if ! type "$tool" >/dev/null 2>&1 ; then 114 if ! type "$tool" >/dev/null 2>&1 ; then
115 warn "ERROR: need \"$tool\"" 115 warn "ERROR: need \"$tool\""
116 errors=yes 116 errors=yes
117 fi 117 fi
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 cd "$WORKDIR" 651 cd "$WORKDIR"
652 warn "Working in $WORKDIR/" 652 warn "Working in $WORKDIR/"
653 rm -f "$debug" 653 rm -f "$debug"
654 654
655 # Download the config file to see what choices we have. 655 # Download the config file to see what choices we have.
656 warn "Downloading config file from $CONFIGURL" 656 warn "Downloading config file from $CONFIGURL"
657 fetch_url "$CONFIGURL" "$tmpfile" || \ 657 fetch_url "$CONFIGURL" "$tmpfile" || \
658 gfatal "Unable to download the config file" 658 gfatal "Unable to download the config file"
659 659
660 # Un-DOS-ify the config file and separate the version info from the images 660 # Un-DOS-ify the config file and separate the version info from the images
661 sed 's/\r//g' "$tmpfile" | grep '^recovery_tool' > "$version" 661 tr -d '\015' < "$tmpfile" | grep '^recovery_tool' > "$version"
662 sed 's/\r//g' "$tmpfile" | grep -v '^#' | grep -v '^recovery_tool' > "$config" 662 tr -d '\015' < "$tmpfile" | grep -v '^#' | grep -v '^recovery_tool' > "$config"
663 # Add one empty line to the config file to terminate the last stanza 663 # Add one empty line to the config file to terminate the last stanza
664 echo >> "$config" 664 echo >> "$config"
665 665
666 # Make sure that the config file version matches this script version 666 # Make sure that the config file version matches this script version
667 tmp=$(grep '^recovery_tool_version=' "$version") || \ 667 tmp=$(grep '^recovery_tool_version=' "$version") || \
668 gfatal "The config file doesn't contain a version string." 668 gfatal "The config file doesn't contain a version string."
669 filevers=${tmp#*=} 669 filevers=${tmp#*=}
670 if [ "$filevers" != "$MYVERSION" ]; then 670 if [ "$filevers" != "$MYVERSION" ]; then
671 tmp=$(grep '^recovery_tool_update=' "$version"); 671 tmp=$(grep '^recovery_tool_update=' "$version");
672 msg=${tmp#*=} 672 msg=${tmp#*=}
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 quit 718 quit
719 fi 719 fi
720 echo " 720 echo "
721 721
722 Installing the recovery image 722 Installing the recovery image
723 723
724 " 724 "
725 725
726 # Unmount anything on that device. 726 # Unmount anything on that device.
727 echo "unmounting..." 727 echo "unmounting..."
728 for tmp in $(mount | grep ^"/dev/${user_choice}" | sed 's/[ \t].*//'); do 728 for tmp in $(mount | grep ^"/dev/${user_choice}" | cut -d' ' -f1); do
729 umount $tmp || ufatal "Unable to unmount $tmp." 729 umount $tmp || ufatal "Unable to unmount $tmp."
730 done 730 done
731 731
732 # Write it. 732 # Write it.
733 echo "copying... (this may take several minutes)" 733 echo "copying... (this may take several minutes)"
734 dd of=/dev/${user_choice} if="$image_file" || 734 dd of=/dev/${user_choice} if="$image_file" ||
735 ufatal "Unable to write the image." 735 ufatal "Unable to write the image."
736 sync 736 sync
737 737
738 echo " 738 echo "
739 739
740 Done. Remove the USB drive and insert it in your Chrome OS netbook. 740 Done. Remove the USB drive and insert it in your Chrome OS netbook.
741 741
742 " 742 "
743 743
744 exit 0 744 exit 0
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