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

Side by Side Diff: cros_workon

Issue 2883012: cros_workon: quick hack at package name checking (Closed) Base URL: ssh://git@chromiumos-git/crosutils.git
Patch Set: Send again. Created 10 years, 5 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
« 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 27 matching lines...) Expand all
38 WORKON_CMD=$1 38 WORKON_CMD=$1
39 shift 39 shift
40 40
41 BOARD_DIR=/build/"${FLAGS_board}" 41 BOARD_DIR=/build/"${FLAGS_board}"
42 KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords 42 KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords
43 KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon 43 KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon
44 44
45 sudo mkdir -p "${KEYWORDS_DIR}" || die "mkdir -p ${KEYWORDS_DIR}" 45 sudo mkdir -p "${KEYWORDS_DIR}" || die "mkdir -p ${KEYWORDS_DIR}"
46 sudo touch "${KEYWORDS_FILE}" || die "touch ${KEYWORDS_FILE}" 46 sudo touch "${KEYWORDS_FILE}" || die "touch ${KEYWORDS_FILE}"
47 47
48 # Canonicalize package name to category/package.
49 canonicalize_name () {
50 equery-${FLAGS_board} which $1 | \
sosa 2010/07/01 17:44:07 If only equery list could do this with an option i
51 awk -F '/' '{ print $(NF-2) "/" $(NF-1) }'
52 }
53
54 # Canonicalize a list of names
sosa 2010/07/01 17:44:07 Period at end.
55 canonicalize_names () {
56 local atoms=$1
57 local names
sosa 2010/07/01 17:44:07 Prefer if you explicitly set names to ""
58
59 for atom in ${atoms}; do
60 local name=$(canonicalize_name "${atom}")
61 [ -n "${name}" ] || return 1
62 names+=" ${name}"
63 done
64 echo ${names}
65 }
66
48 # Display ebuilds currently part of the live branch and open for development. 67 # Display ebuilds currently part of the live branch and open for development.
49 show_live_ebuilds () { 68 show_live_ebuilds () {
50 cat "${KEYWORDS_FILE}" 69 cat "${KEYWORDS_FILE}"
51 } 70 }
52 71
53 ATOM_LIST=$@ 72 ATOM_LIST=$@
73 ATOM_LIST=$(canonicalize_names "${ATOM_LIST}") || die "Invalid package name"
54 [ -n "${ATOM_LIST}" ] || ATOM_LIST=$(show_live_ebuilds) 74 [ -n "${ATOM_LIST}" ] || ATOM_LIST=$(show_live_ebuilds)
55 75
56 # Move a stable ebuild to the live development catgeory. The ebuild 76 # Move a stable ebuild to the live development catgeory. The ebuild
57 # src_unpack step fetches the package source for local development. 77 # src_unpack step fetches the package source for local development.
58 ebuild_to_live () { 78 ebuild_to_live () {
59 local atoms=$1 79 local atoms=$1
60 80
61 for atom in ${atoms}; do 81 for atom in ${atoms}; do
62 if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then 82 if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then
63 sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\"" 83 sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\""
(...skipping 23 matching lines...) Expand all
87 done 107 done
88 } 108 }
89 109
90 case ${WORKON_CMD} in 110 case ${WORKON_CMD} in
91 start) ebuild_to_live "${ATOM_LIST}" ;; 111 start) ebuild_to_live "${ATOM_LIST}" ;;
92 stop) ebuild_to_stable "${ATOM_LIST}" ;; 112 stop) ebuild_to_stable "${ATOM_LIST}" ;;
93 list) show_live_ebuilds ;; 113 list) show_live_ebuilds ;;
94 forall) ebuild_forall "${ATOM_LIST}" ;; 114 forall) ebuild_forall "${ATOM_LIST}" ;;
95 *) die "invalid cros_workon command" ;; 115 *) die "invalid cros_workon command" ;;
96 esac 116 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