blob: 891480099ceaf2da5c654e9a038e6708fb763486 [file] [log] [blame]
Mike Frysinger6627cf62018-08-16 15:09:04 -04001#!/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.
7CONTRIB_DIR=$(dirname "$(readlink -f "$0")")
8. "${CONTRIB_DIR}/common.sh" || exit 1
9
10usage() {
11 cat >&2 <<EOF
12Use:
13 update_aosp.sh [all] [<add_targets> ...] [~<remove_targets> ...]
14
15Arguments:
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
22Example:
23 ./update_aosp.sh all ~chromeos-base/webserver brillo-base/libsparse
24EOF
25}
26
27# Script must run inside the chroot.
28assert_inside_chroot
29
30OVERLAY="${SRC_ROOT}/third_party/chromiumos-overlay"
31cd "${OVERLAY}" || \
32 die "Need to run inside the chroot."
33
34REPOS=()
35
36for 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
69done
70
71if [[ "${#REPOS[@]}" == 0 ]]; then
72 usage
73 exit 1
74fi
75
76# Sort the repo to be more consistent.
77REPOS=( $(echo "${REPOS[@]}" | tr ' ' '\n' | sort) )
78echo "Will uprev the following ${#REPOS[@]} repos:"
79for repo in "${REPOS[@]}"; do
80 echo " * ${repo}"
81done
82
83### Do the actual work now ###
84git diff-files || \
85 die "There are uncommited changes in chromiumos-overlay"
86
87repos_str=$(echo "${REPOS[@]}" | tr ' ' ':')
88set -x
89
90git checkout -f cros/master
91git branch -D stabilizing_branch 2>/dev/null
92cros_mark_as_stable commit -p "${repos_str}" --force --list-changes 100 || \
93 die "cros_mark_as_stable failed"
94
95git show --find-copies-harder HEAD
96
97echo "New stabilizing_branch ready. Amend message and upload."