OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Wrapper scripts around cros_mark_as_stable that marks all packages as stable | 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 | 8 # that have CROS_WORKON_COMMIT that is different than the current HEAD commit |
9 # of the corresponding git repository. | 9 # of the corresponding git repository. |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 [ -f "${BLACKLIST_FILE}" ] && \ | 47 [ -f "${BLACKLIST_FILE}" ] && \ |
48 PACKAGE_BLACKLIST=$(cat "${BLACKLIST_FILE}") | 48 PACKAGE_BLACKLIST=$(cat "${BLACKLIST_FILE}") |
49 | 49 |
50 function package_is_blacklisted() { | 50 function package_is_blacklisted() { |
51 # Makes a list that looks like "\|package1\|package2\|...packagen". | 51 # Makes a list that looks like "\|package1\|package2\|...packagen". |
52 local blist_regex=$(for i in ${PACKAGE_BLACKLIST}; do echo -n "\\|${i}"; done) | 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 | 53 expr "${1}" : "^\(${blist_regex/\\|/}\)$" &> /dev/null && return 0 || return 1 |
54 } | 54 } |
55 | 55 |
| 56 function ifs_normalize() { |
| 57 for i in $*; do echo "${i}"; done | sort -u |tr '\n' ' ' |
| 58 } |
| 59 |
| 60 function eclass_affected_ebuilds() { |
| 61 CHROMIUMOS_OVERLAY="${HOME}/trunk/src/third_party/chromiumos-overlay/" |
| 62 |
| 63 info "Tracking eclass changes" |
| 64 pushd "${CHROMIUMOS_OVERLAY}" 1> /dev/null |
| 65 |
| 66 # Look at the last time chrome-bot commited anything. |
| 67 last_bot_commit=$( |
| 68 git log --author=chrome-bot -1|head -n 1|cut -f2 -d' ' |
| 69 ) |
| 70 info "Last bot commit is: ${last_bot_commit}" |
| 71 |
| 72 # List of eclasses touched in all commits since that commit. |
| 73 eclass_touched=$(ifs_normalize $( |
| 74 git diff --name-only ${last_bot_commit}|grep "^eclass\/.*\.eclass" | \ |
| 75 sed -e 's,eclass/\(.*\)\.eclass,\1,' | \ |
| 76 sort -u |
| 77 ) |
| 78 ) |
| 79 eclass_touched_prev="" |
| 80 |
| 81 if [ -z "${eclass_touched}" ]; then |
| 82 info "No eclasses changed" |
| 83 return 0 |
| 84 fi |
| 85 |
| 86 # Iteratively add all eclasses that inherit the current list, until |
| 87 # the first iteration that will not add anything. |
| 88 while [ "${eclass_touched}" != "${eclass_touched_prev}" ]; do |
| 89 eclass_touched_prev=${eclass_touched} |
| 90 |
| 91 # regexp to search for eclass inheritance |
| 92 searchregexp="$(for i in ${eclass_touched}; do echo -n "\|${i}"; done)" |
| 93 searchregexp="inherit.*\(${searchregexp/|/}\).*" |
| 94 |
| 95 # Iterate the current list of eclasses and add immediate dependencies. |
| 96 eclass_touched=$(ifs_normalize $( |
| 97 find "eclass/" -name '*.eclass' | \ |
| 98 xargs grep -l "${searchregexp}" | \ |
| 99 sed -e "s,eclass/\(.*\)\.eclass,\1," |
| 100 ) ${eclass_touched} |
| 101 ) |
| 102 done |
| 103 |
| 104 info "Eclasses changed: ${eclass_touched}" |
| 105 |
| 106 # Look which ebuilds are affected. |
| 107 # NOTE: searchregexp is usable because last two lists of eclasses were the sam
e |
| 108 ebuilds_affected=$( |
| 109 find . -name '*9999.ebuild' | \ |
| 110 xargs grep -l "cros-workon" | \ |
| 111 xargs grep -l "${searchregexp}" | \ |
| 112 sed -e "s,.\/\(.*\)/.*-9999.ebuild,\1," |
| 113 ) |
| 114 |
| 115 echo "${ebuilds_affected}" |
| 116 |
| 117 popd 1> /dev/null |
| 118 } |
| 119 |
56 # For each package, compares the head commit id to the commit id in the ebuild. | 120 # 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} | 121 # If they do not match, add the package and its commit id into ${PACKAGE_LIST} |
58 # and ${COMMIT_ID_LIST} | 122 # and ${COMMIT_ID_LIST} |
59 for package in ${PACKAGES}; do | 123 for package in ${PACKAGES}; do |
60 if package_is_blacklisted ${package}; then | 124 if package_is_blacklisted ${package}; then |
61 info "${package} blacklisted, skipping" | 125 info "${package} blacklisted, skipping" |
62 continue | 126 continue |
63 fi | 127 fi |
64 # We need to pick up any stable ebuilds for any platform. | 128 # We need to pick up any stable ebuilds for any platform. |
65 ebuild_path=$(ACCEPT_KEYWORDS="arm x86 amd64" ${EQUERYCMD} which ${package})\ | 129 ebuild_path=$(ACCEPT_KEYWORDS="arm x86 amd64" ${EQUERYCMD} which ${package})\ |
(...skipping 19 matching lines...) Expand all Loading... |
85 # egrep succeeds if there are important differences between the ebuilds. | 149 # egrep succeeds if there are important differences between the ebuilds. |
86 if diff "${ebuild_path}" "${ebuild_9999_path}" | \ | 150 if diff "${ebuild_path}" "${ebuild_9999_path}" | \ |
87 egrep -v "KEYWORDS|CROS_WORKON_COMMIT|^---|^[<>]\ *$|^[0-9]"; then | 151 egrep -v "KEYWORDS|CROS_WORKON_COMMIT|^---|^[<>]\ *$|^[0-9]"; then |
88 info "Detected 9999 ebuild change for ${package}." | 152 info "Detected 9999 ebuild change for ${package}." |
89 PACKAGE_LIST="${PACKAGE_LIST} ${package}" | 153 PACKAGE_LIST="${PACKAGE_LIST} ${package}" |
90 COMMIT_ID_LIST="${COMMIT_ID_LIST} ${egit_commit}" | 154 COMMIT_ID_LIST="${COMMIT_ID_LIST} ${egit_commit}" |
91 fi | 155 fi |
92 fi | 156 fi |
93 done | 157 done |
94 | 158 |
| 159 PACKAGE_LIST=$( |
| 160 ifs_normalize ${PACKAGE_LIST} $(eclass_affected_ebuilds) |
| 161 ) |
| 162 |
95 if [ -n "${PACKAGE_LIST}" ] ; then | 163 if [ -n "${PACKAGE_LIST}" ] ; then |
96 info "Candidate package list ${PACKAGE_LIST}" | 164 info "Candidate package list ${PACKAGE_LIST}" |
97 info "With commit id list ${COMMIT_ID_LIST}" | 165 info "With commit id list ${COMMIT_ID_LIST}" |
98 | 166 |
99 ./cros_mark_as_stable --board ${FLAGS_board} -p "${PACKAGE_LIST}" \ | 167 ./cros_mark_as_stable --board ${FLAGS_board} -p "${PACKAGE_LIST}" \ |
100 -i "${COMMIT_ID_LIST}" -t ${FLAGS_tracking_branch} commit || \ | 168 -i "${COMMIT_ID_LIST}" -t ${FLAGS_tracking_branch} commit || \ |
101 die "Could not mark all packages as stable" | 169 die "Could not mark all packages as stable" |
102 else | 170 else |
103 info "No candidate packages to be marked" | 171 info "No candidate packages to be marked" |
104 fi | 172 fi |
OLD | NEW |