From b0d4eb74236f5cffe7392da9126dffb100665680 Mon Sep 17 00:00:00 2001 From: Mandeep Singh Baines Date: Mon, 23 Aug 2010 13:57:25 -0700 Subject: [PATCH] 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