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
This commit is contained in:
Mandeep Singh Baines 2010-08-25 17:21:14 -07:00 committed by David James
parent 8216bd952c
commit 7d25eedbb6

View File

@ -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