summaryrefslogtreecommitdiff
path: root/build-aux/couchdb-build-release.sh
blob: 2d219e5e418daf72d7f22fd7eb8398ab71270576 (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
#!/bin/sh -e

VERSION=$1

if [ -z "$VERSION" ]; then
  echo "NO VERSION"
  exit 1
fi

echo "Building Apache CouchDB $VERSION"

RELDIR=apache-couchdb-$VERSION
# make release dir
rm -rf $RELDIR
mkdir $RELDIR

CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`

# copy sources over
git archive $CURRENT_BRANCH | tar -xC $RELDIR/ -f -
cd src/

for repo in *; do
  cd $repo
  if [ -d ".git" ]; then
    mkdir -p ../../$RELDIR/src/$repo
    git_ish=`git rev-parse --short HEAD`
    git archive $git_ish | tar --exclude '*do_not_compile.erl' -xC ../../$RELDIR/src/$repo/ -f -
  fi
  set +e
  grep -rl '{vsn, git}' ../../$RELDIR/src/$repo/ | xargs sed -ie "s/{vsn, git}/{vsn, \"`git describe --always --tags`\"}/" 2> /dev/null
  set -e
  cd ..
done

cd ..


if test -e .git; then
    # save git sha in version.mk
    git_sha=`git rev-parse --short HEAD`
    echo "git_sha=$git_sha" >> $RELDIR/version.mk
    # create CONTRIBUTORS file
    OS=`uname -s`
    case "$OS" in
    Linux|CYGWIN*) # GNU sed
        SED_ERE_FLAG=-r
    ;;
    *) # BSD sed
        SED_ERE_FLAG=-E
    ;;
    esac

    sed -e "/^#.*/d" CONTRIBUTORS.in > $RELDIR/CONTRIBUTORS
    CONTRIB_EMAIL_SED_COMMAND="s/^[[:blank:]]{5}[[:digit:]]+[[:blank:]]/ * /"
    git shortlog -se 6c976bd..HEAD \
        | grep -v @apache.org \
        | sed $SED_ERE_FLAG -e "$CONTRIB_EMAIL_SED_COMMAND" >> $RELDIR/CONTRIBUTORS
    echo "" >> $RELDIR/CONTRIBUTORS # simplest portable newline
    echo "For a list of authors see the \`AUTHORS\` file." >> $RELDIR/CONTRIBUTORS
fi

# copy our rebar
cp bin/rebar $RELDIR/bin/rebar