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

Side by Side Diff: cros_workon

Issue 2852019: cros_workon: initial implementation (Closed) Base URL: ssh://git@gitrw.chromium.org//crosutils.git
Patch Set: arg reordering complete, simple is better; sed --> grep Created 10 years, 6 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
(Empty)
1 #!/bin/bash
2
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
5 # found in the LICENSE file.
6
7 # This script moves ebuilds between 'stable' and 'live' states.
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)
10 # is intended to support development. The current source tip is fetched,
11 # source modified and built using the unstable 'live' (9999) ebuild.
12 #
13 # Usage:
14 # cros_workon <start|stop> <package> [<package> ...] [--board=<board-name]
15 # cros_workon list
16
17 # Load common constants. This should be the first executable line.
18 # The path to common.sh should be relative to your script's location.
19 . "$(dirname "$0")/common.sh"
20
21 # Script must be run inside the chroot
22 restart_in_chroot_if_needed $*
23 get_default_board
24
25 DEFINE_string board "${DEFAULT_BOARD}" \
26 "The board to set package keywords for."
27
28 FLAGS_HELP="usage: $0 [flags]"
29 FLAGS "$@" || exit 1
30 eval set -- "${FLAGS_ARGV}"
31
32 if [ -z "${FLAGS_board}" ] ; then
33 die "--board is required."
34 fi
35
36 # eat the workon command keywords: start, stop or list.
37 WORKON_CMD=$1
38 shift
39
40 ATOM_LIST=$@
41
42 BOARD_DIR=/build/"${FLAGS_board}"
43 KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords
44 KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon
45
46 # Move a stable ebuild to the live development catgeory. The ebuild
47 # src_unpack step fetches the package source for local development.
48 ebuild_to_live () {
49
50 local atoms=$1
51
52 echo
53 echo "Moving stable ebuild to live development:"
54
55 if [[ -d "${KEYWORDS_DIR}" ]]; then
56 sudo mkdir -p "${KEYWORDS_DIR}"
57 fi
58
59 for atom in ${atoms}; do
60
61 if [[ -f "${KEYWORDS_FILE}" ]] &&
62 $(grep -qx "${atom}" "${KEYWORDS_FILE}") ; then
63 echo " '${atom}' already marked for development"
64 else
65 echo " '${atom}'"
66 sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\""
67 fi
68 done
69 }
70
71 # Move a live development ebuild back to stable.
72 ebuild_to_stable () {
73
74 local atoms=$1
75
76 echo
77 echo "Moving live development ebuild to stable:"
78
79 for atom in ${atoms}; do
80
81 if [[ -f "${KEYWORDS_FILE}" ]] &&
82 $(grep -qx "${atom}" "${KEYWORDS_FILE}") ; then
83 echo " '${atom}'"
84 sudo bash -c "grep -v '^${atom}\$' \"${KEYWORDS_FILE}\" > \
85 \"${KEYWORDS_FILE}+\""
86 sudo mv "${KEYWORDS_FILE}+" "${KEYWORDS_FILE}"
87 fi
88 done
89 }
90
91 # Display ebuilds currently part of the live branch and open for development.
92 show_live_ebuilds () {
93 echo
94 echo "Live development ebuilds:"
95
96 cat "${KEYWORDS_FILE}"
97 }
98
99 case ${WORKON_CMD} in
100 start) ebuild_to_live "${ATOM_LIST}" ;;
101 stop) ebuild_to_stable "${ATOM_LIST}" ;;
102 list) show_live_ebuilds ;;
103 *) die "valid cros_workon commands: start|stop|list" ;;
104 esac
105
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