summaryrefslogtreecommitdiff
path: root/buildscripts/update-vendor-wiredtiger
blob: b6afe920de3602caa5e5e0cdbd6579fea20f179b (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
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
#
# Updates src/third_party/wiredtiger contents
# from github.com/wiredtiger/wiredtiger branch "mongodb-3.2" or the first argument passed
#

set -o errexit

REMOTEBRANCH="${1:-develop}"
LOCALBRANCH=$(git symbolic-ref HEAD)

# Ensure working directory is TOPLEVEL/src/third_party
STARTPWD=$(pwd)
TOPLEVEL=$(git rev-parse --show-toplevel)
cd ${TOPLEVEL}/src/third_party

# Write file according to "Content-Disposition: attachment" header. Example:
# Content-Disposition: attachment; filename=wiredtiger-wiredtiger-2.4.0-109-ge5aec44.tar.gz

rm -f wiredtiger-wiredtiger-*.tar.gz
curl -OJL https://api.github.com/repos/wiredtiger/wiredtiger/tarball/${REMOTEBRANCH}

TARBALL=$(echo wiredtiger-wiredtiger-*.tar.gz)
test -f "$TARBALL"

# Delete everything in wiredtiger dir, then selectively undelete

mkdir -p wiredtiger
(cd wiredtiger;
 rm -rf *;
 git checkout -- .gitignore 'SCons*';
 git checkout -- 'build_*/wiredtiger_config.h')

# Tar options:
# - Exclude subdirs "api", "test", "src/docs"
# - Strip 'wiredtiger-wiredtiger-e5aec44/' prefix after exclude applied
# - Change to dir "wiredtiger" before extracting

tar -x --strip-components 1 \
    --exclude '*/api' --exclude '*/dist/package' --exclude '*/examples' \
    --exclude '*/src/docs' --exclude '*/test' \
    --exclude '*/tools/wtperf_stats' \
    --exclude '*/tools/wtstats/template' \
    -C wiredtiger -f ${TARBALL}

# Add wiredtiger as a remote called 'wt'; ignore errors if it already
# exists -- fetch will catch any problems
echo "Fetching latest wiredtiger code; this may take a while..."
git remote add wt git@github.com:wiredtiger/wiredtiger.git > /dev/null 2>&1 || true
git fetch wt

# Build a changelog for the revision history
# - get the githash for this drop from the tarball name
newhash="`echo $TARBALL | sed -e 's/.*-g\([0-9a-f]*\)\..*/\1/'`"
[ -z "$newhash" ] && echo "Can't find hash for this drop" && exit 1

# - find the githash from the previous drop from the summary
oldhash="`git log --format=%s | grep 'Import wiredtiger' | head -n 1 | sed -e's/.*-g\([0-9a-f]*\)\..*/\1/g'`"
[ -z "$oldhash" ] && echo "Can't find hash for previous drop" && exit 1

# - build the changelog; unfortunately the format is branch-dependant
case ${REMOTEBRANCH} in
    "mongodb-3.0") format="--format=\"%h  %s\"" ;;
    "mongodb-3.2") format="--grep=\"Merge pull\" --format=\"%h  %b\"" ;;
    *) echo "${REMOTEBRANCH} is not supported; bailing out" ; exit 1 ;;
esac
gitlog="git log $format ${oldhash}..${newhash} wt/${REMOTEBRANCH}"
changelog="`eval $gitlog`"

echo
git add wiredtiger
git commit -m "Import ${TARBALL} from wiredtiger branch ${REMOTEBRANCH}" \
 -m "ref: ${oldhash}..${newhash}" \
 -m "$changelog"
echo
git log -n 1

set -o errexit
cd $STARTPWD
echo "
Done applying $TARBALL to $LOCALBRANCH.
The revision history was computed as follows:

  $gitlog

Please review it before you push. You can edit it with:

  git commit --amend

"