-
Notifications
You must be signed in to change notification settings - Fork 22
/
install-git-annex
executable file
·111 lines (103 loc) · 3.22 KB
/
install-git-annex
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
#!/bin/sh
set -e
# should normally be 0
NEED_PRERELEASE=0
linux_install () {
ARCH=""
UNAME_M="$(uname -m)"
case $UNAME_M in
'x86_64') ARCH="amd64";;
arm*l) ARCH="armel";;
i*86) ARCH="i386";;
*) echo "ERROR: Unhandled architecture: $UNAME_M"; exit 1;;
esac
if [ -d git-annex.linux ]; then
if upgrade_avail ./git-annex.linux/git-annex https://downloads.kitenet.net/git-annex/linux/current/git-annex-standalone-"$ARCH".tar.gz.info; then
rm -rf git-annex.linux
fi
if [ "$NEED_PRERELEASE" = 1 ] && ! [ -e git-annex.linux/.prerelease ]; then
rm -rf git-annex.linux
fi
fi
if [ ! -d git-annex.linux ]; then
echo "Installing a recent version of git-annex ..."
rm -f git-annex-standalone-"$ARCH".tar.gz
if [ "$NEED_PRERELEASE" = 1 ]; then
URL="https://downloads.kitenet.net/git-annex/autobuild/${ARCH}/git-annex-standalone-${ARCH}.tar.gz"
else
# released version
URL="https://downloads.kitenet.net/git-annex/linux/current/git-annex-standalone-${ARCH}.tar.gz"
fi
if ! $(wget "${URL}"); then
echo "wget failed to download git-annex; clear the erroneous condition and try again."
exit 1
fi
if ! tar xf git-annex-standalone-"$ARCH".tar.gz; then
echo "tar failed to extract git-annex; clear the erroneous condition and try again."
exit 1
fi
if [ "$NEED_PRERELEASE" = 1 ]; then
touch git-annex.linux/.prerelease
fi
rm -f git-annex-standalone-"$ARCH".tar.gz
echo "Installed in $(pwd)/git-annex.linux"
echo
fi
}
osx_install () {
if [ -d git-annex.osx ]; then
if upgrade_avail ./git-annex.osx/git-annex https://downloads.kitenet.net/git-annex/OSX/current/10.10_Yosemite/git-annex.dmg.info; then
rm -rf git-annex.osx
fi
if [ "$NEED_PRERELEASE" = 1 ] && ! [ -e git-annex.osx/.prerelease ]; then
rm -rf git-annex.osx
fi
fi
if [ ! -d git-annex.osx ]; then
echo "Installing a recent version of git-annex ..."
rm -f git-annex.dmg
if [ "$NEED_PRERELEASE" = 1 ]; then
URL="https://downloads.kitenet.net/git-annex/autobuild/x86_64-apple-yosemite/git-annex.dmg"
else
# released version
URL="https://downloads.kitenet.net/git-annex/OSX/current/10.10_Yosemite/git-annex.dmg"
fi
if ! $(wget "${URL}"); then
echo "wget failed to download git-annex; clear the erroneous condition and try again."
exit 1
fi
mkdir git-annex.osx.mnt
hdiutil attach git-annex.dmg -mountpoint git-annex.osx.mnt
if ! $(cp -r git-annex.osx.mnt/git-annex.app/Contents/MacOS/ git-annex.osx); then
echo "failed to extract git-annex; clear the erroneous condition and try again."
exit 1
fi
hdiutil eject git-annex.osx.mnt
if [ "$NEED_PRERELEASE" = 1 ]; then
touch git-annex.osx/.prerelease
fi
rm -f git-annex.dmg
rm -rf git-annex.osx.mnt
echo "Installed in $(pwd)/git-annex.osx"
echo
fi
}
upgrade_avail () {
cmd="$1"
infourl="$2"
installedVersion="$($cmd version --raw 2>/dev/null | cut -d '-' -f 1 | cut -d . -f 2)"
if [ -z "$installedVersion" ]; then
installedVersion=0
fi
# version is in line 4 of the file
newVersion=$(wget $infourl -o /dev/null -O - | tail -3 | head -1 | cut -d '.' -f 2-)
test -n "$newVersion" && test "$installedVersion" -lt "$newVersion"
}
case "$(uname)" in
Darwin)
osx_install
;;
*)
linux_install
;;
esac