flatcar-scripts/cros_mark_all_as_stable
Anush Elangovan 189d85d20e Revert "Fix issue with stale cache from bad builds."
This reverts commit 365d4b0cc8b21204e6e093bf910d53d3673f113c.

Fix preflight breakage, this seems like the most possible cause. Will recommit if not.

BUG=
TEST=

Review URL: http://codereview.chromium.org/3767012

Change-Id: I93fe463fec77c445e7ff0ec86db25d5ef2997ad7
2010-10-15 11:36:53 -07:00

105 lines
3.8 KiB
Bash
Executable File

#!/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.
# Wrapper scripts around cros_mark_as_stable that marks all packages as stable
# that have CROS_WORKON_COMMIT that is different than the current HEAD commit
# of the corresponding git repository.
# 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"
# Load common functions for workon scripts.
. "$(dirname "$0")/lib/cros_workon_common.sh"
get_default_board
DEFINE_string board "${DEFAULT_BOARD}" \
"The board to set package keywords for."
DEFINE_string tracking_branch "origin" \
"Used with commit to specify branch to track against."
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
set -e
BOARD_DIR=/build/"${FLAGS_board}"
EQUERYCMD=equery-"${FLAGS_board}"
EBUILDCMD=ebuild-"${FLAGS_board}"
PACKAGES=$( show_workon_ebuilds )
GRAB_HEAD_COMMIT_CMD="git show HEAD | head -1 | cut -f 2 -d ' '"
# Packages to mark as stable.
PACKAGE_LIST=""
# List of commit ids corresponding to package list.
COMMIT_ID_LIST=""
# List of IFS-delimited ebuilds to ignore.
PACKAGE_BLACKLIST=""
# File containing the names of blacklisted packages.
BLACKLIST_FILE=$(dirname "${0}")/cros_mark_as_stable_blacklist
[ -f "${BLACKLIST_FILE}" ] && \
PACKAGE_BLACKLIST=$(cat "${BLACKLIST_FILE}")
function package_is_blacklisted() {
# Makes a list that looks like "\|package1\|package2\|...packagen".
local blist_regex=$(for i in ${PACKAGE_BLACKLIST}; do echo -n "\\|${i}"; done)
expr "${1}" : "^\(${blist_regex/\\|/}\)$" &> /dev/null && return 0 || return 1
}
# For each package, compares the head commit id to the commit id in the ebuild.
# If they do not match, add the package and its commit id into ${PACKAGE_LIST}
# and ${COMMIT_ID_LIST}
for package in ${PACKAGES}; do
if package_is_blacklisted ${package}; then
info "${package} blacklisted, skipping"
continue
fi
# We need to pick up any stable ebuilds for any platform.
ebuild_path=$(ACCEPT_KEYWORDS="arm x86 amd64" ${EQUERYCMD} which ${package})\
|| continue
# Get 9999 ebuild path to see if it got changed.
ebuild_9999_path=$(ACCEPT_KEYWORDS="~*" ${EQUERYCMD} which ${package}) \
|| continue
# Sets ${CROS_WORKON_SRCDIR} from the ebuild.
eval $(${EBUILDCMD} ${ebuild_path} info) &> /dev/null || continue
head_commit=$( cd "${CROS_WORKON_SRCDIR}" &&\
bash -c "${GRAB_HEAD_COMMIT_CMD}" ) || continue
egit_commit=$(\
eval echo $(grep CROS_WORKON_COMMIT ${ebuild_path} | cut -f 2 -d '=')) ||\
echo "No CROS_WORKON_COMMIT found in ${ebuild_path}"
if [[ ${head_commit} != ${egit_commit} ]] && \
[ -n "${head_commit}" ]; then
info\
"HEAD ${head_commit} != CROS_WORKON_COMMIT ${egit_commit} for ${package}"
PACKAGE_LIST="${PACKAGE_LIST} ${package}"
COMMIT_ID_LIST="${COMMIT_ID_LIST} ${head_commit}"
elif [[ ${head_commit} = ${egit_commit} ]]; then
info "Commit id's match for ${package}, checking for 9999 ebuild change."
# egrep succeeds if there are important differences between the ebuilds.
if diff "${ebuild_path}" "${ebuild_9999_path}" | \
egrep -v "KEYWORDS|CROS_WORKON_COMMIT|^---|^[<>]\ *$|^[0-9]"; then
info "Detected 9999 ebuild change for ${package}."
PACKAGE_LIST="${PACKAGE_LIST} ${package}"
COMMIT_ID_LIST="${COMMIT_ID_LIST} ${egit_commit}"
fi
fi
done
if [ -n "${PACKAGE_LIST}" ] ; then
info "Candidate package list ${PACKAGE_LIST}"
info "With commit id list ${COMMIT_ID_LIST}"
./cros_mark_as_stable --board ${FLAGS_board} -p "${PACKAGE_LIST}" \
-i "${COMMIT_ID_LIST}" -t ${FLAGS_tracking_branch} commit || \
die "Could not mark all packages as stable"
else
info "No candidate packages to be marked"
fi