OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
| 2 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
2 | 5 |
3 # Usage: | 6 # Usage: |
4 # revert_image.sh [image_to_revert] | 7 # revert_image.sh [image_to_revert] |
5 # | 8 # |
6 # This assumes the image has been updated by update_image.sh. | 9 # This assumes the image has been updated by update_image.sh. |
7 usage() | 10 usage() |
8 { | 11 { |
9 cat <<EOF | 12 cat <<EOF |
10 | 13 |
11 usage: | 14 usage: |
12 revert_image.sh [image_to_revert] | 15 revert_image.sh [image_to_revert] |
13 EOF | 16 EOF |
14 } | 17 } |
15 | 18 |
16 if [[ $# < 1 ]]; then | 19 if [[ $# < 1 ]]; then |
17 echo "Not enough arguments supplied." | 20 echo "Not enough arguments supplied." |
18 usage | 21 usage |
19 exit 1 | 22 exit 1 |
20 fi | 23 fi |
21 | 24 |
22 IMAGE=$( readlink -f ${1} ) | 25 IMAGE=$(readlink -f "$1") |
23 IMAGE_DIR=$( dirname ${IMAGE} ) | 26 IMAGE_DIR=$(dirname "$IMAGE") |
24 | 27 |
25 if [[ -z "${IMAGE}" ]]; then | 28 if [[ -z "$IMAGE" ]]; then |
26 echo "Missing required argument 'image_to_revert'" | 29 echo "Missing required argument 'image_to_revert'" |
27 usage | 30 usage |
28 exit 1 | 31 exit 1 |
29 fi | 32 fi |
30 | 33 |
31 cd ${IMAGE_DIR} | 34 cd "$IMAGE_DIR" |
32 | 35 |
33 if [[ ! -d "./orig_partitions" ]]; then | 36 if [[ ! -d "./orig_partitions" ]]; then |
34 echo "Could not find original partitions." | 37 echo "Could not find original partitions." |
35 exit 1 | 38 exit 1 |
36 fi | 39 fi |
37 | 40 |
38 yes | cp ./orig_partitions/* ./ | 41 cp -f ./orig_partitions/* ./ |
39 | 42 |
40 ./pack_partitions.sh ${IMAGE} | 43 ./pack_partitions.sh "$IMAGE" |
41 rm -rf ./orig_partitions | 44 rm -rf ./orig_partitions |
42 cd - | |
OLD | NEW |