| 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, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 # there's no way to override. | 52 # there's no way to override. |
| 53 [ -n "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_TRUE} ] && \ | 53 [ -n "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_TRUE} ] && \ |
| 54 FLAGS_board="" # kill board | 54 FLAGS_board="" # kill board |
| 55 [ -z "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \ | 55 [ -z "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \ |
| 56 die "You must specify either --host or --board=" | 56 die "You must specify either --host or --board=" |
| 57 | 57 |
| 58 if [ -n "${FLAGS_board}" ]; then | 58 if [ -n "${FLAGS_board}" ]; then |
| 59 BOARD_DIR=/build/"${FLAGS_board}" # --board specified | 59 BOARD_DIR=/build/"${FLAGS_board}" # --board specified |
| 60 EQUERYCMD=equery-"${FLAGS_board}" | 60 EQUERYCMD=equery-"${FLAGS_board}" |
| 61 EBUILDCMD=ebuild-"${FLAGS_board}" | 61 EBUILDCMD=ebuild-"${FLAGS_board}" |
| 62 BOARD_STR="${FLAGS_board}" |
| 62 else | 63 else |
| 63 BOARD_DIR="" # --host specified | 64 BOARD_DIR="" # --host specified |
| 64 EQUERYCMD=equery | 65 EQUERYCMD=equery |
| 65 EBUILDCMD=ebuild | 66 EBUILDCMD=ebuild |
| 67 BOARD_STR="host" |
| 66 fi | 68 fi |
| 67 | 69 |
| 68 WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon | 70 WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon |
| 69 KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords | 71 KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords |
| 70 UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask | 72 UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask |
| 71 WORKON_FILE=${WORKON_DIR}/${FLAGS_board:-host} | 73 WORKON_FILE=${WORKON_DIR}/${FLAGS_board:-host} |
| 72 KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon | 74 KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon |
| 73 UNMASK_FILE=${UNMASK_DIR}/cros-workon | 75 UNMASK_FILE=${UNMASK_DIR}/cros-workon |
| 74 | 76 |
| 75 # TODO(msb): remove the backward compatibility after 09/01/2010 | 77 # TODO(msb): remove the backward compatibility after 09/01/2010 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | sort | uniq >> "${local_manifest}" | 195 | sort | uniq >> "${local_manifest}" |
| 194 echo "</manifest>" >> "${local_manifest}" | 196 echo "</manifest>" >> "${local_manifest}" |
| 195 echo "Please run \"repo sync\" now." | 197 echo "Please run \"repo sync\" now." |
| 196 fi | 198 fi |
| 197 } | 199 } |
| 198 | 200 |
| 199 # Move a stable ebuild to the live development catgeory. The ebuild | 201 # Move a stable ebuild to the live development catgeory. The ebuild |
| 200 # src_unpack step fetches the package source for local development. | 202 # src_unpack step fetches the package source for local development. |
| 201 ebuild_to_live () { | 203 ebuild_to_live () { |
| 202 local atoms=$1 | 204 local atoms=$1 |
| 205 local atoms_success="" |
| 203 | 206 |
| 204 for atom in ${atoms}; do | 207 for atom in ${atoms}; do |
| 205 if ! grep -qx "[~=]${atom}-9999" "${WORKON_FILE}" ; then | 208 if ! grep -qx "[~=]${atom}-9999" "${WORKON_FILE}" ; then |
| 206 sudo bash -c "echo \"=${atom}-9999\" >> \"${WORKON_FILE}\"" | 209 if sudo bash -c "echo \"=${atom}-9999\" >> \"${WORKON_FILE}\""; then |
| 210 atoms_success="${atoms_success} ${atom}" |
| 211 fi |
| 207 else | 212 else |
| 208 warn "Already working on ${atom}" | 213 warn "Already working on ${atom}" |
| 209 fi | 214 fi |
| 210 done | 215 done |
| 216 [ -n "${atoms_success}" ] && regen_manifest_and_sync && \ |
| 217 info "Started working on '${atoms_success/ /}' for '${BOARD_STR}'" |
| 211 } | 218 } |
| 212 | 219 |
| 213 # Move a live development ebuild back to stable. | 220 # Move a live development ebuild back to stable. |
| 214 ebuild_to_stable () { | 221 ebuild_to_stable () { |
| 215 local atoms=$1 | 222 local atoms=$1 |
| 223 local atoms_success="" |
| 216 | 224 |
| 217 for atom in ${atoms}; do | 225 for atom in ${atoms}; do |
| 218 if grep -qx "[~=]${atom}-9999" "${WORKON_FILE}" ; then | 226 if grep -qx "[~=]${atom}-9999" "${WORKON_FILE}" ; then |
| 219 sudo bash -c "grep -v '^[~=]${atom}-9999\$' \"${WORKON_FILE}\" > \ | 227 if sudo sed -e "/^[~=]${atom/\//\\/}-9999\$/d" -i "${WORKON_FILE}"; then |
| 220 \"${WORKON_FILE}+\"" | 228 atoms_success="${atoms_success} ${atom}" |
| 221 sudo mv "${WORKON_FILE}+" "${WORKON_FILE}" | 229 fi |
| 222 else | 230 else |
| 223 warn "Not working on ${atom}" | 231 warn "Not working on ${atom}" |
| 224 fi | 232 fi |
| 225 done | 233 done |
| 234 [ -n "${atoms_success}" ] && \ |
| 235 info "Stopped working on '${atoms_success/ /}' for '${BOARD_STR}'" |
| 226 } | 236 } |
| 227 | 237 |
| 228 # Run a command on all or a set of repos. | 238 # Run a command on all or a set of repos. |
| 229 ebuild_iterate() { | 239 ebuild_iterate() { |
| 230 local atoms=$1 | 240 local atoms=$1 |
| 231 | 241 |
| 232 for atom in ${atoms}; do | 242 for atom in ${atoms}; do |
| 233 info "Running \"${FLAGS_command}\" on ${atom}" | 243 info "Running \"${FLAGS_command}\" on ${atom}" |
| 234 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${atom}) info) | 244 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${atom}) info) |
| 235 (cd "${CROS_WORKON_SRCDIR}" && bash -c "${FLAGS_command}") | 245 (cd "${CROS_WORKON_SRCDIR}" && bash -c "${FLAGS_command}") |
| (...skipping 15 matching lines...) Expand all Loading... |
| 251 if [ -z "${ATOM_LIST}" ]; then | 261 if [ -z "${ATOM_LIST}" ]; then |
| 252 die "${WORKON_CMD}: No packages specified" | 262 die "${WORKON_CMD}: No packages specified" |
| 253 elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then | 263 elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then |
| 254 die "Error parsing package list" | 264 die "Error parsing package list" |
| 255 fi;; | 265 fi;; |
| 256 *) ;; | 266 *) ;; |
| 257 esac | 267 esac |
| 258 fi | 268 fi |
| 259 | 269 |
| 260 case ${WORKON_CMD} in | 270 case ${WORKON_CMD} in |
| 261 start) ebuild_to_live "${ATOM_LIST}"; regen_manifest_and_sync ;; | 271 start) ebuild_to_live "${ATOM_LIST}" ;; |
| 262 stop) ebuild_to_stable "${ATOM_LIST}" ;; | 272 stop) ebuild_to_stable "${ATOM_LIST}" ;; |
| 263 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko
n_ebuilds ;; | 273 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko
n_ebuilds ;; |
| 264 iterate)ebuild_iterate "${ATOM_LIST}" ;; | 274 iterate)ebuild_iterate "${ATOM_LIST}" ;; |
| 265 *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; | 275 *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; |
| 266 esac | 276 esac |
| OLD | NEW |