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

Side by Side Diff: src/scripts/mount_gpt_image.sh

Issue 1648018: New helper script to mount (and umount) gpt image into image_dir/rootfs and mount /var, /usr/local (Closed)
Patch Set: nit Created 10 years, 8 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
« no previous file with comments | « no previous file | src/scripts/prep_usb.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2
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
5 # found in the LICENSE file.
6
7 # Helper script that mounts chromium os image from a device or directory
8 # and creates mount points for /var and /usr/local (if in dev_mode).
9
10 . "$(dirname "$0")/common.sh"
11
12 get_default_board
13
14 # Flags.
15 DEFINE_string board "$DEFAULT_BOARD" \
16 "The board for which the image was built." b
17 DEFINE_boolean unmount $FLAGS_FALSE \
18 "Unmount previously mounted dir." u
19 DEFINE_string from "/dev/sdc" \
20 "Directory containing image or device with image on it" f
21 DEFINE_boolean test $FLAGS_FALSE "Use chromiumos_test_image.bin" t
22 DEFINE_string "rootfs_mountpt" "/tmp/m" "Mount point for rootfs" "r"
23 DEFINE_string "stateful_mountpt" "/tmp/s" \
24 "Mount point for stateful partition" "s"
25 DEFINE_boolean most_recent ${FLAGS_FALSE} "Use the most recent image dir" m
26
27 # Parse flags
28 FLAGS "$@" || exit 1
29 eval set -- "${FLAGS_ARGV}"
30
31 # Die on error
32 set -e
33
34 # Common umounts for either a device or directory
35 function unmount_common() {
36 echo "Unmounting image from ${FLAGS_stateful_mountpt}" \
37 "and ${FLAGS_rootfs_mountpt}"
38 # Don't die on error to force cleanup
39 set +e
40 if [ -e "${FLAGS_rootfs_mountpt}/root/.dev_mode" ] ; then
41 sudo umount "${FLAGS_rootfs_mountpt}/usr/local"
42 fi
43 sudo umount "${FLAGS_rootfs_mountpt}/var"
44 sudo umount -d "${FLAGS_stateful_mountpt}"
45 sudo umount -d "${FLAGS_rootfs_mountpt}"
46 set -e
47 }
48
49 # Sets up the rootfs and stateful partitions specified by
50 # ${FLAGS_from}${prefix}[31] to the given mount points and sets up var and
51 # usr/local
52 # ${1} - prefix name for the partition
53 # ${2} - extra mount options for the partitions
54 function mount_common() {
55 mkdir -p "${FLAGS_rootfs_mountpt}"
56 mkdir -p "${FLAGS_stateful_mountpt}"
57 sudo mount ${2} "${FLAGS_from}${1}3" "${FLAGS_rootfs_mountpt}"
58 sudo mount ${2} "${FLAGS_from}${1}1" "${FLAGS_stateful_mountpt}"
59 sudo mount --bind "${FLAGS_stateful_mountpt}/var" \
60 "${FLAGS_rootfs_mountpt}/var"
61 if [ -e "${FLAGS_rootfs_mountpt}/root/.dev_mode" ] ; then
62 sudo mount --bind "${FLAGS_stateful_mountpt}/dev_image" \
63 "${FLAGS_rootfs_mountpt}/usr/local"
64 fi
65 echo "Root FS specified by "${FLAGS_from}${1}3" mounted at"\
66 "${FLAGS_rootfs_mountpt} successfully."
67 }
68
69 # Find the last image built on the board
70 if [ ${FLAGS_most_recent} -eq ${FLAGS_TRUE} ] ; then
71 IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}"
72 FLAGS_from="${IMAGES_DIR}/$(ls -t ${IMAGES_DIR} 2>&-| head -1)"
73 fi
74
75 # Turn into absolute path
76 FLAGS_from=`eval readlink -f ${FLAGS_from}`
77
78 # Set the file name of the image if ${FLAGS_from} is not a device and cd
79 if [ -d "${FLAGS_from}" ] ; then
80 cd "${FLAGS_from}"
81 IMAGE_NAME=chromiumos_image.bin
82 [ ${FLAGS_test} -eq ${FLAGS_TRUE} ] && IMAGE_NAME=chromiumos_test_image.bin
83 fi
84
85 if [ ${FLAGS_unmount} -eq ${FLAGS_TRUE} ] ; then
86 unmount_common
87 if [ -d "${FLAGS_from}" ] ; then
88 echo "Re-packing partitions onto ${FLAGS_from}/${IMAGE_NAME}"
89 ./pack_partitions.sh ${IMAGE_NAME} 2> /dev/null
90 sudo rm part_*
91 fi
92 else
93 if [ -b ${FLAGS_from} ] ; then
94 mount_common "" ""
95 else
96 echo "Unpacking partitions from ${FLAGS_from}/${IMAGE_NAME}"
97 ./unpack_partitions.sh ${IMAGE_NAME} 2> /dev/null
98 mount_common "/part_" "-o loop"
99 fi
100 fi
OLDNEW
« no previous file with comments | « no previous file | src/scripts/prep_usb.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698