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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 EBUILDCMD=ebuild | 61 EBUILDCMD=ebuild |
62 fi | 62 fi |
63 | 63 |
64 KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords | 64 KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords |
65 UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask | 65 UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask |
66 KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon | 66 KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon |
67 UNMASK_FILE=${UNMASK_DIR}/cros-workon | 67 UNMASK_FILE=${UNMASK_DIR}/cros-workon |
68 | 68 |
69 sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \ | 69 sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \ |
70 die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}" | 70 die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}" |
71 sudo touch "${KEYWORDS_FILE}" "${UNMASK_FILE}" || \ | 71 if [ ! -L "${KEYWORDS_FILE}" ]; then |
72 die "touch ${KEYWORDS_FILE} ${UNMASK_FILE}" | 72 sudo rm -f "${KEYWORDS_FILE}" |
| 73 sudo ln -s "${UNMASK_FILE}" "${KEYWORDS_FILE}" || \ |
| 74 die "ln -s ${UNMASK_FILE} ${KEYWORDS_FILE}" |
| 75 fi |
| 76 sudo touch "${UNMASK_FILE}" || \ |
| 77 die "touch ${UNMASK_FILE}" |
73 | 78 |
74 # Canonicalize package name to category/package. | 79 # Canonicalize package name to category/package. |
75 canonicalize_name () { | 80 canonicalize_name () { |
76 local pkgfile | 81 local pkgfile |
77 local pkgname | 82 local pkgname |
78 | 83 |
79 if ! pkgfile=$(ACCEPT_KEYWORDS="**" ${EQUERYCMD} which $1); then | 84 if ! pkgfile=$(ACCEPT_KEYWORDS="**" ${EQUERYCMD} which $1); then |
80 warn "error looking up package $1" 1>&2 | 85 warn "error looking up package $1" 1>&2 |
81 return 1 | 86 return 1 |
82 fi | 87 fi |
(...skipping 18 matching lines...) Expand all Loading... |
101 local name=$(canonicalize_name "${atom}") | 106 local name=$(canonicalize_name "${atom}") |
102 [ -n "${name}" ] || return 1 | 107 [ -n "${name}" ] || return 1 |
103 names+=" ${name}" | 108 names+=" ${name}" |
104 done | 109 done |
105 | 110 |
106 echo "${names}" | 111 echo "${names}" |
107 } | 112 } |
108 | 113 |
109 # Display ebuilds currently part of the live branch and open for development. | 114 # Display ebuilds currently part of the live branch and open for development. |
110 show_live_ebuilds () { | 115 show_live_ebuilds () { |
111 cat "${KEYWORDS_FILE}" | 116 sed -n 's/^[~=]\(.*\)-9999$/\1/p' "${UNMASK_FILE}" |
112 } | 117 } |
113 | 118 |
114 find_repo_dir () { | 119 find_repo_dir () { |
115 curdir=`pwd` | 120 curdir=`pwd` |
116 while [ $curdir != / ]; do | 121 while [ $curdir != / ]; do |
117 if [ -d "$curdir/.repo" ]; then | 122 if [ -d "$curdir/.repo" ]; then |
118 #echo "Found .repo directory at ${curdir}" | 123 #echo "Found .repo directory at ${curdir}" |
119 REPODIR=${curdir}/.repo | 124 REPODIR=${curdir}/.repo |
120 return 0 | 125 return 0 |
121 fi | 126 fi |
122 curdir=`dirname "$curdir"` | 127 curdir=`dirname "$curdir"` |
123 done | 128 done |
124 echo "Unable to find .repo directory. Did you checkout with repo?" | 129 echo "Unable to find .repo directory. Did you checkout with repo?" |
125 exit 1 | 130 exit 1 |
126 } | 131 } |
127 | 132 |
128 | 133 |
129 # This is called only for "cros-workon start". We dont handle the "stop" case si
nce the local changes are ignored anyway since the 9999.ebuild is masked and we
dont want to deal with what to do with the user's local changes. | 134 # This is called only for "cros-workon start". We dont handle the "stop" case si
nce the local changes are ignored anyway since the 9999.ebuild is masked and we
dont want to deal with what to do with the user's local changes. |
130 regen_manifest_and_sync() { | 135 regen_manifest_and_sync() { |
131 find_repo_dir | 136 find_repo_dir |
132 local_manifest="${REPODIR}/local_manifest.xml" | 137 local_manifest="${REPODIR}/local_manifest.xml" |
133 | 138 |
134 # preserve old manifest entries | 139 # preserve old manifest entries |
135 [ -f "${local_manifest}" ] && \ | 140 [ -f "${local_manifest}" ] && \ |
136 MANIFEST_ENTRIES_OLD=$(cat "${local_manifest}" | grep "^<project") | 141 MANIFEST_ENTRIES_OLD=$(cat "${local_manifest}" | grep "^<project") |
137 | 142 |
138 rm -f "${local_manifest}" | 143 rm -f "${local_manifest}" |
139 | 144 |
140 # get new manifest entries | 145 # get new manifest entries |
141 MANIFEST_ENTRIES=$(cat ${KEYWORDS_FILE} | | 146 MANIFEST_ENTRIES=$(show_live_ebuilds | |
142 { | 147 { |
143 while read line | 148 while read line |
144 do | 149 do |
145 pkgname=`basename ${line}` | 150 pkgname=`basename ${line}` |
146 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info) | 151 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info) |
147 REPO_ELEMENT=$(sed -n '/START_MINILAYOUT/,/STOP_MINILAYOUT/p' $REPODIR/man
ifest.xml | grep "name=\"${CROS_WORKON_PROJECT}\"" | sed -e 's/^[ \t]*//') | 152 REPO_ELEMENT=$(sed -n '/START_MINILAYOUT/,/STOP_MINILAYOUT/p' $REPODIR/man
ifest.xml | grep "name=\"${CROS_WORKON_PROJECT}\"" | sed -e 's/^[ \t]*//') |
148 echo "$REPO_ELEMENT" | 153 echo "$REPO_ELEMENT" |
149 done | 154 done |
150 }) | 155 }) |
151 | 156 |
152 if [ -n "${MANIFEST_ENTRIES}" ] || [ -n "${MANIFEST_ENTRIES_OLD}" ]; then | 157 if [ -n "${MANIFEST_ENTRIES}" ] || [ -n "${MANIFEST_ENTRIES_OLD}" ]; then |
153 info "Creating local manifest for workon packages.." | 158 info "Creating local manifest for workon packages.." |
154 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" >> "${local_manifest}" | 159 echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" >> "${local_manifest}" |
155 echo "<manifest>" >> "${local_manifest}" | 160 echo "<manifest>" >> "${local_manifest}" |
156 echo -e "${MANIFEST_ENTRIES}\n${MANIFEST_ENTRIES_OLD}" \ | 161 echo -e "${MANIFEST_ENTRIES}\n${MANIFEST_ENTRIES_OLD}" \ |
157 | sort | uniq >> "${local_manifest}" | 162 | sort | uniq >> "${local_manifest}" |
158 echo "</manifest>" >> "${local_manifest}" | 163 echo "</manifest>" >> "${local_manifest}" |
159 echo "Please run \"repo sync\" now." | 164 echo "Please run \"repo sync\" now." |
160 fi | 165 fi |
161 } | 166 } |
162 | 167 |
163 # Move a stable ebuild to the live development catgeory. The ebuild | 168 # Move a stable ebuild to the live development catgeory. The ebuild |
164 # src_unpack step fetches the package source for local development. | 169 # src_unpack step fetches the package source for local development. |
165 ebuild_to_live () { | 170 ebuild_to_live () { |
166 local atoms=$1 | 171 local atoms=$1 |
167 | 172 |
168 for atom in ${atoms}; do | 173 for atom in ${atoms}; do |
169 if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then | 174 if ! grep -qx "[~=]${atom}-9999" "${UNMASK_FILE}" ; then |
170 sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\"" | 175 sudo bash -c "echo \"=${atom}-9999\" >> \"${UNMASK_FILE}\"" |
171 sudo bash -c "echo \"~${atom}-9999\" >> \"${UNMASK_FILE}\"" | |
172 else | 176 else |
173 warn "Already working on ${atom}" | 177 warn "Already working on ${atom}" |
174 fi | 178 fi |
175 done | 179 done |
176 } | 180 } |
177 | 181 |
178 # Move a live development ebuild back to stable. | 182 # Move a live development ebuild back to stable. |
179 ebuild_to_stable () { | 183 ebuild_to_stable () { |
180 local atoms=$1 | 184 local atoms=$1 |
181 | 185 |
182 for atom in ${atoms}; do | 186 for atom in ${atoms}; do |
183 if grep -qx "${atom}" "${KEYWORDS_FILE}" ; then | 187 if grep -qx "[~=]${atom}-9999" "${UNMASK_FILE}" ; then |
184 # remove the keyword | 188 sudo bash -c "grep -v '^[~=]${atom}-9999\$' \"${UNMASK_FILE}\" > \ |
185 sudo bash -c "grep -v '^${atom}\$' \"${KEYWORDS_FILE}\" > \ | |
186 \"${KEYWORDS_FILE}+\"" | |
187 sudo mv "${KEYWORDS_FILE}+" "${KEYWORDS_FILE}" | |
188 # remove the unmask | |
189 sudo bash -c "grep -v '^~${atom}-9999\$' \"${UNMASK_FILE}\" > \ | |
190 \"${UNMASK_FILE}+\"" | 189 \"${UNMASK_FILE}+\"" |
191 sudo mv "${UNMASK_FILE}+" "${UNMASK_FILE}" | 190 sudo mv "${UNMASK_FILE}+" "${UNMASK_FILE}" |
192 else | 191 else |
193 warn "Not working on ${atom}" | 192 warn "Not working on ${atom}" |
194 fi | 193 fi |
195 done | 194 done |
196 } | 195 } |
197 | 196 |
198 # Run a command on all or a set of repos. | 197 # Run a command on all or a set of repos. |
199 ebuild_iterate() { | 198 ebuild_iterate() { |
(...skipping 27 matching lines...) Expand all Loading... |
227 esac | 226 esac |
228 fi | 227 fi |
229 | 228 |
230 case ${WORKON_CMD} in | 229 case ${WORKON_CMD} in |
231 start) ebuild_to_live "${ATOM_LIST}"; regen_manifest_and_sync ;; | 230 start) ebuild_to_live "${ATOM_LIST}"; regen_manifest_and_sync ;; |
232 stop) ebuild_to_stable "${ATOM_LIST}" ;; | 231 stop) ebuild_to_stable "${ATOM_LIST}" ;; |
233 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko
n_ebuilds ;; | 232 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko
n_ebuilds ;; |
234 iterate)ebuild_iterate "${ATOM_LIST}" ;; | 233 iterate)ebuild_iterate "${ATOM_LIST}" ;; |
235 *) die "invalid cros_workon command" ;; | 234 *) die "invalid cros_workon command" ;; |
236 esac | 235 esac |
OLD | NEW |