1#!/bin/bash 2 3set -ex 4 5function usage() { echo "$0 [-s][-b] <bug number>" && exit 1; } 6 7sync="" 8branch="" 9while getopts 'sb' FLAG; do 10 case ${FLAG} in 11 s) 12 sync="sync" 13 ;; 14 b) 15 branch="branch" 16 ;; 17 ?) 18 echo "unknown flag." 19 usage 20 ;; 21 esac 22done 23 24shift $((OPTIND-1)) 25if [ $# != 1 ]; then 26 echo "Requires exactly 1 positional argument (bug number)." 27 usage 28fi 29bug_number="$1" 30 31if [ "$sync" = "sync" ] 32then 33 read -p "This script will sync your crosvm project. Do you wish to proceed? [y/N]" -n 1 -r 34 if [[ ! $REPLY =~ ^[Yy]$ ]] 35 then 36 exit 1; 37 fi 38fi 39 40if [ -z $ANDROID_BUILD_TOP ]; then echo "forgot to source build/envsetup.sh?" && exit 1; fi 41cd $ANDROID_BUILD_TOP/external/crosvm 42 43if [[ ! -z $(git branch --list merge) && ! "$branch" = "branch" ]]; 44 then 45 echo "branch merge already exists. Forgot to clean up?" && exit 1; 46fi 47 48# needed in 'install-deps', but timeout is too tight still sometimes 49sudo echo Sudo prepared. 50 51rustup update 52 53# TODO: sometimes we want to sync the entire tree, and sometimes we only 54# want to fetch upstream. Should we have independent options? 55if [ "$sync" = "sync" ] 56then 57 repo sync -c -j96 58 git fetch aosp upstream-main 59fi 60 61source $ANDROID_BUILD_TOP/build/envsetup.sh 62m blueprint_tools cargo_embargo crosvm 63 64if [ ! "$branch" = "branch" ]; 65 then 66 repo start merge; 67fi 68 69git merge --log aosp/upstream-main --no-edit 70OLD_MSG=$(git log --format=%B -n1) 71git commit --amend -m "$OLD_MSG 72Bug: $bug_number 73Test: TH" 74 75$ANDROID_BUILD_TOP/external/crosvm/tools/deps/install-x86_64-other 76$ANDROID_BUILD_TOP/external/crosvm/android-fork-stats.sh 77 78# continue if the merge was clean 79./android-merge-2-cargo-embargo.sh 80 81git commit --amend -a --no-edit 82 83# TODO: add more automated local tests/run host tests? 84m crosvm 85 86repo upload . $(cat OWNERS.android | grep @google | sed 's/^/--re=/') 87