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

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

Issue 3362018: Kill factory partition dead. (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 | « client/site_tests/factory_Wipe/factory_Wipe.py ('k') | 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]}
19 # Note: this works only for single digit partition numbers.
20 ROOT_PART=$(echo "${ROOT_DEV}" | sed -e 's/^.*\([0-9]\)$/\1/')
hungte 2010/09/13 02:37:32 sed -e 's/.*[^0-9]//' would be simpler.
21
18 # Successfully being able to mount the other partition 22 # Successfully being able to mount the other partition
19 # and run postinst guarantees that there is a real partition there. 23 # and run postinst guarantees that there is a real partition there.
20 echo "Running postinst on $OTHER_ROOT_DEV" 24 echo "Running postinst on $OTHER_ROOT_DEV"
21 MOUNTPOINT=$(mktemp -d) 25 MOUNTPOINT=$(mktemp -d)
22 mkdir -p "$MOUNTPOINT" 26 mkdir -p "$MOUNTPOINT"
23 mount -o ro "$OTHER_ROOT_DEV" "$MOUNTPOINT" 27 mount -o ro "$OTHER_ROOT_DEV" "$MOUNTPOINT"
24 "$MOUNTPOINT"/postinst --noupdate_firmware "$OTHER_ROOT_DEV" 28 "$MOUNTPOINT"/postinst --noupdate_firmware "$OTHER_ROOT_DEV"
25 POSTINST_RETURN_CODE=$? 29 POSTINST_RETURN_CODE=$?
26 umount "$MOUNTPOINT" 30 umount "$MOUNTPOINT"
27 rmdir "$MOUNTPOINT" 31 rmdir "$MOUNTPOINT"
28 32
33 # Destroy this root partition if we've successfully switched.
34 if [ "${POSTINST_RETURN_CODE}" = "0" ]; then
35 cgpt add -i "$((${ROOT_PART} - 1))" -P 0 -S 0 -T 0 "${DEV}"
36 RC=$?
37 if [ "${RC}" != "0" ]; then
38 echo "Failed to run cgpt"
39 return 1
40 fi
41 fi
42
29 exit $POSTINST_RETURN_CODE 43 exit $POSTINST_RETURN_CODE
OLDNEW
« no previous file with comments | « client/site_tests/factory_Wipe/factory_Wipe.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698