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 # This script moves ebuilds between 'stable' and 'live' states. | 7 # This script moves ebuilds between 'stable' and 'live' states. |
8 # By default 'stable' ebuilds point at and build from source at the | 8 # By default 'stable' ebuilds point at and build from source at the |
9 # last known good commit. Moving an ebuild to 'live' (via cros_workon start) | 9 # last known good commit. Moving an ebuild to 'live' (via cros_workon start) |
10 # is intended to support development. The current source tip is fetched, | 10 # is intended to support development. The current source tip is fetched, |
11 # source modified and built using the unstable 'live' (9999) ebuild. | 11 # source modified and built using the unstable 'live' (9999) ebuild. |
12 | 12 |
13 # Load common constants. This should be the first executable line. | 13 # Load common constants. This should be the first executable line. |
14 # The path to common.sh should be relative to your script's location. | 14 # The path to common.sh should be relative to your script's location. |
15 . "$(dirname "$0")/common.sh" | 15 . "$(dirname "$0")/common.sh" |
16 | 16 |
| 17 # Load common functions for workon scripts. |
| 18 . "$(dirname "$0")/lib/cros_workon_common.sh" |
| 19 |
17 # Script must be run inside the chroot | 20 # Script must be run inside the chroot |
18 restart_in_chroot_if_needed $* | 21 restart_in_chroot_if_needed $* |
19 get_default_board | 22 get_default_board |
20 | 23 |
21 DEFINE_string board "${DEFAULT_BOARD}" \ | 24 DEFINE_string board "${DEFAULT_BOARD}" \ |
22 "The board to set package keywords for." | 25 "The board to set package keywords for." |
23 DEFINE_boolean host "${FLAGS_FALSE}" \ | 26 DEFINE_boolean host "${FLAGS_FALSE}" \ |
24 "Uses the host instead of board" | 27 "Uses the host instead of board" |
25 DEFINE_string command "git status" \ | 28 DEFINE_string command "git status" \ |
26 "The command to be run by forall." | 29 "The command to be run by forall." |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 ebuild_iterate() { | 150 ebuild_iterate() { |
148 local atoms=$1 | 151 local atoms=$1 |
149 | 152 |
150 for atom in ${atoms}; do | 153 for atom in ${atoms}; do |
151 info "Running \"${FLAGS_command}\" on ${atom}" | 154 info "Running \"${FLAGS_command}\" on ${atom}" |
152 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${atom}) info) | 155 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${atom}) info) |
153 (cd "${CROS_WORKON_SRCDIR}" && bash -c "${FLAGS_command}") | 156 (cd "${CROS_WORKON_SRCDIR}" && bash -c "${FLAGS_command}") |
154 done | 157 done |
155 } | 158 } |
156 | 159 |
157 show_workon_ebuilds() { | |
158 pushd "${BOARD_DIR}"/etc/ 1> /dev/null | |
159 source make.conf | |
160 popd 1> /dev/null | |
161 local CROS_OVERLAYS="${PORTDIR_OVERLAY}" | |
162 | |
163 for overlay in ${CROS_OVERLAYS}; do | |
164 pushd ${overlay} 1> /dev/null | |
165 find . -name '*.ebuild' | xargs fgrep cros-workon | \ | |
166 awk -F / '{ print $2 "/" $3 }' | uniq | sort | |
167 popd 1> /dev/null | |
168 done | |
169 } | |
170 | |
171 # --all makes commands operate on different lists | 160 # --all makes commands operate on different lists |
172 if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then | 161 if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then |
173 case ${WORKON_CMD} in | 162 case ${WORKON_CMD} in |
174 start) ATOM_LIST=$(show_workon_ebuilds);; | 163 start) ATOM_LIST=$(show_workon_ebuilds);; |
175 stop|iterate) ATOM_LIST=$(show_live_ebuilds);; | 164 stop|iterate) ATOM_LIST=$(show_live_ebuilds);; |
176 list) ;; | 165 list) ;; |
177 *) die "--all is invalid for the given command";; | 166 *) die "--all is invalid for the given command";; |
178 esac | 167 esac |
179 else # not selected --all | 168 else # not selected --all |
180 case ${WORKON_CMD} in | 169 case ${WORKON_CMD} in |
181 start|stop|iterate) | 170 start|stop|iterate) |
182 ATOM_LIST=$@ | 171 ATOM_LIST=$@ |
183 if [ -z "${ATOM_LIST}" ]; then | 172 if [ -z "${ATOM_LIST}" ]; then |
184 die "${WORKON_CMD}: No packages specified" | 173 die "${WORKON_CMD}: No packages specified" |
185 elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then | 174 elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then |
186 die "Error parsing package list" | 175 die "Error parsing package list" |
187 fi;; | 176 fi;; |
188 *) ;; | 177 *) ;; |
189 esac | 178 esac |
190 fi | 179 fi |
191 | 180 |
192 case ${WORKON_CMD} in | 181 case ${WORKON_CMD} in |
193 start) ebuild_to_live "${ATOM_LIST}" ;; | 182 start) ebuild_to_live "${ATOM_LIST}" ;; |
194 stop) ebuild_to_stable "${ATOM_LIST}" ;; | 183 stop) ebuild_to_stable "${ATOM_LIST}" ;; |
195 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko
n_ebuilds ;; | 184 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko
n_ebuilds ;; |
196 iterate)ebuild_iterate "${ATOM_LIST}" ;; | 185 iterate)ebuild_iterate "${ATOM_LIST}" ;; |
197 *) die "invalid cros_workon command" ;; | 186 *) die "invalid cros_workon command" ;; |
198 esac | 187 esac |
OLD | NEW |