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

Side by Side Diff: cros_workon

Issue 2963011: cros_workon: introduce --all flag (Closed) Base URL: ssh://gitrw.chromium.org/crosutils
Patch Set: Fixed the comment Created 10 years, 5 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 # Script must be run inside the chroot 17 # Script must be run inside the chroot
18 restart_in_chroot_if_needed $* 18 restart_in_chroot_if_needed $*
19 get_default_board 19 get_default_board
20 20
21 DEFINE_string board "${DEFAULT_BOARD}" \ 21 DEFINE_string board "${DEFAULT_BOARD}" \
22 "The board to set package keywords for." 22 "The board to set package keywords for."
23 DEFINE_boolean host "${FLAGS_FALSE}" \ 23 DEFINE_boolean host "${FLAGS_FALSE}" \
24 "Uses the host instead of board" 24 "Uses the host instead of board"
25 DEFINE_string command "git status" \ 25 DEFINE_string command "git status" \
26 "The command to be run by forall." 26 "The command to be run by forall."
27 DEFINE_boolean all "${FLAGS_FALSE}" \
28 "Apply to all possible packages for the given command"
27 29
28 FLAGS_HELP="usage: $0 <command> [flags] 30 FLAGS_HELP="usage: $0 <command> [flags]
29 commands: 31 commands:
30 start: Moves an ebuild to live (intended to support development) 32 start: Moves an ebuild to live (intended to support development)
31 stop: Moves an ebuild to stable (use last known good) 33 stop: Moves an ebuild to stable (use last known good)
32 list: List of current live ebuilds 34 list: List of live ebuilds (workon ebuilds if --all)
33 listall: List all possible cros-workon ebuilds
34 forall: For each ebuild, cd to the source dir and run a commond" 35 forall: For each ebuild, cd to the source dir and run a commond"
35 FLAGS "$@" || exit 1 36 FLAGS "$@" || exit 1
36 eval set -- "${FLAGS_ARGV}" 37 eval set -- "${FLAGS_ARGV}"
37 38
38 39
39 # eat the workon command keywords: start, stop or list. 40 # eat the workon command keywords: start, stop or list.
40 WORKON_CMD=$1 41 WORKON_CMD=$1
41 shift 42 shift
42 43
43 44
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 done 99 done
99 100
100 echo "${names}" 101 echo "${names}"
101 } 102 }
102 103
103 # Display ebuilds currently part of the live branch and open for development. 104 # Display ebuilds currently part of the live branch and open for development.
104 show_live_ebuilds () { 105 show_live_ebuilds () {
105 cat "${KEYWORDS_FILE}" 106 cat "${KEYWORDS_FILE}"
106 } 107 }
107 108
108 ATOM_LIST=$@
109 if [ -z "${ATOM_LIST}" ]; then
110 ATOM_LIST=$(show_live_ebuilds)
111 else
112 if ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then
113 die "Error parsing package list"
114 fi
115 fi
116
117 # Move a stable ebuild to the live development catgeory. The ebuild 109 # Move a stable ebuild to the live development catgeory. The ebuild
118 # src_unpack step fetches the package source for local development. 110 # src_unpack step fetches the package source for local development.
119 ebuild_to_live () { 111 ebuild_to_live () {
120 local atoms=$1 112 local atoms=$1
121 113
122 for atom in ${atoms}; do 114 for atom in ${atoms}; do
123 if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then 115 if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then
124 sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\"" 116 sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\""
125 sudo bash -c "echo \"~${atom}-9999\" >> \"${UNMASK_FILE}\"" 117 sudo bash -c "echo \"~${atom}-9999\" >> \"${UNMASK_FILE}\""
126 else 118 else
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 local CROS_OVERLAYS="${PORTDIR_OVERLAY}" 159 local CROS_OVERLAYS="${PORTDIR_OVERLAY}"
168 160
169 for overlay in ${CROS_OVERLAYS}; do 161 for overlay in ${CROS_OVERLAYS}; do
170 pushd ${overlay} 1> /dev/null 162 pushd ${overlay} 1> /dev/null
171 find . -name '*.ebuild' | xargs fgrep cros-workon | \ 163 find . -name '*.ebuild' | xargs fgrep cros-workon | \
172 awk -F / '{ print $2 "/" $3 }' | uniq | sort 164 awk -F / '{ print $2 "/" $3 }' | uniq | sort
173 popd 1> /dev/null 165 popd 1> /dev/null
174 done 166 done
175 } 167 }
176 168
169 # --all makes commands operate on different lists
170 if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then
171 case ${WORKON_CMD} in
172 start) ATOM_LIST=$(show_workon_ebuilds);;
173 stop) ATOM_LIST=$(show_live_ebuilds);;
174 list) ;;
175 *) die "--all is invalid for the given command";;
176 esac
177 else # not selected --all
178 ATOM_LIST=$@
179 case ${WORKON_CMD} in
180 start|stop)
181 if [ -z "${ATOM_LIST}" ]; then
182 die "${WORKON_CMD}: No packages specified"
183 elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then
184 die "Error parsing package list"
185 fi;;
186 forall)
187 if [ -z "${ATOM_LIST}" ]; then
188 ATOM_LIST=$(show_workon_ebuilds)
189 elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then
190 die "Error parsing package list"
191 fi;;
192 *) ;;
193 esac
194 fi
195
177 case ${WORKON_CMD} in 196 case ${WORKON_CMD} in
178 start) ebuild_to_live "${ATOM_LIST}" ;; 197 start) ebuild_to_live "${ATOM_LIST}" ;;
179 stop) ebuild_to_stable "${ATOM_LIST}" ;; 198 stop) ebuild_to_stable "${ATOM_LIST}" ;;
180 list) show_live_ebuilds ;; 199 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko n_ebuilds ;;
181 forall) ebuild_forall "${ATOM_LIST}" ;; 200 forall) ebuild_forall "${ATOM_LIST}" ;;
182 listall)show_workon_ebuilds ;;
183 *) die "invalid cros_workon command" ;; 201 *) die "invalid cros_workon command" ;;
184 esac 202 esac
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698