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

Side by Side Diff: client/site_tests/factory_Wipe/src/switch_partitions.sh

Issue 3440011: Force success (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git
Patch Set: Created 10 years, 3 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/sh 1 #!/bin/sh
2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # This script can be called to switch from kernel slot A / sda3 6 # This script can be called to switch from kernel slot A / sda3
7 # to kernel slot B / sda5 and vice versa. 7 # to kernel slot B / sda5 and vice versa.
8 8
9 ROOT_DEV=$(rootdev -s) 9 ROOT_DEV=$(rootdev -s)
10 OTHER_ROOT_DEV=$(echo $ROOT_DEV | tr '35' '53') 10 OTHER_ROOT_DEV=$(echo $ROOT_DEV | tr '35' '53')
11 11
12 if [ "${ROOT_DEV}" = "${OTHER_ROOT_DEV}" ] 12 if [ "${ROOT_DEV}" = "${OTHER_ROOT_DEV}" ]
13 then 13 then
14 echo "Not a normal rootfs partition (3 or 5): ${ROOT_DEV}" 14 echo "Not a normal rootfs partition (3 or 5): ${ROOT_DEV}"
15 exit 1 15 exit 1
16 fi 16 fi
17 17
18 DEV=${ROOT_DEV%[0-9]} 18 DEV=${ROOT_DEV%[0-9]}
19 # Note: this works only for single digit partition numbers. 19 # Note: this works only for single digit partition numbers.
20 ROOT_PART=$(echo "${ROOT_DEV}" | sed -e 's/^.*\([0-9]\)$/\1/') 20 ROOT_PART=$(echo "${ROOT_DEV}" | sed -e 's/^.*\([0-9]\)$/\1/')
21 OTHER_ROOT_PART=$(echo "${OTHER_ROOT_DEV}" | sed -e 's/^.*\([0-9]\)$/\1/')
21 22
22 # Successfully being able to mount the other partition 23 # Successfully being able to mount the other partition
23 # and run postinst guarantees that there is a real partition there. 24 # and run postinst guarantees that there is a real partition there.
24 echo "Running postinst on $OTHER_ROOT_DEV" 25 echo "Running postinst on $OTHER_ROOT_DEV"
25 MOUNTPOINT=$(mktemp -d) 26 MOUNTPOINT=$(mktemp -d)
26 mkdir -p "$MOUNTPOINT" 27 mkdir -p "$MOUNTPOINT"
27 mount -o ro "$OTHER_ROOT_DEV" "$MOUNTPOINT" 28 mount -o ro "$OTHER_ROOT_DEV" "$MOUNTPOINT"
28 "$MOUNTPOINT"/postinst --noupdate_firmware "$OTHER_ROOT_DEV" 29 "$MOUNTPOINT"/postinst --noupdate_firmware "$OTHER_ROOT_DEV"
29 POSTINST_RETURN_CODE=$? 30 POSTINST_RETURN_CODE=$?
30 umount "$MOUNTPOINT" 31 umount "$MOUNTPOINT"
31 rmdir "$MOUNTPOINT" 32 rmdir "$MOUNTPOINT"
32 33
33 # Destroy this root partition if we've successfully switched. 34 # Destroy this root partition if we've successfully switched.
34 if [ "${POSTINST_RETURN_CODE}" = "0" ]; then 35 if [ "${POSTINST_RETURN_CODE}" = "0" ]; then
35 cgpt add -i "$((${ROOT_PART} - 1))" -P 0 -S 0 -T 0 "${DEV}" 36 cgpt add -i "$((${ROOT_PART} - 1))" -P 0 -S 0 -T 0 "${DEV}"
36 RC=$? 37 if [ "$?" != "0" ]; then
37 if [ "${RC}" != "0" ]; then
38 echo "Failed to run cgpt" 38 echo "Failed to run cgpt"
39 return 1 39 return 1
40 fi 40 fi
41 cgpt add -i "$((${OTHER_ROOT_PART} - 1))" -P 3 -S 1 -T 0 "${DEV}"
42 if [ "$?" != "0" ]; then
43 echo "Failed to run cgpt"
44 return 1
45 fi
41 fi 46 fi
42 47
43 exit $POSTINST_RETURN_CODE 48 exit $POSTINST_RETURN_CODE
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