|
|
Created:
10 years, 8 months ago by sosa Modified:
9 years, 6 months ago CC:
chromium-os-reviews_chromium.org Visibility:
Public. |
DescriptionNew helper script to mount (and umount) gpt image into image_dir/rootfs and mount /var, /usr/local
Patch Set 1 #Patch Set 2 : Merge scripts #
Total comments: 6
Patch Set 3 : Added some echos #Patch Set 4 : Function cleanup #Patch Set 5 : Fix description #
Total comments: 1
Patch Set 6 : nit #
Messages
Total messages: 13 (0 generated)
Adding information to the commit message about what this is used for would be helpful On Mon, Apr 19, 2010 at 10:52 AM, <sosa@chromium.org> wrote: > Reviewers: cmasone, Nick Sanders, > > Description: > New helper script to mount (and umount) gpt image into image_dir/rootfs and > mount /var, /usr/local > > Please review this at http://codereview.chromium.org/1648018/show > > Affected files: > A src/scripts/mount_rootfs_with_var.sh > > > Index: src/scripts/mount_rootfs_with_var.sh > diff --git a/src/scripts/mount_rootfs_with_var.sh > b/src/scripts/mount_rootfs_with_var.sh > new file mode 100755 > index > 0000000000000000000000000000000000000000..ce3eb88a7c9963309db68b97d6575131a650f2b0 > --- /dev/null > +++ b/src/scripts/mount_rootfs_with_var.sh > @@ -0,0 +1,67 @@ > +#!/bin/bash > + > +# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. > +# Use of this source code is governed by a BSD-style license that can be > +# found in the LICENSE file. > + > +# Helper script that unpacks (or re-packs) a chromium os image > +# and creates mount points for /var and /usr/local. It will try > +# to find the newest image of your board (uses default if not set) > +# if $FLAGS_from isn't set > + > +. "$(dirname "$0")/common.sh" > + > +get_default_board > + > +# Flags. > +DEFINE_string board "$DEFAULT_BOARD" \ > + "The board to build an image for." b > +DEFINE_boolean umount $FLAGS_FALSE \ > + "Unmount previously mounted dir." u > +DEFINE_string from "" \ > + "Directory containing chromiumos_image.bin" f > +DEFINE_boolean use_test $FLAGS_FALSE "Use chromiumos_test.bin" t > + > +# Parse flags > +FLAGS "$@" || exit 1 > +eval set -- "${FLAGS_ARGV}" > + > +# Die on error > +set -e > + > +# We have a board name but no image set. Use image at default location > +if [ -z "${FLAGS_from}" ]; then > + IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}" > + FLAGS_from="${IMAGES_DIR}/$(ls -t ${IMAGES_DIR} 2>&-| head -1)" > +fi > + > +if [ ! -d "${FLAGS_from}" ] ; then > + echo "Cannot find image directory ${FLAGS_from}" > + exit 1 > +fi > + > +IMAGE_NAME=chromiumos_image.bin > +[ ${FLAGS_use_test} -eq ${FLAGS_TRUE} ] && > IMAGE_NAME=chromiumos_test_image.bin > + > +cd ${FLAGS_from} > + > +if [ ${FLAGS_umount} -eq ${FLAGS_FALSE} ] ; then > + ./unpack_partitions.sh ${IMAGE_NAME} > + mkdir -p rootfs > + mkdir -p stateful_partition > + sudo mount -o loop part_3 rootfs > + sudo mount -o loop part_1 stateful_partition > + sudo mount --bind stateful_partition/var rootfs/var > + sudo mount --bind stateful_partition/dev_image rootfs/usr/local > + echo "${IMAGE_NAME} mounted on ${FLAGS_from}/rootfs" > +else > + echo "umounting ${FLAGS_from}/${IMAGE_NAME} and re-packaging" > + sudo umount rootfs/usr/local > + sudo umount rootfs/var > + sudo umount -d stateful_partition > + sudo umount -d rootfs > + rmdir stateful_partition > + rmdir rootfs > + ./pack_partitions.sh ${IMAGE_NAME} > + sudo rm part_* > +fi > > >
This script is useful for people who emerge packages onto an already created chromium os image. This script mounts takes a previously created image dir (with unpack / pack partitions) and mounts the binary into a directory called rootfs in that image dir. This directory contains the rootfs image with it's "var" directory mounted on the stateful directory created as part of build_image. Therefore someone could emerge-$BOARD --root image_dir/rootfs package/foo. The -u option undoes all the mount points.
Can this be merged with/supersede the script I already checked in that does the same thing for a USB stick? On Mon, Apr 19, 2010 at 11:01 AM, <sosa@chromium.org> wrote: > This script is useful for people who emerge packages onto an already > created > chromium os image. This script mounts takes a previously created image dir > (with unpack / pack partitions) and mounts the binary into a directory > called > rootfs in that image dir. This directory contains the rootfs image with > it's > "var" directory mounted on the stateful directory created as part of > build_image. Therefore someone could emerge-$BOARD --root image_dir/rootfs > package/foo. The -u option undoes all the mount points. > > > http://codereview.chromium.org/1648018/show >
Didn't you ask me to write this script on Friday or was it Nick? On Mon, Apr 19, 2010 at 11:06 AM, Chris Masone <cmasone@chromium.org> wrote: > Can this be merged with/supersede the script I already checked in that does > the same thing for a USB stick? > > On Mon, Apr 19, 2010 at 11:01 AM, <sosa@chromium.org> wrote: >> >> This script is useful for people who emerge packages onto an already >> created >> chromium os image. This script mounts takes a previously created image >> dir >> (with unpack / pack partitions) and mounts the binary into a directory >> called >> rootfs in that image dir. This directory contains the rootfs image with >> it's >> "var" directory mounted on the stateful directory created as part of >> build_image. Therefore someone could emerge-$BOARD --root >> image_dir/rootfs >> package/foo. The -u option undoes all the mount points. >> >> http://codereview.chromium.org/1648018/show > >
I don't recall asking you to write this, no. The question stands, though. On Mon, Apr 19, 2010 at 11:09 AM, Chris Sosa <sosa@chromium.org> wrote: > Didn't you ask me to write this script on Friday or was it Nick? > > On Mon, Apr 19, 2010 at 11:06 AM, Chris Masone <cmasone@chromium.org> > wrote: > > Can this be merged with/supersede the script I already checked in that > does > > the same thing for a USB stick? > > > > On Mon, Apr 19, 2010 at 11:01 AM, <sosa@chromium.org> wrote: > >> > >> This script is useful for people who emerge packages onto an already > >> created > >> chromium os image. This script mounts takes a previously created image > >> dir > >> (with unpack / pack partitions) and mounts the binary into a directory > >> called > >> rootfs in that image dir. This directory contains the rootfs image with > >> it's > >> "var" directory mounted on the stateful directory created as part of > >> build_image. Therefore someone could emerge-$BOARD --root > >> image_dir/rootfs > >> package/foo. The -u option undoes all the mount points. > >> > >> http://codereview.chromium.org/1648018/show > > > > >
Yes. Maybe rename and send you another CL that merges them. On Mon, Apr 19, 2010 at 11:12 AM, Chris Masone <cmasone@chromium.org> wrote: > I don't recall asking you to write this, no. The question stands, though. > > On Mon, Apr 19, 2010 at 11:09 AM, Chris Sosa <sosa@chromium.org> wrote: >> >> Didn't you ask me to write this script on Friday or was it Nick? >> >> On Mon, Apr 19, 2010 at 11:06 AM, Chris Masone <cmasone@chromium.org> >> wrote: >> > Can this be merged with/supersede the script I already checked in that >> > does >> > the same thing for a USB stick? >> > >> > On Mon, Apr 19, 2010 at 11:01 AM, <sosa@chromium.org> wrote: >> >> >> >> This script is useful for people who emerge packages onto an already >> >> created >> >> chromium os image. This script mounts takes a previously created image >> >> dir >> >> (with unpack / pack partitions) and mounts the binary into a directory >> >> called >> >> rootfs in that image dir. This directory contains the rootfs image >> >> with >> >> it's >> >> "var" directory mounted on the stateful directory created as part of >> >> build_image. Therefore someone could emerge-$BOARD --root >> >> image_dir/rootfs >> >> package/foo. The -u option undoes all the mount points. >> >> >> >> http://codereview.chromium.org/1648018/show >> > >> > > >
PTAL. Have merged prep_usb key and last script. Have renamed to mount_gpt_image for more generic usage
http://codereview.chromium.org/1648018/diff/9001/10001 File src/scripts/mount_gpt_image.sh (right): http://codereview.chromium.org/1648018/diff/9001/10001#newcode16 src/scripts/mount_gpt_image.sh:16: "The board to build an image for." b The board for which the image was built. http://codereview.chromium.org/1648018/diff/9001/10001#newcode86 src/scripts/mount_gpt_image.sh:86: mkdir -p "${FLAGS_stateful_mountpt}" SHouldn't these mkdir -p's happen earlier, and whether or not this is mounting a device or an image? http://codereview.chromium.org/1648018/diff/9001/10001#newcode94 src/scripts/mount_gpt_image.sh:94: fi Can't most of the body of this if and the body of the if [ -b ${FLAGS_from} ] above be moved into a function together?
Functionalized the mount component. http://codereview.chromium.org/1648018/diff/9001/10001 File src/scripts/mount_gpt_image.sh (right): http://codereview.chromium.org/1648018/diff/9001/10001#newcode16 src/scripts/mount_gpt_image.sh:16: "The board to build an image for." b On 2010/04/19 19:48:10, cmasone wrote: > The board for which the image was built. Done. http://codereview.chromium.org/1648018/diff/9001/10001#newcode86 src/scripts/mount_gpt_image.sh:86: mkdir -p "${FLAGS_stateful_mountpt}" Yes. Done. On 2010/04/19 19:48:10, cmasone wrote: > SHouldn't these mkdir -p's happen earlier, and whether or not this is mounting a > device or an image? http://codereview.chromium.org/1648018/diff/9001/10001#newcode94 src/scripts/mount_gpt_image.sh:94: fi On 2010/04/19 19:48:10, cmasone wrote: > Can't most of the body of this if and the body of the if [ -b ${FLAGS_from} ] > above be moved into a function together? Done.
LGTM with nit http://codereview.chromium.org/1648018/diff/19001/20001 File src/scripts/mount_gpt_image.sh (right): http://codereview.chromium.org/1648018/diff/19001/20001#newcode98 src/scripts/mount_gpt_image.sh:98: mount_common /part_ "-o loop" "/part_" would seem safer
Yeah, adlr and I were asking about it Friday, LGTM
Thanks, sorry for the confusion! On Mon, Apr 19, 2010 at 9:07 PM, <nsanders@chromium.org> wrote: > Yeah, adlr and I were asking about it Friday, LGTM > > http://codereview.chromium.org/1648018/show > |