forked from matterhorn-chat/matterhorn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkrelease.sh
executable file
·79 lines (66 loc) · 1.77 KB
/
mkrelease.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
#!/usr/bin/env bash
set -e
HERE=$(cd `dirname $0`; pwd)
function get_platform {
if [ -f "/etc/redhat-release" ]
then
if grep Fedora /etc/redhat-release >/dev/null
then
echo "Fedora"
else
echo "Unknown-Redhat"
fi
elif grep -i ubuntu /etc/apt/sources.list 2>/dev/null >/dev/null
then
echo "Ubuntu"
else
uname -s
fi
}
function get_arch {
uname -m
}
VERSION=$(grep "^version:" matterhorn.cabal | awk '{ print $2 }')
BASENAME=matterhorn
ARCH=$(get_arch)
PLATFORM=$(get_platform)
LONG_HEAD=$(git log | head -1 | awk '{ print $2 }')
SHORT_HEAD=${LONG_HEAD:0:8}
DIRNAME=$BASENAME-$VERSION-$PLATFORM-$ARCH
FILENAME=$DIRNAME.tar.bz2
CABAL_DEPS_REPO=https://github.com/matterhorn-chat/cabal-dependency-licenses.git
CABAL_DEPS_TOOL_DIR=$HOME/.cabal/bin
function prepare_dist {
local dest=$1
cp $HERE/dist-newstyle/build/matterhorn-$VERSION/build/matterhorn/matterhorn $dest
strip $dest/matterhorn
cp $HERE/sample-config.ini $dest
cp $HERE/README.md $dest
cp $HERE/CHANGELOG.md $dest
echo $LONG_HEAD > $dest/COMMIT
cd $HERE && $CABAL_DEPS_TOOL_DIR/cabal-dependency-licenses > $dest/COPYRIGHT
}
function install_tools {
if [ ! -f $CABAL_DEPS_TOOL_DIR/cabal-dependency-licenses ]
then
BUILD=$(mktemp -d)
cd $BUILD
git clone $CABAL_DEPS_REPO
cd cabal-dependency-licenses
cabal install
mkdir -p $CABAL_DEPS_TOOL_DIR
cd $HERE && rm -rf $BUILD
fi
}
install_tools
echo Version: $VERSION
echo Filename: $FILENAME
cd $HERE && ./install.sh
TMPDIR=$(mktemp -d)
function cleanup {
rm -rf $TMPDIR
}
trap cleanup EXIT
mkdir $TMPDIR/$DIRNAME
prepare_dist $TMPDIR/$DIRNAME
cd $TMPDIR && tar -cj $DIRNAME > $HERE/$FILENAME