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

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: Minor changes 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') | mod_image_for_test.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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 # Default location for chroot 107 # Default location for chroot
100 DEFAULT_CHROOT_DIR=${CHROMEOS_CHROOT_DIR:-"$GCLIENT_ROOT/chroot"} 108 DEFAULT_CHROOT_DIR=${CHROMEOS_CHROOT_DIR:-"$GCLIENT_ROOT/chroot"}
101 109
102 # All output files from build should go under $DEFAULT_BUILD_ROOT, so that 110 # All output files from build should go under $DEFAULT_BUILD_ROOT, so that
103 # they don't pollute the source directory. 111 # they don't pollute the source directory.
104 DEFAULT_BUILD_ROOT=${CHROMEOS_BUILD_ROOT:-"$SRC_ROOT/build"} 112 DEFAULT_BUILD_ROOT=${CHROMEOS_BUILD_ROOT:-"$SRC_ROOT/build"}
105 113
106 # Set up a global ALL_BOARDS value 114 # Set up a global ALL_BOARDS value
107 if [ -d $SRC_ROOT/overlays ]; then 115 if [ -d $SRC_ROOT/overlays ]; then
108 ALL_BOARDS=$(cd $SRC_ROOT/overlays;ls -1d overlay-* 2>&-|sed 's,overlay-,,g') 116 ALL_BOARDS=$(cd $SRC_ROOT/overlays;ls -1d overlay-* 2>&-|sed 's,overlay-,,g')
109 fi 117 fi
110 # Strip CR 118 # Strip CR
111 ALL_BOARDS=$(echo $ALL_BOARDS) 119 ALL_BOARDS=$(echo $ALL_BOARDS)
112 # Set a default BOARD 120 # Set a default BOARD
113 #DEFAULT_BOARD=x86-generic # or... 121 #DEFAULT_BOARD=x86-generic # or...
114 DEFAULT_BOARD=$(echo $ALL_BOARDS | awk '{print $NF}') 122 DEFAULT_BOARD=$(echo $ALL_BOARDS | awk '{print $NF}')
115 123
116 # Enable --fast by default on non-official builds 124 # Enable --fast by default on non-official builds
117 DEFAULT_FAST="${FLAGS_TRUE}" 125 DEFAULT_FAST="${FLAGS_TRUE}"
118 if [ "${CHROMEOS_OFFICIAL:-0}" = "1" ]; then 126 if [ "${CHROMEOS_OFFICIAL:-0}" = "1" ]; then
119 DEFAULT_FAST="${FLAGS_FALSE}" 127 DEFAULT_FAST="${FLAGS_FALSE}"
120 fi 128 fi
121 129
122 # Detect whether we're inside a chroot or not 130 # Detect whether we're inside a chroot or not
123 if [ -e /etc/debian_chroot ] 131 if [ -e /etc/debian_chroot ]
124 then 132 then
125 INSIDE_CHROOT=1 133 INSIDE_CHROOT=1
126 else 134 else
127 INSIDE_CHROOT=0 135 INSIDE_CHROOT=0
128 fi 136 fi
129 137
138
139 # Standard filenames
140 CHROMEOS_IMAGE_NAME="chromiumos_image.bin"
141 CHROMEOS_TEST_IMAGE_NAME="chromiumos_test_image.bin"
Nick Sanders 2010/12/02 00:01:48 Can you modify the output name based on test/facto
sjg 2010/12/02 00:28:52 I haven't added constants for these also at this s
142
143
130 # Directory locations inside the dev chroot 144 # Directory locations inside the dev chroot
131 CHROOT_TRUNK_DIR="/home/$USER/trunk" 145 CHROOT_TRUNK_DIR="/home/$USER/trunk"
132 146
133 # Install make for portage ebuilds. Used by build_image and gmergefs. 147 # Install make for portage ebuilds. Used by build_image and gmergefs.
134 # TODO: Is /usr/local/autotest-chrome still used by anyone? 148 # TODO: Is /usr/local/autotest-chrome still used by anyone?
135 DEFAULT_INSTALL_MASK="/usr/include /usr/man /usr/share/man /usr/share/doc \ 149 DEFAULT_INSTALL_MASK="/usr/include /usr/man /usr/share/man /usr/share/doc \
136 /usr/share/gtk-doc /usr/share/gtk-2.0 /usr/lib/gtk-2.0/include \ 150 /usr/share/gtk-doc /usr/share/gtk-2.0 /usr/lib/gtk-2.0/include \
137 /usr/share/info /usr/share/aclocal /usr/lib/gcc /usr/lib/pkgconfig \ 151 /usr/share/info /usr/share/aclocal /usr/lib/gcc /usr/lib/pkgconfig \
138 /usr/share/pkgconfig /usr/share/gettext /usr/share/readline /etc/runlevels \ 152 /usr/share/pkgconfig /usr/share/gettext /usr/share/readline /etc/runlevels \
139 /usr/share/openrc /lib/rc *.a *.la /etc/init.d /usr/lib/debug 153 /usr/share/openrc /lib/rc *.a *.la /etc/init.d /usr/lib/debug
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 chroot_hacks_from_outside() { 533 chroot_hacks_from_outside() {
520 # Give args better names. 534 # Give args better names.
521 local chroot_dir="${1}" 535 local chroot_dir="${1}"
522 536
523 # Add root as a sudoer if not already done. 537 # Add root as a sudoer if not already done.
524 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then 538 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then
525 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers" 539 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers"
526 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\"" 540 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\""
527 fi 541 fi
528 } 542 }
543
544 # This function converts a chromiumos image into a test image, either
545 # in place or by copying to a new test image filename first. It honors
546 # the following flags (see mod_image_for_test.sh)
547 #
548 # --factory
549 # --factory_install
550 # --force_copy
551 #
552 # On entry, pass the directory containing the image, and the image filename
553 # On exit, it echoes the pathname of the resulting test image
554 #
555 # Usage:
556 # SRC_IMAGE=$(prepare_test_image "directory" "imagefile")
557 prepare_test_image() {
558 # If we're asked to modify the image for test, then let's make a copy and
559 # modify that instead.
560 # Check for manufacturing image.
561 local args
562
563 if [ ${FLAGS_factory} -eq ${FLAGS_TRUE} ]; then
564 args="--factory"
565 fi
566
567 # Check for install shim.
568 if [ ${FLAGS_factory_install} -eq ${FLAGS_TRUE} ]; then
569 args="--factory_install"
570 fi
571
572 # Check for forcing copy of image
573 if [ ${FLAGS_force_copy} -eq ${FLAGS_TRUE} ]; then
574 args="${args} --force_copy"
575 fi
576
577 # Modify the image for test, creating a new test image
578 "${SCRIPTS_DIR}/mod_image_for_test.sh" --board=${FLAGS_board} \
579 --image="$1/$2" --noinplace ${args} >/dev/stderr
Nick Sanders 2010/12/02 00:07:51 Can you get this output on stdout? It doesn't seem
sjg 2010/12/02 00:28:52 Chris suggested making this a function which takes
580
581 # From now on we use the just-created test image
582 echo "$1/${CHROMEOS_TEST_IMAGE_NAME}"
583 }
OLDNEW
« no previous file with comments | « no previous file | image_to_usb.sh » ('j') | mod_image_for_test.sh » ('J')

Powered by Google App Engine
This is Rietveld 408576698