From 01772ff58f371940650daf46b45b333f7e489b3c Mon Sep 17 00:00:00 2001 From: Brian Daugherty Date: Wed, 23 Jun 2010 14:43:28 -0600 Subject: [PATCH 01/64] cros_workon: initial implementation Moves ebuild(s) between stable and live states. Lists ebuilds currently under development in the testing branch. Stable ebuilds obtain and build against the last known good commit. Live ebuilds (9999) perform a 'git clone' during the src_unpack step to obtain and save the source for development and building. Example usage: Sync & build 'ibus-hangul' testing ebuild (9999) ./cros_workon start app-i18n/ibus-hangul Build 'ibus-hangul' from the last stable commit ./cros_workon stop app-i18n/ibus-hangul List of ebuilds under development ./cros_workon list Change-Id: I2ea4babd7597d5cea9ca96419a74152f9f0b23f1 Note: --board must be specified if the --default option to setup_board was not used. Review URL: http://codereview.chromium.org/2852019 --- cros_workon | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100755 cros_workon diff --git a/cros_workon b/cros_workon new file mode 100755 index 0000000000..5854b889ab --- /dev/null +++ b/cros_workon @@ -0,0 +1,105 @@ +#!/bin/bash + +# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This script moves ebuilds between 'stable' and 'live' states. +# By default 'stable' ebuilds point at and build from source at the +# last known good commit. Moving an ebuild to 'live' (via cros_workon start) +# is intended to support development. The current source tip is fetched, +# source modified and built using the unstable 'live' (9999) ebuild. +# +# Usage: +# cros_workon [ ...] [--board=> \"${KEYWORDS_FILE}\"" + fi + done +} + +# Move a live development ebuild back to stable. +ebuild_to_stable () { + + local atoms=$1 + + echo + echo "Moving live development ebuild to stable:" + + for atom in ${atoms}; do + + if [[ -f "${KEYWORDS_FILE}" ]] && + $(grep -qx "${atom}" "${KEYWORDS_FILE}") ; then + echo " '${atom}'" + sudo bash -c "grep -v '^${atom}\$' \"${KEYWORDS_FILE}\" > \ + \"${KEYWORDS_FILE}+\"" + sudo mv "${KEYWORDS_FILE}+" "${KEYWORDS_FILE}" + fi + done +} + +# Display ebuilds currently part of the live branch and open for development. +show_live_ebuilds () { + echo + echo "Live development ebuilds:" + + cat "${KEYWORDS_FILE}" +} + +case ${WORKON_CMD} in + start) ebuild_to_live "${ATOM_LIST}" ;; + stop) ebuild_to_stable "${ATOM_LIST}" ;; + list) show_live_ebuilds ;; + *) die "valid cros_workon commands: start|stop|list" ;; +esac + From 4cf9fdb84eba7003eb577a55a86e35725392504b Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Wed, 30 Jun 2010 09:21:55 -0700 Subject: [PATCH 02/64] cros_workon: modify to be less verbose We need to be able to use "cros_workon list" in pipelines. Also, would be nice if the other commands were less verbose. Ideally, they should die and return a non-zero value. Also cleaned up the logic in some of the functions. This fixed a couple of bugs: 1) "cros-workon list" would fail if KEYWORDS_FILE didn't exist 2) "cros-workon start" would fail if KEYWORDS_DIR didn't exit Change-Id: I76c87f0e36b72c12e8ae937cbadca6cf21a34bad Review URL: http://codereview.chromium.org/2880005 --- cros_workon | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/cros_workon b/cros_workon index 5854b889ab..3915448058 100755 --- a/cros_workon +++ b/cros_workon @@ -43,26 +43,16 @@ BOARD_DIR=/build/"${FLAGS_board}" KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon +sudo mkdir -p "${KEYWORDS_DIR}" || die "mkdir -p ${KEYWORDS_DIR}" +sudo touch "${KEYWORDS_FILE}" || die "touch ${KEYWORDS_FILE}" + # Move a stable ebuild to the live development catgeory. The ebuild # src_unpack step fetches the package source for local development. ebuild_to_live () { - local atoms=$1 - echo - echo "Moving stable ebuild to live development:" - - if [[ -d "${KEYWORDS_DIR}" ]]; then - sudo mkdir -p "${KEYWORDS_DIR}" - fi - for atom in ${atoms}; do - - if [[ -f "${KEYWORDS_FILE}" ]] && - $(grep -qx "${atom}" "${KEYWORDS_FILE}") ; then - echo " '${atom}' already marked for development" - else - echo " '${atom}'" + if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\"" fi done @@ -70,29 +60,17 @@ ebuild_to_live () { # Move a live development ebuild back to stable. ebuild_to_stable () { - local atoms=$1 - echo - echo "Moving live development ebuild to stable:" - for atom in ${atoms}; do - - if [[ -f "${KEYWORDS_FILE}" ]] && - $(grep -qx "${atom}" "${KEYWORDS_FILE}") ; then - echo " '${atom}'" - sudo bash -c "grep -v '^${atom}\$' \"${KEYWORDS_FILE}\" > \ - \"${KEYWORDS_FILE}+\"" - sudo mv "${KEYWORDS_FILE}+" "${KEYWORDS_FILE}" - fi + sudo bash -c "grep -v '^${atom}\$' \"${KEYWORDS_FILE}\" > \ + \"${KEYWORDS_FILE}+\"" + sudo mv "${KEYWORDS_FILE}+" "${KEYWORDS_FILE}" done } # Display ebuilds currently part of the live branch and open for development. show_live_ebuilds () { - echo - echo "Live development ebuilds:" - cat "${KEYWORDS_FILE}" } @@ -102,4 +80,3 @@ case ${WORKON_CMD} in list) show_live_ebuilds ;; *) die "valid cros_workon commands: start|stop|list" ;; esac - From a8df0aed429468787a1297611aaf3c0e39193f81 Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Wed, 30 Jun 2010 18:51:48 -0700 Subject: [PATCH 03/64] cros_workon: add support for a forall command Change-Id: If0c75ee905c4a8076340fa9675c17e9292125268 Review URL: http://codereview.chromium.org/2880007 --- cros_workon | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/cros_workon b/cros_workon index 3915448058..6f7aeaaf60 100755 --- a/cros_workon +++ b/cros_workon @@ -9,10 +9,6 @@ # last known good commit. Moving an ebuild to 'live' (via cros_workon start) # is intended to support development. The current source tip is fetched, # source modified and built using the unstable 'live' (9999) ebuild. -# -# Usage: -# cros_workon [ ...] [--board= Date: Thu, 1 Jul 2010 14:05:19 -0700 Subject: [PATCH 04/64] cros_workon: quick hack at package name checking Change-Id: I30e97760d5b96077e38414be31ef434542021361 Review URL: http://codereview.chromium.org/2883012 --- cros_workon | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cros_workon b/cros_workon index 6f7aeaaf60..8477d90bd0 100755 --- a/cros_workon +++ b/cros_workon @@ -45,12 +45,32 @@ KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon sudo mkdir -p "${KEYWORDS_DIR}" || die "mkdir -p ${KEYWORDS_DIR}" sudo touch "${KEYWORDS_FILE}" || die "touch ${KEYWORDS_FILE}" +# Canonicalize package name to category/package. +canonicalize_name () { + equery-${FLAGS_board} which $1 | \ + awk -F '/' '{ print $(NF-2) "/" $(NF-1) }' +} + +# Canonicalize a list of names. +canonicalize_names () { + local atoms=$1 + local names="" + + for atom in ${atoms}; do + local name=$(canonicalize_name "${atom}") + [ -n "${name}" ] || return 1 + names+=" ${name}" + done + echo ${names} +} + # Display ebuilds currently part of the live branch and open for development. show_live_ebuilds () { cat "${KEYWORDS_FILE}" } ATOM_LIST=$@ +ATOM_LIST=$(canonicalize_names "${ATOM_LIST}") || die "Invalid package name" [ -n "${ATOM_LIST}" ] || ATOM_LIST=$(show_live_ebuilds) # Move a stable ebuild to the live development catgeory. The ebuild From d26c7eec732a17f88ce604871ac8ac70d3fa30ff Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Fri, 9 Jul 2010 18:08:46 -0700 Subject: [PATCH 05/64] cros_workon: also create unmask * This fixes the issue, where cros-workon packages have a package.mask set to prevent upstream ebuilds from rolling in. In general, it brings out the cavalry for unmasking the live package in every possible way. Review URL: http://codereview.chromium.org/2934007 --- cros_workon | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cros_workon b/cros_workon index 8477d90bd0..904997f36a 100755 --- a/cros_workon +++ b/cros_workon @@ -39,11 +39,14 @@ WORKON_CMD=$1 shift BOARD_DIR=/build/"${FLAGS_board}" -KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords -KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon -sudo mkdir -p "${KEYWORDS_DIR}" || die "mkdir -p ${KEYWORDS_DIR}" -sudo touch "${KEYWORDS_FILE}" || die "touch ${KEYWORDS_FILE}" +KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords +UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask +KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon +UNMASK_FILE=${UNMASK_DIR}/cros-workon + +sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}" +sudo touch "${KEYWORDS_FILE}" "${UNMASK_FILE}" || die "touch ${KEYWORDS_FILE} ${UNMASK_FILE}" # Canonicalize package name to category/package. canonicalize_name () { @@ -81,6 +84,7 @@ ebuild_to_live () { for atom in ${atoms}; do if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\"" + sudo bash -c "echo \"~${atom}-9999\" >> \"${UNMASK_FILE}\"" fi done } @@ -90,9 +94,15 @@ ebuild_to_stable () { local atoms=$1 for atom in ${atoms}; do + # remove the keyword sudo bash -c "grep -v '^${atom}\$' \"${KEYWORDS_FILE}\" > \ \"${KEYWORDS_FILE}+\"" sudo mv "${KEYWORDS_FILE}+" "${KEYWORDS_FILE}" + # remove the unmask + sudo bash -c "grep -v '^~${atom}-9999\$' \"${UNMASK_FILE}\" > \ + \"${UNMASK_FILE}+\"" + sudo mv "${UNMASK_FILE}+" "${UNMASK_FILE}" + done } From e906f22eee5d573b00486cebbf89bc41b23f29bb Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Mon, 12 Jul 2010 15:40:49 -0700 Subject: [PATCH 06/64] cros_workon: allow unmasking packages for the host modified: cros_workon Review URL: http://codereview.chromium.org/2945010 --- cros_workon | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/cros_workon b/cros_workon index 904997f36a..ff4414fc9c 100755 --- a/cros_workon +++ b/cros_workon @@ -20,6 +20,8 @@ get_default_board DEFINE_string board "${DEFAULT_BOARD}" \ "The board to set package keywords for." +DEFINE_boolean host "${FLAGS_FALSE}" \ + "Uses the host instead of board" DEFINE_string command "git status" \ "The command to be run by forall." @@ -32,25 +34,39 @@ commands: FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" -[ -n "${FLAGS_board}" ] || die "--board is required." +# board dir config +[ -n "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_TRUE} ] && \ + die "Flags --host and --board are mutually exclusive." +[ -z "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \ + die "You must specify either --host or --board=" + +if [ -n "${FLAGS_board}" ]; then + BOARD_DIR=/build/"${FLAGS_board}" # --board specified + EQUERY=equery-"${FLAGS_board}" +else + BOARD_DIR="" # --host specified + EQUERY=equery +fi + # eat the workon command keywords: start, stop or list. WORKON_CMD=$1 shift -BOARD_DIR=/build/"${FLAGS_board}" KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon UNMASK_FILE=${UNMASK_DIR}/cros-workon -sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}" -sudo touch "${KEYWORDS_FILE}" "${UNMASK_FILE}" || die "touch ${KEYWORDS_FILE} ${UNMASK_FILE}" +sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \ + die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}" +sudo touch "${KEYWORDS_FILE}" "${UNMASK_FILE}" || \ + die "touch ${KEYWORDS_FILE} ${UNMASK_FILE}" # Canonicalize package name to category/package. canonicalize_name () { - equery-${FLAGS_board} which $1 | \ + ${EQUERY} which $1 | \ awk -F '/' '{ print $(NF-2) "/" $(NF-1) }' } @@ -112,7 +128,7 @@ ebuild_forall() { for atom in ${atoms}; do info "Running \"${FLAGS_command}\" on ${atom}" - eval $(ebuild-${FLAGS_board} $(equery-${FLAGS_board} which ${atom}) info) + eval $(ebuild-${FLAGS_board} $(${EQUERY} which ${atom}) info) (cd "${CROS_WORKON_SRCDIR}" && bash -c "${FLAGS_command}") done } From c075f0401e07c3582250073216a2c0549b109064 Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Tue, 13 Jul 2010 13:31:44 -0700 Subject: [PATCH 07/64] cros_workon: corner case fixes * Warn if user stops working on a package he wasn't working on * Warn if user starts to work on a package he already is working on Review URL: http://codereview.chromium.org/2978002 --- cros_workon | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/cros_workon b/cros_workon index ff4414fc9c..fb73f09abd 100755 --- a/cros_workon +++ b/cros_workon @@ -101,6 +101,8 @@ ebuild_to_live () { if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\"" sudo bash -c "echo \"~${atom}-9999\" >> \"${UNMASK_FILE}\"" + else + warn "Already working on ${atom}" fi done } @@ -110,15 +112,18 @@ ebuild_to_stable () { local atoms=$1 for atom in ${atoms}; do - # remove the keyword - sudo bash -c "grep -v '^${atom}\$' \"${KEYWORDS_FILE}\" > \ - \"${KEYWORDS_FILE}+\"" - sudo mv "${KEYWORDS_FILE}+" "${KEYWORDS_FILE}" - # remove the unmask - sudo bash -c "grep -v '^~${atom}-9999\$' \"${UNMASK_FILE}\" > \ - \"${UNMASK_FILE}+\"" - sudo mv "${UNMASK_FILE}+" "${UNMASK_FILE}" - + if grep -qx "${atom}" "${KEYWORDS_FILE}" ; then + # remove the keyword + sudo bash -c "grep -v '^${atom}\$' \"${KEYWORDS_FILE}\" > \ + \"${KEYWORDS_FILE}+\"" + sudo mv "${KEYWORDS_FILE}+" "${KEYWORDS_FILE}" + # remove the unmask + sudo bash -c "grep -v '^~${atom}-9999\$' \"${UNMASK_FILE}\" > \ + \"${UNMASK_FILE}+\"" + sudo mv "${UNMASK_FILE}+" "${UNMASK_FILE}" + else + warn "Not working on ${atom}" + fi done } From 627eb08855a63778c0f01cee0523001548945be7 Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Tue, 13 Jul 2010 15:08:07 -0700 Subject: [PATCH 08/64] cros_workon: check selected packages if they are cros-workon, related fixes Override locally warn/error functions to not interfere with stdout of canonicalize_name. Future FIXME in common.sh. Review URL: http://codereview.chromium.org/2985003 --- cros_workon | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/cros_workon b/cros_workon index fb73f09abd..0e5534063f 100755 --- a/cros_workon +++ b/cros_workon @@ -66,8 +66,23 @@ sudo touch "${KEYWORDS_FILE}" "${UNMASK_FILE}" || \ # Canonicalize package name to category/package. canonicalize_name () { - ${EQUERY} which $1 | \ - awk -F '/' '{ print $(NF-2) "/" $(NF-1) }' + local pkgfile + local pkgname + + if ! pkgfile=$(${EQUERY} which $1); then + warn "error looking up package $1" 1>&2 + return 1 + fi + + pkgname=$(\ + echo "${pkgfile}" |awk -F '/' '{ print $(NF-2) "/" $(NF-1) }') + + if ! grep -q "cros-workon" ${pkgfile}; then + warn "${pkgname} is not a cros-workon package" 1>&2 + return 1 + fi + echo "${pkgname}" + return 0 } # Canonicalize a list of names. @@ -80,7 +95,8 @@ canonicalize_names () { [ -n "${name}" ] || return 1 names+=" ${name}" done - echo ${names} + + echo "${names}" } # Display ebuilds currently part of the live branch and open for development. @@ -89,8 +105,13 @@ show_live_ebuilds () { } ATOM_LIST=$@ -ATOM_LIST=$(canonicalize_names "${ATOM_LIST}") || die "Invalid package name" -[ -n "${ATOM_LIST}" ] || ATOM_LIST=$(show_live_ebuilds) +if [ -z "${ATOM_LIST}" ]; then + ATOM_LIST=$(show_live_ebuilds) +else + if ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then + die "Error parsing package list" + fi +fi # Move a stable ebuild to the live development catgeory. The ebuild # src_unpack step fetches the package source for local development. From 7d12cb8bd1231167f10c8e247924997a8494a6ad Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Tue, 13 Jul 2010 16:48:12 -0700 Subject: [PATCH 09/64] cros_workon: introduce a very simple listall command TBR: sosa, msb - I already got the LGTM, then made a silly whitespace change! Review URL: http://codereview.chromium.org/2909009 --- cros_workon | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/cros_workon b/cros_workon index 0e5534063f..4ff535c0cb 100755 --- a/cros_workon +++ b/cros_workon @@ -29,11 +29,18 @@ FLAGS_HELP="usage: $0 [flags] commands: start: Moves an ebuild to live (intended to support development) stop: Moves an ebuild to stable (use last known good) - list: List of all live ebuilds + list: List of current live ebuilds + listall: List all possible cros-workon ebuilds forall: For each ebuild, cd to the source dir and run a commond" FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" + +# eat the workon command keywords: start, stop or list. +WORKON_CMD=$1 +shift + + # board dir config [ -n "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_TRUE} ] && \ die "Flags --host and --board are mutually exclusive." @@ -48,12 +55,6 @@ else EQUERY=equery fi - -# eat the workon command keywords: start, stop or list. -WORKON_CMD=$1 -shift - - KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon @@ -159,10 +160,25 @@ ebuild_forall() { done } +show_workon_ebuilds() { + pushd "${BOARD_DIR}"/etc/ 1> /dev/null + source make.conf + popd 1> /dev/null + local CROS_OVERLAYS="${PORTDIR_OVERLAY}" + + for overlay in ${CROS_OVERLAYS}; do + pushd ${overlay} 1> /dev/null + find . -name '*.ebuild' | xargs fgrep cros-workon | \ + awk -F / '{ print $2 "/" $3 }' | uniq | sort + popd 1> /dev/null + done +} + case ${WORKON_CMD} in start) ebuild_to_live "${ATOM_LIST}" ;; stop) ebuild_to_stable "${ATOM_LIST}" ;; list) show_live_ebuilds ;; forall) ebuild_forall "${ATOM_LIST}" ;; + listall)show_workon_ebuilds ;; *) die "invalid cros_workon command" ;; esac From f9a42ed40bd8b47be2a04b5f7d8c012ac3a92a91 Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Wed, 14 Jul 2010 15:47:09 -0700 Subject: [PATCH 10/64] cros_workon: introduce --all flag * Replaced listall with list --all * stop/start without arguments will now fail * stop/start with --all will do just the expected thing * Rewritten package list decision logic TBR: msb - already got LGTM, then fixed a comment i noticed Review URL: http://codereview.chromium.org/2963011 --- cros_workon | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/cros_workon b/cros_workon index 4ff535c0cb..33eb594c80 100755 --- a/cros_workon +++ b/cros_workon @@ -24,13 +24,14 @@ DEFINE_boolean host "${FLAGS_FALSE}" \ "Uses the host instead of board" DEFINE_string command "git status" \ "The command to be run by forall." +DEFINE_boolean all "${FLAGS_FALSE}" \ + "Apply to all possible packages for the given command" FLAGS_HELP="usage: $0 [flags] commands: start: Moves an ebuild to live (intended to support development) stop: Moves an ebuild to stable (use last known good) - list: List of current live ebuilds - listall: List all possible cros-workon ebuilds + list: List of live ebuilds (workon ebuilds if --all) forall: For each ebuild, cd to the source dir and run a commond" FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" @@ -105,15 +106,6 @@ show_live_ebuilds () { cat "${KEYWORDS_FILE}" } -ATOM_LIST=$@ -if [ -z "${ATOM_LIST}" ]; then - ATOM_LIST=$(show_live_ebuilds) -else - if ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then - die "Error parsing package list" - fi -fi - # Move a stable ebuild to the live development catgeory. The ebuild # src_unpack step fetches the package source for local development. ebuild_to_live () { @@ -174,11 +166,37 @@ show_workon_ebuilds() { done } +# --all makes commands operate on different lists +if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then + case ${WORKON_CMD} in + start) ATOM_LIST=$(show_workon_ebuilds);; + stop) ATOM_LIST=$(show_live_ebuilds);; + list) ;; + *) die "--all is invalid for the given command";; + esac +else # not selected --all + ATOM_LIST=$@ + case ${WORKON_CMD} in + start|stop) + if [ -z "${ATOM_LIST}" ]; then + die "${WORKON_CMD}: No packages specified" + elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then + die "Error parsing package list" + fi;; + forall) + if [ -z "${ATOM_LIST}" ]; then + ATOM_LIST=$(show_workon_ebuilds) + elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then + die "Error parsing package list" + fi;; + *) ;; + esac +fi + case ${WORKON_CMD} in start) ebuild_to_live "${ATOM_LIST}" ;; stop) ebuild_to_stable "${ATOM_LIST}" ;; - list) show_live_ebuilds ;; + list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ;; forall) ebuild_forall "${ATOM_LIST}" ;; - listall)show_workon_ebuilds ;; *) die "invalid cros_workon command" ;; esac From 014939b2c73d4f71c8724f927f68634bbab7443d Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Thu, 15 Jul 2010 15:41:52 -0700 Subject: [PATCH 11/64] cros_workon: fix forall (broken by --host) :/ Review URL: http://codereview.chromium.org/2966016 --- cros_workon | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cros_workon b/cros_workon index 33eb594c80..fc9d6d15cf 100755 --- a/cros_workon +++ b/cros_workon @@ -50,10 +50,12 @@ shift if [ -n "${FLAGS_board}" ]; then BOARD_DIR=/build/"${FLAGS_board}" # --board specified - EQUERY=equery-"${FLAGS_board}" + EQUERYCMD=equery-"${FLAGS_board}" + EBUILDCMD=ebuild-"${FLAGS_board}" else BOARD_DIR="" # --host specified - EQUERY=equery + EQUERYCMD=equery + EBUILDCMD=ebuild fi KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords @@ -71,7 +73,7 @@ canonicalize_name () { local pkgfile local pkgname - if ! pkgfile=$(${EQUERY} which $1); then + if ! pkgfile=$(${EQUERYCMD} which $1); then warn "error looking up package $1" 1>&2 return 1 fi @@ -147,7 +149,7 @@ ebuild_forall() { for atom in ${atoms}; do info "Running \"${FLAGS_command}\" on ${atom}" - eval $(ebuild-${FLAGS_board} $(${EQUERY} which ${atom}) info) + eval $(${EBUILDCMD} $(${EQUERYCMD} which ${atom}) info) (cd "${CROS_WORKON_SRCDIR}" && bash -c "${FLAGS_command}") done } From d17540f6bc30ed74349dc507390c9cc2f183bf49 Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Thu, 15 Jul 2010 16:13:00 -0700 Subject: [PATCH 12/64] cros-workon: change forall into iterate * Bend iterate to accept either list of packages or --all, following the new semantics This is a re-upload of the original CL which seems to be broken beyond repair by the git malfunctions yesterday Review URL: http://codereview.chromium.org/3040001 --- cros_workon | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/cros_workon b/cros_workon index fc9d6d15cf..652a721ff1 100755 --- a/cros_workon +++ b/cros_workon @@ -27,12 +27,12 @@ DEFINE_string command "git status" \ DEFINE_boolean all "${FLAGS_FALSE}" \ "Apply to all possible packages for the given command" -FLAGS_HELP="usage: $0 [flags] +FLAGS_HELP="usage: $0 [flags] [|--all] commands: start: Moves an ebuild to live (intended to support development) stop: Moves an ebuild to stable (use last known good) list: List of live ebuilds (workon ebuilds if --all) - forall: For each ebuild, cd to the source dir and run a commond" + iterate: For each ebuild, cd to the source dir and run a commond" FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" @@ -144,7 +144,7 @@ ebuild_to_stable () { } # Run a command on all or a set of repos. -ebuild_forall() { +ebuild_iterate() { local atoms=$1 for atom in ${atoms}; do @@ -172,33 +172,23 @@ show_workon_ebuilds() { if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then case ${WORKON_CMD} in start) ATOM_LIST=$(show_workon_ebuilds);; - stop) ATOM_LIST=$(show_live_ebuilds);; + stop|iterate) ATOM_LIST=$(show_live_ebuilds);; list) ;; *) die "--all is invalid for the given command";; esac else # not selected --all ATOM_LIST=$@ - case ${WORKON_CMD} in - start|stop) - if [ -z "${ATOM_LIST}" ]; then - die "${WORKON_CMD}: No packages specified" - elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then - die "Error parsing package list" - fi;; - forall) - if [ -z "${ATOM_LIST}" ]; then - ATOM_LIST=$(show_workon_ebuilds) - elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then - die "Error parsing package list" - fi;; - *) ;; - esac + if [ -z "${ATOM_LIST}" ]; then + die "${WORKON_CMD}: No packages specified" + elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then + die "Error parsing package list" + fi fi case ${WORKON_CMD} in start) ebuild_to_live "${ATOM_LIST}" ;; stop) ebuild_to_stable "${ATOM_LIST}" ;; list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ;; - forall) ebuild_forall "${ATOM_LIST}" ;; + iterate) ebuild_iterate "${ATOM_LIST}" ;; *) die "invalid cros_workon command" ;; esac From d52cade7d37331de31b136d477cb8a403dde5437 Mon Sep 17 00:00:00 2001 From: David James Date: Thu, 15 Jul 2010 20:37:23 -0700 Subject: [PATCH 13/64] Revert "cros-workon: change forall into iterate" This breaks cros-workon list, which is used by build_packages. This reverts commit dc3359ba7cd3d67886a958d580e83bdce9e14faf. Review URL: http://codereview.chromium.org/3008005 --- cros_workon | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/cros_workon b/cros_workon index 652a721ff1..fc9d6d15cf 100755 --- a/cros_workon +++ b/cros_workon @@ -27,12 +27,12 @@ DEFINE_string command "git status" \ DEFINE_boolean all "${FLAGS_FALSE}" \ "Apply to all possible packages for the given command" -FLAGS_HELP="usage: $0 [flags] [|--all] +FLAGS_HELP="usage: $0 [flags] commands: start: Moves an ebuild to live (intended to support development) stop: Moves an ebuild to stable (use last known good) list: List of live ebuilds (workon ebuilds if --all) - iterate: For each ebuild, cd to the source dir and run a commond" + forall: For each ebuild, cd to the source dir and run a commond" FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" @@ -144,7 +144,7 @@ ebuild_to_stable () { } # Run a command on all or a set of repos. -ebuild_iterate() { +ebuild_forall() { local atoms=$1 for atom in ${atoms}; do @@ -172,23 +172,33 @@ show_workon_ebuilds() { if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then case ${WORKON_CMD} in start) ATOM_LIST=$(show_workon_ebuilds);; - stop|iterate) ATOM_LIST=$(show_live_ebuilds);; + stop) ATOM_LIST=$(show_live_ebuilds);; list) ;; *) die "--all is invalid for the given command";; esac else # not selected --all ATOM_LIST=$@ - if [ -z "${ATOM_LIST}" ]; then - die "${WORKON_CMD}: No packages specified" - elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then - die "Error parsing package list" - fi + case ${WORKON_CMD} in + start|stop) + if [ -z "${ATOM_LIST}" ]; then + die "${WORKON_CMD}: No packages specified" + elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then + die "Error parsing package list" + fi;; + forall) + if [ -z "${ATOM_LIST}" ]; then + ATOM_LIST=$(show_workon_ebuilds) + elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then + die "Error parsing package list" + fi;; + *) ;; + esac fi case ${WORKON_CMD} in start) ebuild_to_live "${ATOM_LIST}" ;; stop) ebuild_to_stable "${ATOM_LIST}" ;; list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ;; - iterate) ebuild_iterate "${ATOM_LIST}" ;; + forall) ebuild_forall "${ATOM_LIST}" ;; *) die "invalid cros_workon command" ;; esac From 3a1cf2061f7ee2d24a8a659da67065c2a457c527 Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Fri, 16 Jul 2010 16:05:14 -0700 Subject: [PATCH 14/64] cros-workon: change forall into iterate * Bend iterate to accept either list of packages or --all, following the new semantics Reintroduces commit dc3359ba7cd3d67886a958d580e83bdce9e14faf, with fixed list cmd Review URL: http://codereview.chromium.org/3022003 --- cros_workon | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/cros_workon b/cros_workon index fc9d6d15cf..73431a3109 100755 --- a/cros_workon +++ b/cros_workon @@ -27,12 +27,12 @@ DEFINE_string command "git status" \ DEFINE_boolean all "${FLAGS_FALSE}" \ "Apply to all possible packages for the given command" -FLAGS_HELP="usage: $0 [flags] +FLAGS_HELP="usage: $0 [flags] [|--all] commands: start: Moves an ebuild to live (intended to support development) stop: Moves an ebuild to stable (use last known good) list: List of live ebuilds (workon ebuilds if --all) - forall: For each ebuild, cd to the source dir and run a commond" + iterate: For each ebuild, cd to the source dir and run a commond" FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" @@ -144,7 +144,7 @@ ebuild_to_stable () { } # Run a command on all or a set of repos. -ebuild_forall() { +ebuild_iterate() { local atoms=$1 for atom in ${atoms}; do @@ -172,25 +172,19 @@ show_workon_ebuilds() { if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then case ${WORKON_CMD} in start) ATOM_LIST=$(show_workon_ebuilds);; - stop) ATOM_LIST=$(show_live_ebuilds);; + stop|iterate) ATOM_LIST=$(show_live_ebuilds);; list) ;; *) die "--all is invalid for the given command";; esac else # not selected --all - ATOM_LIST=$@ case ${WORKON_CMD} in - start|stop) + start|stop|iterate) + ATOM_LIST=$@ if [ -z "${ATOM_LIST}" ]; then die "${WORKON_CMD}: No packages specified" elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then die "Error parsing package list" fi;; - forall) - if [ -z "${ATOM_LIST}" ]; then - ATOM_LIST=$(show_workon_ebuilds) - elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then - die "Error parsing package list" - fi;; *) ;; esac fi @@ -199,6 +193,6 @@ case ${WORKON_CMD} in start) ebuild_to_live "${ATOM_LIST}" ;; stop) ebuild_to_stable "${ATOM_LIST}" ;; list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ;; - forall) ebuild_forall "${ATOM_LIST}" ;; + iterate)ebuild_iterate "${ATOM_LIST}" ;; *) die "invalid cros_workon command" ;; esac From 8b61e59b147e7f83f65520310d10eb507b44cf33 Mon Sep 17 00:00:00 2001 From: Chris Sosa Date: Mon, 19 Jul 2010 11:50:11 -0700 Subject: [PATCH 15/64] Create common script file for workon tools. Planning on using in another CL. Review URL: http://codereview.chromium.org/3022010 --- cros_workon | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/cros_workon b/cros_workon index 73431a3109..e9d02426be 100755 --- a/cros_workon +++ b/cros_workon @@ -14,6 +14,9 @@ # The path to common.sh should be relative to your script's location. . "$(dirname "$0")/common.sh" +# Load common functions for workon scripts. +. "$(dirname "$0")/lib/cros_workon_common.sh" + # Script must be run inside the chroot restart_in_chroot_if_needed $* get_default_board @@ -154,20 +157,6 @@ ebuild_iterate() { done } -show_workon_ebuilds() { - pushd "${BOARD_DIR}"/etc/ 1> /dev/null - source make.conf - popd 1> /dev/null - local CROS_OVERLAYS="${PORTDIR_OVERLAY}" - - for overlay in ${CROS_OVERLAYS}; do - pushd ${overlay} 1> /dev/null - find . -name '*.ebuild' | xargs fgrep cros-workon | \ - awk -F / '{ print $2 "/" $3 }' | uniq | sort - popd 1> /dev/null - done -} - # --all makes commands operate on different lists if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then case ${WORKON_CMD} in From 9e1daf4f03589df5dbbf30b64b53696a87265a8c Mon Sep 17 00:00:00 2001 From: Anush Elangovan Date: Wed, 28 Jul 2010 12:07:48 -0700 Subject: [PATCH 16/64] Add repo local manifest support --- cros_workon | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/cros_workon b/cros_workon index e9d02426be..d48bed9298 100755 --- a/cros_workon +++ b/cros_workon @@ -111,6 +111,50 @@ show_live_ebuilds () { cat "${KEYWORDS_FILE}" } +find_repo_dir () { + curdir=`pwd` + while [ $curdir != / ]; do + if [ -d "$curdir/.repo" ]; then + #echo "Found .repo directory at ${curdir}" + REPODIR=${curdir}/.repo + return 0 + fi + curdir=`dirname "$curdir"` + done + echo "Unable to find .repo directory. Did you checkout with repo?" + exit 1 +} + + +# This is called only for "cros-workon start". We dont handle the "stop" case since 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. +regen_manifest_and_sync() { + find_repo_dir + echo Using $REPODIR + echo "Trying to generate local manifests for.." + rm -f $REPODIR/local_manifest.xml + echo "" >> $REPODIR/local_manifest.xml + echo "" >> $REPODIR/local_manifest.xml + + cat ${KEYWORDS_FILE} | + { + while read line + do + pkgname=`basename ${line}` + echo "Now working on ... ${pkgname}" + eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info) + echo "Looking for ${CROS_WORKON_PROJECT}.git" + REPO_ELEMENT=$(sed -n '/START_MINILAYOUT/,/STOP_MINILAYOUT/p' $REPODIR/manifest.xml | grep "name=\"${CROS_WORKON_PROJECT}\"" | sed -e 's/^[ \t]*//') + echo $REPO_ELEMENT + if [ -z "${REPO_ELEMENT}" ] ; then + echo "Unable to find ${pkgname} in manifest. Aborting." + exit 1 + fi + echo ${REPO_ELEMENT} >> $REPODIR/local_manifest.xml + done + } + echo "" >> $REPODIR/local_manifest.xml +} + # Move a stable ebuild to the live development catgeory. The ebuild # src_unpack step fetches the package source for local development. ebuild_to_live () { @@ -120,6 +164,7 @@ ebuild_to_live () { if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\"" sudo bash -c "echo \"~${atom}-9999\" >> \"${UNMASK_FILE}\"" + regen_manifest_and_sync else warn "Already working on ${atom}" fi From 805eef45fd1ff50ce3d4e62ca42babe1d7915078 Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Fri, 6 Aug 2010 15:13:03 -0700 Subject: [PATCH 17/64] cros_workon: when finding the ebuild path, look for the 9999 ebuild modified: cros_workon Review URL: http://codereview.chromium.org/3015063 --- cros_workon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cros_workon b/cros_workon index d48bed9298..5cccfe4ecd 100755 --- a/cros_workon +++ b/cros_workon @@ -76,7 +76,7 @@ canonicalize_name () { local pkgfile local pkgname - if ! pkgfile=$(${EQUERYCMD} which $1); then + if ! pkgfile=$(ACCEPT_KEYWORDS="**" ${EQUERYCMD} which $1); then warn "error looking up package $1" 1>&2 return 1 fi From 1af68e778126ae965c86ede4b5abac987b439415 Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Mon, 9 Aug 2010 13:51:25 -0700 Subject: [PATCH 18/64] cros_workon: refactor local manifest creation, kill duplicate entries (repo doesn't like them) modified: cros_workon Review URL: http://codereview.chromium.org/3076046 --- cros_workon | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/cros_workon b/cros_workon index 5cccfe4ecd..e2c04bc45b 100755 --- a/cros_workon +++ b/cros_workon @@ -132,27 +132,30 @@ regen_manifest_and_sync() { echo Using $REPODIR echo "Trying to generate local manifests for.." rm -f $REPODIR/local_manifest.xml - echo "" >> $REPODIR/local_manifest.xml - echo "" >> $REPODIR/local_manifest.xml - cat ${KEYWORDS_FILE} | + MANIFEST_ENTRIES=$(cat ${KEYWORDS_FILE} | { while read line do pkgname=`basename ${line}` - echo "Now working on ... ${pkgname}" + echo "Now working on ... ${pkgname}" 1>&2 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info) - echo "Looking for ${CROS_WORKON_PROJECT}.git" + echo "Looking for ${CROS_WORKON_PROJECT}.git" 1>&2 REPO_ELEMENT=$(sed -n '/START_MINILAYOUT/,/STOP_MINILAYOUT/p' $REPODIR/manifest.xml | grep "name=\"${CROS_WORKON_PROJECT}\"" | sed -e 's/^[ \t]*//') - echo $REPO_ELEMENT + echo "$REPO_ELEMENT" if [ -z "${REPO_ELEMENT}" ] ; then - echo "Unable to find ${pkgname} in manifest. Aborting." + echo "Unable to find ${pkgname} in manifest. Aborting." 1>&2 exit 1 fi - echo ${REPO_ELEMENT} >> $REPODIR/local_manifest.xml done - } - echo "" >> $REPODIR/local_manifest.xml + }) + + if [ -n "${MANIFEST_ENTRIES}" ]; then + echo "" >> $REPODIR/local_manifest.xml + echo "" >> $REPODIR/local_manifest.xml + echo "${MANIFEST_ENTRIES}"|sort|uniq >> ${REPODIR}/local_manifest.xml + echo "" >> $REPODIR/local_manifest.xml + fi } # Move a stable ebuild to the live development catgeory. The ebuild From c2e8607b9915db88ab3cf5c0c9109cd9127d8889 Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Mon, 9 Aug 2010 18:03:01 -0700 Subject: [PATCH 19/64] cros_workon: misc fixes to manifest re-generation * Only run the regenerate once, after start * Make regenerate preserve old projects from local manifest * Make pkgname not found a non-fatal error * Delete misc debug messages modified: cros_workon Review URL: http://codereview.chromium.org/3115001 --- cros_workon | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/cros_workon b/cros_workon index e2c04bc45b..9fb7c37bee 100755 --- a/cros_workon +++ b/cros_workon @@ -129,32 +129,33 @@ find_repo_dir () { # This is called only for "cros-workon start". We dont handle the "stop" case since 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. regen_manifest_and_sync() { find_repo_dir - echo Using $REPODIR - echo "Trying to generate local manifests for.." - rm -f $REPODIR/local_manifest.xml + local_manifest="${REPODIR}/local_manifest.xml" + # preserve old manifest entries + MANIFEST_ENTRIES_OLD=$(cat "${local_manifest}" | grep "^&2 eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info) - echo "Looking for ${CROS_WORKON_PROJECT}.git" 1>&2 REPO_ELEMENT=$(sed -n '/START_MINILAYOUT/,/STOP_MINILAYOUT/p' $REPODIR/manifest.xml | grep "name=\"${CROS_WORKON_PROJECT}\"" | sed -e 's/^[ \t]*//') echo "$REPO_ELEMENT" - if [ -z "${REPO_ELEMENT}" ] ; then - echo "Unable to find ${pkgname} in manifest. Aborting." 1>&2 - exit 1 - fi done }) - if [ -n "${MANIFEST_ENTRIES}" ]; then - echo "" >> $REPODIR/local_manifest.xml - echo "" >> $REPODIR/local_manifest.xml - echo "${MANIFEST_ENTRIES}"|sort|uniq >> ${REPODIR}/local_manifest.xml - echo "" >> $REPODIR/local_manifest.xml + if [ -n "${MANIFEST_ENTRIES}" ] || [ -n "${MANIFEST_ENTRIES_OLD}" ]; then + info "Creating local manifest for workon packages.." + echo "" >> "${local_manifest}" + echo "" >> "${local_manifest}" + echo -e "${MANIFEST_ENTRIES}\n${MANIFEST_ENTRIES_OLD}" \ + | sort | uniq >> "${local_manifest}" + echo "" >> "${local_manifest}" + echo "Please run \"repo sync\" now." fi } @@ -167,7 +168,6 @@ ebuild_to_live () { if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\"" sudo bash -c "echo \"~${atom}-9999\" >> \"${UNMASK_FILE}\"" - regen_manifest_and_sync else warn "Already working on ${atom}" fi @@ -227,7 +227,7 @@ else # not selected --all fi case ${WORKON_CMD} in - start) ebuild_to_live "${ATOM_LIST}" ;; + start) ebuild_to_live "${ATOM_LIST}"; regen_manifest_and_sync ;; stop) ebuild_to_stable "${ATOM_LIST}" ;; list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ;; iterate)ebuild_iterate "${ATOM_LIST}" ;; From 008b957b76335406a22371a99c8843d59064c0cd Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Tue, 10 Aug 2010 18:27:25 -0700 Subject: [PATCH 20/64] cros_workon: check for existence of local manifest before cat * Fixes a dumb error message modified: cros_workon Review URL: http://codereview.chromium.org/3129008 --- cros_workon | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cros_workon b/cros_workon index 9fb7c37bee..d7ecc65d5d 100755 --- a/cros_workon +++ b/cros_workon @@ -132,7 +132,8 @@ regen_manifest_and_sync() { local_manifest="${REPODIR}/local_manifest.xml" # preserve old manifest entries - MANIFEST_ENTRIES_OLD=$(cat "${local_manifest}" | grep "^ Date: Mon, 23 Aug 2010 13:57:25 -0700 Subject: [PATCH 21/64] cros_workon: simplify by symlinking the keywords file to the unmask file This is a refactoring change I want to do before I solve the problem of cros_workon list of packages being clobbered by a new setup_board. BUG=5641 TEST=Verified all cases work correctly. 1. Verified that a pre-existing list of workon packages continues to work. 2. Verified that the package.keywords symlink is created correctly. 3. Verified that a new package can be worked on. 4. Verified that an existing package continues to be worked on. Change-Id: I566ac898ac4f74bdd5beb532c1ef0f70d4c02cec pause Change-Id: Ie2d96c897da13292f985d87adfaf3a416a614613 Review URL: http://codereview.chromium.org/3143035 --- cros_workon | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/cros_workon b/cros_workon index d7ecc65d5d..ca2dab6072 100755 --- a/cros_workon +++ b/cros_workon @@ -68,8 +68,13 @@ UNMASK_FILE=${UNMASK_DIR}/cros-workon sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \ die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}" -sudo touch "${KEYWORDS_FILE}" "${UNMASK_FILE}" || \ - die "touch ${KEYWORDS_FILE} ${UNMASK_FILE}" +if [ ! -L "${KEYWORDS_FILE}" ]; then + sudo rm -f "${KEYWORDS_FILE}" + sudo ln -s "${UNMASK_FILE}" "${KEYWORDS_FILE}" || \ + die "ln -s ${UNMASK_FILE} ${KEYWORDS_FILE}" +fi +sudo touch "${UNMASK_FILE}" || \ + die "touch ${UNMASK_FILE}" # Canonicalize package name to category/package. canonicalize_name () { @@ -108,7 +113,7 @@ canonicalize_names () { # Display ebuilds currently part of the live branch and open for development. show_live_ebuilds () { - cat "${KEYWORDS_FILE}" + sed -n 's/^[~=]\(.*\)-9999$/\1/p' "${UNMASK_FILE}" } find_repo_dir () { @@ -138,7 +143,7 @@ regen_manifest_and_sync() { rm -f "${local_manifest}" # get new manifest entries - MANIFEST_ENTRIES=$(cat ${KEYWORDS_FILE} | + MANIFEST_ENTRIES=$(show_live_ebuilds | { while read line do @@ -166,9 +171,8 @@ ebuild_to_live () { local atoms=$1 for atom in ${atoms}; do - if ! grep -qx "${atom}" "${KEYWORDS_FILE}" ; then - sudo bash -c "echo \"${atom}\" >> \"${KEYWORDS_FILE}\"" - sudo bash -c "echo \"~${atom}-9999\" >> \"${UNMASK_FILE}\"" + if ! grep -qx "[~=]${atom}-9999" "${UNMASK_FILE}" ; then + sudo bash -c "echo \"=${atom}-9999\" >> \"${UNMASK_FILE}\"" else warn "Already working on ${atom}" fi @@ -180,13 +184,8 @@ ebuild_to_stable () { local atoms=$1 for atom in ${atoms}; do - if grep -qx "${atom}" "${KEYWORDS_FILE}" ; then - # remove the keyword - sudo bash -c "grep -v '^${atom}\$' \"${KEYWORDS_FILE}\" > \ - \"${KEYWORDS_FILE}+\"" - sudo mv "${KEYWORDS_FILE}+" "${KEYWORDS_FILE}" - # remove the unmask - sudo bash -c "grep -v '^~${atom}-9999\$' \"${UNMASK_FILE}\" > \ + if grep -qx "[~=]${atom}-9999" "${UNMASK_FILE}" ; then + sudo bash -c "grep -v '^[~=]${atom}-9999\$' \"${UNMASK_FILE}\" > \ \"${UNMASK_FILE}+\"" sudo mv "${UNMASK_FILE}+" "${UNMASK_FILE}" else From 8216bd952c0ce53b37cbbbde246058f612dd6737 Mon Sep 17 00:00:00 2001 From: "J. Richard Barnette" Date: Tue, 24 Aug 2010 11:10:17 -0700 Subject: [PATCH 22/64] Fix cros_workon error complaints to be more descriptive BUG=none TEST=./cros_workon kernel Review URL: http://codereview.chromium.org/3142032 --- cros_workon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cros_workon b/cros_workon index ca2dab6072..374f15d0e8 100755 --- a/cros_workon +++ b/cros_workon @@ -231,5 +231,5 @@ case ${WORKON_CMD} in stop) ebuild_to_stable "${ATOM_LIST}" ;; list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ;; iterate)ebuild_iterate "${ATOM_LIST}" ;; - *) die "invalid cros_workon command" ;; + *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; esac From 7d25eedbb6401f42953bbaf72acc0c6bcde31adb Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Wed, 25 Aug 2010 17:21:14 -0700 Subject: [PATCH 23/64] cros_workon: store cros_workon state outside of /build This solves the problem of cros_workon list of packages being clobbered by a new setup_board. BUG=5641 TEST=Verified all cases work correctly. 1. Verified that a pre-existing list of workon packages continues to work. 2. Verified that the package.unmask symlink is created correctly. 3. Verified that a new package can be worked on. 4. Verified that an existing package continues to be worked on. Change-Id: I566ac898ac4f74bdd5beb532c1ef0f70d4c02cec Review URL: http://codereview.chromium.org/3151039 --- cros_workon | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/cros_workon b/cros_workon index 374f15d0e8..1a9626b1f6 100755 --- a/cros_workon +++ b/cros_workon @@ -61,20 +61,28 @@ else EBUILDCMD=ebuild fi +WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask +WORKON_FILE=${WORKON_DIR}/${FLAGS_board:-host} KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon UNMASK_FILE=${UNMASK_DIR}/cros-workon -sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \ - die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}" +# TODO(msb): remove the backward compatibility after 09/01/2010 +sudo mkdir -p "${WORKON_DIR}" "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \ + die "mkdir -p ${WORKON_DIR} ${KEYWORDS_DIR} ${UNMASK_DIR}" if [ ! -L "${KEYWORDS_FILE}" ]; then sudo rm -f "${KEYWORDS_FILE}" - sudo ln -s "${UNMASK_FILE}" "${KEYWORDS_FILE}" || \ - die "ln -s ${UNMASK_FILE} ${KEYWORDS_FILE}" + sudo ln -s "${WORKON_FILE}" "${KEYWORDS_FILE}" || \ + die "ln -s ${WORKON_FILE} ${KEYWORDS_FILE}" fi -sudo touch "${UNMASK_FILE}" || \ - die "touch ${UNMASK_FILE}" +if [ ! -L "${UNMASK_FILE}" ]; then + [ -f "${UNMASK_FILE}" ] && sudo mv "${UNMASK_FILE}" "${WORKON_FILE}" + sudo ln -s "${WORKON_FILE}" "${UNMASK_FILE}" || \ + die "ln -s ${WORKON_FILE} ${UNMASK_FILE}" +fi +sudo touch "${WORKON_FILE}" || \ + die "touch ${WORKON_FILE}" # Canonicalize package name to category/package. canonicalize_name () { @@ -113,7 +121,7 @@ canonicalize_names () { # Display ebuilds currently part of the live branch and open for development. show_live_ebuilds () { - sed -n 's/^[~=]\(.*\)-9999$/\1/p' "${UNMASK_FILE}" + sed -n 's/^[~=]\(.*\)-9999$/\1/p' "${WORKON_FILE}" } find_repo_dir () { @@ -171,8 +179,8 @@ ebuild_to_live () { local atoms=$1 for atom in ${atoms}; do - if ! grep -qx "[~=]${atom}-9999" "${UNMASK_FILE}" ; then - sudo bash -c "echo \"=${atom}-9999\" >> \"${UNMASK_FILE}\"" + if ! grep -qx "[~=]${atom}-9999" "${WORKON_FILE}" ; then + sudo bash -c "echo \"=${atom}-9999\" >> \"${WORKON_FILE}\"" else warn "Already working on ${atom}" fi @@ -184,10 +192,10 @@ ebuild_to_stable () { local atoms=$1 for atom in ${atoms}; do - if grep -qx "[~=]${atom}-9999" "${UNMASK_FILE}" ; then - sudo bash -c "grep -v '^[~=]${atom}-9999\$' \"${UNMASK_FILE}\" > \ - \"${UNMASK_FILE}+\"" - sudo mv "${UNMASK_FILE}+" "${UNMASK_FILE}" + if grep -qx "[~=]${atom}-9999" "${WORKON_FILE}" ; then + sudo bash -c "grep -v '^[~=]${atom}-9999\$' \"${WORKON_FILE}\" > \ + \"${WORKON_FILE}+\"" + sudo mv "${WORKON_FILE}+" "${WORKON_FILE}" else warn "Not working on ${atom}" fi From 7a726953ce8b8620692dbf45889d2b681e9d416f Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Thu, 26 Aug 2010 16:17:03 -0700 Subject: [PATCH 24/64] cros_workon: make --board and --host not exclusive This fixes a case where you can't specify host if you have a default board set. BUG=6039 TEST=cros_workon start with --host, --board, both Change-Id: Iad0d3f646dde10cc4adc4131e93f75fabe92f392 Review URL: http://codereview.chromium.org/3157044 --- cros_workon | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cros_workon b/cros_workon index 1a9626b1f6..128933a84a 100755 --- a/cros_workon +++ b/cros_workon @@ -45,9 +45,13 @@ WORKON_CMD=$1 shift -# board dir config +# Board dir config + +# If both are specified, just use host, because board does not +# have to be specified and may come from default, in which case +# there's no way to override. [ -n "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_TRUE} ] && \ - die "Flags --host and --board are mutually exclusive." + FLAGS_board="" # kill board [ -z "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \ die "You must specify either --host or --board=" From faabfed88500eda66b46b639444a616446161e80 Mon Sep 17 00:00:00 2001 From: Jon Kliegman Date: Wed, 1 Sep 2010 09:39:44 -0400 Subject: [PATCH 25/64] Cause cros_workon to die rather than clobber local_manifest cros_workon would clobber local edits to local_manifest in many cases This is a quick fix to prevent it. The proper solution is to actually parse local_manifest as an XML doc and modify the DOM. Not play tricks with grep. BUG=chromium-os:6272 TEST=Ran cros_workon against missing local_manifest, auto-generated local_manifest, local_manifest with indented tags. local_manifest with multi-line tags and local_manifest with tags at all." + fi + sed -ne '/^[[:space:]]\+[^[:space:]]/q1' "${local_manifest}" + if [ $? -ne 0 ]; then + die "Your local manifest will be clobbered running cros_workon. You can not have any tags that span multiple lines or are indented." + fi + egrep -q "^[^<]" "${local_manifest}" + if [ $? -ne 1 ]; then + die "Your local manifest will be clobbered running cros_workon. You can not have any tags that span multiple lines" + fi + grep -v " Date: Fri, 3 Sep 2010 17:29:09 -0700 Subject: [PATCH 26/64] cros_workon: print out short summary of what has been done for start/stop BUG=6325 TEST=cros_workon start and stop for board and host and see it work Change-Id: Ic0680a273391fdf93b6ebbe0e34497807f31f240 Review URL: http://codereview.chromium.org/3352002 --- cros_workon | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cros_workon b/cros_workon index e9400da47d..57835f8d51 100755 --- a/cros_workon +++ b/cros_workon @@ -59,10 +59,12 @@ if [ -n "${FLAGS_board}" ]; then BOARD_DIR=/build/"${FLAGS_board}" # --board specified EQUERYCMD=equery-"${FLAGS_board}" EBUILDCMD=ebuild-"${FLAGS_board}" + BOARD_STR="${FLAGS_board}" else BOARD_DIR="" # --host specified EQUERYCMD=equery EBUILDCMD=ebuild + BOARD_STR="host" fi WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon @@ -200,29 +202,37 @@ regen_manifest_and_sync() { # src_unpack step fetches the package source for local development. ebuild_to_live () { local atoms=$1 + local atoms_success="" for atom in ${atoms}; do if ! grep -qx "[~=]${atom}-9999" "${WORKON_FILE}" ; then - sudo bash -c "echo \"=${atom}-9999\" >> \"${WORKON_FILE}\"" + if sudo bash -c "echo \"=${atom}-9999\" >> \"${WORKON_FILE}\""; then + atoms_success="${atoms_success} ${atom}" + fi else warn "Already working on ${atom}" fi done + [ -n "${atoms_success}" ] && regen_manifest_and_sync && \ + info "Started working on '${atoms_success/ /}' for '${BOARD_STR}'" } # Move a live development ebuild back to stable. ebuild_to_stable () { local atoms=$1 + local atoms_success="" for atom in ${atoms}; do if grep -qx "[~=]${atom}-9999" "${WORKON_FILE}" ; then - sudo bash -c "grep -v '^[~=]${atom}-9999\$' \"${WORKON_FILE}\" > \ - \"${WORKON_FILE}+\"" - sudo mv "${WORKON_FILE}+" "${WORKON_FILE}" + if sudo sed -e "/^[~=]${atom/\//\\/}-9999\$/d" -i "${WORKON_FILE}"; then + atoms_success="${atoms_success} ${atom}" + fi else warn "Not working on ${atom}" fi done + [ -n "${atoms_success}" ] && \ + info "Stopped working on '${atoms_success/ /}' for '${BOARD_STR}'" } # Run a command on all or a set of repos. @@ -258,7 +268,7 @@ else # not selected --all fi case ${WORKON_CMD} in - start) ebuild_to_live "${ATOM_LIST}"; regen_manifest_and_sync ;; + start) ebuild_to_live "${ATOM_LIST}" ;; stop) ebuild_to_stable "${ATOM_LIST}" ;; list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ;; iterate)ebuild_iterate "${ATOM_LIST}" ;; From 8e79ec4bffc3e44a4e26f4a6fedea8e152a3ce56 Mon Sep 17 00:00:00 2001 From: Jon Kliegman Date: Tue, 7 Sep 2010 11:12:20 -0400 Subject: [PATCH 27/64] Whitespace/tab cleanup for cros_workon Change-Id: I17379dc302fcad0f3a7f59771c48d86df320c0d0 BUG=NONE TEST=Manual diff inspection. Ran scripts and confirmed no syntax errors. Review URL: http://codereview.chromium.org/3335004 --- cros_workon | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/cros_workon b/cros_workon index 57835f8d51..9720079a8c 100755 --- a/cros_workon +++ b/cros_workon @@ -152,22 +152,22 @@ regen_manifest_and_sync() { # ensure we don't clobber existing manifest entries if [ -f "${local_manifest}" ]; then - grep -q -i " tags at all." - fi - sed -ne '/^[[:space:]]\+[^[:space:]]/q1' "${local_manifest}" - if [ $? -ne 0 ]; then - die "Your local manifest will be clobbered running cros_workon. You can not have any tags that span multiple lines or are indented." - fi - egrep -q "^[^<]" "${local_manifest}" - if [ $? -ne 1 ]; then - die "Your local manifest will be clobbered running cros_workon. You can not have any tags that span multiple lines" - fi - grep -v " tags at all." + fi + sed -ne '/^[[:space:]]\+[^[:space:]]/q1' "${local_manifest}" + if [ $? -ne 0 ]; then + die "Your local manifest will be clobbered running cros_workon. You can not have any tags that span multiple lines or are indented." + fi + egrep -q "^[^<]" "${local_manifest}" + if [ $? -ne 1 ]; then + die "Your local manifest will be clobbered running cros_workon. You can not have any tags that span multiple lines" + fi + grep -v " Date: Wed, 15 Sep 2010 11:33:54 -0700 Subject: [PATCH 28/64] cros_workon: redefine the concept of a "workon" package list to depend on the board * Modified all workon listing functions to also look for keyword * Added a fallback to list all workon ebuilds if keyword is not specified, which is needed for cros_mark_all_as_stable, which does not differentiate between boards. This, amongst other potential issues, resolves the case when it was possible to start working on a package not keyworded for the given board, and making build_packages fail unconditionally. TEST=below $ ./cros_workon list --all --board=x86-generic |wc -l 73 $ ./cros_workon list --all --host |wc -l 57 Looking at the lists rather than "|wc -l" looks correct $ ./cros_mark_all_as_stable ^ Produces satisfactory result BUG=6700 Change-Id: Ieee92a39febcef5fb95e59cf97b6e63281a7c750 Review URL: http://codereview.chromium.org/3400001 --- cros_workon | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cros_workon b/cros_workon index 9720079a8c..74285cd259 100755 --- a/cros_workon +++ b/cros_workon @@ -60,11 +60,13 @@ if [ -n "${FLAGS_board}" ]; then EQUERYCMD=equery-"${FLAGS_board}" EBUILDCMD=ebuild-"${FLAGS_board}" BOARD_STR="${FLAGS_board}" + BOARD_KEYWORD="$(portageq-${FLAGS_board} envvar ARCH)" else BOARD_DIR="" # --host specified EQUERYCMD=equery EBUILDCMD=ebuild BOARD_STR="host" + BOARD_KEYWORD="$(portageq envvar ARCH)" fi WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon @@ -95,7 +97,7 @@ canonicalize_name () { local pkgfile local pkgname - if ! pkgfile=$(ACCEPT_KEYWORDS="**" ${EQUERYCMD} which $1); then + if ! pkgfile=$(ACCEPT_KEYWORDS="~${BOARD_KEYWORD}" ${EQUERYCMD} which $1); then warn "error looking up package $1" 1>&2 return 1 fi @@ -249,7 +251,7 @@ ebuild_iterate() { # --all makes commands operate on different lists if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then case ${WORKON_CMD} in - start) ATOM_LIST=$(show_workon_ebuilds);; + start) ATOM_LIST=$(show_workon_ebuilds ${BOARD_KEYWORD});; stop|iterate) ATOM_LIST=$(show_live_ebuilds);; list) ;; *) die "--all is invalid for the given command";; @@ -270,7 +272,7 @@ fi case ${WORKON_CMD} in start) ebuild_to_live "${ATOM_LIST}" ;; stop) ebuild_to_stable "${ATOM_LIST}" ;; - list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ;; + list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ${BOARD_KEYWORD} ;; iterate)ebuild_iterate "${ATOM_LIST}" ;; *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; esac From 99b0085555d18d2026568e90ea2dc9fe6c90402b Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Wed, 15 Sep 2010 12:28:42 -0700 Subject: [PATCH 29/64] cros_workon: WORKON_FILE should be owned by the user BUG=none TEST=Verified that WORKON_FILE is now owned by the user. Change-Id: I32f05d5de5177756945b6f5bc037a2f738ffffe5 Review URL: http://codereview.chromium.org/3446002 --- cros_workon | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cros_workon b/cros_workon index 74285cd259..d48038ee14 100755 --- a/cros_workon +++ b/cros_workon @@ -76,9 +76,15 @@ WORKON_FILE=${WORKON_DIR}/${FLAGS_board:-host} KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon UNMASK_FILE=${UNMASK_DIR}/cros-workon -# TODO(msb): remove the backward compatibility after 09/01/2010 -sudo mkdir -p "${WORKON_DIR}" "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \ - die "mkdir -p ${WORKON_DIR} ${KEYWORDS_DIR} ${UNMASK_DIR}" +# TODO(msb): remove the backward compatibility after 10/01/2010 +if [ -d "${WORKON_DIR}" ]; then + sudo chown -R "${USER}" "${WORKON_DIR}" +fi + +mkdir -p "${WORKON_DIR}" || die "mkdir -p ${WORKON_DIR}" +touch "${WORKON_FILE}" || die "touch ${WORKON_FILE}" +sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \ + die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}" if [ ! -L "${KEYWORDS_FILE}" ]; then sudo rm -f "${KEYWORDS_FILE}" sudo ln -s "${WORKON_FILE}" "${KEYWORDS_FILE}" || \ @@ -89,8 +95,6 @@ if [ ! -L "${UNMASK_FILE}" ]; then sudo ln -s "${WORKON_FILE}" "${UNMASK_FILE}" || \ die "ln -s ${WORKON_FILE} ${UNMASK_FILE}" fi -sudo touch "${WORKON_FILE}" || \ - die "touch ${WORKON_FILE}" # Canonicalize package name to category/package. canonicalize_name () { From f0eb4604d7df554278db1974018a7806609c6212 Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Thu, 16 Sep 2010 10:57:54 -0700 Subject: [PATCH 30/64] cros_workon: modify regen_manifest_and_sync to use loman This fixes a bug where user added local_manifest.xml entries get clobbered. BUG=5787 TEST=Verified start of various packages works correctly. Change-Id: I2348dfb1be098b81ede5928426192c655160564d Review URL: http://codereview.chromium.org/3389013 --- cros_workon | 56 ++++++++--------------------------------------------- 1 file changed, 8 insertions(+), 48 deletions(-) diff --git a/cros_workon b/cros_workon index d48038ee14..22b375201d 100755 --- a/cros_workon +++ b/cros_workon @@ -153,55 +153,15 @@ find_repo_dir () { # This is called only for "cros-workon start". We dont handle the "stop" case since 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. regen_manifest_and_sync() { - find_repo_dir - local_manifest="${REPODIR}/local_manifest.xml" + for pkgname in $(show_live_ebuilds); do + eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info) + local srcdir=$(readlink -f ${CROS_WORKON_SRCDIR}) + local trunkdir=$(readlink -f ${CHROOT_TRUNK_DIR}) + local project_path=${srcdir#$(readlink -f ${CHROOT_TRUNK_DIR})/} - # ensure we don't clobber existing manifest entries - if [ -f "${local_manifest}" ]; then - grep -q -i " tags at all." - fi - sed -ne '/^[[:space:]]\+[^[:space:]]/q1' "${local_manifest}" - if [ $? -ne 0 ]; then - die "Your local manifest will be clobbered running cros_workon. You can not have any tags that span multiple lines or are indented." - fi - egrep -q "^[^<]" "${local_manifest}" - if [ $? -ne 1 ]; then - die "Your local manifest will be clobbered running cros_workon. You can not have any tags that span multiple lines" - fi - grep -v "" >> "${local_manifest}" - echo "" >> "${local_manifest}" - echo -e "${MANIFEST_ENTRIES}\n${MANIFEST_ENTRIES_OLD}" \ - | sort | uniq >> "${local_manifest}" - echo "" >> "${local_manifest}" - echo "Please run \"repo sync\" now." - fi + loman add --workon "${CROS_WORKON_PROJECT}" "${project_path}" + done + echo "Please run \"repo sync\" now." } # Move a stable ebuild to the live development catgeory. The ebuild From 120d91df01affed9dd6986dd0213885e9bbcb61c Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Thu, 16 Sep 2010 14:28:31 -0700 Subject: [PATCH 31/64] cros_workon: fix bug where cros_workon start doesn't work for first start If the checkout dir doesn't already exist cros_workon start will print the wrong dir. Fixed by using readlink -m instead. BUG=none TEST=Verified that first start is incorrect without this patch but is fixed with this patch. Change-Id: I5db29a8c1737dea1dbe4866e18576f67b9355f84 Review URL: http://codereview.chromium.org/3434008 --- cros_workon | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cros_workon b/cros_workon index 22b375201d..d71879f930 100755 --- a/cros_workon +++ b/cros_workon @@ -155,9 +155,9 @@ find_repo_dir () { regen_manifest_and_sync() { for pkgname in $(show_live_ebuilds); do eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info) - local srcdir=$(readlink -f ${CROS_WORKON_SRCDIR}) - local trunkdir=$(readlink -f ${CHROOT_TRUNK_DIR}) - local project_path=${srcdir#$(readlink -f ${CHROOT_TRUNK_DIR})/} + local srcdir=$(readlink -m ${CROS_WORKON_SRCDIR}) + local trunkdir=$(readlink -m ${CHROOT_TRUNK_DIR}) + local project_path=${srcdir#${trunkdir}/} loman add --workon "${CROS_WORKON_PROJECT}" "${project_path}" done From 4d13b5ef3f04e52eef4cb2a442148cb042f1799b Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Tue, 21 Sep 2010 12:05:10 -0700 Subject: [PATCH 32/64] cros_workon: only touch local_manifest for minilayout users Otherwise, you'll duplicate an entry already in the developers manifest and cause repo to get confused. BUG=6898 TEST=Verified that local_manifest gets updated when using minilayout.xml Verified that the local_manifset does not get updated when not. Change-Id: I67ffc7004a2267d0d5aaa31570ac2bbeaa8f4f96 Review URL: http://codereview.chromium.org/3468009 --- cros_workon | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/cros_workon b/cros_workon index d71879f930..6892e7a669 100755 --- a/cros_workon +++ b/cros_workon @@ -136,23 +136,14 @@ show_live_ebuilds () { sed -n 's/^[~=]\(.*\)-9999$/\1/p' "${WORKON_FILE}" } -find_repo_dir () { - curdir=`pwd` - while [ $curdir != / ]; do - if [ -d "$curdir/.repo" ]; then - #echo "Found .repo directory at ${curdir}" - REPODIR=${curdir}/.repo - return 0 - fi - curdir=`dirname "$curdir"` - done - echo "Unable to find .repo directory. Did you checkout with repo?" - exit 1 -} - - # This is called only for "cros-workon start". We dont handle the "stop" case since 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. regen_manifest_and_sync() { + # Nothing to do unless you are working on the minilayout + local manifest=${CHROOT_TRUNK_DIR}/.repo/manifest.xml + if [ $(basename $(readlink -f ${manifest})) != "minilayout.xml" ]; then + return + fi + for pkgname in $(show_live_ebuilds); do eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info) local srcdir=$(readlink -m ${CROS_WORKON_SRCDIR}) From a5af91266ea88ffea6c42c547a64f312e0af3453 Mon Sep 17 00:00:00 2001 From: Anton Staaf Date: Tue, 2 Nov 2010 11:23:00 -0700 Subject: [PATCH 33/64] Change "cros_workon list" to show packages for all boards. Change-Id: Id4880b423eaabbdefc91060a04629a9018295b4d BUG=None TEST="cros_workon list" works, so does "cros_workon --board tegra2_seaboard start chromeos-u-boot" Review URL: http://codereview.chromium.org/4131008 --- cros_workon | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cros_workon b/cros_workon index 6892e7a669..c48b6431e5 100755 --- a/cros_workon +++ b/cros_workon @@ -35,6 +35,7 @@ commands: start: Moves an ebuild to live (intended to support development) stop: Moves an ebuild to stable (use last known good) list: List of live ebuilds (workon ebuilds if --all) + list-all: List all of the live ebuilds for all setup boards iterate: For each ebuild, cd to the source dir and run a commond" FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" @@ -53,6 +54,7 @@ shift [ -n "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_TRUE} ] && \ FLAGS_board="" # kill board [ -z "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \ +[ "${WORKON_CMD}" != "list-all" ] && \ die "You must specify either --host or --board=" if [ -n "${FLAGS_board}" ]; then @@ -136,6 +138,18 @@ show_live_ebuilds () { sed -n 's/^[~=]\(.*\)-9999$/\1/p' "${WORKON_FILE}" } +# Display ebuilds currently part of the live branch and open for development +# for any board that currently has live ebuilds. +show_all_live_ebuilds () { + for workon_file in ${WORKON_DIR}/*; do + if [ -s "${workon_file}" ]; then + echo -e "${V_BOLD_GREEN}$(basename ${workon_file}):${V_VIDOFF}" + sed -n 's/^[~=]\(.*\)-9999$/ \1/p' "${workon_file}" + echo "" + fi + done +} + # This is called only for "cros-workon start". We dont handle the "stop" case since 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. regen_manifest_and_sync() { # Nothing to do unless you are working on the minilayout @@ -208,7 +222,7 @@ if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then case ${WORKON_CMD} in start) ATOM_LIST=$(show_workon_ebuilds ${BOARD_KEYWORD});; stop|iterate) ATOM_LIST=$(show_live_ebuilds);; - list) ;; + list|list-all) ;; *) die "--all is invalid for the given command";; esac else # not selected --all @@ -228,6 +242,7 @@ case ${WORKON_CMD} in start) ebuild_to_live "${ATOM_LIST}" ;; stop) ebuild_to_stable "${ATOM_LIST}" ;; list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ${BOARD_KEYWORD} ;; + list-all) show_all_live_ebuilds ;; iterate)ebuild_iterate "${ATOM_LIST}" ;; *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; esac From 2a183678664112cf41bc3ff691a316edb90db1bb Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Mon, 24 Jan 2011 13:46:52 -0800 Subject: [PATCH 34/64] cros_workon: remove logic for handling ~ in workon file We stopped using ~ in the workon files many months ago. BUG=n0ne TEST=See below. (cros-chroot) msb@msb ~/trunk/src/scripts $ ./cros_workon --board x86-generic list sys-kernel/chromeos-kernel (cros-chroot) msb@msb ~/trunk/src/scripts $ ./cros_workon --board x86-generic start perf Please run "repo sync" now. INFO : Started working on 'dev-util/perf' for 'x86-generic' (cros-chroot) msb@msb ~/trunk/src/scripts $ ./cros_workon --board x86-generic list sys-kernel/chromeos-kernel dev-util/perf (cros-chroot) msb@msb ~/trunk/src/scripts $ ./cros_workon --board x86-generic stop perf INFO : Stopped working on 'dev-util/perf' for 'x86-generic' (cros-chroot) msb@msb ~/trunk/src/scripts $ ./cros_workon --board x86-generic list sys-kernel/chromeos-kernel Change-Id: I61babd89073d749111be7257b2e8491f07ca52f2 Review URL: http://codereview.chromium.org/6268012 --- cros_workon | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cros_workon b/cros_workon index c48b6431e5..f12bc7a9e4 100755 --- a/cros_workon +++ b/cros_workon @@ -135,7 +135,7 @@ canonicalize_names () { # Display ebuilds currently part of the live branch and open for development. show_live_ebuilds () { - sed -n 's/^[~=]\(.*\)-9999$/\1/p' "${WORKON_FILE}" + sed -n 's/^=\(.*\)-9999$/\1/p' "${WORKON_FILE}" } # Display ebuilds currently part of the live branch and open for development @@ -144,7 +144,7 @@ show_all_live_ebuilds () { for workon_file in ${WORKON_DIR}/*; do if [ -s "${workon_file}" ]; then echo -e "${V_BOLD_GREEN}$(basename ${workon_file}):${V_VIDOFF}" - sed -n 's/^[~=]\(.*\)-9999$/ \1/p' "${workon_file}" + sed -n 's/^=\(.*\)-9999$/ \1/p' "${workon_file}" echo "" fi done @@ -176,7 +176,7 @@ ebuild_to_live () { local atoms_success="" for atom in ${atoms}; do - if ! grep -qx "[~=]${atom}-9999" "${WORKON_FILE}" ; then + if ! grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then if sudo bash -c "echo \"=${atom}-9999\" >> \"${WORKON_FILE}\""; then atoms_success="${atoms_success} ${atom}" fi @@ -194,8 +194,8 @@ ebuild_to_stable () { local atoms_success="" for atom in ${atoms}; do - if grep -qx "[~=]${atom}-9999" "${WORKON_FILE}" ; then - if sudo sed -e "/^[~=]${atom/\//\\/}-9999\$/d" -i "${WORKON_FILE}"; then + if grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then + if sudo sed -e "/^=${atom/\//\\/}-9999\$/d" -i "${WORKON_FILE}"; then atoms_success="${atoms_success} ${atom}" fi else From 893fb5789f0812798b03672a0cd04758e54bf7a4 Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Mon, 24 Jan 2011 14:04:35 -0800 Subject: [PATCH 35/64] cros_workon: allow a stop on a dead package Previously, you could not stop working on a package if its ebuild had been removed. This fixes this issue by skipping canonicalization if the package name exactly matches a name in the workon file. BUG=11214 TEST=See below. (cros-chroot) msb@msb ~/trunk/src/scripts $ ./cros_workon --board x86-generic list sys-kernel/chromeos-kernel (cros-chroot) msb@msb ~/trunk/src/scripts $ echo "=foo/bar-9999" >> ~/trunk/.config/cros_workon/x86-generic (cros-chroot) msb@msb ~/trunk/src/scripts $ ./cros_workon --board x86-generic list sys-kernel/chromeos-kernel foo/bar (cros-chroot) msb@msb ~/trunk/src/scripts $ ./cros_workon --board x86-generic stop foo/bar !!! No packages matching 'foo/bar' WARNING: error looking up package foo/bar ERROR : Error parsing package list *** I made changes to cros_workon here (cros-chroot) msb@msb ~/trunk/src/scripts $ ./cros_workon --board x86-generic list sys-kernel/chromeos-kernel foo/bar (cros-chroot) msb@msb ~/trunk/src/scripts $ ./cros_workon --board x86-generic stop foo/bar INFO : Stopped working on 'foo/bar' for 'x86-generic' (cros-chroot) msb@msb ~/trunk/src/scripts $ ./cros_workon --board x86-generic list sys-kernel/chromeos-kernel Change-Id: Id5cbd2b145b4d0fca96cfb245f1ac99e0b3cbdf3 Review URL: http://codereview.chromium.org/6379006 --- cros_workon | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cros_workon b/cros_workon index f12bc7a9e4..61b1e47420 100755 --- a/cros_workon +++ b/cros_workon @@ -103,6 +103,11 @@ canonicalize_name () { local pkgfile local pkgname + if grep -qx "=$1-9999" "${WORKON_FILE}" ; then + echo $1 + return 0 + fi + if ! pkgfile=$(ACCEPT_KEYWORDS="~${BOARD_KEYWORD}" ${EQUERYCMD} which $1); then warn "error looking up package $1" 1>&2 return 1 From 0295fffe884d514a12d9a3224c3c681235ef2908 Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Mon, 31 Jan 2011 16:13:30 -0800 Subject: [PATCH 36/64] cros_workon: collapse cros_workon_common.sh cros_workon is the only user of cros_workon_common.sh This is pre-requisite to moving cros_workon into devutils.git BUG=11507 TEST=Ran ./cros_workon --board x86-generic --all list Change-Id: I1eab551ab33646360e507328932c151a0d36f50a Review URL: http://codereview.chromium.org/6347052 --- cros_workon | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/cros_workon b/cros_workon index 61b1e47420..0c7ded12ad 100755 --- a/cros_workon +++ b/cros_workon @@ -14,9 +14,6 @@ # The path to common.sh should be relative to your script's location. . "$(dirname "$0")/common.sh" -# Load common functions for workon scripts. -. "$(dirname "$0")/lib/cros_workon_common.sh" - # Script must be run inside the chroot restart_in_chroot_if_needed $* get_default_board @@ -98,6 +95,32 @@ if [ ! -L "${UNMASK_FILE}" ]; then die "ln -s ${WORKON_FILE} ${UNMASK_FILE}" fi +find_keyword_workon_ebuilds() { + keyword="${1}" + + pushd "${BOARD_DIR}"/etc/ 1> /dev/null + source make.conf + popd 1> /dev/null + local CROS_OVERLAYS="${PORTDIR_OVERLAY}" + + # NOTE: overlay may be a symlink, and we have to use ${overlay}/ + for overlay in ${CROS_OVERLAYS}; do + # only look up ebuilds named 9999 to eliminate duplicates + find ${overlay}/ -name '*9999.ebuild' | \ + xargs grep -l "inherit.*cros-workon" | \ + xargs grep -l "KEYWORDS=.*${keyword}.*" + done +} + +show_workon_ebuilds() { + keyword=$1 + + find_keyword_workon_ebuilds ${keyword} | \ + sed -e 's/.*\/\([^/]*\)\/\([^/]*\)\/.*\.ebuild/\1\/\2/' | \ + sort -u + # This changes the absolute path to ebuilds into category/package. +} + # Canonicalize package name to category/package. canonicalize_name () { local pkgfile From 034218dbf031692ebd0bb5d96d0a4c700e9d201d Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Mon, 31 Jan 2011 16:59:37 -0800 Subject: [PATCH 37/64] cros_workon: use portageq instead of sourcing make.conf Fixes the following issue: /home/msb/trunk/src/overlays/overlay-x86-generic/make.conf: line 7: prebuilt.conf: No such file or directory BUG=11513 TEST=Verified that the error goes away. Change-Id: I5b1dfab55394ba40c02e2a1a2ee7b03a5c4a7941 Review URL: http://codereview.chromium.org/6409031 --- cros_workon | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cros_workon b/cros_workon index 0c7ded12ad..5d890bd488 100755 --- a/cros_workon +++ b/cros_workon @@ -58,12 +58,14 @@ if [ -n "${FLAGS_board}" ]; then BOARD_DIR=/build/"${FLAGS_board}" # --board specified EQUERYCMD=equery-"${FLAGS_board}" EBUILDCMD=ebuild-"${FLAGS_board}" + PORTAGEQCMD=portageq-"${FLAGS_board}" BOARD_STR="${FLAGS_board}" BOARD_KEYWORD="$(portageq-${FLAGS_board} envvar ARCH)" else BOARD_DIR="" # --host specified EQUERYCMD=equery EBUILDCMD=ebuild + PORTAGEQCMD=portageq BOARD_STR="host" BOARD_KEYWORD="$(portageq envvar ARCH)" fi @@ -98,13 +100,10 @@ fi find_keyword_workon_ebuilds() { keyword="${1}" - pushd "${BOARD_DIR}"/etc/ 1> /dev/null - source make.conf - popd 1> /dev/null - local CROS_OVERLAYS="${PORTDIR_OVERLAY}" + local cros_overlays=$("${PORTAGEQCMD}" envvar PORTDIR_OVERLAY) # NOTE: overlay may be a symlink, and we have to use ${overlay}/ - for overlay in ${CROS_OVERLAYS}; do + for overlay in ${cros_overlays}; do # only look up ebuilds named 9999 to eliminate duplicates find ${overlay}/ -name '*9999.ebuild' | \ xargs grep -l "inherit.*cros-workon" | \ From 4e224217a6292e6ba01fdbe7cd01f6265c2c04cf Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Tue, 1 Feb 2011 14:20:00 -0800 Subject: [PATCH 38/64] cros_workon: apply gspencer's cleanup from issue 6240018 Note: this is the moved version of cros_workon BUG=11507 TEST=./cros_workon --board x86-generic list --all Change-Id: I4bee245743b4390e1efb634887ea8858c4540f34 Review URL: http://codereview.chromium.org/6368032 --- cros_workon | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/cros_workon b/cros_workon index 5d890bd488..9632ea6f92 100755 --- a/cros_workon +++ b/cros_workon @@ -10,12 +10,9 @@ # is intended to support development. The current source tip is fetched, # source modified and built using the unstable 'live' (9999) ebuild. -# Load common constants. This should be the first executable line. -# The path to common.sh should be relative to your script's location. -. "$(dirname "$0")/common.sh" +. /usr/lib/crosutils/common.sh || (echo "Unable to load common.sh" && exit 1) # Script must be run inside the chroot -restart_in_chroot_if_needed $* get_default_board DEFINE_string board "${DEFAULT_BOARD}" \ @@ -42,7 +39,6 @@ eval set -- "${FLAGS_ARGV}" WORKON_CMD=$1 shift - # Board dir config # If both are specified, just use host, because board does not @@ -98,7 +94,8 @@ if [ ! -L "${UNMASK_FILE}" ]; then fi find_keyword_workon_ebuilds() { - keyword="${1}" + local keyword="${1}" + local overlay local cros_overlays=$("${PORTAGEQCMD}" envvar PORTDIR_OVERLAY) @@ -112,7 +109,7 @@ find_keyword_workon_ebuilds() { } show_workon_ebuilds() { - keyword=$1 + local keyword=$1 find_keyword_workon_ebuilds ${keyword} | \ sed -e 's/.*\/\([^/]*\)\/\([^/]*\)\/.*\.ebuild/\1\/\2/' | \ @@ -150,6 +147,7 @@ canonicalize_name () { canonicalize_names () { local atoms=$1 local names="" + local atom for atom in ${atoms}; do local name=$(canonicalize_name "${atom}") @@ -168,6 +166,7 @@ show_live_ebuilds () { # Display ebuilds currently part of the live branch and open for development # for any board that currently has live ebuilds. show_all_live_ebuilds () { + local workon_file for workon_file in ${WORKON_DIR}/*; do if [ -s "${workon_file}" ]; then echo -e "${V_BOLD_GREEN}$(basename ${workon_file}):${V_VIDOFF}" @@ -177,7 +176,10 @@ show_all_live_ebuilds () { done } -# This is called only for "cros-workon start". We dont handle the "stop" case since 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. +# This is called only for "cros-workon start". We dont handle the +# "stop" case since 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. regen_manifest_and_sync() { # Nothing to do unless you are working on the minilayout local manifest=${CHROOT_TRUNK_DIR}/.repo/manifest.xml @@ -185,6 +187,7 @@ regen_manifest_and_sync() { return fi + local pkgname for pkgname in $(show_live_ebuilds); do eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info) local srcdir=$(readlink -m ${CROS_WORKON_SRCDIR}) @@ -201,6 +204,7 @@ regen_manifest_and_sync() { ebuild_to_live () { local atoms=$1 local atoms_success="" + local atom for atom in ${atoms}; do if ! grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then @@ -219,6 +223,7 @@ ebuild_to_live () { ebuild_to_stable () { local atoms=$1 local atoms_success="" + local atom for atom in ${atoms}; do if grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then @@ -236,6 +241,7 @@ ebuild_to_stable () { # Run a command on all or a set of repos. ebuild_iterate() { local atoms=$1 + local atom for atom in ${atoms}; do info "Running \"${FLAGS_command}\" on ${atom}" @@ -249,7 +255,7 @@ if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then case ${WORKON_CMD} in start) ATOM_LIST=$(show_workon_ebuilds ${BOARD_KEYWORD});; stop|iterate) ATOM_LIST=$(show_live_ebuilds);; - list|list-all) ;; + list) ;; *) die "--all is invalid for the given command";; esac else # not selected --all @@ -266,10 +272,11 @@ else # not selected --all fi case ${WORKON_CMD} in - start) ebuild_to_live "${ATOM_LIST}" ;; - stop) ebuild_to_stable "${ATOM_LIST}" ;; - list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ${BOARD_KEYWORD} ;; + start) ebuild_to_live "${ATOM_LIST}" ;; + stop) ebuild_to_stable "${ATOM_LIST}" ;; + list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || \ + show_workon_ebuilds ${BOARD_KEYWORD} ;; list-all) show_all_live_ebuilds ;; - iterate)ebuild_iterate "${ATOM_LIST}" ;; + iterate) ebuild_iterate "${ATOM_LIST}" ;; *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; esac From 514f69e8bc543f642c2d2ef3acf8be602b7dffea Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Sat, 5 Feb 2011 12:09:55 -0800 Subject: [PATCH 39/64] cros_workon: fix --help to return an exit code of 0 BUG=n0ne TEST=cros_workon --help && echo "test passed" Change-Id: I4d0835b0651f70256e7df82a174fbc8d025cba88 Review URL: http://codereview.chromium.org/6312176 --- cros_workon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cros_workon b/cros_workon index 9632ea6f92..d991356c55 100755 --- a/cros_workon +++ b/cros_workon @@ -31,7 +31,7 @@ commands: list: List of live ebuilds (workon ebuilds if --all) list-all: List all of the live ebuilds for all setup boards iterate: For each ebuild, cd to the source dir and run a commond" -FLAGS "$@" || exit 1 +FLAGS "$@" || { [ "${FLAGS_help}" = "${FLAGS_TRUE}" ] && exit 0; } || exit 1 eval set -- "${FLAGS_ARGV}" From 230883f9eca4c6765831125b7984597aa945ef93 Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Fri, 25 Mar 2011 15:37:43 -0700 Subject: [PATCH 40/64] cros_workon: fix common.sh check Error message not necessary since you already get an error message from bash. BUG=none TEST=see below $ ./cros_workon ./cros_workon: line 13: /usr/lib/crosutils/common.sh: No such file or directory $ ./cros_workon_make ./cros_workon_make: line 10: /usr/lib/crosutils/common.sh: No such file or directory Change-Id: I2087d77876376af9ccb497d0a67c354af281c007 R=petkov@chromium.org,anush@chromium.org Review URL: http://codereview.chromium.org/6726039 --- cros_workon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cros_workon b/cros_workon index d991356c55..fc1c365ba8 100755 --- a/cros_workon +++ b/cros_workon @@ -10,7 +10,7 @@ # is intended to support development. The current source tip is fetched, # source modified and built using the unstable 'live' (9999) ebuild. -. /usr/lib/crosutils/common.sh || (echo "Unable to load common.sh" && exit 1) +. /usr/lib/crosutils/common.sh || exit 1 # Script must be run inside the chroot get_default_board From 82bbe72ac7b257a6a9ad9ff4444061ed96055b95 Mon Sep 17 00:00:00 2001 From: Taylor Hutt Date: Thu, 7 Apr 2011 17:27:14 -0700 Subject: [PATCH 41/64] Fix a typo in cros_workon, and make command help output nicer Details The cros_workong help text has a typographic error of 'commond' rather than 'command'. This change addresses that issue. The help text output for the list of commands was also not nicely aligned, so I've addressed that, too. Testing ~thutt/g-chroot-execute sudo emerge cros-devutils After the build & install completed, I executed: ~thutt/scripts/g-workon --help The output now looks like the following. The typo was on the 'iterate' command. usage: /usr/bin/cros_workon [flags] [|--all] commands: start: Moves an ebuild to live (intended to support development) stop: Moves an ebuild to stable (use last known good) list: List of live ebuilds (workon ebuilds if --all) list-all: List all of the live ebuilds for all setup boards iterate: For each ebuild, cd to the source dir and run a command flags: --board: The board to set package keywords for. (default: '') --[no]host: Uses the host instead of board (default: false) --command: The command to be run by forall. (default: 'git status') --[no]all: Apply to all possible packages for the given command (default: false) -h,--[no]help: show this help (default: false) BUG=0 TEST=See above Review URL: http://codereview.chromium.org/6812022 Change-Id: Idbf9f2cdde1095c310a79740eeef08087c0d415c --- cros_workon | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cros_workon b/cros_workon index fc1c365ba8..30fb68e80e 100755 --- a/cros_workon +++ b/cros_workon @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. +# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -26,11 +26,11 @@ DEFINE_boolean all "${FLAGS_FALSE}" \ FLAGS_HELP="usage: $0 [flags] [|--all] commands: - start: Moves an ebuild to live (intended to support development) - stop: Moves an ebuild to stable (use last known good) - list: List of live ebuilds (workon ebuilds if --all) + start: Moves an ebuild to live (intended to support development) + stop: Moves an ebuild to stable (use last known good) + list: List of live ebuilds (workon ebuilds if --all) list-all: List all of the live ebuilds for all setup boards - iterate: For each ebuild, cd to the source dir and run a commond" + iterate: For each ebuild, cd to the source dir and run a command" FLAGS "$@" || { [ "${FLAGS_help}" = "${FLAGS_TRUE}" ] && exit 0; } || exit 1 eval set -- "${FLAGS_ARGV}" From 0d6b94577174fdea1a43da941aea31051b4cdd0a Mon Sep 17 00:00:00 2001 From: David James Date: Fri, 13 May 2011 11:29:53 -0700 Subject: [PATCH 42/64] Add 'info' command for showing package name, repo name, and source directory of ebuilds. BUG=chromium-os:5932, chromium-os:6126 TEST=Run cros_workon --all --host info and cros_workon info --host power_manager kernel Change-Id: I46849db55d9879cbd65b4400eea9fd6b697e0a10 Reviewed-on: http://gerrit.chromium.org/gerrit/861 Reviewed-by: Zdenek Behan Tested-by: David James --- cros_workon | 53 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/cros_workon b/cros_workon index 30fb68e80e..43064e8741 100755 --- a/cros_workon +++ b/cros_workon @@ -28,6 +28,7 @@ FLAGS_HELP="usage: $0 [flags] [|--all] commands: start: Moves an ebuild to live (intended to support development) stop: Moves an ebuild to stable (use last known good) + info: Print package name, repo name, and source directory. list: List of live ebuilds (workon ebuilds if --all) list-all: List all of the live ebuilds for all setup boards iterate: For each ebuild, cd to the source dir and run a command" @@ -108,13 +109,48 @@ find_keyword_workon_ebuilds() { done } -show_workon_ebuilds() { - local keyword=$1 - - find_keyword_workon_ebuilds ${keyword} | \ - sed -e 's/.*\/\([^/]*\)\/\([^/]*\)\/.*\.ebuild/\1\/\2/' | \ - sort -u +ebuild_to_package() { # This changes the absolute path to ebuilds into category/package. + sed -e 's/.*\/\([^/]*\)\/\([^/]*\)\/.*\.ebuild/\1\/\2/' +} + +show_project_ebuild_map() { + local keyword="$1" + + # Column 1: Repo name + # Column 2: Package name + for EBUILD in $(find_keyword_workon_ebuilds ${keyword}); do + ( + eval $(grep -E '^CROS_WORKON' "${EBUILD}") + CP=$(echo "$EBUILD" | ebuild_to_package) + echo "${CROS_WORKON_PROJECT}" "${CP}" + ) + done +} + +show_project_path_map() { + # Column 1: Repo name + # Column 2: Source directory + repo forall -c 'echo $REPO_PROJECT $REPO_PATH' +} + +show_workon_ebuilds() { + local keyword="$1" + find_keyword_workon_ebuilds "${keyword}" | ebuild_to_package | sort -u +} + +show_workon_info() { + local atoms="$1" + local keyword="$2" + # Column 1: Package name + # Column 2: Repo name + # Column 3: Source directory (if present locally) + join \ + <(echo "$atoms" | sed -e 's/ /\n/g' | sort -u) \ + <(join -a 1 -e - -o 1.2,1.1,2.2 \ + <(show_project_ebuild_map "${keyword}" | sort -u) \ + <(show_project_path_map | sort -u) \ + | sort -u) } # Canonicalize package name to category/package. @@ -253,14 +289,14 @@ ebuild_iterate() { # --all makes commands operate on different lists if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then case ${WORKON_CMD} in - start) ATOM_LIST=$(show_workon_ebuilds ${BOARD_KEYWORD});; + start|info) ATOM_LIST=$(show_workon_ebuilds ${BOARD_KEYWORD});; stop|iterate) ATOM_LIST=$(show_live_ebuilds);; list) ;; *) die "--all is invalid for the given command";; esac else # not selected --all case ${WORKON_CMD} in - start|stop|iterate) + start|stop|info|iterate) ATOM_LIST=$@ if [ -z "${ATOM_LIST}" ]; then die "${WORKON_CMD}: No packages specified" @@ -274,6 +310,7 @@ fi case ${WORKON_CMD} in start) ebuild_to_live "${ATOM_LIST}" ;; stop) ebuild_to_stable "${ATOM_LIST}" ;; + info) show_workon_info "${ATOM_LIST}" "${BOARD_KEYWORD}" ;; list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || \ show_workon_ebuilds ${BOARD_KEYWORD} ;; list-all) show_all_live_ebuilds ;; From 965983e68d9921b19c65da3b40db42742afda596 Mon Sep 17 00:00:00 2001 From: David James Date: Fri, 13 May 2011 15:06:11 -0700 Subject: [PATCH 43/64] Update cros_workon to use repo list instead of repo forall. repo list is a little faster and is more idiomatic. BUG=chromium-os:5932, chromium-os:6126 TEST=Make sure cros_workon info --all and cros_workon info kernel still work Change-Id: I61dfdc8a00669e88b90298f7c990a497b61c174a Reviewed-on: http://gerrit.chromium.org/gerrit/877 Reviewed-by: Zdenek Behan Tested-by: David James --- cros_workon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cros_workon b/cros_workon index 43064e8741..9374162001 100755 --- a/cros_workon +++ b/cros_workon @@ -131,7 +131,7 @@ show_project_ebuild_map() { show_project_path_map() { # Column 1: Repo name # Column 2: Source directory - repo forall -c 'echo $REPO_PROJECT $REPO_PATH' + repo list | awk -F ' : ' '{ print $2, $1 }' } show_workon_ebuilds() { From e84d24ed032d1850bc1d3a04e636bd48fea765d0 Mon Sep 17 00:00:00 2001 From: Ryan Cui Date: Mon, 15 Aug 2011 19:28:13 -0700 Subject: [PATCH 44/64] cros_workon - temporarily special case chrome package When the user cros_workon starts the chrome package for a board, we set the CHROME_ORIGIN envvar to GERRIT_SOURCE, as part of the new chrome development workflow. The envvar is set in the ${board}/etc/portage/env/chromeos-base/chromeos-chrome file. We delete the file when the user runs cros_workon stop for the chrome package. This change is temporary - GERRIT_SOURCE will eventually become the default behavior. BUG=chromium-os:19112 TEST=Verified ebuild behavior for the cros_workon start and stop cases. Change-Id: I4948383bac3fc4eafc211da2058cbcb24614cedc Reviewed-on: http://gerrit.chromium.org/gerrit/6049 Reviewed-by: Ryan Cui Tested-by: Ryan Cui --- cros_workon | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/cros_workon b/cros_workon index 9374162001..65de881e4e 100755 --- a/cros_workon +++ b/cros_workon @@ -70,9 +70,11 @@ fi WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask +PACKAGE_ENV_DIR=${BOARD_DIR}/etc/portage/env WORKON_FILE=${WORKON_DIR}/${FLAGS_board:-host} KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon UNMASK_FILE=${UNMASK_DIR}/cros-workon +CHROME_ATOM=chromeos-base/chromeos-chrome # TODO(msb): remove the backward compatibility after 10/01/2010 if [ -d "${WORKON_DIR}" ]; then @@ -171,7 +173,10 @@ canonicalize_name () { pkgname=$(\ echo "${pkgfile}" |awk -F '/' '{ print $(NF-2) "/" $(NF-1) }') - if ! grep -q "cros-workon" ${pkgfile}; then + # TODO(rcui): remove special casing of chromeos-chrome here when we make it + # inherit from cros-workon class. Tracked in chromium-os:19259. + if [ "${pkgname}" != "${CHROME_ATOM}" ] && \ + ! grep -q "cros-workon" ${pkgfile}; then warn "${pkgname} is not a cros-workon package" 1>&2 return 1 fi @@ -235,6 +240,25 @@ regen_manifest_and_sync() { echo "Please run \"repo sync\" now." } +chrome_to_live () { + # Switch to using repo manifest checkout of chromium src. + # TODO(rcui): Remove this when CHROME_ORIGIN defaults to GERRIT_SOURCE. + # Tracked in chromium-os:19259. + env_dir=${PACKAGE_ENV_DIR}/chromeos-base + sudo mkdir -p ${env_dir} + sudo_clobber "${env_dir}/chromeos-chrome" <> \"${WORKON_FILE}\""; then atoms_success="${atoms_success} ${atom}" + if [ "${atom}" = "${CHROME_ATOM}" ]; then + chrome_to_live + fi fi else warn "Already working on ${atom}" @@ -265,6 +292,11 @@ ebuild_to_stable () { if grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then if sudo sed -e "/^=${atom/\//\\/}-9999\$/d" -i "${WORKON_FILE}"; then atoms_success="${atoms_success} ${atom}" + # TODO(rcui): Remove special case when CHROME_ORIGIN defaults to + # GERRIT_SOURCE. Tracked in chromium-os:19259. + if [ "${atom}" = "${CHROME_ATOM}" ]; then + chrome_to_stable + fi fi else warn "Not working on ${atom}" From 4a4110b741e1689f35f9c2087dae3028416b4075 Mon Sep 17 00:00:00 2001 From: Ryan Cui Date: Wed, 17 Aug 2011 17:58:52 -0700 Subject: [PATCH 45/64] Use absolute path to chrome_set_ver. So that users don't need to run gclient to update depot_tools when they are developing for chrome in the chroot (i.e., using cros_workon and emerge), since they don't need to run chrome_set_ver manually. Developing for chrome outside of the chroot (running 'make' by themselves) still requires the user to run chrome_set_ver manually after a repo sync. So they also need to run gclient to get the chrome_set_ver symlink. BUG=chromium-os:19112 TEST=ran cros_workon start chromeos-chrome Change-Id: I93a6db4930ccacfa859d83d8fb19ec45b594dd31 Reviewed-on: http://gerrit.chromium.org/gerrit/6201 Reviewed-by: Zdenek Behan Tested-by: Ryan Cui --- cros_workon | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cros_workon b/cros_workon index 65de881e4e..385c940b19 100755 --- a/cros_workon +++ b/cros_workon @@ -71,10 +71,12 @@ WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask PACKAGE_ENV_DIR=${BOARD_DIR}/etc/portage/env +CHROMITE_DIR=${CHROOT_TRUNK_DIR}/chromite WORKON_FILE=${WORKON_DIR}/${FLAGS_board:-host} KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon UNMASK_FILE=${UNMASK_DIR}/cros-workon CHROME_ATOM=chromeos-base/chromeos-chrome +CHROME_SET_VER=${CHROMITE_DIR}/bin/chrome_set_ver.py # TODO(msb): remove the backward compatibility after 10/01/2010 if [ -d "${WORKON_DIR}" ]; then @@ -251,7 +253,7 @@ CHROME_ORIGIN=GERRIT_SOURCE EOF # Run chrome_set_ver to set DEPS info "Setting Chrome dependencies to the correct revision." - chrome_set_ver + ${CHROME_SET_VER} } chrome_to_stable () { From 36770c8eed6b02e83156fc216b6ed42e00349e9d Mon Sep 17 00:00:00 2001 From: Terry Lambert Date: Mon, 12 Sep 2011 16:45:22 -0700 Subject: [PATCH 46/64] Add the ability to specify "." for a project name This uses the current directory and gets the project name out of git and then maps that to the project name(s). In the case of no mapping, it dies with a message. Included more changes per review comments by David and Richard. BUG=chromium-os:20338 TEST=cd src/platform/vpd; cros-workon start . Change-Id: I6d31d63fe515558286623c177c23fa50a0977b9b Reviewed-on: http://gerrit.chromium.org/gerrit/7577 Reviewed-by: Richard Barnette Reviewed-by: David James Reviewed-by: Terry Lambert Tested-by: Terry Lambert --- cros_workon | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/cros_workon b/cros_workon index 385c940b19..ce7a983c3f 100755 --- a/cros_workon +++ b/cros_workon @@ -24,7 +24,7 @@ DEFINE_string command "git status" \ DEFINE_boolean all "${FLAGS_FALSE}" \ "Apply to all possible packages for the given command" -FLAGS_HELP="usage: $0 [flags] [|--all] +FLAGS_HELP="usage: $0 [flags] [|.|--all] commands: start: Moves an ebuild to live (intended to support development) stop: Moves an ebuild to stable (use last known good) @@ -172,8 +172,7 @@ canonicalize_name () { return 1 fi - pkgname=$(\ - echo "${pkgfile}" |awk -F '/' '{ print $(NF-2) "/" $(NF-1) }') + pkgname=$(echo "${pkgfile}" |awk -F '/' '{ print $(NF-2) "/" $(NF-1) }') # TODO(rcui): remove special casing of chromeos-chrome here when we make it # inherit from cros-workon class. Tracked in chromium-os:19259. @@ -201,6 +200,22 @@ canonicalize_names () { echo "${names}" } +# Locate the package name based on the current directory +locate_package () { + local projectname=$(git config --get remote.cros.projectname || + git config --get remote.cros-internal.projectname) + if [ -z "${projectname}" ]; then + die "No project in git config: Can not cros_workon . here" + fi + local reponame=$(show_project_ebuild_map | + grep "^${projectname} " | cut -d" " -f2) + if [ -z "${reponame}" ]; then + die "No matching package for ${projectname}: Can not cros_workon . here" + else + echo "${reponame}" + fi +} + # Display ebuilds currently part of the live branch and open for development. show_live_ebuilds () { sed -n 's/^=\(.*\)-9999$/\1/p' "${WORKON_FILE}" @@ -334,7 +349,11 @@ else # not selected --all ATOM_LIST=$@ if [ -z "${ATOM_LIST}" ]; then die "${WORKON_CMD}: No packages specified" - elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then + fi + if [ "${ATOM_LIST}" = "." ]; then + ATOM_LIST=$(locate_package) + fi + if ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then die "Error parsing package list" fi;; *) ;; @@ -349,5 +368,5 @@ case ${WORKON_CMD} in show_workon_ebuilds ${BOARD_KEYWORD} ;; list-all) show_all_live_ebuilds ;; iterate) ebuild_iterate "${ATOM_LIST}" ;; - *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; + *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; esac From 0ddc35067b0115ecd2c3c8bf71ac4cc8478d8761 Mon Sep 17 00:00:00 2001 From: Ryan Cui Date: Fri, 21 Oct 2011 16:03:23 -0700 Subject: [PATCH 47/64] Don't set CHROME_ORIGIN environment variable CL http://gerrit.chromium.org/gerrit/#change,10530 removes dependency of chrome ebuild on CHROME_ORIGIN being set to GERRIT_SOURCE when user runs cros_workon. So remove this functionality. BUG=chromium-os:21969 TEST=Ran cros_workon start/stop for chrome and cros-devutil Change-Id: I04f7093b45f8e2871f369331bdafbba36443e21d Reviewed-on: http://gerrit.chromium.org/gerrit/10531 Reviewed-by: David James Commit-Ready: Ryan Cui Tested-by: Ryan Cui --- cros_workon | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/cros_workon b/cros_workon index ce7a983c3f..ee4d925f3d 100755 --- a/cros_workon +++ b/cros_workon @@ -70,7 +70,6 @@ fi WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask -PACKAGE_ENV_DIR=${BOARD_DIR}/etc/portage/env CHROMITE_DIR=${CHROOT_TRUNK_DIR}/chromite WORKON_FILE=${WORKON_DIR}/${FLAGS_board:-host} KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon @@ -259,23 +258,11 @@ regen_manifest_and_sync() { chrome_to_live () { # Switch to using repo manifest checkout of chromium src. - # TODO(rcui): Remove this when CHROME_ORIGIN defaults to GERRIT_SOURCE. - # Tracked in chromium-os:19259. - env_dir=${PACKAGE_ENV_DIR}/chromeos-base - sudo mkdir -p ${env_dir} - sudo_clobber "${env_dir}/chromeos-chrome" < Date: Thu, 27 Oct 2011 18:05:11 -0400 Subject: [PATCH 48/64] Add warnings if CHROME_ORIGIN is set on cros_workon start chromeos-chrome Because the chromeos-chrome ebuild will no longer force GERRIT_SOURCE, warn a user that is starting to workon chromeos-chrome that they may not be getting the experience they expect. BUG=None TEST=Ran cros_workon with CHROME_ORIGIN unset, set to GERRIT_SOURCE and set to LOCAL_SOURCE Saw warning only on LOCAL_SOURCE Ran cros_workon start kernel with CHROME_ORIGIN set and saw no warnings Change-Id: Iecbc793d3b190a12a126d42a1bfaee6d8846e9ec Reviewed-on: https://gerrit.chromium.org/gerrit/10815 Tested-by: Jon Kliegman Reviewed-by: Ryan Cui Commit-Ready: Jon Kliegman --- cros_workon | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cros_workon b/cros_workon index ee4d925f3d..6272217caa 100755 --- a/cros_workon +++ b/cros_workon @@ -261,6 +261,11 @@ chrome_to_live () { # Run chrome_set_ver to set DEPS info "Setting Chrome dependencies to the correct revision." ${CHROME_SET_VER} + if [ -n "${CHROME_ORIGIN}" ] && [ "${CHROME_ORIGIN}" != GERRIT_SOURCE ]; then + warn "CHROME_ORIGIN is already set to ${CHROME_ORIGIN}" + warn "To use the new GERRIT_SOURCE workflow, please unset it." + warn "Run 'unset CHROME_ORIGIN' to reset to the default source location." + fi } # Move a stable ebuild to the live development catgeory. The ebuild From 835542154cc7757b01587b967c7d893393e0b1a8 Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Mon, 21 Nov 2011 03:18:33 +0000 Subject: [PATCH 49/64] cros_workon: recreate all workon file symlinks unconditionally Also, remove legacy conversion code slated for deletion long ago. BUG=chromium-os:23096 TEST=have a chroot with invalid symlink in package.*/ and observe the fix Change-Id: I04ecdf28038b63d48cf7d0768c0ccf5ac8f0c0d2 Reviewed-on: https://gerrit.chromium.org/gerrit/11978 Reviewed-by: Mandeep Singh Baines Commit-Ready: Zdenek Behan Tested-by: Zdenek Behan --- cros_workon | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/cros_workon b/cros_workon index 6272217caa..6f4ecc2593 100755 --- a/cros_workon +++ b/cros_workon @@ -77,25 +77,22 @@ UNMASK_FILE=${UNMASK_DIR}/cros-workon CHROME_ATOM=chromeos-base/chromeos-chrome CHROME_SET_VER=${CHROMITE_DIR}/bin/chrome_set_ver.py -# TODO(msb): remove the backward compatibility after 10/01/2010 -if [ -d "${WORKON_DIR}" ]; then - sudo chown -R "${USER}" "${WORKON_DIR}" -fi - mkdir -p "${WORKON_DIR}" || die "mkdir -p ${WORKON_DIR}" touch "${WORKON_FILE}" || die "touch ${WORKON_FILE}" sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \ die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}" -if [ ! -L "${KEYWORDS_FILE}" ]; then - sudo rm -f "${KEYWORDS_FILE}" - sudo ln -s "${WORKON_FILE}" "${KEYWORDS_FILE}" || \ - die "ln -s ${WORKON_FILE} ${KEYWORDS_FILE}" -fi -if [ ! -L "${UNMASK_FILE}" ]; then - [ -f "${UNMASK_FILE}" ] && sudo mv "${UNMASK_FILE}" "${WORKON_FILE}" - sudo ln -s "${WORKON_FILE}" "${UNMASK_FILE}" || \ - die "ln -s ${WORKON_FILE} ${UNMASK_FILE}" -fi + +# Clobber and re-create the WORKON_FILE symlinks every time. This +# is a trivial operation and eliminates all kinds of corner cases +# as well as any possible future renames of WORKON_FILE. +# In particular, chroot is usually built as "amd64-host" but becomes +# just "host" after installation. crosbug.com/23096 +sudo rm -f "${KEYWORDS_FILE}" "${UNMASK_FILE}" +sudo ln -s "${WORKON_FILE}" "${KEYWORDS_FILE}" || \ + die "ln -s ${WORKON_FILE} ${KEYWORDS_FILE}" +sudo ln -s "${WORKON_FILE}" "${UNMASK_FILE}" || \ + die "ln -s ${WORKON_FILE} ${UNMASK_FILE}" + find_keyword_workon_ebuilds() { local keyword="${1}" From e7293bb80c7701c11999998a7a1070cbd7a7d960 Mon Sep 17 00:00:00 2001 From: David James Date: Wed, 7 Dec 2011 15:15:37 -0800 Subject: [PATCH 50/64] Fix sort order for cros_workon info. cros_workon info currently reports warnings about the sort order being wrong. This is because we're sorting the results in a different order from what join expects. We should fix that. BUG=chromium-os:23909 TEST=Verify warnings are gone. Change-Id: I021a6ac97f3ebd9d0ce0c6350b8c080e4a42977b Reviewed-on: https://gerrit.chromium.org/gerrit/12596 Reviewed-by: David James Tested-by: David James Commit-Ready: David James Reviewed-by: Mandeep Singh Baines --- cros_workon | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cros_workon b/cros_workon index 6f4ecc2593..4ea9c0cdbf 100755 --- a/cros_workon +++ b/cros_workon @@ -142,15 +142,16 @@ show_workon_ebuilds() { show_workon_info() { local atoms="$1" local keyword="$2" + local sort="sort -u -k1b,1" # Column 1: Package name # Column 2: Repo name # Column 3: Source directory (if present locally) join \ - <(echo "$atoms" | sed -e 's/ /\n/g' | sort -u) \ + <(echo "${atoms}" | sed -e 's/ /\n/g' | ${sort}) \ <(join -a 1 -e - -o 1.2,1.1,2.2 \ - <(show_project_ebuild_map "${keyword}" | sort -u) \ - <(show_project_path_map | sort -u) \ - | sort -u) + <(show_project_ebuild_map "${keyword}" | ${sort}) \ + <(show_project_path_map | ${sort}) \ + | ${sort}) } # Canonicalize package name to category/package. From 3482223936b024d88b2835a7ef4f78d5e4d9e464 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 8 Feb 2012 14:13:20 -0500 Subject: [PATCH 51/64] cros_workon: automatically display usage when given bad arguments I find this easier to work with. BUG=None TEST=`cros_workon` displays usage now before showing error TEST=`cros_workon-x86-alex` displays usage now before showing error Change-Id: Id307bfe34e4aea4b7da62f383bd543ddbef4ccc6 Reviewed-on: https://gerrit.chromium.org/gerrit/15511 Reviewed-by: David James Commit-Ready: Mike Frysinger Tested-by: Mike Frysinger --- cros_workon | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cros_workon b/cros_workon index 4ea9c0cdbf..963512140a 100755 --- a/cros_workon +++ b/cros_workon @@ -47,9 +47,12 @@ shift # there's no way to override. [ -n "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_TRUE} ] && \ FLAGS_board="" # kill board -[ -z "${FLAGS_board}" ] && [ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \ -[ "${WORKON_CMD}" != "list-all" ] && \ +if [ -z "${FLAGS_board}" ] && \ + [ "${FLAGS_host}" = ${FLAGS_FALSE} ] && \ + [ "${WORKON_CMD}" != "list-all" ]; then + flags_help die "You must specify either --host or --board=" +fi if [ -n "${FLAGS_board}" ]; then BOARD_DIR=/build/"${FLAGS_board}" # --board specified @@ -353,5 +356,8 @@ case ${WORKON_CMD} in show_workon_ebuilds ${BOARD_KEYWORD} ;; list-all) show_all_live_ebuilds ;; iterate) ebuild_iterate "${ATOM_LIST}" ;; - *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; + *) + flags_help + die "$(basename $0): command '${WORKON_CMD}' not recognized" + ;; esac From 3ffa197ac45a271f79426a6f0743d719f698a80f Mon Sep 17 00:00:00 2001 From: Chris Wolfe Date: Tue, 28 Feb 2012 15:41:58 -0500 Subject: [PATCH 52/64] cros_workon: Fix for chromeos-chrome in minilayout The cros_workon script did not support chromeos-chrome in a minilayout. This appears to result from the usual oddities of chromeos-chrome and some assumptions in cros_workon's support for CHROME_ORIGIN=GERRIT_SOURCE. BUG=None TEST=Tested on full and minilayout with x86-alex. cros_workon start and stop succeed, and both equery w and ~/trunk/.config/cros_workon/x86-alex show the correct behavior. Change-Id: Ic239f08ebedc02e6faea36d54c46ae219bfeb044 Reviewed-on: https://gerrit.chromium.org/gerrit/16995 Reviewed-by: Mandeep Singh Baines Reviewed-by: Ryan Cui Tested-by: Chris Wolfe Commit-Ready: Chris Wolfe --- cros_workon | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/cros_workon b/cros_workon index 963512140a..225731c53f 100755 --- a/cros_workon +++ b/cros_workon @@ -245,21 +245,38 @@ regen_manifest_and_sync() { return fi + local need_repo_sync= local pkgname for pkgname in $(show_live_ebuilds); do - eval $(${EBUILDCMD} $(${EQUERYCMD} which ${pkgname}) info) + local pkgpath="$(${EQUERYCMD} which "${pkgname}")" + local pkginfo="$(${EBUILDCMD} "${pkgpath}" info | + grep -v 'pkg_info() is not defined')" + if [ -z "${pkginfo}" ]; then + continue # No package information available + fi + + eval "${pkginfo}" local srcdir=$(readlink -m ${CROS_WORKON_SRCDIR}) local trunkdir=$(readlink -m ${CHROOT_TRUNK_DIR}) local project_path=${srcdir#${trunkdir}/} loman add --workon "${CROS_WORKON_PROJECT}" "${project_path}" + need_repo_sync='yes' done - echo "Please run \"repo sync\" now." + if [ -n "${need_repo_sync}" ]; then + echo "Please run \"repo sync\" now." + fi } chrome_to_live () { # Switch to using repo manifest checkout of chromium src. # Run chrome_set_ver to set DEPS + + # No chromium directory checked out in this repo; probably a minilayout. + if [ ! -d "${CHROOT_TRUNK_DIR}/chromium" ]; then + return + fi + info "Setting Chrome dependencies to the correct revision." ${CHROME_SET_VER} if [ -n "${CHROME_ORIGIN}" ] && [ "${CHROME_ORIGIN}" != GERRIT_SOURCE ]; then From e266b3b850764e8d119a2c6532fc047633c44920 Mon Sep 17 00:00:00 2001 From: Chris Wolfe Date: Tue, 13 Mar 2012 10:07:48 -0400 Subject: [PATCH 53/64] cros_workon: fix for renamed chrome_set_ver The chromite chrome_set_ver.py script lost its '.py' extension as part of some recent refactoring. This updates the cros_workon script with the new name. BUG=None TEST=cros_workon start chromeos-chrome no longer reports missing file. Change-Id: Iae2e88739c4483243581d53daf1ade630e44ab3a Reviewed-on: https://gerrit.chromium.org/gerrit/17963 Tested-by: Chris Wolfe Reviewed-by: Brian Harring Commit-Ready: Chris Wolfe --- cros_workon | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cros_workon b/cros_workon index 225731c53f..281ebe62bd 100755 --- a/cros_workon +++ b/cros_workon @@ -73,12 +73,10 @@ fi WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask -CHROMITE_DIR=${CHROOT_TRUNK_DIR}/chromite WORKON_FILE=${WORKON_DIR}/${FLAGS_board:-host} KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon UNMASK_FILE=${UNMASK_DIR}/cros-workon CHROME_ATOM=chromeos-base/chromeos-chrome -CHROME_SET_VER=${CHROMITE_DIR}/bin/chrome_set_ver.py mkdir -p "${WORKON_DIR}" || die "mkdir -p ${WORKON_DIR}" touch "${WORKON_FILE}" || die "touch ${WORKON_FILE}" @@ -278,7 +276,7 @@ chrome_to_live () { fi info "Setting Chrome dependencies to the correct revision." - ${CHROME_SET_VER} + chrome_set_ver if [ -n "${CHROME_ORIGIN}" ] && [ "${CHROME_ORIGIN}" != GERRIT_SOURCE ]; then warn "CHROME_ORIGIN is already set to ${CHROME_ORIGIN}" warn "To use the new GERRIT_SOURCE workflow, please unset it." From 0d5efffd9734a1a6e8c245a8e13676a125b0cca2 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 14 Mar 2012 18:17:08 -0400 Subject: [PATCH 54/64] cros_workon: don't use sudo to update the workon file We start off cros_workon by doing: touch "${WORKON_FILE}" || die So we've guaranteed that the user owns this file. As such, there's no need to go to sudo to update it, so drop that for a minor speed up. BUG=None TEST=`./cros_workon --board x86-alex start metrics` still works TEST=`./cros_workon --board x86-alex stop metrics` still works Change-Id: I5b78070b85ee53a76b6bdc29e24747b225905368 Reviewed-on: https://gerrit.chromium.org/gerrit/18170 Reviewed-by: Chris Wolfe Reviewed-by: David James Commit-Ready: Mike Frysinger Tested-by: Mike Frysinger --- cros_workon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cros_workon b/cros_workon index 281ebe62bd..18676ce50e 100755 --- a/cros_workon +++ b/cros_workon @@ -293,7 +293,7 @@ ebuild_to_live () { for atom in ${atoms}; do if ! grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then - if sudo bash -c "echo \"=${atom}-9999\" >> \"${WORKON_FILE}\""; then + if echo "=${atom}-9999" >> "${WORKON_FILE}" ; then atoms_success="${atoms_success} ${atom}" if [ "${atom}" = "${CHROME_ATOM}" ]; then chrome_to_live @@ -315,7 +315,7 @@ ebuild_to_stable () { for atom in ${atoms}; do if grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then - if sudo sed -e "/^=${atom/\//\\/}-9999\$/d" -i "${WORKON_FILE}"; then + if sed -i -e "/^=${atom/\//\\/}-9999\$/d" "${WORKON_FILE}" ; then atoms_success="${atoms_success} ${atom}" fi else From 5bf25dbbe721b59c11a34f00f308efc267a7cea2 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 14 Mar 2012 18:20:41 -0400 Subject: [PATCH 55/64] cros_workon: leverage sudo_multi The common.sh file has a `sudo_multi` helper to collapse multiple sudo calls into a single one for a minor speed up. Use it. BUG=None TEST=`./cros_workon --board x86-alex start metrics` still works TEST=`./cros_workon --board x86-alex stop metrics` still works Change-Id: I4b670a4d4d6f1402a69f1f7129cadc645cc93225 Reviewed-on: https://gerrit.chromium.org/gerrit/18171 Reviewed-by: Chris Wolfe Reviewed-by: David James Commit-Ready: Mike Frysinger Tested-by: Mike Frysinger --- cros_workon | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cros_workon b/cros_workon index 18676ce50e..7a7f7d3873 100755 --- a/cros_workon +++ b/cros_workon @@ -80,19 +80,19 @@ CHROME_ATOM=chromeos-base/chromeos-chrome mkdir -p "${WORKON_DIR}" || die "mkdir -p ${WORKON_DIR}" touch "${WORKON_FILE}" || die "touch ${WORKON_FILE}" -sudo mkdir -p "${KEYWORDS_DIR}" "${UNMASK_DIR}" || \ - die "mkdir -p ${KEYWORDS_DIR} ${UNMASK_DIR}" +cmds=( + "mkdir -p '${KEYWORDS_DIR}' '${UNMASK_DIR}'" -# Clobber and re-create the WORKON_FILE symlinks every time. This -# is a trivial operation and eliminates all kinds of corner cases -# as well as any possible future renames of WORKON_FILE. -# In particular, chroot is usually built as "amd64-host" but becomes -# just "host" after installation. crosbug.com/23096 -sudo rm -f "${KEYWORDS_FILE}" "${UNMASK_FILE}" -sudo ln -s "${WORKON_FILE}" "${KEYWORDS_FILE}" || \ - die "ln -s ${WORKON_FILE} ${KEYWORDS_FILE}" -sudo ln -s "${WORKON_FILE}" "${UNMASK_FILE}" || \ - die "ln -s ${WORKON_FILE} ${UNMASK_FILE}" + # Clobber and re-create the WORKON_FILE symlinks every time. This + # is a trivial operation and eliminates all kinds of corner cases + # as well as any possible future renames of WORKON_FILE. + # In particular, chroot is usually built as "amd64-host" but becomes + # just "host" after installation. crosbug.com/23096 + "rm -f '${KEYWORDS_FILE}' '${UNMASK_FILE}'" + "ln -s '${WORKON_FILE}' '${KEYWORDS_FILE}'" + "ln -s '${WORKON_FILE}' '${UNMASK_FILE}'" +) +sudo_multi "${cmds[@]}" find_keyword_workon_ebuilds() { From 904e9905edfd1d066f0e3f1145b06f2e717f229d Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 14 Mar 2012 18:45:41 -0400 Subject: [PATCH 56/64] cros_workon: mask non-live versions People who start working on a package and edit the ebuild but accidentally introduce an error (such as invalid DEPEND) often times don't notice. When they do `emerge-$BOARD` on that package, portage falls back to the non-live version automatically. Then developers waste time trying to figure out why their changes aren't working. Further, emerge doesn't even tell them why it skipped the live version. The only way to find that out is by doing: emerge-$BOARD '=foo-9999' Instead, when someone starts working on a package, automatically mask the non-live version. That way when they attempt to emerge things, portage fails immediately with an error message explaining why. This does make it hard to manually emerge the non-live version like so: emerge-$BOARD ' Tested-by: Mike Frysinger Commit-Ready: Mike Frysinger --- cros_workon | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/cros_workon b/cros_workon index 7a7f7d3873..3f3e35627b 100755 --- a/cros_workon +++ b/cros_workon @@ -71,25 +71,31 @@ else fi WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon -KEYWORDS_DIR=${BOARD_DIR}/etc/portage/package.keywords -UNMASK_DIR=${BOARD_DIR}/etc/portage/package.unmask +CONFIG_DIR=${BOARD_DIR}/etc/portage +KEYWORDS_DIR=${CONFIG_DIR}/package.keywords +MASK_DIR=${CONFIG_DIR}/package.mask +UNMASK_DIR=${CONFIG_DIR}/package.unmask WORKON_FILE=${WORKON_DIR}/${FLAGS_board:-host} +MASK_WORKON_FILE=${WORKON_FILE}.mask KEYWORDS_FILE=${KEYWORDS_DIR}/cros-workon +MASK_FILE=${MASK_DIR}/cros-workon UNMASK_FILE=${UNMASK_DIR}/cros-workon CHROME_ATOM=chromeos-base/chromeos-chrome mkdir -p "${WORKON_DIR}" || die "mkdir -p ${WORKON_DIR}" -touch "${WORKON_FILE}" || die "touch ${WORKON_FILE}" +touch "${WORKON_FILE}" "${MASK_WORKON_FILE}" || \ + die "touch ${WORKON_FILE} ${MASK_WORKON_FILE}" cmds=( - "mkdir -p '${KEYWORDS_DIR}' '${UNMASK_DIR}'" + "mkdir -p '${KEYWORDS_DIR}' '${MASK_DIR}' '${UNMASK_DIR}'" # Clobber and re-create the WORKON_FILE symlinks every time. This # is a trivial operation and eliminates all kinds of corner cases # as well as any possible future renames of WORKON_FILE. # In particular, chroot is usually built as "amd64-host" but becomes # just "host" after installation. crosbug.com/23096 - "rm -f '${KEYWORDS_FILE}' '${UNMASK_FILE}'" + "rm -f '${KEYWORDS_FILE}' '${MASK_FILE}' '${UNMASK_FILE}'" "ln -s '${WORKON_FILE}' '${KEYWORDS_FILE}'" + "ln -s '${MASK_WORKON_FILE}' '${MASK_FILE}'" "ln -s '${WORKON_FILE}' '${UNMASK_FILE}'" ) sudo_multi "${cmds[@]}" @@ -288,42 +294,46 @@ chrome_to_live () { # src_unpack step fetches the package source for local development. ebuild_to_live () { local atoms=$1 - local atoms_success="" + local atoms_success=() local atom for atom in ${atoms}; do if ! grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then - if echo "=${atom}-9999" >> "${WORKON_FILE}" ; then - atoms_success="${atoms_success} ${atom}" - if [ "${atom}" = "${CHROME_ATOM}" ]; then - chrome_to_live - fi + echo "=${atom}-9999" >> "${WORKON_FILE}" || \ + die "Could not update ${WORKON_FILE} with ${atom}" + echo "<${atom}-9999" >> "${MASK_WORKON_FILE}" || \ + die "Could not update ${MASK_WORKON_FILE} with ${atom}" + atoms_success+=( ${atom} ) + if [ "${atom}" = "${CHROME_ATOM}" ]; then + chrome_to_live fi else warn "Already working on ${atom}" fi done - [ -n "${atoms_success}" ] && regen_manifest_and_sync && \ - info "Started working on '${atoms_success/ /}' for '${BOARD_STR}'" + [ ${#atoms_success[@]} -gt 0 ] && regen_manifest_and_sync && \ + info "Started working on '${atoms_success[*]}' for '${BOARD_STR}'" } # Move a live development ebuild back to stable. ebuild_to_stable () { local atoms=$1 - local atoms_success="" + local atoms_success=() local atom for atom in ${atoms}; do - if grep -qx "=${atom}-9999" "${WORKON_FILE}" ; then - if sed -i -e "/^=${atom/\//\\/}-9999\$/d" "${WORKON_FILE}" ; then - atoms_success="${atoms_success} ${atom}" - fi + if grep -qx "=${atom}-9999" "${WORKON_FILE}" "${MASK_WORKON_FILE}" ; then + sed -i -e "/^=${atom/\//\\/}-9999\$/d" "${WORKON_FILE}" || \ + die "Could not update ${WORKON_FILE} with ${atom}" + sed -i -e "/^<${atom/\//\\/}-9999\$/d" "${MASK_WORKON_FILE}" || \ + die "Could not update ${WORKON_FILE} with ${atom}" + atoms_success+=( ${atom} ) else warn "Not working on ${atom}" fi done - [ -n "${atoms_success}" ] && \ - info "Stopped working on '${atoms_success/ /}' for '${BOARD_STR}'" + [ ${#atoms_success[@]} -gt 0 ] && \ + info "Stopped working on '${atoms_success[*]}' for '${BOARD_STR}'" } # Run a command on all or a set of repos. From c585c5aa06ccaca1511c7fed490fbb24a2bc1ae3 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 14 Mar 2012 18:53:08 -0400 Subject: [PATCH 57/64] cros_workon: merge rm/ln commands There's no need to execute `rm -f` directly when `ln -f` will unlink any existing files for us. One less command to exec. BUG=None TEST=`./cros_workon --board x86-alex start metrics` still works TEST=`./cros_workon --board x86-alex stop metrics` still works Change-Id: I784d7a215d975a11a8a4a7b5424f4e7f150bf3df Reviewed-on: https://gerrit.chromium.org/gerrit/18176 Reviewed-by: Mike Frysinger Tested-by: Mike Frysinger Commit-Ready: Mike Frysinger --- cros_workon | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cros_workon b/cros_workon index 3f3e35627b..f61d0af02e 100755 --- a/cros_workon +++ b/cros_workon @@ -93,10 +93,9 @@ cmds=( # as well as any possible future renames of WORKON_FILE. # In particular, chroot is usually built as "amd64-host" but becomes # just "host" after installation. crosbug.com/23096 - "rm -f '${KEYWORDS_FILE}' '${MASK_FILE}' '${UNMASK_FILE}'" - "ln -s '${WORKON_FILE}' '${KEYWORDS_FILE}'" - "ln -s '${MASK_WORKON_FILE}' '${MASK_FILE}'" - "ln -s '${WORKON_FILE}' '${UNMASK_FILE}'" + "ln -sf '${WORKON_FILE}' '${KEYWORDS_FILE}'" + "ln -sf '${MASK_WORKON_FILE}' '${MASK_FILE}'" + "ln -sf '${WORKON_FILE}' '${UNMASK_FILE}'" ) sudo_multi "${cmds[@]}" From 4b7fa1e97c09d4bad2c3018accea6d02877f7acb Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 16 Mar 2012 14:28:45 -0400 Subject: [PATCH 58/64] cros_workon: check for board dir before creating dirs If you pass an invalid board name, or a board that hasn't yet been setup, cros_workon will happily create the dirs in /build/ for you. For invalid boards this isn't a big deal, but for valid ones, this can confuse build steps later on like ./setup_board. Change cros_workon to fail immediately if the desired dir under /build/ does not exist. This will "break" using some operations such as "list" on boards that were installed at one point but currently no longer are, but cros_workon needs quite a bit more work in order for that workflow to be supported (if anyone even cares). BUG=None TEST=`./cros_workon --board x86-marioffffff list` quit early Change-Id: Ib83357d5d1c6383987a6d9e3dae1e86cf4864d82 Reviewed-on: https://gerrit.chromium.org/gerrit/18394 Reviewed-by: David James Tested-by: Mike Frysinger Commit-Ready: Mike Frysinger --- cros_workon | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cros_workon b/cros_workon index f61d0af02e..ca62b6c3dd 100755 --- a/cros_workon +++ b/cros_workon @@ -97,7 +97,13 @@ cmds=( "ln -sf '${MASK_WORKON_FILE}' '${MASK_FILE}'" "ln -sf '${WORKON_FILE}' '${UNMASK_FILE}'" ) -sudo_multi "${cmds[@]}" +# If the board dir doesn't exist yet, we don't want to create it as +# that'll screw up ./setup_board later on. +if [[ -d ${BOARD_DIR:-/} ]] ; then + sudo_multi "${cmds[@]}" +else + die "${BOARD_STR} has not been setup yet" +fi find_keyword_workon_ebuilds() { From 2af1a305e31c88f07ba0d52c8bc5c636aabe4e35 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 16 Mar 2012 15:07:28 -0400 Subject: [PATCH 59/64] cros_workon: optimize "list" slightly Some of the repos that we search have dirs (like profiles/ and metadata/) that will never contain ebuilds but do contain a lot of files. Restrict what find searches for to speed things up a bit. BUG=None TEST=`./cros_workon --board x86-alex list --all` shows same list of packages Change-Id: I09f59f3bb7920a02607cc4595b99ae67c06a18cf Reviewed-on: https://gerrit.chromium.org/gerrit/18395 Reviewed-by: David James Tested-by: Mike Frysinger Commit-Ready: Mike Frysinger --- cros_workon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cros_workon b/cros_workon index ca62b6c3dd..31d72c1b75 100755 --- a/cros_workon +++ b/cros_workon @@ -115,8 +115,8 @@ find_keyword_workon_ebuilds() { # NOTE: overlay may be a symlink, and we have to use ${overlay}/ for overlay in ${cros_overlays}; do # only look up ebuilds named 9999 to eliminate duplicates - find ${overlay}/ -name '*9999.ebuild' | \ - xargs grep -l "inherit.*cros-workon" | \ + find ${overlay}/*-* -maxdepth 2 -type f -name '*9999.ebuild' \ + -exec grep -l 'inherit.*cros-workon' {} + 2>/dev/null | \ xargs grep -l "KEYWORDS=.*${keyword}.*" done } From 95aad59ad35b0ec70d7b0d4dafd8d1fd14fe2992 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 16 Mar 2012 15:13:41 -0400 Subject: [PATCH 60/64] cros_workon: fix regression in "list-all" behavior The addition of the mask file made the output of "list-all" a little weird as it includes it as a "board". Filter out all *.mask files to avoid that. BUG=None TEST=`./cros_workon list-all` no longer shows "x86-alex.mask:" Change-Id: I42c1f6efb53e1d75840c49901c6d2d9edd997fd4 Reviewed-on: https://gerrit.chromium.org/gerrit/18397 Commit-Ready: Mike Frysinger Reviewed-by: Mike Frysinger Tested-by: Mike Frysinger --- cros_workon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cros_workon b/cros_workon index 31d72c1b75..2e8c24074f 100755 --- a/cros_workon +++ b/cros_workon @@ -235,7 +235,7 @@ show_live_ebuilds () { show_all_live_ebuilds () { local workon_file for workon_file in ${WORKON_DIR}/*; do - if [ -s "${workon_file}" ]; then + if [[ -s ${workon_file} && ${workon_file} != *.mask ]] ; then echo -e "${V_BOLD_GREEN}$(basename ${workon_file}):${V_VIDOFF}" sed -n 's/^=\(.*\)-9999$/ \1/p' "${workon_file}" echo "" From bb18db9908855122fb9c03bb7b689cb0c0b451f2 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 16 Mar 2012 15:47:53 -0400 Subject: [PATCH 61/64] cros_workon: minimize portageq penalties Calling portageq is fairly slow, so only call it when required, and combine the multiple calls into a single one. In some cases, we'd end up calling it multiple times which quickly multiplies the slowness. BUG=None TEST=`./cros_workon --board x86-alex start dtc` still works TEST=`./cros_workon --board x86-alex list` still works and is fast TEST=`./cros_workon --board x86-alex stop dtc` still works Change-Id: I6ac6ba283c6529384a7981ad4fffa480bae52234 Reviewed-on: https://gerrit.chromium.org/gerrit/18400 Commit-Ready: Mike Frysinger Reviewed-by: Mike Frysinger Tested-by: Mike Frysinger --- cros_workon | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/cros_workon b/cros_workon index 2e8c24074f..86b7be5350 100755 --- a/cros_workon +++ b/cros_workon @@ -60,14 +60,12 @@ if [ -n "${FLAGS_board}" ]; then EBUILDCMD=ebuild-"${FLAGS_board}" PORTAGEQCMD=portageq-"${FLAGS_board}" BOARD_STR="${FLAGS_board}" - BOARD_KEYWORD="$(portageq-${FLAGS_board} envvar ARCH)" else BOARD_DIR="" # --host specified EQUERYCMD=equery EBUILDCMD=ebuild PORTAGEQCMD=portageq BOARD_STR="host" - BOARD_KEYWORD="$(portageq envvar ARCH)" fi WORKON_DIR=${CHROOT_TRUNK_DIR}/.config/cros_workon @@ -110,10 +108,8 @@ find_keyword_workon_ebuilds() { local keyword="${1}" local overlay - local cros_overlays=$("${PORTAGEQCMD}" envvar PORTDIR_OVERLAY) - # NOTE: overlay may be a symlink, and we have to use ${overlay}/ - for overlay in ${cros_overlays}; do + for overlay in ${PORTDIR_OVERLAY}; do # only look up ebuilds named 9999 to eliminate duplicates find ${overlay}/*-* -maxdepth 2 -type f -name '*9999.ebuild' \ -exec grep -l 'inherit.*cros-workon' {} + 2>/dev/null | \ @@ -176,7 +172,7 @@ canonicalize_name () { return 0 fi - if ! pkgfile=$(ACCEPT_KEYWORDS="~${BOARD_KEYWORD}" ${EQUERYCMD} which $1); then + if ! pkgfile=$(ACCEPT_KEYWORDS="~${ARCH}" ${EQUERYCMD} which $1); then warn "error looking up package $1" 1>&2 return 1 fi @@ -353,10 +349,18 @@ ebuild_iterate() { done } +# Only call portageq when absolutely required, and when we do, only run it +# once -- it's a slow beast and can easily take hundreds of milliseconds :(. +if [[ ${WORKON_CMD} != "list" || ${FLAGS_all} != ${FLAGS_FALSE} ]] ; then + portageq_vars="ARCH PORTDIR_OVERLAY" + unset ${portageq_vars} + eval $(${PORTAGEQCMD} envvar -v ${portageq_vars}) +fi + # --all makes commands operate on different lists if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then case ${WORKON_CMD} in - start|info) ATOM_LIST=$(show_workon_ebuilds ${BOARD_KEYWORD});; + start|info) ATOM_LIST=$(show_workon_ebuilds ${ARCH});; stop|iterate) ATOM_LIST=$(show_live_ebuilds);; list) ;; *) die "--all is invalid for the given command";; @@ -381,9 +385,9 @@ fi case ${WORKON_CMD} in start) ebuild_to_live "${ATOM_LIST}" ;; stop) ebuild_to_stable "${ATOM_LIST}" ;; - info) show_workon_info "${ATOM_LIST}" "${BOARD_KEYWORD}" ;; + info) show_workon_info "${ATOM_LIST}" "${ARCH}" ;; list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || \ - show_workon_ebuilds ${BOARD_KEYWORD} ;; + show_workon_ebuilds ${ARCH} ;; list-all) show_all_live_ebuilds ;; iterate) ebuild_iterate "${ATOM_LIST}" ;; *) From 6ba0ec8b5bd7a88e10dec45c0b058566c0798cc9 Mon Sep 17 00:00:00 2001 From: David James Date: Fri, 30 Mar 2012 17:34:39 -0700 Subject: [PATCH 62/64] Don't unique projects in cros_workon --info. There may be multiple ebuilds associated with the same project. We therefore should not use -u in the sort command here and eliminate needed ebuilds from the list. BUG=none TEST=cros_workon --all --board=x86-generic | grep autotest (Previously it returned 1 ebuild; now it returns them all.) Change-Id: I2e33090e2ba06e7cfde908a7e142267fbd74198b Reviewed-on: https://gerrit.chromium.org/gerrit/19409 Commit-Ready: David James Reviewed-by: David James Tested-by: David James --- cros_workon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cros_workon b/cros_workon index 86b7be5350..682198f290 100755 --- a/cros_workon +++ b/cros_workon @@ -150,7 +150,7 @@ show_workon_ebuilds() { show_workon_info() { local atoms="$1" local keyword="$2" - local sort="sort -u -k1b,1" + local sort="sort -k1b,1" # Column 1: Package name # Column 2: Repo name # Column 3: Source directory (if present locally) From a00ab37b7a70b75c34d594e1f5af30d20770ce4c Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Fri, 4 May 2012 14:39:45 +0200 Subject: [PATCH 63/64] cros_workon: disallow running as root, it doesn't work anyway BUG=chromium-os:30384 TEST=install it, run as root, see it fail Change-Id: Id852af26e2985a86f02212e6c35aeff3324e8b88 Reviewed-on: https://gerrit.chromium.org/gerrit/21857 Commit-Ready: Zdenek Behan Tested-by: Zdenek Behan Reviewed-by: David James Reviewed-by: Luigi Semenzato Reviewed-by: Mike Frysinger --- cros_workon | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cros_workon b/cros_workon index 682198f290..0b0863ce22 100755 --- a/cros_workon +++ b/cros_workon @@ -12,6 +12,8 @@ . /usr/lib/crosutils/common.sh || exit 1 +assert_not_root_user + # Script must be run inside the chroot get_default_board From 6830f055a5eb9ec6340664300f3c3034da8c3a7f Mon Sep 17 00:00:00 2001 From: Zdenek Behan Date: Fri, 6 Apr 2012 17:53:39 +0200 Subject: [PATCH 64/64] cros_workon: allow multiple projects Backwards compatible change, because regular variables are addressable as arrays of up to one item. BUG=chromium-os:25338 TEST=cros_workon --host start sys-libs/glibc (with local multi-project mod), and observe that both projects are correctly added to local_manifest, then repo sync. TEST=cros_workon start number of single-project ebuilds Change-Id: Ib3c7ebec7860f23d9331cecd55e3fc9a70709c93 Reviewed-on: https://gerrit.chromium.org/gerrit/23913 Commit-Ready: Zdenek Behan Reviewed-by: Zdenek Behan Tested-by: Zdenek Behan --- cros_workon | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cros_workon b/cros_workon index 0b0863ce22..d76ac90b5d 100755 --- a/cros_workon +++ b/cros_workon @@ -263,12 +263,17 @@ regen_manifest_and_sync() { fi eval "${pkginfo}" - local srcdir=$(readlink -m ${CROS_WORKON_SRCDIR}) - local trunkdir=$(readlink -m ${CHROOT_TRUNK_DIR}) - local project_path=${srcdir#${trunkdir}/} + local trunkdir=$(readlink -m "${CHROOT_TRUNK_DIR}") - loman add --workon "${CROS_WORKON_PROJECT}" "${project_path}" + local i=0 need_repo_sync='yes' + for S in "${CROS_WORKON_SRCDIR[@]}"; do + local srcdir=$(readlink -m "${S}") + local project_path=${srcdir#${trunkdir}/} + + loman add --workon "${CROS_WORKON_PROJECT[i]}" "${project_path}" + : $(( ++i )) + done done if [ -n "${need_repo_sync}" ]; then echo "Please run \"repo sync\" now." @@ -347,7 +352,9 @@ ebuild_iterate() { for atom in ${atoms}; do info "Running \"${FLAGS_command}\" on ${atom}" eval $(${EBUILDCMD} $(${EQUERYCMD} which ${atom}) info) - (cd "${CROS_WORKON_SRCDIR}" && bash -c "${FLAGS_command}") + for S in "${CROS_WORKON_SRCDIR[@]}"; do + (cd "${S}" && bash -c "${FLAGS_command}") + done done }