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 | |
20 # Script must be run inside the chroot | 17 # Script must be run inside the chroot |
21 restart_in_chroot_if_needed $* | 18 restart_in_chroot_if_needed $* |
22 get_default_board | 19 get_default_board |
23 | 20 |
24 DEFINE_string board "${DEFAULT_BOARD}" \ | 21 DEFINE_string board "${DEFAULT_BOARD}" \ |
25 "The board to set package keywords for." | 22 "The board to set package keywords for." |
26 DEFINE_boolean host "${FLAGS_FALSE}" \ | 23 DEFINE_boolean host "${FLAGS_FALSE}" \ |
27 "Uses the host instead of board" | 24 "Uses the host instead of board" |
28 DEFINE_string command "git status" \ | 25 DEFINE_string command "git status" \ |
29 "The command to be run by forall." | 26 "The command to be run by forall." |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 sudo rm -f "${KEYWORDS_FILE}" | 88 sudo rm -f "${KEYWORDS_FILE}" |
92 sudo ln -s "${WORKON_FILE}" "${KEYWORDS_FILE}" || \ | 89 sudo ln -s "${WORKON_FILE}" "${KEYWORDS_FILE}" || \ |
93 die "ln -s ${WORKON_FILE} ${KEYWORDS_FILE}" | 90 die "ln -s ${WORKON_FILE} ${KEYWORDS_FILE}" |
94 fi | 91 fi |
95 if [ ! -L "${UNMASK_FILE}" ]; then | 92 if [ ! -L "${UNMASK_FILE}" ]; then |
96 [ -f "${UNMASK_FILE}" ] && sudo mv "${UNMASK_FILE}" "${WORKON_FILE}" | 93 [ -f "${UNMASK_FILE}" ] && sudo mv "${UNMASK_FILE}" "${WORKON_FILE}" |
97 sudo ln -s "${WORKON_FILE}" "${UNMASK_FILE}" || \ | 94 sudo ln -s "${WORKON_FILE}" "${UNMASK_FILE}" || \ |
98 die "ln -s ${WORKON_FILE} ${UNMASK_FILE}" | 95 die "ln -s ${WORKON_FILE} ${UNMASK_FILE}" |
99 fi | 96 fi |
100 | 97 |
| 98 find_keyword_workon_ebuilds() { |
| 99 keyword="${1}" |
| 100 |
| 101 pushd "${BOARD_DIR}"/etc/ 1> /dev/null |
| 102 source make.conf |
| 103 popd 1> /dev/null |
| 104 local CROS_OVERLAYS="${PORTDIR_OVERLAY}" |
| 105 |
| 106 # NOTE: overlay may be a symlink, and we have to use ${overlay}/ |
| 107 for overlay in ${CROS_OVERLAYS}; do |
| 108 # only look up ebuilds named 9999 to eliminate duplicates |
| 109 find ${overlay}/ -name '*9999.ebuild' | \ |
| 110 xargs grep -l "inherit.*cros-workon" | \ |
| 111 xargs grep -l "KEYWORDS=.*${keyword}.*" |
| 112 done |
| 113 } |
| 114 |
| 115 show_workon_ebuilds() { |
| 116 keyword=$1 |
| 117 |
| 118 find_keyword_workon_ebuilds ${keyword} | \ |
| 119 sed -e 's/.*\/\([^/]*\)\/\([^/]*\)\/.*\.ebuild/\1\/\2/' | \ |
| 120 sort -u |
| 121 # This changes the absolute path to ebuilds into category/package. |
| 122 } |
| 123 |
101 # Canonicalize package name to category/package. | 124 # Canonicalize package name to category/package. |
102 canonicalize_name () { | 125 canonicalize_name () { |
103 local pkgfile | 126 local pkgfile |
104 local pkgname | 127 local pkgname |
105 | 128 |
106 if grep -qx "=$1-9999" "${WORKON_FILE}" ; then | 129 if grep -qx "=$1-9999" "${WORKON_FILE}" ; then |
107 echo $1 | 130 echo $1 |
108 return 0 | 131 return 0 |
109 fi | 132 fi |
110 | 133 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 fi | 267 fi |
245 | 268 |
246 case ${WORKON_CMD} in | 269 case ${WORKON_CMD} in |
247 start) ebuild_to_live "${ATOM_LIST}" ;; | 270 start) ebuild_to_live "${ATOM_LIST}" ;; |
248 stop) ebuild_to_stable "${ATOM_LIST}" ;; | 271 stop) ebuild_to_stable "${ATOM_LIST}" ;; |
249 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko
n_ebuilds ${BOARD_KEYWORD} ;; | 272 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko
n_ebuilds ${BOARD_KEYWORD} ;; |
250 list-all) show_all_live_ebuilds ;; | 273 list-all) show_all_live_ebuilds ;; |
251 iterate)ebuild_iterate "${ATOM_LIST}" ;; | 274 iterate)ebuild_iterate "${ATOM_LIST}" ;; |
252 *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; | 275 *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; |
253 esac | 276 esac |
OLD | NEW |