OLD | NEW |
---|---|
(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 # Simple wrapper script to build a cros_workon package incrementally. | |
8 # You must already be cros_workon'ing the package in question. | |
9 | |
10 . "$(dirname $0)/../common.sh" | |
11 | |
12 # Script must be run inside the chroot. | |
13 assert_inside_chroot | |
14 | |
15 get_default_board | |
16 | |
17 DEFINE_string board "${DEFAULT_BOARD}" \ | |
18 "Board for which to build the package." | |
19 DEFINE_boolean test "${FLAGS_FALSE}" \ | |
20 "Compile and run tests as well." | |
21 DEFINE_boolean reconf "${FLAGS_FALSE}" \ | |
22 "Re-run configure and prepare steps." | |
23 DEFINE_boolean install "${FLAGS_FALSE}" \ | |
24 "Incrementally build and install your package." | |
25 DEFINE_boolean scrub "${FLAGS_FALSE}" \ | |
26 "Blow away all in-tree files not managed by git." | |
anush
2010/11/23 16:04:59
Should we call this "distclean" to keep with make'
Chris Masone
2010/11/23 19:42:21
I'm torn. --scrub is really destructive, moreso t
rochberg
2010/11/29 21:04:06
+1 to "are you sure"---files you forgot to git add
| |
27 | |
28 set -e | |
29 # Parse command line. | |
30 FLAGS "$@" || exit 1 | |
31 eval set -- "${FLAGS_ARGV}" | |
32 | |
33 if [ $# -lt 1 ]; then | |
34 echo "Usage: ${0} [OPTIONS] <package (read: ebuild) basename>" | |
35 exit 1 | |
36 fi | |
37 | |
38 if [ -n "${FLAGS_board}" ]; then | |
39 BOARD_DIR=/build/"${FLAGS_board}" | |
40 EBUILDCMD=ebuild-"${FLAGS_board}" | |
41 EMERGECMD=emerge-"${FLAGS_board}" | |
42 EQUERYCMD=equery-"${FLAGS_board}" | |
43 BOARD_STR="${FLAGS_board}" | |
44 BOARD_KEYWORD="$(portageq-${FLAGS_board} envvar ARCH)" | |
45 fi | |
46 | |
47 unstable_suffix="9999" | |
48 workon_name="${1}-${unstable_suffix}" | |
49 pkgfile= | |
50 workpath= | |
51 | |
52 if ! pkgfile=$("${EQUERYCMD}" which "${workon_name}" 2> /dev/null); then | |
53 if ACCEPT_KEYWORDS="~${BOARD_KEYWORD}" "${EQUERYCMD}" which "${workon_name}" \ | |
54 > /dev/null 2>&1; then | |
55 die "run './cros_workon --board ${BOARD_STR} start ${1}' first!" 1>&2 | |
anush
2010/11/23 16:04:59
I was wondering if we should just call the command
Chris Masone
2010/11/23 19:42:21
I always prefer the toolbox approach to the swiss
| |
56 fi | |
57 die "error looking up package $1" | |
58 fi | |
59 | |
60 if [ "${FLAGS_scrub}" = "${FLAGS_TRUE}" ]; then | |
61 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${workon_name}) info) | |
62 srcdir=$(readlink -m ${CROS_WORKON_SRCDIR}) | |
63 trunkdir=$(readlink -m ${CHROOT_TRUNK_DIR}) | |
64 project_path=${srcdir#${trunkdir}/} | |
65 if ! (cd "${GCLIENT_ROOT}/${project_path}" && git clean -xf); then | |
66 die "Could not scrub source directory" | |
67 fi | |
68 exit 0 | |
69 fi | |
70 | |
71 workpath=$(\ | |
72 echo "${pkgfile}" | \ | |
73 awk -F '/' '{ print $(NF-2) "/" $(NF-1) }')-"${unstable_suffix}" | |
74 | |
75 emerge_features= | |
76 to_do="compile" | |
77 if [ "${FLAGS_test}" = "${FLAGS_TRUE}" ]; then | |
78 to_do="test" | |
79 emerge_features="test" | |
80 fi | |
81 if [ "${FLAGS_install}" = "${FLAGS_TRUE}" ]; then | |
anush
2010/11/23 16:04:59
Can we make this the default i.e without an "insta
Chris Masone
2010/11/23 19:42:21
No, the whole point of this tool is to enable incr
| |
82 FEATURES="${emerge_features}" "${EMERGECMD}" "${1}" | |
83 exit $? | |
84 fi | |
85 | |
86 clean= | |
87 if [ "${FLAGS_reconf}" = "${FLAGS_TRUE}" ]; then | |
88 clean="clean" | |
89 else | |
90 rm -f "/build/${BOARD_STR}/tmp/portage/${workpath}/.compiled" | |
91 fi | |
92 SANDBOX_WRITE=~/trunk CROS_WORKON_INPLACE=1 \ | |
93 "${EBUILDCMD}" "${pkgfile}" ${clean} "${to_do}" | |
anush
2010/11/23 16:04:59
If we make the default as "install" then this need
Chris Masone
2010/11/23 19:42:21
nah, I think this should stay the default. I'm wr
rochberg
2010/11/29 21:04:06
Since my incremental workflow involves the device,
rochberg
2010/11/29 21:04:06
Since my incremental workflow involves the device,
| |
OLD | NEW |