Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2020 The Chromium OS Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | # |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 6 | # Script to update base firmware in a program's config, and then |
| 7 | # regenerate the configs of projects that are part of the program. |
| 8 | # Also updates the firmware manifest, and uploads all of the changes |
| 9 | # for review. |
| 10 | # |
| 11 | # Usage: |
Andrew McRae | d0aee43 | 2020-07-22 15:40:55 +1000 | [diff] [blame] | 12 | # ./update_program_fw --board=program --release=NNNNN.nn [ --reviewer=reviewers ] |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 13 | # [ --project=proj... ] |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 14 | # E.g: |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 15 | # ./update_program_fw --board=puff --release=13291 --reviewer=amcrae@google.com |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 16 | # |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 17 | CONTRIB_DIR=$(dirname "$(readlink -f "$0")") |
| 18 | . "${CONTRIB_DIR}/common.sh" || exit 1 |
| 19 | |
| 20 | FLAGS_HELP=" |
| 21 | Command to update the firmware version for a board. |
| 22 | |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 23 | Updates the firmware version configuration for a board's |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 24 | master configuration (program.star) and for selected projects |
| 25 | that include the master configuration. |
| 26 | |
| 27 | If no projects are specified, all projects for that board are selected. |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 28 | An optional skip list can be specified to skip selected boards. |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 29 | |
| 30 | The configurations for the selected projects are regenerated, |
| 31 | and the firmware manifest are updated for the projects. |
| 32 | |
| 33 | The necessary CLs for these changes are created and uploaded for review. |
| 34 | An optional reviewer can be specified to send all the CLs to. |
| 35 | " |
| 36 | # Flags |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 37 | DEFINE_string board "${DEFAULT_BOARD}" "Which board (program) the firmware is for (e.g 'puff')" b |
Andrew McRae | b46a336 | 2020-07-16 12:12:18 +1000 | [diff] [blame] | 38 | DEFINE_string release "${DEFAULT_RELEASE}" "The firmware release to update to (e.g 13310.3)" r |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 39 | DEFINE_string project "${DEFAULT_PROJECT}" "Which projects this release is for (defaults to all), e.g 'duffy'" p |
Andrew McRae | 3b94aaf | 2020-06-25 15:28:18 +1000 | [diff] [blame] | 40 | DEFINE_string bug "none" "The bug to reference in the CL e.g b:12345" |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 41 | DEFINE_string skip "${DEFAULT_SKIP}" "Skip these projects (comma separated list)" s |
| 42 | DEFINE_boolean build "${FLAGS_TRUE}" "Attempt to build coreboot" |
| 43 | DEFINE_boolean program "${FLAGS_TRUE}" "Update the version in the base program.star" |
Andrew McRae | d0aee43 | 2020-07-22 15:40:55 +1000 | [diff] [blame] | 44 | DEFINE_string reviewer "${DEFAULT_REVIEWER}" "The reviewer(s) to send the CLs to (optional)" |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 45 | DEFINE_string test "none" "The 'TEST=' string added to the commit message" |
| 46 | DEFINE_boolean dryrun "${FLAGS_FALSE}" "Do not perform any actions, just validate and print arguments" |
Andrew McRae | a164ca6 | 2020-07-20 11:56:50 +1000 | [diff] [blame] | 47 | DEFINE_boolean verify "${FLAGS_TRUE}" "Ask for verification before proceeding" |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 48 | |
| 49 | # Set before flag processing |
| 50 | COMMAND=$(basename "$0") |
| 51 | CMDARGS="$*" |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 52 | |
| 53 | # Parse command line |
| 54 | FLAGS "$@" || exit 1 |
| 55 | eval set -- "${FLAGS_ARGV}" |
| 56 | set -e |
| 57 | |
| 58 | # Script must be run inside the chroot. |
| 59 | assert_inside_chroot |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 60 | # |
| 61 | # Variables |
| 62 | # |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 63 | PATH="${PATH}:${GCLIENT_ROOT}/src/config/bin" |
Andrew McRae | b46a336 | 2020-07-16 12:12:18 +1000 | [diff] [blame] | 64 | MAJOR_RE="[1-9][0-9]{4}" |
| 65 | MINOR_RE="(0|[1-9][0-9]*)" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 66 | BRANCH="" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 67 | PROGRAM_CL="" |
Andrew McRae | b46a336 | 2020-07-16 12:12:18 +1000 | [diff] [blame] | 68 | MAJOR_PREFIX="major_version = " |
| 69 | MINOR_PREFIX="minor_version = " |
| 70 | ANY_MAJOR="${MAJOR_PREFIX}${MAJOR_RE}" |
| 71 | ANY_MINOR="${MINOR_PREFIX}${MINOR_RE}" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 72 | # |
| 73 | # Common functions |
| 74 | # |
| 75 | cleanup() { |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 76 | if [[ -d "${TEMPDIR}" ]]; then |
| 77 | rm -rf "${TEMPDIR}" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 78 | fi |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 79 | } |
| 80 | # |
| 81 | # Abort the update, and clean up branches and CLs |
| 82 | # |
| 83 | abort() { |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 84 | CLS=$(gerrit -i --raw search "owner:me status:open hashtag:${BRANCH}") |
| 85 | if [[ -n "${CLS}" ]]; then |
| 86 | echo "Abandoning uploaded CLs" |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 87 | for cl in ${CLS}; do |
| 88 | gerrit -i abandon "${cl}" |
| 89 | done |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 90 | fi |
Andrew McRae | c603912 | 2020-07-30 15:03:05 +1000 | [diff] [blame] | 91 | "cros-workon-${FLAGS_board}" stop "chromeos-base/chromeos-firmware-${FLAGS_board}" |
| 92 | "cros-workon-${FLAGS_board}" stop "chromeos-base/chromeos-config-bsp-${FLAGS_board}-private" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 93 | repo abandon "${BRANCH}" |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 94 | die "$*" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 95 | } |
| 96 | # |
Andrew McRae | 802326f | 2020-07-23 13:48:16 +1000 | [diff] [blame] | 97 | # Return 0 if file has major or minor version in it. |
| 98 | # |
| 99 | has_version() { |
| 100 | (grep -E -q "(${ANY_MAJOR}|${ANY_MINOR})" "${1}") |
| 101 | } |
| 102 | # |
| 103 | # Return 0 if file has major version in it. |
| 104 | # |
| 105 | has_major_version() { |
| 106 | (grep -E -q "${ANY_MAJOR}" "${1}") |
| 107 | } |
| 108 | # |
| 109 | # Return 0 if file has minor version in it. |
| 110 | # |
| 111 | has_minor_version() { |
| 112 | (grep -E -q "${ANY_MINOR}" "${1}") |
| 113 | } |
| 114 | # |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 115 | # Extract a CL number from the file containing the output of repo upload |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 116 | # |
| 117 | getcl() { |
| 118 | CL=$(grep -o "https://chrome-internal-review.googlesource.com/c/chromeos/$1/+/[0-9][0-9]*" "$2") |
| 119 | if [[ -z "${CL}" ]]; then |
| 120 | cat "$2" |
| 121 | abort CL number not found in repo upload output |
| 122 | fi |
| 123 | echo "${CL}" | grep -o "[0-9][0-9]*" |
| 124 | } |
| 125 | # |
| 126 | # If not on this branch, start a branch |
| 127 | # |
| 128 | branch() { |
| 129 | if ! (git branch --show-current | grep -q "${BRANCH}"); then |
| 130 | repo start "${BRANCH}" |
| 131 | else |
| 132 | echo "${BRANCH} already exists, skipping repo start" |
| 133 | fi |
| 134 | } |
| 135 | # |
Andrew McRae | a164ca6 | 2020-07-20 11:56:50 +1000 | [diff] [blame] | 136 | # return 'yes' or 'no' for boolean true or false |
Andrew McRae | d0aee43 | 2020-07-22 15:40:55 +1000 | [diff] [blame] | 137 | # |
Andrew McRae | a164ca6 | 2020-07-20 11:56:50 +1000 | [diff] [blame] | 138 | yes_no() { |
| 139 | if [[ "${1}" -eq "${FLAGS_FALSE}" ]]; then |
| 140 | echo -n "no" |
| 141 | else |
| 142 | echo -n "yes" |
| 143 | fi |
| 144 | } |
| 145 | # |
Andrew McRae | d0aee43 | 2020-07-22 15:40:55 +1000 | [diff] [blame] | 146 | # Normalise a comma or space separated argument or arguments to |
| 147 | # a single set of space separated arguments. |
| 148 | # |
| 149 | rd_list() { |
| 150 | local l=() |
| 151 | for arg in "$@"; do |
| 152 | IFS=', ' read -r -a la <<< "${arg}" |
| 153 | l+=("${la[@]}") |
| 154 | done |
| 155 | echo "${l[@]}" |
| 156 | } |
| 157 | # |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 158 | # Return true if repo has changes. |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 159 | # |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 160 | changed() { |
| 161 | [[ -n $(git status -s) ]] |
| 162 | } |
| 163 | # |
| 164 | # Add a Cq-Depend line to a commit. |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 165 | # |
| 166 | amend() { |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 167 | git log -1 --pretty=%B > "${TEMPDIR}/amend-msg" |
| 168 | sed -i "/^Change-Id/ i ${1}" "${TEMPDIR}/amend-msg" |
| 169 | git commit -q --amend -F "${TEMPDIR}/amend-msg" |
| 170 | } |
| 171 | # |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 172 | # Confirm that $1 is a valid project |
| 173 | # |
| 174 | check_project() { |
Andrew McRae | 802326f | 2020-07-23 13:48:16 +1000 | [diff] [blame] | 175 | PFILE="${GCLIENT_ROOT}/src/project/${FLAGS_board}/${1}/config.star" |
| 176 | if [[ ! -f "${PFILE}" ]]; then |
| 177 | die "${P} is not a valid project (${PFILE} missing)" |
| 178 | fi |
| 179 | # |
| 180 | # If the board's program.star is not being updated, check that the |
| 181 | # project has the right config lines to update. |
| 182 | # |
| 183 | if [[ "${FLAGS_program}" -eq "${FLAGS_FALSE}" ]]; then |
| 184 | if ! (has_major_version "${PFILE}") ;then |
| 185 | version_error "${PFILE} requires major_version" |
| 186 | fi |
| 187 | if [[ "${MINOR_VERSION}" -ne "0" ]] && ! (has_minor_version "${PFILE}"); then |
| 188 | version_error "${PFILE} requires minor_version" |
| 189 | fi |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 190 | fi |
| 191 | } |
| 192 | # |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 193 | # Return true if $1 is in list $2 |
| 194 | # |
| 195 | in_list() { |
| 196 | for S in ${2}; do |
| 197 | if [[ "$1" == "${S}" ]]; then |
| 198 | return 0 |
| 199 | fi |
| 200 | done |
| 201 | return 1 |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 202 | } |
| 203 | # |
Andrew McRae | 802326f | 2020-07-23 13:48:16 +1000 | [diff] [blame] | 204 | # Dump a message about the version expectations and quit. |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 205 | # |
Andrew McRae | 802326f | 2020-07-23 13:48:16 +1000 | [diff] [blame] | 206 | version_error() { |
| 207 | echo "ERROR: ${1}" |
| 208 | cat << EOF |
| 209 | |
| 210 | To correctly update the version, the config files must have existing version |
| 211 | configuration lines in them that the script can find and replace. |
| 212 | These lines are in the form of (e.g): |
| 213 | |
| 214 | ... |
| 215 | major_version = 12345, |
| 216 | minor_version = 10 |
| 217 | ... |
| 218 | |
| 219 | The regular expressions used to find and replace these configuration lines are |
| 220 | "/${ANY_MAJOR}/" and "/${ANY_MINOR}/". |
| 221 | The version configuration lines must match these regular expressions. |
| 222 | |
| 223 | These configuration lines may appear in the board's base program.star file, or in |
| 224 | the projects' config.star file. If the minor version is not 0, a 'minor_version' line |
| 225 | must exist in the files to be updated. |
| 226 | |
| 227 | If the board's program.star file is updated (the default --program option), then carefully |
| 228 | check that the inherited project configs are correct, especially if projects are skipped. |
| 229 | |
| 230 | If the --noprogram option is selected, then a config line of 'major_version' (and |
| 231 | 'minor_version' if the minor version is not 0) must exist in the project config.star files. |
| 232 | |
| 233 | Since the project's config is inherited from the board's program.star file, and can override |
| 234 | the version of the config, ensure that selectively updating either the program.star or |
| 235 | the project versions will not leave projects in an inconsistent state. |
| 236 | EOF |
| 237 | exit 1 |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 238 | } |
| 239 | # |
Andrew McRae | b46a336 | 2020-07-16 12:12:18 +1000 | [diff] [blame] | 240 | # Update the version in the file passed. |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 241 | # return 0 if version updated. |
| 242 | # return 1 if version not in file, or unchanged. |
| 243 | # |
| 244 | update_version() { |
Andrew McRae | b46a336 | 2020-07-16 12:12:18 +1000 | [diff] [blame] | 245 | # Check for major or minor version in file. |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 246 | if ! (has_version "${1}") ;then |
| 247 | return 1 |
| 248 | fi |
| 249 | local nf="${TEMPDIR}/new-${1}" |
Andrew McRae | b46a336 | 2020-07-16 12:12:18 +1000 | [diff] [blame] | 250 | sed -E "s/${ANY_MAJOR}/${NEW_MAJOR}/" "${1}" > "${nf}" |
| 251 | sed -i -E "s/${ANY_MINOR}/${NEW_MINOR}/" "${nf}" |
| 252 | if cmp -s "${1}" "${nf}"; then |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 253 | return 1 |
| 254 | fi |
| 255 | cp "${nf}" "${1}" |
| 256 | return 0 |
| 257 | } |
| 258 | # |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 259 | # Validate arguments |
| 260 | # |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 261 | if [[ -z "${FLAGS_board}" ]]; then |
| 262 | die "-b or --board required." |
| 263 | fi |
| 264 | if [[ -z "${FLAGS_release}" ]]; then |
| 265 | die "-r or --release required." |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 266 | fi |
| 267 | # |
| 268 | # Program must exist as a directory |
| 269 | # |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 270 | PROGDIR="${GCLIENT_ROOT}/src/program/${FLAGS_board}" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 271 | if [[ ! -d "${PROGDIR}" ]]; then |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 272 | die "${FLAGS_board} is not a valid program (${PROGDIR} missing)" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 273 | fi |
Andrew McRae | 802326f | 2020-07-23 13:48:16 +1000 | [diff] [blame] | 274 | PROGFILE="${PROGDIR}/program.star" |
Andrew McRae | b46a336 | 2020-07-16 12:12:18 +1000 | [diff] [blame] | 275 | # |
| 276 | # Validate release |
| 277 | # Major must be a 5 digit number |
| 278 | # Optional minor release must be a number. |
| 279 | # |
| 280 | if [[ "${FLAGS_release}" =~ ^${MAJOR_RE}$ ]]; then |
| 281 | MAJOR_VERSION=${FLAGS_release} |
| 282 | MINOR_VERSION="0" |
| 283 | elif [[ "${FLAGS_release}" =~ ^${MAJOR_RE}\.${MINOR_RE}$ ]]; then |
| 284 | MAJOR_VERSION=$(echo "${FLAGS_release}" | cut -d. -f1) |
| 285 | MINOR_VERSION=$(echo "${FLAGS_release}" | cut -d. -f2) |
| 286 | else |
| 287 | die "Unknown release format (must be NNNNN[.n])" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 288 | fi |
Andrew McRae | b46a336 | 2020-07-16 12:12:18 +1000 | [diff] [blame] | 289 | NEW_MAJOR="${MAJOR_PREFIX}${MAJOR_VERSION}" |
| 290 | NEW_MINOR="${MINOR_PREFIX}${MINOR_VERSION}" |
Andrew McRae | 802326f | 2020-07-23 13:48:16 +1000 | [diff] [blame] | 291 | # |
| 292 | # If updating the board config, check for program.star |
| 293 | # and for version strings. |
| 294 | # |
| 295 | if [[ "${FLAGS_program}" -eq "${FLAGS_TRUE}" ]]; then |
| 296 | if [[ ! -f "${PROGFILE}" ]]; then |
| 297 | die "${FLAGS_board} is not a valid program (${PROGFILE} missing)" |
| 298 | fi |
| 299 | if ! (has_major_version "${PROGFILE}") ;then |
| 300 | version_error "${PROGFILE} requires major_version" |
| 301 | fi |
| 302 | if [[ "${MINOR_VERSION}" -ne "0" ]] && ! (has_minor_version "${PROGFILE}"); then |
| 303 | version_error "${PROGFILE} requires minor_version" |
| 304 | fi |
| 305 | fi |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 306 | # Use a common git branch name. |
Andrew McRae | b46a336 | 2020-07-16 12:12:18 +1000 | [diff] [blame] | 307 | BRANCH="update_${FLAGS_board}_fw_${MAJOR_VERSION}_${MINOR_VERSION}" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 308 | # |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 309 | # Build the project list. |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 310 | # If no projects are specified, use all in the programs directory. |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 311 | # |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 312 | if [[ -z "${FLAGS_project}" ]]; then |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 313 | BDIR="${GCLIENT_ROOT}/src/project/${FLAGS_board}" |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 314 | cd "${BDIR}" |
| 315 | mapfile -t PROJLIST < <(ls) |
| 316 | else |
Andrew McRae | d0aee43 | 2020-07-22 15:40:55 +1000 | [diff] [blame] | 317 | read -r -a PROJLIST <<< "$(rd_list "${FLAGS_project}")" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 318 | fi |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 319 | # |
Andrew McRae | d0aee43 | 2020-07-22 15:40:55 +1000 | [diff] [blame] | 320 | # Get list of reviewers (if any) |
| 321 | # |
| 322 | read -r -a REVIEWERS <<< "$(rd_list "${FLAGS_reviewer}")" |
| 323 | # |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 324 | # Filter out the projects that are to be skipped. |
| 325 | # |
| 326 | if [[ -n "${FLAGS_skip}" ]]; then |
| 327 | PROJECTS=() |
Andrew McRae | d0aee43 | 2020-07-22 15:40:55 +1000 | [diff] [blame] | 328 | read -r -a SKIP_ARRAY <<< "$(rd_list "${FLAGS_skip}")" |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 329 | # Validate skipped projects |
| 330 | for S in "${SKIP_ARRAY[@]}"; do |
| 331 | check_project "${S}" |
| 332 | done |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 333 | SKIPPED="${SKIP_ARRAY[*]}" |
| 334 | for P in "${PROJLIST[@]}"; do |
| 335 | if ! (in_list "${P}" "${SKIPPED}"); then |
| 336 | PROJECTS+=("${P}") |
| 337 | fi |
| 338 | done |
| 339 | else |
| 340 | PROJECTS=("${PROJLIST[@]}") |
| 341 | fi |
| 342 | # |
Andrew McRae | d0aee43 | 2020-07-22 15:40:55 +1000 | [diff] [blame] | 343 | # Validate bug number (if any). |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 344 | # Must be of the form b:nnnnn or chromium:nnnnn |
| 345 | # |
| 346 | if [[ "${FLAGS_bug}" != "none" ]]; then |
| 347 | BG="b:[0-9]+|chromium:[0-9]+" |
| 348 | BGRE="^(${BG})(,(${BG}))*$" |
| 349 | if [[ ! "${FLAGS_bug}" =~ ${BGRE} ]]; then |
| 350 | echo "Bug must be of the form b:nnn or chromium:nnn" |
| 351 | die "A comma separated list is allowed" |
| 352 | fi |
| 353 | fi |
| 354 | # |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 355 | # Validate project list and file locations. |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 356 | # |
| 357 | for P in "${PROJECTS[@]}"; do |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 358 | check_project "${P}" |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 359 | done |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 360 | OVERLAY="${GCLIENT_ROOT}/src/private-overlays/overlay-${FLAGS_board}-private/chromeos-base/chromeos-firmware-${FLAGS_board}" |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 361 | # Validate project overlay and ebuild file |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 362 | EB9999="chromeos-firmware-${FLAGS_board}-9999.ebuild" |
| 363 | if [[ ! -f "${OVERLAY}/${EB9999}" ]]; then |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 364 | die "${OVERLAY}/${EB9999}: overlay error" |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 365 | fi |
| 366 | # Make sure dev/contrib is accessible |
| 367 | DEVCONTRIB="${GCLIENT_ROOT}/src/platform/dev/contrib" |
| 368 | if [[ ! -d "${DEVCONTRIB}" ]]; then |
| 369 | die "${DEVCONTRIB}: invalid directory" |
| 370 | fi |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 371 | # |
Andrew McRae | a164ca6 | 2020-07-20 11:56:50 +1000 | [diff] [blame] | 372 | # Display arguments. |
| 373 | # |
| 374 | echo "Invoked as:" |
| 375 | echo "${COMMAND} ${CMDARGS}" |
| 376 | echo "Program (board) to be updated: ${FLAGS_board}" |
| 377 | echo -n "Projects to be updated are: " |
| 378 | for PROJ in "${PROJECTS[@]}"; do |
| 379 | echo -n " ${PROJ}" |
| 380 | done |
| 381 | if [[ -n "${SKIPPED}" ]]; then |
| 382 | echo -n " (skipped:" |
| 383 | for S in "${SKIPPED[@]}"; do |
| 384 | echo -n " ${S}" |
| 385 | done |
| 386 | echo -n ")" |
| 387 | fi |
| 388 | echo |
| 389 | echo "Release number of upgrade: ${FLAGS_release}" |
| 390 | echo "Major version of release: ${MAJOR_VERSION}" |
| 391 | echo "Minor version of release: ${MINOR_VERSION}" |
| 392 | echo "BUG string used in commit: ${FLAGS_bug}" |
| 393 | echo "TEST string used in commit: ${FLAGS_test}" |
Andrew McRae | d0aee43 | 2020-07-22 15:40:55 +1000 | [diff] [blame] | 394 | echo "Reviewer(s) assigned to CLs: ${REVIEWERS[*]}" |
Andrew McRae | a164ca6 | 2020-07-20 11:56:50 +1000 | [diff] [blame] | 395 | echo "repo branch to be used is: ${BRANCH}" |
Andrew McRae | d0aee43 | 2020-07-22 15:40:55 +1000 | [diff] [blame] | 396 | echo "Update program.star version: $(yes_no "${FLAGS_program}")" |
| 397 | echo "Coreboot build enabled: $(yes_no "${FLAGS_build}")" |
| 398 | echo "Dry run requested: $(yes_no "${FLAGS_dryrun}")" |
| 399 | echo "Verify before proceeding: $(yes_no "${FLAGS_verify}")" |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 400 | # |
| 401 | if [[ "${FLAGS_dryrun}" -eq "${FLAGS_TRUE}" ]]; then |
Andrew McRae | a164ca6 | 2020-07-20 11:56:50 +1000 | [diff] [blame] | 402 | echo "Dry run requested, exiting" |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 403 | exit 0 |
| 404 | fi |
Andrew McRae | a164ca6 | 2020-07-20 11:56:50 +1000 | [diff] [blame] | 405 | read -p "Proceed with updating firmware (y/N)? " -r |
| 406 | if [[ ! "${REPLY}" =~ ^[Yy]$ ]]; then |
| 407 | die "Not verified, exiting..." |
| 408 | fi |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 409 | if [[ "${FLAGS_build}" -eq "${FLAGS_FALSE}" ]]; then |
| 410 | echo |
| 411 | echo "******************************************" |
| 412 | echo "* You have elected not to build coreboot *" |
| 413 | echo "* This assumes coreboot is already built *" |
| 414 | echo "******************************************" |
| 415 | echo |
| 416 | fi |
| 417 | # |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 418 | # Create a temp directory. |
| 419 | TEMPDIR=$(mktemp -d -t fw-XXXXXXXXXX) |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 420 | |
| 421 | trap "exit 1" HUP INT PIPE QUIT TERM |
| 422 | trap 'cleanup' EXIT |
| 423 | |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 424 | # |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 425 | # From now on, all errors should invoke 'abort' |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 426 | # so that the branches and CLs are cleaned up on exit. |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 427 | # |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 428 | # If required, update the firmware version in the program's program.star file |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 429 | # |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 430 | if [[ "${FLAGS_program}" -eq "${FLAGS_TRUE}" ]]; then |
| 431 | cd "${PROGDIR}" |
| 432 | echo "Updating program.star for board ${FLAGS_board}" |
| 433 | branch |
| 434 | if (update_version "program.star") ;then |
| 435 | # |
| 436 | # If config has changed, create a CL. |
| 437 | # |
| 438 | git add . |
| 439 | git commit -q -F - <<EOF |
| 440 | ${FLAGS_board}: Update program firmware to ${FLAGS_release} |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 441 | |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 442 | Autogenerated by: |
Andrew McRae | d0aee43 | 2020-07-22 15:40:55 +1000 | [diff] [blame] | 443 | $(echo "${COMMAND} ${CMDARGS}" | fold -s -w 70 | sed '2,$s/^/ /') |
Andrew McRae | 3b94aaf | 2020-06-25 15:28:18 +1000 | [diff] [blame] | 444 | |
| 445 | BUG=${FLAGS_bug} |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 446 | TEST=${FLAGS_test} |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 447 | EOF |
Rob Barnes | aafdcbd | 2020-07-21 07:42:37 -0600 | [diff] [blame] | 448 | if ! repo upload -y --verify "--ht=${BRANCH}" --cbr . > "${TEMPDIR}/upload.output" 2>&1 ;then |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 449 | cat "${TEMPDIR}/upload.output" |
| 450 | abort "repo upload failed" |
| 451 | fi |
| 452 | PROGRAM_CL=$(getcl "program/${FLAGS_board}" "${TEMPDIR}/upload.output") |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 453 | fi |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 454 | fi |
| 455 | # |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 456 | # Now walk through the projects and update the version (if present) |
| 457 | # and regenerate the configs. |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 458 | # Create and upload a CL and capture the CL number and project directory |
| 459 | # if the project has changed. |
| 460 | # |
| 461 | PROJ_CLS=() |
| 462 | PROJ_DIRS=() |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 463 | for PROJ in "${PROJECTS[@]}"; do |
| 464 | echo "Updating configs for project ${PROJ}" |
| 465 | PDIR="${GCLIENT_ROOT}/src/project/${FLAGS_board}/${PROJ}" |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 466 | cd "${PDIR}" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 467 | branch |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 468 | update_version "config.star" || true |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 469 | ./config.star || abort "Generate config failed for ${PROJ}" |
| 470 | check_config > "${TEMPDIR}/check_config-${PROJ}.output" || abort "check_config failed for ${PROJ}" |
| 471 | # |
| 472 | # Check if any files changed. |
| 473 | # |
| 474 | if changed; then |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 475 | echo "Creating CL for changes to project ${PROJ}" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 476 | git add . |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 477 | git commit -q -F - <<EOF |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 478 | ${PROJ}: Update firmware to ${FLAGS_release} |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 479 | |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 480 | Autogenerated by: |
| 481 | ${COMMAND} ${CMDARGS} |
Andrew McRae | 3b94aaf | 2020-06-25 15:28:18 +1000 | [diff] [blame] | 482 | |
| 483 | BUG=${FLAGS_bug} |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 484 | TEST=${FLAGS_test} |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 485 | EOF |
Rob Barnes | aafdcbd | 2020-07-21 07:42:37 -0600 | [diff] [blame] | 486 | if ! repo upload -y --verify "--ht=${BRANCH}" --cbr . > "${TEMPDIR}/upload.${PROJ}.output" 2>&1 ;then |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 487 | cat "${TEMPDIR}/upload.${PROJ}.output" |
| 488 | abort "repo upload failed" |
| 489 | fi |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 490 | P_CL=$(getcl "project/${FLAGS_board}/${PROJ}" "${TEMPDIR}/upload.${PROJ}.output") |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 491 | PROJ_CLS+=("${P_CL}") |
| 492 | PROJ_DIRS+=("${PDIR}") |
| 493 | fi |
| 494 | done |
| 495 | # |
| 496 | # Create a Cq-Depend line with all the project CLs |
| 497 | # |
| 498 | if [[ -n "${PROJ_CLS[*]}" ]];then |
| 499 | SEP=" " |
| 500 | PROG_CQD="Cq-Depend:" |
| 501 | for CL in "${PROJ_CLS[@]}"; do |
| 502 | PROG_CQD="${PROG_CQD}${SEP}chrome-internal:${CL}" |
| 503 | SEP=", " |
| 504 | done |
| 505 | # |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 506 | # If a program CL exists, add the Cq-Depend line to it. |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 507 | # |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 508 | if [[ -n "${PROGRAM_CL}" ]]; then |
| 509 | cd "${PROGDIR}" |
| 510 | amend "${PROG_CQD}" |
Rob Barnes | aafdcbd | 2020-07-21 07:42:37 -0600 | [diff] [blame] | 511 | if ! repo upload -y --verify "--ht=${BRANCH}" --cbr . > "${TEMPDIR}/upload.amend.output" 2>&1 ;then |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 512 | cat "${TEMPDIR}/upload.amend.output" |
| 513 | abort "repo upload failed" |
| 514 | fi |
| 515 | fi |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 516 | fi |
| 517 | # |
| 518 | # All the boxster configs have been uploaded. |
| 519 | # Now run the update script and update the firmware manifest. |
| 520 | # |
| 521 | # Build base coreboot files |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 522 | # |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 523 | if [[ "${FLAGS_build}" -eq "${FLAGS_TRUE}" ]]; then |
| 524 | echo "Running coreboot build. This may take a while..." |
| 525 | # |
| 526 | # Attempt to customise the coreboot build depending on the platform. |
| 527 | # |
| 528 | case "${FLAGS_board}" in |
| 529 | "zork") |
| 530 | PACKAGES=(coreboot-zork chromeos-bootimage) |
| 531 | ;; |
| 532 | "puff") |
| 533 | PACKAGES=(chromeos-ec coreboot depthcharge vboot_reference libpayload chromeos-bootimage coreboot-private-files intel-cmlfsp coreboot-private-files-puff) |
| 534 | ;; |
| 535 | *) |
| 536 | # Use general packages |
| 537 | echo "Taking a guess at coreboot packages for ${FLAGS_board}" |
| 538 | echo "If the coreboot build fails, this script may have to be customized for this board" |
| 539 | PACKAGES=(coreboot depthcharge vboot_reference libpayload chromeos-bootimage) |
| 540 | ;; |
| 541 | esac |
Andrew McRae | 9463964 | 2020-07-14 17:14:04 +1000 | [diff] [blame] | 542 | if ! ("emerge-${FLAGS_board}" -j --quiet-build "${PACKAGES[@]}"); then |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 543 | abort "coreboot build failed!" |
| 544 | fi |
| 545 | echo "coreboot build successful" |
| 546 | else |
| 547 | echo "Coreboot build not attempted" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 548 | fi |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 549 | EB9999="chromeos-firmware-${FLAGS_board}-9999.ebuild" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 550 | # |
| 551 | # Remove any previous attempts to build the firmware. |
| 552 | # |
Andrew McRae | c603912 | 2020-07-30 15:03:05 +1000 | [diff] [blame] | 553 | "cros-workon-${FLAGS_board}" stop "chromeos-base/chromeos-firmware-${FLAGS_board}" |
| 554 | "cros-workon-${FLAGS_board}" stop "chromeos-base/chromeos-config-bsp-${FLAGS_board}-private" |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 555 | cd "${OVERLAY}" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 556 | branch |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 557 | cd "${DEVCONTRIB}" |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 558 | if ! (./cros_update_firmware -q "--board=${FLAGS_board}"); then |
| 559 | abort "cros_update_firmware failed for ${FLAGS_board}" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 560 | fi |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 561 | cd "${OVERLAY}" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 562 | # |
| 563 | # If files have been updated, then create a CL for the changes. |
| 564 | # |
| 565 | OVERLAY_CL="" |
| 566 | if changed; then |
| 567 | # |
| 568 | # Bump the version in the ebuild file. Relies on the format |
| 569 | # of the version so that the last number is at the end of the line. |
| 570 | # |
| 571 | CURVERS=$(grep "VERSION=REVBUMP" "${EB9999}" | grep -o "[0-9][0-9]*$") |
| 572 | NEXTVERS=$((CURVERS + 1)) |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 573 | sed -i "/VERSION=REVBUMP/s/${CURVERS}$/${NEXTVERS}/" "${EB9999}" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 574 | git add . |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 575 | git commit -q -F - <<EOF |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 576 | ${FLAGS_board}: Update firmware to ${FLAGS_release} |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 577 | |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 578 | Autogenerated by: |
| 579 | ${COMMAND} ${CMDARGS} |
Andrew McRae | 3b94aaf | 2020-06-25 15:28:18 +1000 | [diff] [blame] | 580 | |
| 581 | BUG=${FLAGS_bug} |
Andrew McRae | 88eda24 | 2020-06-26 12:35:55 +1000 | [diff] [blame] | 582 | TEST=${FLAGS_test} |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 583 | |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 584 | ${PROG_CQD} |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 585 | EOF |
| 586 | # |
| 587 | # Upload with no-verify since the file lines are too long. |
| 588 | # |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 589 | if ! repo upload "--ht=${BRANCH}" -y --no-verify --cbr . > "${TEMPDIR}/overlay.output" 2>&1 ;then |
| 590 | cat "${TEMPDIR}/overlay.output" |
| 591 | abort "repo upload failed" |
| 592 | fi |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 593 | OVERLAY_CL=$(getcl "overlays/overlay-${FLAGS_board}-private" "${TEMPDIR}/overlay.output") |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 594 | # |
| 595 | # Go back and amend all the project commit messages with a Cq-Depend on |
| 596 | # the program and overlay CLs. |
| 597 | # |
| 598 | CQD="Cq-Depend: chrome-internal:${OVERLAY_CL}" |
| 599 | if [[ -n "${PROGRAM_CL}" ]]; then |
| 600 | CQD="${CQD}, chrome-internal:${PROGRAM_CL}" |
| 601 | fi |
| 602 | for DIR in "${PROJ_DIRS[@]}"; do |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 603 | cd "${DIR}" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 604 | amend "${CQD}" |
Rob Barnes | aafdcbd | 2020-07-21 07:42:37 -0600 | [diff] [blame] | 605 | if ! repo upload -y --verify --cbr . > "${TEMPDIR}/cqd.output" 2>&1 ;then |
Andrew McRae | f96cd60 | 2020-06-23 23:06:19 +1000 | [diff] [blame] | 606 | cat "${TEMPDIR}/cqd.output" |
| 607 | abort "repo upload failed" |
| 608 | fi |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 609 | done |
| 610 | fi |
| 611 | # |
| 612 | # Send all of the CLs to the CQ for a dry run. |
| 613 | # |
| 614 | ALL_CLS=$(gerrit -i --raw search "owner:me status:open hashtag:${BRANCH}") |
| 615 | if [[ -z "${ALL_CLS}" ]]; then |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 616 | echo "No changes required for program ${FLAGS_board}" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 617 | repo abandon "${BRANCH}" |
| 618 | exit 0 |
| 619 | fi |
| 620 | for cl in ${ALL_CLS}; do |
| 621 | gerrit -i label-cq "${cl}" 1 |
| 622 | gerrit -i label-v "${cl}" 1 |
| 623 | gerrit -i label-as "${cl}" 1 |
| 624 | done |
| 625 | # |
| 626 | # If reviewer is set, then add them to the CLs |
| 627 | # |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 628 | if [[ -n "${FLAGS_reviewer}" ]]; then |
Andrew McRae | d0aee43 | 2020-07-22 15:40:55 +1000 | [diff] [blame] | 629 | echo "Sending CLs ${ALL_CLS} to ${REVIEWERS[*]} for review" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 630 | for cl in ${ALL_CLS}; do |
Andrew McRae | d0aee43 | 2020-07-22 15:40:55 +1000 | [diff] [blame] | 631 | gerrit -i reviewers "${cl}" "${REVIEWERS[@]}" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 632 | done |
| 633 | else |
| 634 | echo "Send CLs for review by running:" |
| 635 | echo " for cl in ${ALL_CLS}; do gerrit -i reviewers \$cl <reviewer>; done" |
| 636 | fi |
| 637 | # |
| 638 | # Final instructions. |
| 639 | # |
| 640 | echo "Run:" |
Andrew McRae | 7c9655c | 2020-06-22 15:09:54 +1000 | [diff] [blame] | 641 | echo " /build/${FLAGS_board}/usr/sbin/chromeos-firmwareupdate --manifest" |
Andrew McRae | 0809eb5 | 2020-06-18 00:13:36 +1000 | [diff] [blame] | 642 | echo "to verify firmware update" |
| 643 | echo "When submitted, cleanup by running:" |
| 644 | echo "repo abandon ${BRANCH}" |