1#!/bin/bash 2# 3# Copyright 2017 The Android Open Source Project. 4# 5# Retrieves the current Dexmaker to source code into the current directory, excluding portions related 6# to mockito's internal build system and javadoc. 7 8# Force stop on first error. 9set -e 10 11if [ $# -ne 1 ]; then 12 echo "$0 <version>" >&2 13 exit 1; 14fi 15 16if [ -z "$ANDROID_BUILD_TOP" ]; then 17 echo "Missing environment variables. Did you run build/envsetup.sh and lunch?" >&2 18 exit 1 19fi 20 21VERSION=${1} 22 23SOURCE="https://github.com/linkedin/dexmaker" 24INCLUDE=" 25 LICENSE 26 27 dexmaker 28 dexmaker-mockito 29 dexmaker-mockito-inline 30 dexmaker-mockito-inline-extended 31 32 dexmaker-mockito-inline-dispatcher 33 34 dexmaker-tests 35 dexmaker-mockito-tests 36 dexmaker-mockito-inline-tests 37 dexmaker-mockito-inline-extended-tests 38 " 39 40EXCLUDE=" 41 " 42 43working_dir="$(mktemp -d)" 44trap "echo \"Removing temporary directory\"; rm -rf $working_dir" EXIT 45 46echo "Fetching Dexmaker source into $working_dir" 47git clone $SOURCE $working_dir/source 48ORG_DIR=$(pwd) 49cd $working_dir/source 50git checkout $VERSION 51SHA=$(git rev-parse $VERSION) 52cd $ORG_DIR 53 54for include in ${INCLUDE}; do 55 echo "Updating $include" 56 rm -rf $include 57 mkdir -p $(dirname $include) 58 cp -R $working_dir/source/$include $include 59done; 60 61for exclude in ${EXCLUDE}; do 62 echo "Excluding $exclude" 63 rm -r $exclude 64done; 65 66# Remove 3rd party code 67rm -r dexmaker-mockito-inline/external 68 69echo "Updating README.version" 70 71# Update the version. 72perl -pi -e "s|^Version: .*$|Version: ${VERSION} (${SHA})|" "README.version" 73 74# Remove any documentation about local modifications. 75mv README.version README.tmp 76grep -B 100 "Local Modifications" README.tmp > README.version 77echo " None" >> README.version 78rm README.tmp 79 80echo "Done" 81