| OLD | NEW |
| (Empty) |
| 1 #!/bin/bash | |
| 2 | |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 # Wrapper scripts around cros_mark_as_stable that marks all packages as stable | |
| 8 # that have CROS_WORKON_COMMIT that is different than the current HEAD commit | |
| 9 # of the corresponding git repository. | |
| 10 | |
| 11 # Load common constants. This should be the first executable line. | |
| 12 # The path to common.sh should be relative to your script's location. | |
| 13 . "$(dirname "$0")/common.sh" | |
| 14 | |
| 15 # Load common functions for workon scripts. | |
| 16 . "$(dirname "$0")/lib/cros_workon_common.sh" | |
| 17 | |
| 18 get_default_board | |
| 19 | |
| 20 DEFINE_string board "${DEFAULT_BOARD}" \ | |
| 21 "The board to set package keywords for." | |
| 22 DEFINE_string tracking_branch "origin" \ | |
| 23 "Used with commit to specify branch to track against." | |
| 24 | |
| 25 FLAGS "$@" || exit 1 | |
| 26 eval set -- "${FLAGS_ARGV}" | |
| 27 | |
| 28 set -e | |
| 29 | |
| 30 BOARD_DIR=/build/"${FLAGS_board}" | |
| 31 EQUERYCMD=equery-"${FLAGS_board}" | |
| 32 EBUILDCMD=ebuild-"${FLAGS_board}" | |
| 33 | |
| 34 PACKAGES=$( show_workon_ebuilds ) | |
| 35 | |
| 36 GRAB_HEAD_COMMIT_CMD="git show HEAD | head -1 | cut -f 2 -d ' '" | |
| 37 | |
| 38 # Packages to mark as stable. | |
| 39 PACKAGE_LIST="" | |
| 40 # List of commit ids corresponding to package list. | |
| 41 COMMIT_ID_LIST="" | |
| 42 # List of IFS-delimited ebuilds to ignore. | |
| 43 PACKAGE_BLACKLIST="" | |
| 44 # File containing the names of blacklisted packages. | |
| 45 BLACKLIST_FILE=$(dirname "${0}")/cros_mark_as_stable_blacklist | |
| 46 | |
| 47 [ -f "${BLACKLIST_FILE}" ] && \ | |
| 48 PACKAGE_BLACKLIST=$(cat "${BLACKLIST_FILE}") | |
| 49 | |
| 50 function package_is_blacklisted() { | |
| 51 # Makes a list that looks like "\|package1\|package2\|...packagen". | |
| 52 local blist_regex=$(for i in ${PACKAGE_BLACKLIST}; do echo -n "\\|${i}"; done) | |
| 53 expr "${1}" : "^\(${blist_regex/\\|/}\)$" &> /dev/null && return 0 || return 1 | |
| 54 } | |
| 55 | |
| 56 # For each package, compares the head commit id to the commit id in the ebuild. | |
| 57 # If they do not match, add the package and its commit id into ${PACKAGE_LIST} | |
| 58 # and ${COMMIT_ID_LIST} | |
| 59 for package in ${PACKAGES}; do | |
| 60 if package_is_blacklisted ${package}; then | |
| 61 info "${package} blacklisted, skipping" | |
| 62 continue | |
| 63 fi | |
| 64 # We need to pick up any stable ebuilds for any platform. | |
| 65 ebuild_path=$(ACCEPT_KEYWORDS="arm x86 amd64" ${EQUERYCMD} which ${package})\ | |
| 66 || continue | |
| 67 # Get 9999 ebuild path to see if it got changed. | |
| 68 ebuild_9999_path=$(ACCEPT_KEYWORDS="~*" ${EQUERYCMD} which ${package}) \ | |
| 69 || continue | |
| 70 # Sets ${CROS_WORKON_SRCDIR} from the ebuild. | |
| 71 eval $(${EBUILDCMD} ${ebuild_path} info) &> /dev/null || continue | |
| 72 head_commit=$( cd "${CROS_WORKON_SRCDIR}" &&\ | |
| 73 bash -c "${GRAB_HEAD_COMMIT_CMD}" ) || continue | |
| 74 egit_commit=$(\ | |
| 75 eval echo $(grep CROS_WORKON_COMMIT ${ebuild_path} | cut -f 2 -d '=')) ||\ | |
| 76 echo "No CROS_WORKON_COMMIT found in ${ebuild_path}" | |
| 77 if [[ ${head_commit} != ${egit_commit} ]] && \ | |
| 78 [ -n "${head_commit}" ]; then | |
| 79 info\ | |
| 80 "HEAD ${head_commit} != CROS_WORKON_COMMIT ${egit_commit} for ${package}" | |
| 81 PACKAGE_LIST="${PACKAGE_LIST} ${package}" | |
| 82 COMMIT_ID_LIST="${COMMIT_ID_LIST} ${head_commit}" | |
| 83 elif [[ ${head_commit} = ${egit_commit} ]]; then | |
| 84 info "Commit id's match for ${package}, checking for 9999 ebuild change." | |
| 85 # egrep succeeds if there are important differences between the ebuilds. | |
| 86 if diff "${ebuild_path}" "${ebuild_9999_path}" | \ | |
| 87 egrep -v "KEYWORDS|CROS_WORKON_COMMIT|^---|^[<>]\ *$|^[0-9]"; then | |
| 88 info "Detected 9999 ebuild change for ${package}." | |
| 89 PACKAGE_LIST="${PACKAGE_LIST} ${package}" | |
| 90 COMMIT_ID_LIST="${COMMIT_ID_LIST} ${egit_commit}" | |
| 91 fi | |
| 92 fi | |
| 93 done | |
| 94 | |
| 95 if [ -n "${PACKAGE_LIST}" ] ; then | |
| 96 info "Candidate package list ${PACKAGE_LIST}" | |
| 97 info "With commit id list ${COMMIT_ID_LIST}" | |
| 98 | |
| 99 ./cros_mark_as_stable --board ${FLAGS_board} -p "${PACKAGE_LIST}" \ | |
| 100 -i "${COMMIT_ID_LIST}" -t ${FLAGS_tracking_branch} commit || \ | |
| 101 die "Could not mark all packages as stable" | |
| 102 else | |
| 103 info "No candidate packages to be marked" | |
| 104 fi | |
| OLD | NEW |