OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 # | 6 # |
7 # Simple wrapper script to build a cros_workon package incrementally. | 7 # Simple wrapper script to build a cros_workon package incrementally. |
8 # You must already be cros_workon'ing the package in question. | 8 # You must already be cros_workon'ing the package in question. |
9 | 9 |
10 # --- BEGIN COMMON.SH BOILERPLATE --- | 10 # --- BEGIN COMMON.SH BOILERPLATE --- |
(...skipping 10 matching lines...) Expand all Loading... |
21 SCRIPT_ROOT=${path} | 21 SCRIPT_ROOT=${path} |
22 break | 22 break |
23 fi | 23 fi |
24 done | 24 done |
25 } | 25 } |
26 | 26 |
27 find_common_sh | 27 find_common_sh |
28 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) | 28 . "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) |
29 # --- END COMMON.SH BOILERPLATE --- | 29 # --- END COMMON.SH BOILERPLATE --- |
30 | 30 |
31 # Script must be run inside the chroot. | 31 die "error: Please run cros_workon_make from chroot:/usr/bin/cros_workon_make" |
32 restart_in_chroot_if_needed "$@" | |
33 | |
34 get_default_board | |
35 | |
36 DEFINE_string board "${DEFAULT_BOARD}" \ | |
37 "Board for which to build the package." | |
38 DEFINE_boolean test "${FLAGS_FALSE}" \ | |
39 "Compile and run tests as well." | |
40 DEFINE_boolean reconf "${FLAGS_FALSE}" \ | |
41 "Re-run configure and prepare steps." | |
42 DEFINE_boolean install "${FLAGS_FALSE}" \ | |
43 "Incrementally build and install your package." | |
44 DEFINE_boolean scrub "${FLAGS_FALSE}" \ | |
45 "Blow away all in-tree files not managed by git." | |
46 | |
47 set -e | |
48 # Parse command line. | |
49 FLAGS "$@" || exit 1 | |
50 eval set -- "${FLAGS_ARGV}" | |
51 | |
52 if [ $# -lt 1 ]; then | |
53 echo "Usage: ${0} [OPTIONS] <package (read: ebuild) basename>" | |
54 exit 1 | |
55 fi | |
56 | |
57 if [ -n "${FLAGS_board}" ]; then | |
58 BOARD_DIR=/build/"${FLAGS_board}" | |
59 EBUILDCMD=ebuild-"${FLAGS_board}" | |
60 EMERGECMD=emerge-"${FLAGS_board}" | |
61 EQUERYCMD=equery-"${FLAGS_board}" | |
62 BOARD_STR="${FLAGS_board}" | |
63 BOARD_KEYWORD="$(portageq-${FLAGS_board} envvar ARCH)" | |
64 fi | |
65 | |
66 unstable_suffix="9999" | |
67 workon_name="${1}-${unstable_suffix}" | |
68 pkgfile= | |
69 workpath= | |
70 | |
71 if ! pkgfile=$("${EQUERYCMD}" which "${workon_name}" 2> /dev/null); then | |
72 if ACCEPT_KEYWORDS="~${BOARD_KEYWORD}" "${EQUERYCMD}" which "${workon_name}" \ | |
73 > /dev/null 2>&1; then | |
74 die "run 'cros_workon --board ${BOARD_STR} start ${1}' first!" 1>&2 | |
75 fi | |
76 die "error looking up package $1" | |
77 fi | |
78 | |
79 if [ "${FLAGS_scrub}" = "${FLAGS_TRUE}" ]; then | |
80 warn "--scrub will destroy ALL FILES unknown to git!" | |
81 read -p "Are you sure you want to do this? [y|N]" resp | |
82 if egrep -qi "^y(es)?$" <(echo -n "${resp}"); then | |
83 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${workon_name}) info) | |
84 srcdir=$(readlink -m ${CROS_WORKON_SRCDIR}) | |
85 trunkdir=$(readlink -m ${CHROOT_TRUNK_DIR}) | |
86 project_path=${srcdir#${trunkdir}/} | |
87 if ! (cd "${GCLIENT_ROOT}/${project_path}" && git clean -xf); then | |
88 die "Could not scrub source directory" | |
89 fi | |
90 else | |
91 info "Not scrubbing; exiting gracefully" | |
92 fi | |
93 exit 0 | |
94 fi | |
95 | |
96 workpath=$(\ | |
97 echo "${pkgfile}" | \ | |
98 awk -F '/' '{ print $(NF-2) "/" $(NF-1) }')-"${unstable_suffix}" | |
99 | |
100 emerge_features= | |
101 to_do="compile" | |
102 if [ "${FLAGS_test}" = "${FLAGS_TRUE}" ]; then | |
103 to_do="test" | |
104 emerge_features="test" | |
105 fi | |
106 if [ "${FLAGS_install}" = "${FLAGS_TRUE}" ]; then | |
107 SANDBOX_WRITE=~/trunk CROS_WORKON_INPLACE=1 \ | |
108 FEATURES="${emerge_features} ${FEATURES}" "${EMERGECMD}" "${1}" | |
109 exit $? | |
110 fi | |
111 | |
112 clean= | |
113 if [ "${FLAGS_reconf}" = "${FLAGS_TRUE}" ]; then | |
114 clean="clean" | |
115 else | |
116 rm -f "/build/${BOARD_STR}/tmp/portage/${workpath}/.compiled" | |
117 fi | |
118 SANDBOX_WRITE=~/trunk CROS_WORKON_INPLACE=1 \ | |
119 "${EBUILDCMD}" "${pkgfile}" ${clean} "${to_do}" | |
OLD | NEW |