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

Side by Side Diff: common.sh

Issue 5271010: Factored out the code to copy an image and modify it for test (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils.git@master
Patch Set: Changed to use a temp variable Created 10 years 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 | image_to_usb.sh » ('j') | image_to_usb.sh » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Common constants for build scripts 5 # Common constants for build scripts
6 # This must evaluate properly for both /bin/bash and /bin/sh 6 # This must evaluate properly for both /bin/bash and /bin/sh
7 7
8 # All scripts should die on error unless commands are specifically excepted 8 # All scripts should die on error unless commands are specifically excepted
9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. 9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'.
10 # TODO: Re-enable this once shflags is less prone to dying. 10 # TODO: Re-enable this once shflags is less prone to dying.
11 #set -e 11 #set -e
12 12
13 # The number of jobs to pass to tools that can run in parallel (such as make 13 # The number of jobs to pass to tools that can run in parallel (such as make
14 # and dpkg-buildpackage 14 # and dpkg-buildpackage
15 NUM_JOBS=`grep -c "^processor" /proc/cpuinfo` 15 NUM_JOBS=`grep -c "^processor" /proc/cpuinfo`
16 16
17 # True if we have the 'pv' utility - also set up COMMON_PV_CAT for convenience
18 COMMON_PV_OK=1
19 COMMON_PV_CAT=pv
20 pv -V >/dev/null 2>&1 || COMMON_PV_OK=0
21 if [ $COMMON_PV_OK -eq 0 ]; then
22 COMMON_PV_CAT=cat
23 fi
24
17 # Store location of the calling script. 25 # Store location of the calling script.
18 TOP_SCRIPT_DIR="${TOP_SCRIPT_DIR:-$(dirname $0)}" 26 TOP_SCRIPT_DIR="${TOP_SCRIPT_DIR:-$(dirname $0)}"
19 27
20 # Find root of source tree 28 # Find root of source tree
21 if [ "x$GCLIENT_ROOT" != "x" ] 29 if [ "x$GCLIENT_ROOT" != "x" ]
22 then 30 then
23 # GCLIENT_ROOT already set, so we're done 31 # GCLIENT_ROOT already set, so we're done
24 true 32 true
25 elif [ "x$COMMON_SH" != "x" ] 33 elif [ "x$COMMON_SH" != "x" ]
26 then 34 then
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 DEFAULT_FAST="${FLAGS_TRUE}" 125 DEFAULT_FAST="${FLAGS_TRUE}"
118 126
119 # Detect whether we're inside a chroot or not 127 # Detect whether we're inside a chroot or not
120 if [ -e /etc/debian_chroot ] 128 if [ -e /etc/debian_chroot ]
121 then 129 then
122 INSIDE_CHROOT=1 130 INSIDE_CHROOT=1
123 else 131 else
124 INSIDE_CHROOT=0 132 INSIDE_CHROOT=0
125 fi 133 fi
126 134
135
136 # Standard filenames
137 CHROMEOS_IMAGE_NAME="chromiumos_image.bin"
138 CHROMEOS_TEST_IMAGE_NAME="chromiumos_test_image.bin"
139
140
127 # Directory locations inside the dev chroot 141 # Directory locations inside the dev chroot
128 CHROOT_TRUNK_DIR="/home/$USER/trunk" 142 CHROOT_TRUNK_DIR="/home/$USER/trunk"
129 143
130 # Install make for portage ebuilds. Used by build_image and gmergefs. 144 # Install make for portage ebuilds. Used by build_image and gmergefs.
131 # TODO: Is /usr/local/autotest-chrome still used by anyone? 145 # TODO: Is /usr/local/autotest-chrome still used by anyone?
132 DEFAULT_INSTALL_MASK="/usr/include /usr/man /usr/share/man /usr/share/doc \ 146 DEFAULT_INSTALL_MASK="/usr/include /usr/man /usr/share/man /usr/share/doc \
133 /usr/share/gtk-doc /usr/share/gtk-2.0 /usr/lib/gtk-2.0/include \ 147 /usr/share/gtk-doc /usr/share/gtk-2.0 /usr/lib/gtk-2.0/include \
134 /usr/share/info /usr/share/aclocal /usr/lib/gcc /usr/lib/pkgconfig \ 148 /usr/share/info /usr/share/aclocal /usr/lib/gcc /usr/lib/pkgconfig \
135 /usr/share/pkgconfig /usr/share/gettext /usr/share/readline /etc/runlevels \ 149 /usr/share/pkgconfig /usr/share/gettext /usr/share/readline /etc/runlevels \
136 /usr/share/openrc /lib/rc *.a *.la /etc/init.d /usr/lib/debug 150 /usr/share/openrc /lib/rc *.a *.la /etc/init.d /usr/lib/debug
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 chroot_hacks_from_outside() { 534 chroot_hacks_from_outside() {
521 # Give args better names. 535 # Give args better names.
522 local chroot_dir="${1}" 536 local chroot_dir="${1}"
523 537
524 # Add root as a sudoer if not already done. 538 # Add root as a sudoer if not already done.
525 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then 539 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then
526 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers" 540 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers"
527 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\"" 541 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\""
528 fi 542 fi
529 } 543 }
544
545 # This function converts a chromiumos image into a test image, either
546 # in place or by copying to a new test image filename first. It honors
547 # the following flags (see mod_image_for_test.sh)
548 #
549 # --factory
550 # --factory_install
551 # --force_copy
552 #
553 # On entry, pass the directory containing the image, and the image filename
554 # On exit, it puts the pathname of the resulting test image into
555 # CHROMEOS_RETURN_VAL
556 # (yes this is ugly, but perhaps less ugly than the alternatives)
557 #
558 # Usage:
559 # SRC_IMAGE=$(prepare_test_image "directory" "imagefile")
560 prepare_test_image() {
561 # If we're asked to modify the image for test, then let's make a copy and
562 # modify that instead.
563 # Check for manufacturing image.
564 local args
565
566 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then
567 args="--factory"
568 fi
569
570 # Check for install shim.
571 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then
572 args="--factory_install"
573 fi
574
575 # Check for forcing copy of image
576 if [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ]; then
577 args="${args} --force_copy"
578 fi
579
580 # Modify the image for test, creating a new test image
581 "${SCRIPTS_DIR}/mod_image_for_test.sh" --board=${FLAGS_board} \
582 --image="$1/$2" --noinplace ${args}
583
584 # From now on we use the just-created test image
585 CHROMEOS_RETURN_VAL="$1/${CHROMEOS_TEST_IMAGE_NAME}"
586 }
OLDNEW
« no previous file with comments | « no previous file | image_to_usb.sh » ('j') | image_to_usb.sh » ('J')

Powered by Google App Engine
This is Rietveld 408576698