-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetSrcTarFromGithub.bash
More file actions
executable file
·53 lines (41 loc) · 1.27 KB
/
Copy pathGetSrcTarFromGithub.bash
File metadata and controls
executable file
·53 lines (41 loc) · 1.27 KB
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
#!/bin/bash
################### CONFIGURE ###############################
# if not set it will not use the sha512 sum and tell you it
SHA512SUM=
############################################################
# This gets a tarball from github.
#Usage: GetSrcTarFromGithub user package tag tarname [sha512]
function GetSrcTarFromGithub()
{
[ -n "$4" ] || exit 1
local path="$1/$2"
local tag="$3"
local tarfile=$4.tar.gz
if [ -e "$tarfile" ] && [ -n "$5" ] ; then
if ! echo "$5 $tarfile" | sha512sum -c ; then
set +x
echo "You have \"$tarfile\" with a bad sha512 sum"
exit 1
else
# success
set +x
echo "We have the tar file \"$tarfile\" already"
exit 0
fi
fi
# This gets a tarball file from github for the package
wget --no-check-certificate -O $tarfile https://github.com/$path/tarball/$tag
if [ -n "$5" ] ; then
set +e
# Check that the file has a good SHA512 sum
if ! echo "$5 $tarfile" | sha512sum -c ; then
set +x
echo "You have $tarfile with a bad sha512 sum"
exit 1 # FAIL
fi
else
# Just report the SHA512 sum
sha512sum $tarfile
fi
# Success
}