aboutsummaryrefslogtreecommitdiff
path: root/update_source.sh
blob: fc0c0533687798a1c1a3d9b8adbc000892bf8c69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
#
# Copyright 2017 The Android Open Source Project.
#
# Retrieves the current Dexmaker to source code into the current directory, excluding portions related
# to mockito's internal build system and javadoc.

# Force stop on first error.
set -e

if [ $# -ne 1 ]; then
    echo "$0 <version>" >&2
    exit 1;
fi

if [ -z "$ANDROID_BUILD_TOP" ]; then
    echo "Missing environment variables. Did you run build/envsetup.sh and lunch?" >&2
    exit 1
fi

VERSION=${1}

SOURCE="https://github.com/linkedin/dexmaker"
INCLUDE="
    LICENSE

    dexmaker
    dexmaker-mockito
    dexmaker-mockito-inline
    dexmaker-mockito-inline-extended

    dexmaker-mockito-inline-dispatcher

    dexmaker-tests
    dexmaker-mockito-tests
    dexmaker-mockito-inline-tests
    dexmaker-mockito-inline-extended-tests
    "

EXCLUDE="
    "

working_dir="$(mktemp -d)"
trap "echo \"Removing temporary directory\"; rm -rf $working_dir" EXIT

echo "Fetching Dexmaker source into $working_dir"
git clone $SOURCE $working_dir/source
ORG_DIR=$(pwd)
cd $working_dir/source
git checkout $VERSION
SHA=$(git rev-parse $VERSION)
cd $ORG_DIR

for include in ${INCLUDE}; do
  echo "Updating $include"
  rm -rf $include
  mkdir -p $(dirname $include)
  cp -R $working_dir/source/$include $include
done;

for exclude in ${EXCLUDE}; do
  echo "Excluding $exclude"
  rm -r $exclude
done;

# Remove 3rd party code
rm -r dexmaker-mockito-inline/external

echo "Updating README.version"

# Update the version.
perl -pi -e "s|^Version: .*$|Version: ${VERSION} (${SHA})|" "README.version"

# Remove any documentation about local modifications.
mv README.version README.tmp
grep -B 100 "Local Modifications" README.tmp > README.version
echo "        None" >> README.version
rm README.tmp

echo "Done"