bundle embeddable/nativeUI Harrison plugins
[ardour.git] / tools / videotimeline / install_video_tools.sh
1 #!/bin/sh
2 TARGETDIR="$1"
3
4 if test -z "$(which curl)"; then
5         echo "This script requires 'curl' - please install it" >&2
6         exit 1
7 fi
8
9 ###############################################################################
10 ### look-up architecture
11
12 case $(uname -m) in
13         i[3456789]86|x86|i86pc)
14                 echo "Architecture is x86"
15                 MULTIARCH="i386"
16                 ;;
17         x86_64|amd64|AMD64)
18                 echo "Architecture is x86_64"
19                 MULTIARCH="x86_64"
20                 ;;
21         *)
22                 echo
23                 echo "ERROR: Unknown architecture `uname -m`" >&2
24                 exit 1
25                 ;;
26 esac
27
28 case $(uname) in
29         Linux|linux)
30                 MULTIARCH="${MULTIARCH}-linux-gnu"
31                 ;;
32         *)
33                 echo
34                 echo "ERROR: Platform `uname` is not supported by this script" >&2
35                 exit 1
36                 ;;
37 esac
38
39 echo "Multiarch triplet is '$MULTIARCH'"
40
41
42 ###############################################################################
43 ### install target directory
44
45 checkdir () {
46   DUT="$1"
47         CHECKPATH="${2:-yes}"
48         ECHO="${3:-echo}"
49
50         if test -z "$DUT"; then
51                 echo "-1"
52                 return
53         fi
54
55         if test ! -d "$DUT"; then
56                 $ECHO "ERROR: '$DUT' is not a directory'"; >&2
57                 echo "-1"
58                 return
59         fi
60
61         if test ! -w "$DUT"; then
62                 $ECHO "ERROR: no write permissions for '$DUT'" >&2
63                 echo "-1"
64                 return
65         fi
66
67         echo $PATH | grep -q "$DUT"
68         if test $? != 0; then
69                 if test "$CHECKPATH" != "yes"; then
70                         $ECHO "WARNING: '$DUT' is not in \$PATH" >&2
71                 else
72                         $ECHO "ERROR: '$DUT' is not in \$PATH" >&2
73                         echo "-1"
74                         return
75                 fi
76         fi
77
78         echo 0
79 }
80
81 while test $(checkdir "$TARGETDIR" no) != 0 ; do
82
83         ARDOUR=$(ls -td /opt/Ardour* 2>/dev/null | head -n 1)
84         if test -n "${ARDOUR}" -a $(checkdir "${ARDOUR}/bin" no true) = 0; then
85                 echo -n "found ardour installation in '${ARDOUR}/bin'. Install there? [Y|n] "
86                 read a;
87                 if test "$a" != "n" -a "$a" != "N"; then
88                         TARGETDIR="${ARDOUR}/bin"
89                         continue
90                 fi
91         fi
92
93         if test $(checkdir "/usr/bin" yes true) = 0; then
94                 echo -n "Can write to '/usr/bin' Install there? [Y|n] "
95                 read a;
96                 if test "$a" != "n" -a "$a" != "N"; then
97                         TARGETDIR="/usr/bin"
98                         continue
99                 fi
100         fi
101
102         if test $(checkdir "${HOME}/bin" yes true) = 0; then
103                 echo -n "Found '${HOME}/bin' in PATH. Install there? [Y|n] "
104                 read a;
105                 if test "$a" != "n" -a "$a" != "N"; then
106                         TARGETDIR="${HOME}/bin"
107                         continue
108                 fi
109         fi
110
111         if test $(checkdir "/usr/local/bin" yes true) = 0; then
112                 echo -n "Can write to '/usr/local/bin' Install there? [Y|n] "
113                 read a;
114                 if test "$a" != "n" -a "$a" != "N"; then
115                         TARGETDIR="/usr/local/bin"
116                         continue
117                 fi
118         fi
119
120         echo
121         echo "ERROR: Cannot find a suitable installation directory" >&2
122         echo "run:  $0 /install/path/bin" >&2
123         echo "'/install/path/bin' must be an existing directory and should be in \$PATH" >&2
124         exit 1
125 done
126
127 ###############################################################################
128 ### actual install procedure
129
130 echo "installing video-tools to '${TARGETDIR}'."
131 cd "$TARGETDIR" || exit 1
132
133 HARVID_VERSION=$(curl -s http://ardour.org/files/video-tools/harvid_version.txt)
134 echo "Downloading harvid-${MULTIARCH}-${HARVID_VERSION}."
135 curl -L --progress-bar \
136         http://ardour.org/files/video-tools/harvid-${MULTIARCH}-${HARVID_VERSION}.tgz \
137         | tar -x -z --exclude=README --exclude=harvid.1 --strip-components=1 || exit 1
138
139 XJADEO_VERSION=$(curl -s http://ardour.org/files/video-tools/xjadeo_version.txt)
140 echo "Downloading xjadeo-${MULTIARCH}-${XJADEO_VERSION}."
141 curl -L --progress-bar \
142         http://ardour.org/files/video-tools/xjadeo-${MULTIARCH}-${XJADEO_VERSION}.tgz \
143         | tar -x -z --exclude=README --exclude=xjadeo.1 --strip-components=1 || exit 1
144 mv xjadeo xjremote
145
146 echo "ardour video tools installed successfully."