-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·56 lines (51 loc) · 1.42 KB
/
build.sh
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
#!/bin/bash
# Based on https://gist.github.com/chrismdp/6c6b6c825b07f680e710
function putS3 {
file=$1
aws_path=$2
aws_id=$3
aws_token=$4
aws_bucket=$5
date=$(date +"%a, %d %b %Y %T %z")
acl="x-amz-acl:public-read"
content_type='application/x-compressed-tar'
string="PUT\n\n$content_type\n$date\n$acl\n/$aws_bucket$aws_path$file"
signature=$(echo -en "${string}" | openssl sha1 -hmac "${aws_token}" -binary | base64)
curl -X PUT -T "$file" \
-H "Host: $aws_bucket.s3.amazonaws.com" \
-H "Date: $date" \
-H "Content-Type: $content_type" \
-H "$acl" \
-H "Authorization: AWS ${aws_id}:$signature" \
"https://$aws_bucket.s3.amazonaws.com$aws_path$file"
echo "Uploaded to https://$aws_bucket.s3.amazonaws.com$aws_path$file"
}
# These should be set from the outside. A git version and heroku/travis respectively
if [ -z "$VERSION" ]
then
VERSION="unknown"
fi
if [ -z "$TARGET" ]
then
TARGET="unknown"
fi
CCV_REVISION=07fc691
git clone https://github.com/liuliu/ccv.git
cd ccv/lib
git checkout $CCV_REVISION
./configure
echo "Configured..."
make -j4
echo "Built..."
cd -
echo "Right dir..."
tar czf libccv-${VERSION}-${TARGET}.tgz -C ccv/lib .
echo "Packing..."
if [ -z "$AMAZON_API_TOKEN" ];
then
echo "Amazon API Token not provided, skipping upload";
else
putS3 "libccv-${VERSION}-${TARGET}.tgz" "/bundles/" $AMAZON_API_ID $AMAZON_API_TOKEN $AMAZON_API_BUCKET
echo "Success!"
fi
echo "End."