forked from jprjr/turtlecoin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-release.sh
executable file
·129 lines (103 loc) · 2.73 KB
/
build-release.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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/sh
set -o errexit
TAG_VERSION=$1
BUILD_DIRECTORY=$2
function usage()
{
echo "This script builds the dynamically and statically linked version"
echo "and generates the checksum files of the TurtleCoin tag provided."
echo
echo "USAGE: $0 <tag> <build-directory>"
echo
exit 1
}
function checkout_tag()
{
echo "cloning Github repository $GITHUB_REPO to $CLONE_DIR .."
git clone $GITHUB_REPO $CLONE_DIR
echo "checking out tag $TAG_VERSION .."
cd $CLONE_DIR
git checkout $TAG_VERSION
}
function build_dynamic_linked_version()
{
echo "starting dynamic build .."
cd $CLONE_DIR
mkdir -p build/release
cd build/release
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-fassociative-math" -DCMAKE_CXX_FLAGS="-fassociative-math" ../..
make
cd ../..
echo "dynamic build done .."
generate_tarball $DYNAMIC_RELEASE
}
function build_static_linked_version()
{
echo "starting static build .."
cd $CLONE_DIR
make clean
mkdir -p build/release
cd build/release
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-fassociative-math" -DCMAKE_CXX_FLAGS="-fassociative-math" -DSTATIC=true ../..
make
cd ../..
echo "static build done .."
generate_tarball $STATIC_RELEASE
}
function generate_tarball()
{
RELEASE_NAME=$1
if [ ! -d "$TARGET_DIR" ];
then
mkdir -p "$TARGET_DIR"
fi
TARBALL="$TARGET_DIR/$RELEASE_NAME.tar.gz"
echo "generating tarball $TARBALL .."
tar --transform "s,^,$RELEASE_NAME/," -c -f $TARBALL -z -C "$CLONE_DIR/build/release/src" \
miner \
simplewallet \
TurtleCoind \
walletd \
connectivity_tool
generate_checksums $TARBALL
}
function generate_checksums()
{
FILE_TO_CHECK=$1
echo "generating md5sum .."
md5sum $FILE_TO_CHECK > $FILE_TO_CHECK.md5
echo "generating sha512sum .."
sha512sum $FILE_TO_CHECK > $FILE_TO_CHECK.sha512
}
function cleanup()
{
if [ -d "$CLONE_DIR" ];
then
echo "removing git clone directory .."
echo "rm -rf $CLONE_DIR"
fi
}
if [ -z $TAG_VERSION ];
then
usage
fi
if [ -z $BUILD_DIRECTORY ];
then
echo "No build directory given, will build in $HOME/build .."
BUILD_DIRECTORY="$HOME/build"
fi
if [ ! -d "$BUILD_DIRECTORY" ];
then
echo "creating build directory $BUILD_DIRECTOR .."
mkdir -p "$BUILD_DIRECTORY"
fi
# -- Config
GITHUB_REPO="https://github.com/turtlecoin/turtlecoin.git"
CLONE_DIR="$BUILD_DIRECTORY/turtlecoin-buildall"
TARGET_DIR="$BUILD_DIRECTORY/turtlecoin-releases"
DYNAMIC_RELEASE="turtlecoin-${TAG_VERSION}-linux-CLI"
STATIC_RELEASE="turtlecoin-${TAG_VERSION}-linux-staticboost-CLI"
checkout_tag
build_static_linked_version
build_dynamic_linked_version
cleanup