forked from tarantool/tt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gen_tarballs.sh
executable file
·99 lines (85 loc) · 2 KB
/
.gen_tarballs.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
#!/bin/bash
set -u
# This script generates tarballs needed to create the Gentoo ebuilds.
die() {
echo "$*" >&2
exit 2
}
needs_arg() {
if [ -z "$OPTARG" ]; then
die "No arg for --${OPT} option"
fi
}
TAG=""
while getopts ht:-: OPT; do
if [ "$OPT" = "-" ]; then
OPT="${OPTARG%%=*}"
OPTARG="${OPTARG#$OPT}"
OPTARG="${OPTARG#=}"
fi
case "$OPT" in
(h | help)
echo "Usage: ${0} -t <tag>"
exit 0
;;
(t | tag)
needs_arg; TAG="$OPTARG"
;;
(??*)
die "Illegal option --$OPT"
;;
(?)
exit 1
;;
esac
done
if [ $# == 0 ]; then
die "Usage: ${0} -t <tag>"
fi
TAG_ORIG=${TAG}
TAG=${TAG//v}
TAG=${TAG##*/} # Remove everything before the last / to avoid using / in file names.
TMPDIR="/tmp/gentoo_tarballs"
TT_DIR="${TMPDIR}/tt-${TAG}"
# Cleanup.
test -d $TMPDIR && rm -rf $TMPDIR
mkdir -p $TMPDIR/go-mod
echo -n "* Download sources... "
git clone https://github.com/tarantool/tt.git -b $TAG_ORIG --depth=1 --recursive $TT_DIR \
> /dev/null 2>${TMPDIR}/log.txt
if [ "$?" != 0 ]; then
echo "Err: "
cat ${TMPDIR}/log.txt
exit 1
else
echo "Done"
fi
echo -n "* Create complete sources tarball... "
pushd ${TMPDIR} > /dev/null
tar czf tt-${TAG}-complete.tar.gz tt-${TAG}
if [ "$?" != 0 ]; then
echo "Err"
exit 1
else
echo "Done"
fi
echo "* TT sources tarball: $(realpath tt-${TAG}-complete.tar.gz)"
echo -n "* Create dependency tarball... "
pushd ${TT_DIR} > /dev/null
GOMODCACHE=${TMPDIR}/go-mod go mod download -modcacherw
rc=$?
pushd ${TT_DIR}/cli/cartridge/third_party/cartridge-cli > /dev/null
GOMODCACHE=${TMPDIR}/go-mod go mod download -modcacherw
let rc+=$?
popd > /dev/null
popd > /dev/null
tar --create --auto-compress --file tt-${TAG}-deps.tar.xz go-mod
let rc+=$?
if [ $rc != 0 ]; then
echo "Err"
exit 1
else
echo "Done"
fi
echo "* TT deps tarball: $(realpath tt-${TAG}-deps.tar.xz)"
popd > /dev/null