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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon | 59 KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon |
60 UNMASK_FILE=${UNMASK_DIR}/cros-workon | 60 UNMASK_FILE=${UNMASK_DIR}/cros-workon |
61 | 61 |
62 sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \ | 62 sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \ |
63 die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}" | 63 die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}" |
64 sudo touch "${KEYWORDS_FILE}" "${UNMASK_FILE}" || \ | 64 sudo touch "${KEYWORDS_FILE}" "${UNMASK_FILE}" || \ |
65 die "touch ${KEYWORDS_FILE} ${UNMASK_FILE}" | 65 die "touch ${KEYWORDS_FILE} ${UNMASK_FILE}" |
66 | 66 |
67 # Canonicalize package name to category/package. | 67 # Canonicalize package name to category/package. |
68 canonicalize_name () { | 68 canonicalize_name () { |
69 ${EQUERY} which $1 | \ | 69 local pkgfile |
70 awk -F '/' '{ print $(NF-2) "/" $(NF-1) }' | 70 local pkgname |
| 71 |
| 72 if ! pkgfile=$(${EQUERY} which $1); then |
| 73 warn "error looking up package $1" 1>&2 |
| 74 return 1 |
| 75 fi |
| 76 |
| 77 pkgname=$(\ |
| 78 echo "${pkgfile}" |awk -F '/' '{ print $(NF-2) "/" $(NF-1) }') |
| 79 |
| 80 if ! grep -q "cros-workon" ${pkgfile}; then |
| 81 warn "${pkgname} is not a cros-workon package" 1>&2 |
| 82 return 1 |
| 83 fi |
| 84 echo "${pkgname}" |
| 85 return 0 |
71 } | 86 } |
72 | 87 |
73 # Canonicalize a list of names. | 88 # Canonicalize a list of names. |
74 canonicalize_names () { | 89 canonicalize_names () { |
75 local atoms=$1 | 90 local atoms=$1 |
76 local names="" | 91 local names="" |
77 | 92 |
78 for atom in ${atoms}; do | 93 for atom in ${atoms}; do |
79 local name=$(canonicalize_name "${atom}") | 94 local name=$(canonicalize_name "${atom}") |
80 [ -n "${name}" ] || return 1 | 95 [ -n "${name}" ] || return 1 |
81 names+=" ${name}" | 96 names+=" ${name}" |
82 done | 97 done |
83 echo ${names} | 98 |
| 99 echo "${names}" |
84 } | 100 } |
85 | 101 |
86 # Display ebuilds currently part of the live branch and open for development. | 102 # Display ebuilds currently part of the live branch and open for development. |
87 show_live_ebuilds () { | 103 show_live_ebuilds () { |
88 cat "${KEYWORDS_FILE}" | 104 cat "${KEYWORDS_FILE}" |
89 } | 105 } |
90 | 106 |
91 ATOM_LIST=$@ | 107 ATOM_LIST=$@ |
92 ATOM_LIST=$(canonicalize_names "${ATOM_LIST}") || die "Invalid package name" | 108 if [ -z "${ATOM_LIST}" ]; then |
93 [ -n "${ATOM_LIST}" ] || ATOM_LIST=$(show_live_ebuilds) | 109 ATOM_LIST=$(show_live_ebuilds) |
| 110 else |
| 111 if ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then |
| 112 die "Error parsing package list" |
| 113 fi |
| 114 fi |
94 | 115 |
95 # Move a stable ebuild to the live development catgeory. The ebuild | 116 # Move a stable ebuild to the live development catgeory. The ebuild |
96 # src_unpack step fetches the package source for local development. | 117 # src_unpack step fetches the package source for local development. |
97 ebuild_to_live () { | 118 ebuild_to_live () { |
98 local atoms=$1 | 119 local atoms=$1 |
99 | 120 |
100 for atom in ${atoms}; do | 121 for atom in ${atoms}; do |
101 if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then | 122 if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then |
102 sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\"" | 123 sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\"" |
103 sudo bash -c "echo \"~${atom}-9999\" >> \"${UNMASK_FILE}\"" | 124 sudo bash -c "echo \"~${atom}-9999\" >> \"${UNMASK_FILE}\"" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 done | 159 done |
139 } | 160 } |
140 | 161 |
141 case ${WORKON_CMD} in | 162 case ${WORKON_CMD} in |
142 start) ebuild_to_live "${ATOM_LIST}" ;; | 163 start) ebuild_to_live "${ATOM_LIST}" ;; |
143 stop) ebuild_to_stable "${ATOM_LIST}" ;; | 164 stop) ebuild_to_stable "${ATOM_LIST}" ;; |
144 list) show_live_ebuilds ;; | 165 list) show_live_ebuilds ;; |
145 forall) ebuild_forall "${ATOM_LIST}" ;; | 166 forall) ebuild_forall "${ATOM_LIST}" ;; |
146 *) die "invalid cros_workon command" ;; | 167 *) die "invalid cros_workon command" ;; |
147 esac | 168 esac |
OLD | NEW |