install-sharness.sh: use git instead of wget and shasum
License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Christian Couder committed
Jan 9, 2015 at 23:13 UTC
9e8fc3826a97c04a89d14330b1db57d65056b651
1 file changed
+9
-42
test/sharness/lib/install-sharness.sh
+9
-42
@@ -7,53 +7,20 @@
7
8
# settings
9
version=50229a79ba22b2f13ccd82451d86570fecbd194c
10
-urlprefix=https://raw.githubusercontent.com/mlafeldt/sharness/$version
11
-installpath=lib/sharness
12
-
13
-# files to download
14
-sfile=sharness.sh
15
-shash=eeaf96630fc25ec58fb678b64ef9772d5eb92f64
16
-
17
-afile=aggregate-results.sh
18
-ahash=948d6bc03222c5c00a1ed048068508d5ea1cce59
10
+urlprefix=https://github.com/mlafeldt/sharness.git
11
+clonedir=lib
12
+sharnessdir=sharness
13
14
die() {
21
- echo >&2 $@
15
+ echo >&2 "$@"
16
exit 1
17
}
18
25
-verified_download() {
26
- file=$1
27
- hash1=$2
28
- url=$urlprefix/$file
29
-
30
- # download it
31
- wget -q $url -O $file.test
32
-
33
- # verify it's the right file
34
- hash2=`cat $file.test | shasum | cut -c1-40`
35
- if test "$hash1" != "$hash2"; then
36
- echo "$file verification failed:"
37
- echo " $hash1 != $hash2"
38
- return -1
39
- fi
40
- return 0
41
-}
42
-
43
-mkdir -p $installpath || die "Could not create 'sharness' directory"
44
-cd $installpath || die "Could not cd into 'sharness' directory"
19
+mkdir -p "$clonedir" || die "Could not create '$clonedir' directory"
20
+cd "$clonedir" || die "Could not cd into '$clonedir' directory"
21
46
-verified_download "$sfile" "$shash"; sok=$?
47
-verified_download "$afile" "$ahash"; aok=$?
48
-if test "$sok" != 0 || test "$aok" != 0; then
49
- rm $afile.test
50
- rm $sfile.test
51
- exit -1
52
-fi
22
+git clone "$urlprefix" || die "Could not clone '$urlprefix'"
23
+cd "$sharnessdir" || die "Could not cd into '$sharnessdir' directory"
24
+git checkout "$version" || die "Could not checkout '$version'"
25
54
-# ok, move things into place
55
-mv $sfile.test $sfile
56
-mv $afile.test $afile
57
-chmod +x $sfile
58
-chmod +x $afile
26
exit 0