summaryrefslogtreecommitdiff
path: root/storage/tokudb/scripts/tokutek.make.mysql.bash
blob: 1b0526d432d0d0f67990ce4f647d1364f699d83a (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash

function usage() {
    echo "make mysql and copy the tarballs to an amazon s3 bucket"
    return 1
}

# copy build files to amazon s3
function copy_to_s3() {
    local s3_build_bucket=$1; local s3_release_bucket=$2
    local ts=$(date +%s)
    local ymd=$(date +%Y%m%d -d @$ts)
    local ym=$(date +%Y%m -d @$ts)
    local exitcode=0; local r=0
    for f in $(find . -maxdepth 1 \( -name '*.tar.gz*' -o -name '*.rpm*' \) ) ; do
        f=$(basename $f)
        echo `date` s3put $s3_build_bucket $f
        s3put $s3_build_bucket $f $f
        r=$?
        # index the file by date
        echo `date` s3put $s3_build_bucket $f $r
        if [ $r != 0 ] ; then exitcode=1; fi
        s3put $s3_build_bucket-date $ymd/$f /dev/null
        r=$?
        echo `date` s3put $s3_build_bucket-date $ymd/$f $r
        if [ $r != 0 ] ; then exitcode=1; fi
        # copy to partition by date
        s3mkbucket $s3_build_bucket-$ym
        s3copykey $s3_build_bucket-$ym $f $s3_build_bucket $f
    done
    if [[ $git_tag =~ tokudb-.* ]] ; then
        s3mkbucket $s3_release_bucket-$git_tag
        if [ $r != 0 ] ; then 
            exitcode=1
        else
            for f in $(find . -maxdepth 1 \( -name '*.tar.gz*' -o -name '*.rpm*' \) ) ; do
                f=$(basename $f)
                echo `date` s3copykey $s3_release_bucket-$git_tag $f
                s3copykey $s3_release_bucket-$git_tag $f $s3_build_bucket $f
                r=$?
                echo `date` s3copykey $s3_release_bucket-$git_tag $f $r
                if [ $r != 0 ] ; then exitcode=1; fi
            done
        fi
    fi
    test $exitcode = 0
}

mysqlbuild=
s3=1
s3_build_bucket=tokutek-mysql-build
s3_release_bucket=tokutek-mysql
system=$(uname -s | tr '[:upper:]' '[:lower:]')
arch=$(uname -m | tr '[:upper:]' '[:lower:]')

pushd $(dirname $0)
source ./common.sh
popd

exitcode=0
make_args=
while [ $# -gt 0 ] ; do
    arg=$1; shift
    if [[ $arg =~ --(s3.*)=(.*) ]] ; then
        eval ${BASH_REMATCH[1]}=${BASH_REMATCH[2]}
    elif [[ $arg =~ --(.*)=(.*) ]] ; then
        eval ${BASH_REMATCH[1]}=${BASH_REMATCH[2]}
        make_args="$make_args $arg"
    else
        usage; exit 1
    fi   
done

if [ -z $mysqlbuild ] ; then exit 1; fi

# parse the mysqlbuild string
parse_mysqlbuild $mysqlbuild
if [ $? != 0 ] ; then exit 1; fi

# make the build dir
build_dir=build-tokudb-$tokudb_version
if [ -d builds ] ; then build_dir=builds/$build_dir; fi
if [ ! -d $build_dir ] ; then mkdir $build_dir; fi
pushd $build_dir
if [ $? != 0 ] ; then exit 1; fi

# make mysql
bash -x $HOME/github/ft-engine/scripts/make.mysql.bash $make_args
if [ $? != 0 ] ; then exitcode=1; fi

# generate md5 sums
for f in $(find $mysql_distro/build.* -maxdepth 1 \( -name '*.tar.gz' -o -name '*.rpm' \) ) ; do
    newf=$(basename $f)
    ln $f $newf
    if [ $? != 0 ] ; then exitcode=1; fi
    md5sum $newf >$newf.md5
    if [ $? != 0 ] ; then exitcode=1; fi
done

# copy to s3
if [ $s3 != 0 ] ; then
    copy_to_s3 $s3_build_bucket $s3_release_bucket
    if [ $? != 0 ] ; then exitcode=1; fi
fi

popd

exit $exitcode