aboutsummaryrefslogtreecommitdiffstats
path: root/build-aux/travis-deploy.sh
blob: a959ccbec3e2e4c0cc5d6bca330d0f1e03545bba (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
#!/bin/bash

set -e

if [[ "x${TARGET}" != xw* ]] && [[ "x${TARGET}" != xdist* ]]; then
    echo "Nothing to deploy."
    exit 0
fi

if [[ ! -d build ]]; then
    echo "Build directory not found."
    exit 1
fi

if [[ "x${TARGET}" = xw* ]]; then
    FILES=( build/*.zip )
elif [[ "x${TARGET}" = "xdist-srpm" ]]; then
    FILES=( build/*.src.rpm )
else
    FILES=( build/*.{*.tar.{gz,bz2,xz},zip} )
fi

TARNAME="$(grep PACKAGE_TARNAME build/config.h | cut -d\" -f2)"
VERSION="$(grep PACKAGE_VERSION build/config.h | cut -d\" -f2)"

do_curl() {
    curl \
        --ftp-create-dirs \
        --upload-file "${1}" \
        --user "${FTP_USER}:${FTP_PASSWORD}" \
        "ftp://${FTP_HOST}/public_html/${TARNAME}/${TARNAME}-${VERSION}/$(basename ${1})"
}

echo " * Found files:"
for f in "${FILES[@]}"; do
    echo "   $(basename ${f})"
done
echo

for f in "${FILES[@]}"; do
    echo " * Processing file: $(basename ${f}):"

    echo -n "   Generating SHA512 checksum ... "
    pushd build > /dev/null
    sha512sum "$(basename ${f})" > "$(basename ${f}).sha512"
    popd > /dev/null
    echo "done"

    echo -n "   Uploading file ... "
    do_curl "${f}"
    echo "done"

    echo -n "   Uploading SHA512 checksum ... "
    do_curl "${f}.sha512"
    echo "done"

    echo
done