From db51f311399ac12e9faa56aa65d0c447252afb35 Mon Sep 17 00:00:00 2001 From: Chris Sosa Date: Mon, 19 Jul 2010 11:57:31 -0700 Subject: [PATCH] Add wrapper script to get list of updates to pass to stablizing script without other changes TEST=Ran script Review URL: http://codereview.chromium.org/3034011 --- cros_mark_all_as_stable | 67 +++++++++++++++++++++++++++++++++++++++++ cros_mark_as_stable.py | 6 ++-- 2 files changed, 70 insertions(+), 3 deletions(-) create mode 100755 cros_mark_all_as_stable diff --git a/cros_mark_all_as_stable b/cros_mark_all_as_stable new file mode 100755 index 0000000000..3d7967bc2c --- /dev/null +++ b/cros_mark_all_as_stable @@ -0,0 +1,67 @@ +#!/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." + +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="" + +# 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 + ebuild_path=$(${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}" + fi +done + +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}" commit || \ + die "Could not mark all packages as stable" diff --git a/cros_mark_as_stable.py b/cros_mark_as_stable.py index df87985a9a..8c9ba50d68 100755 --- a/cros_mark_as_stable.py +++ b/cros_mark_as_stable.py @@ -275,9 +275,9 @@ class EBuildStableMarker(object): elif line.startswith('EAPI'): # Always add new commit_id after EAPI definition. redirect_file.write(line) - redirect_file.write('EGIT_COMMIT="%s"' % commit_id) - elif not line.startswith('EGIT_COMMIT'): - # Skip old EGIT_COMMIT definition. + redirect_file.write('CROS_WORKON_COMMIT="%s"' % commit_id) + elif not line.startswith('CROS_WORKON_COMMIT'): + # Skip old CROS_WORKON_COMMIT definition. redirect_file.write(line) fileinput.close()