From 904e9905edfd1d066f0e3f1145b06f2e717f229d Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 14 Mar 2012 18:45:41 -0400 Subject: [PATCH] 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.