Mike Frysinger | 6627cf6 | 2018-08-16 15:09:04 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2016 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 | |
| 6 | # Loads script libraries. |
| 7 | CONTRIB_DIR=$(dirname "$(readlink -f "$0")") |
| 8 | . "${CONTRIB_DIR}/common.sh" || exit 1 |
| 9 | |
| 10 | usage() { |
| 11 | cat >&2 <<EOF |
| 12 | Use: |
| 13 | update_aosp.sh [all] [<add_targets> ...] [~<remove_targets> ...] |
| 14 | |
| 15 | Arguments: |
| 16 | all: Include all the AOSP targets from chromeos-base/* |
| 17 | <add_target>: Include the given package name in the uprev, such as |
| 18 | "chromeos-base/libbrillo". |
| 19 | ~<remove_target>: Filter out from the list of targets the given package name. |
| 20 | This is useful in combination with "all". |
| 21 | |
| 22 | Example: |
| 23 | ./update_aosp.sh all ~chromeos-base/webserver brillo-base/libsparse |
| 24 | EOF |
| 25 | } |
| 26 | |
| 27 | # Script must run inside the chroot. |
| 28 | assert_inside_chroot |
| 29 | |
| 30 | OVERLAY="${SRC_ROOT}/third_party/chromiumos-overlay" |
| 31 | cd "${OVERLAY}" || \ |
| 32 | die "Need to run inside the chroot." |
| 33 | |
| 34 | REPOS=() |
| 35 | |
| 36 | for arg in "$@"; do |
| 37 | case "${arg}" in |
| 38 | "all") |
| 39 | for f in chromeos-base/*/*9999.ebuild; do |
| 40 | if grep '^CROS_WORKON_BLACKLIST=1$' "$f" >/dev/null && \ |
| 41 | grep '^CROS_WORKON_REPO.*android.googlesource.com' "$f" >/dev/null; then |
| 42 | REPOS+=($(dirname $f)) |
| 43 | fi |
| 44 | done |
| 45 | ;; |
| 46 | "~"*) |
| 47 | FILTERED=() |
| 48 | for repo in "${REPOS[@]}"; do |
| 49 | if [[ "~${repo}" != "${arg}" ]]; then |
| 50 | FILTERED+=( "${repo}" ) |
| 51 | fi |
| 52 | done |
| 53 | REPOS=( "${FILTERED[@]}" ) |
| 54 | ;; |
| 55 | ue) |
| 56 | REPOS+=( |
| 57 | "chromeos-base/update_engine" |
| 58 | "chromeos-base/update_engine-client" |
| 59 | ) |
| 60 | ;; |
| 61 | "-"*) |
| 62 | echo "Unknown option ${arg}" >&2 |
| 63 | usage |
| 64 | exit 1 |
| 65 | ;; |
| 66 | *) |
| 67 | REPOS+=( "${arg}" ) |
| 68 | esac |
| 69 | done |
| 70 | |
| 71 | if [[ "${#REPOS[@]}" == 0 ]]; then |
| 72 | usage |
| 73 | exit 1 |
| 74 | fi |
| 75 | |
| 76 | # Sort the repo to be more consistent. |
| 77 | REPOS=( $(echo "${REPOS[@]}" | tr ' ' '\n' | sort) ) |
| 78 | echo "Will uprev the following ${#REPOS[@]} repos:" |
| 79 | for repo in "${REPOS[@]}"; do |
| 80 | echo " * ${repo}" |
| 81 | done |
| 82 | |
| 83 | ### Do the actual work now ### |
| 84 | git diff-files || \ |
| 85 | die "There are uncommited changes in chromiumos-overlay" |
| 86 | |
| 87 | repos_str=$(echo "${REPOS[@]}" | tr ' ' ':') |
| 88 | set -x |
| 89 | |
| 90 | git checkout -f cros/master |
| 91 | git branch -D stabilizing_branch 2>/dev/null |
| 92 | cros_mark_as_stable commit -p "${repos_str}" --force --list-changes 100 || \ |
| 93 | die "cros_mark_as_stable failed" |
| 94 | |
| 95 | git show --find-copies-harder HEAD |
| 96 | |
| 97 | echo "New stabilizing_branch ready. Amend message and upload." |