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

Side by Side Diff: cros_workon

Issue 3151039: cros_workon: store cros_workon state outside of /build (Closed) Base URL: http://git.chromium.org/git/crosutils.git
Patch Set: Fixed. Created 10 years, 3 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 | Annotate | Revision Log
« 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,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 if [ -n "${FLAGS_board}" ]; then 54 if [ -n "${FLAGS_board}" ]; then
55 BOARD_DIR=/build/"${FLAGS_board}" # --board specified 55 BOARD_DIR=/build/"${FLAGS_board}" # --board specified
56 EQUERYCMD=equery-"${FLAGS_board}" 56 EQUERYCMD=equery-"${FLAGS_board}"
57 EBUILDCMD=ebuild-"${FLAGS_board}" 57 EBUILDCMD=ebuild-"${FLAGS_board}"
58 else 58 else
59 BOARD_DIR="" # --host specified 59 BOARD_DIR="" # --host specified
60 EQUERYCMD=equery 60 EQUERYCMD=equery
61 EBUILDCMD=ebuild 61 EBUILDCMD=ebuild
62 fi 62 fi
63 63
64 WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon
64 KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords 65 KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords
65 UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask 66 UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask
67 WORKON_FILE=${WORKON_DIR}/${FLAGS_board:-host}
66 KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon 68 KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon
67 UNMASK_FILE=${UNMASK_DIR}/cros-workon 69 UNMASK_FILE=${UNMASK_DIR}/cros-workon
68 70
69 sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \ 71 # TODO(msb): remove the backward compatibility after 09/01/2010
70 die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}" 72 sudo mkdir -p "${WORKON_DIR}" "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \
73 die "mkdir -p ${WORKON_DIR} ${KEYWORDS_DIR} ${UNMASK_DIR}"
71 if [ ! -L "${KEYWORDS_FILE}" ]; then 74 if [ ! -L "${KEYWORDS_FILE}" ]; then
72 sudo rm -f "${KEYWORDS_FILE}" 75 sudo rm -f "${KEYWORDS_FILE}"
73 sudo ln -s "${UNMASK_FILE}" "${KEYWORDS_FILE}" || \ 76 sudo ln -s "${WORKON_FILE}" "${KEYWORDS_FILE}" || \
74 die "ln -s ${UNMASK_FILE} ${KEYWORDS_FILE}" 77 die "ln -s ${WORKON_FILE} ${KEYWORDS_FILE}"
75 fi 78 fi
76 sudo touch "${UNMASK_FILE}" || \ 79 if [ ! -L "${UNMASK_FILE}" ]; then
77 die "touch ${UNMASK_FILE}" 80 [ -f "${UNMASK_FILE}" ] && sudo mv "${UNMASK_FILE}" "${WORKON_FILE}"
81 sudo ln -s "${WORKON_FILE}" "${UNMASK_FILE}" || \
82 die "ln -s ${WORKON_FILE} ${UNMASK_FILE}"
83 fi
84 sudo touch "${WORKON_FILE}" || \
85 die "touch ${WORKON_FILE}"
78 86
79 # Canonicalize package name to category/package. 87 # Canonicalize package name to category/package.
80 canonicalize_name () { 88 canonicalize_name () {
81 local pkgfile 89 local pkgfile
82 local pkgname 90 local pkgname
83 91
84 if ! pkgfile=$(ACCEPT_KEYWORDS="**" ${EQUERYCMD} which $1); then 92 if ! pkgfile=$(ACCEPT_KEYWORDS="**" ${EQUERYCMD} which $1); then
85 warn "error looking up package $1" 1>&2 93 warn "error looking up package $1" 1>&2
86 return 1 94 return 1
87 fi 95 fi
(...skipping 18 matching lines...) Expand all
106 local name=$(canonicalize_name "${atom}") 114 local name=$(canonicalize_name "${atom}")
107 [ -n "${name}" ] || return 1 115 [ -n "${name}" ] || return 1
108 names+=" ${name}" 116 names+=" ${name}"
109 done 117 done
110 118
111 echo "${names}" 119 echo "${names}"
112 } 120 }
113 121
114 # Display ebuilds currently part of the live branch and open for development. 122 # Display ebuilds currently part of the live branch and open for development.
115 show_live_ebuilds () { 123 show_live_ebuilds () {
116 sed -n 's/^[~=]\(.*\)-9999$/\1/p' "${UNMASK_FILE}" 124 sed -n 's/^[~=]\(.*\)-9999$/\1/p' "${WORKON_FILE}"
117 } 125 }
118 126
119 find_repo_dir () { 127 find_repo_dir () {
120 curdir=`pwd` 128 curdir=`pwd`
121 while [ $curdir != / ]; do 129 while [ $curdir != / ]; do
122 if [ -d "$curdir/.repo" ]; then 130 if [ -d "$curdir/.repo" ]; then
123 #echo "Found .repo directory at ${curdir}" 131 #echo "Found .repo directory at ${curdir}"
124 REPODIR=${curdir}/.repo 132 REPODIR=${curdir}/.repo
125 return 0 133 return 0
126 fi 134 fi
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 echo "Please run \"repo sync\" now." 172 echo "Please run \"repo sync\" now."
165 fi 173 fi
166 } 174 }
167 175
168 # Move a stable ebuild to the live development catgeory. The ebuild 176 # Move a stable ebuild to the live development catgeory. The ebuild
169 # src_unpack step fetches the package source for local development. 177 # src_unpack step fetches the package source for local development.
170 ebuild_to_live () { 178 ebuild_to_live () {
171 local atoms=$1 179 local atoms=$1
172 180
173 for atom in ${atoms}; do 181 for atom in ${atoms}; do
174 if ! grep -qx "[~=]${atom}-9999" "${UNMASK_FILE}" ; then 182 if ! grep -qx "[~=]${atom}-9999" "${WORKON_FILE}" ; then
175 sudo bash -c "echo \"=${atom}-9999\" >> \"${UNMASK_FILE}\"" 183 sudo bash -c "echo \"=${atom}-9999\" >> \"${WORKON_FILE}\""
176 else 184 else
177 warn "Already working on ${atom}" 185 warn "Already working on ${atom}"
178 fi 186 fi
179 done 187 done
180 } 188 }
181 189
182 # Move a live development ebuild back to stable. 190 # Move a live development ebuild back to stable.
183 ebuild_to_stable () { 191 ebuild_to_stable () {
184 local atoms=$1 192 local atoms=$1
185 193
186 for atom in ${atoms}; do 194 for atom in ${atoms}; do
187 if grep -qx "[~=]${atom}-9999" "${UNMASK_FILE}" ; then 195 if grep -qx "[~=]${atom}-9999" "${WORKON_FILE}" ; then
188 sudo bash -c "grep -v '^[~=]${atom}-9999\$' \"${UNMASK_FILE}\" > \ 196 sudo bash -c "grep -v '^[~=]${atom}-9999\$' \"${WORKON_FILE}\" > \
189 \"${UNMASK_FILE}+\"" 197 \"${WORKON_FILE}+\""
190 sudo mv "${UNMASK_FILE}+" "${UNMASK_FILE}" 198 sudo mv "${WORKON_FILE}+" "${WORKON_FILE}"
191 else 199 else
192 warn "Not working on ${atom}" 200 warn "Not working on ${atom}"
193 fi 201 fi
194 done 202 done
195 } 203 }
196 204
197 # Run a command on all or a set of repos. 205 # Run a command on all or a set of repos.
198 ebuild_iterate() { 206 ebuild_iterate() {
199 local atoms=$1 207 local atoms=$1
200 208
(...skipping 25 matching lines...) Expand all
226 esac 234 esac
227 fi 235 fi
228 236
229 case ${WORKON_CMD} in 237 case ${WORKON_CMD} in
230 start) ebuild_to_live "${ATOM_LIST}"; regen_manifest_and_sync ;; 238 start) ebuild_to_live "${ATOM_LIST}"; regen_manifest_and_sync ;;
231 stop) ebuild_to_stable "${ATOM_LIST}" ;; 239 stop) ebuild_to_stable "${ATOM_LIST}" ;;
232 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko n_ebuilds ;; 240 list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_worko n_ebuilds ;;
233 iterate)ebuild_iterate "${ATOM_LIST}" ;; 241 iterate)ebuild_iterate "${ATOM_LIST}" ;;
234 *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; 242 *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;;
235 esac 243 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