mirror of
https://github.com/flatcar/scripts.git
synced 2026-02-26 18:11:45 +01:00
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
This commit is contained in:
parent
01772ff58f
commit
4cf9fdb84e
37
cros_workon
37
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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user