1 |
dpavlin |
6 |
#!/bin/sh |
2 |
|
|
|
3 |
|
|
sudo echo "Cache credentials for sudo..." |
4 |
|
|
|
5 |
|
|
function check_upstream() { |
6 |
|
|
what="$1" |
7 |
|
|
upstream=`wget -O - http://${what}.sourceforge.net/ -o /dev/null | grep "Latest Source Package" | cut -d\" -f2` |
8 |
|
|
|
9 |
|
|
echo "Upstream version of $what is $upstream" |
10 |
|
|
|
11 |
|
|
if echo $upstream | grep 'http://' ; then |
12 |
|
|
wget -nc -c $upstream |
13 |
|
|
else |
14 |
|
|
wget -nc -c http://${what}.sourceforge.net/$upstream |
15 |
|
|
fi |
16 |
|
|
|
17 |
|
|
upstream_ver=`echo $upstream | cut -d- -f2 | sed 's/\.tar.gz//'` |
18 |
|
|
} |
19 |
|
|
|
20 |
|
|
d=`pwd` |
21 |
|
|
tmp="/tmp/tc-latest" |
22 |
|
|
|
23 |
|
|
function extract() { |
24 |
|
|
arc="$1" |
25 |
|
|
|
26 |
|
|
name=`echo $arc | cut -d- -f1` |
27 |
|
|
ver=`echo $arc | cut -d- -f2 | sed 's/\.tar.gz//'` |
28 |
|
|
|
29 |
|
|
if dpkg -l "$name" | grep "^ii" | grep "$ver" 2>&1 >/dev/null ; then |
30 |
|
|
echo "Skipping $name [$ver], allready installed." |
31 |
|
|
return |
32 |
|
|
fi |
33 |
|
|
|
34 |
|
|
mkdir $tmp |
35 |
|
|
cd $tmp |
36 |
|
|
|
37 |
|
|
opt="" |
38 |
|
|
|
39 |
|
|
echo "Extracting $name [$ver] to $tmp" |
40 |
|
|
tar xvfz "$d/$arc" |
41 |
|
|
cd * |
42 |
|
|
|
43 |
|
|
if [ "$ver" == "perl" ] ; then |
44 |
|
|
|
45 |
|
|
dh-make-perl --depends tokyocabinet |
46 |
|
|
./debian/rules binary |
47 |
|
|
|
48 |
|
|
else |
49 |
|
|
|
50 |
|
|
./configure |
51 |
|
|
make |
52 |
|
|
sudo checkinstall -y |
53 |
|
|
|
54 |
|
|
fi |
55 |
|
|
|
56 |
|
|
cd $d |
57 |
|
|
sudo rm -Rf $tmp |
58 |
|
|
} |
59 |
|
|
|
60 |
|
|
dpkg -l | awk '{ print $2 }' | egrep '^(tokyocabinet|)' | xargs sudo apt-get remove -y |
61 |
|
|
|
62 |
|
|
tokyocabinet_ver="$1" |
63 |
|
|
perl_ver="$2" |
64 |
|
|
|
65 |
|
|
if [ -z "$tokyocabinet_ver" ] ; then |
66 |
|
|
check_upstream 'tokyocabinet' |
67 |
|
|
extract "tokyocabinet-${upstream_ver}.tar.gz" |
68 |
|
|
else |
69 |
|
|
extract `ls -m tokyocabinet-${tokyocabinet_ver}.tar.gz | head -1` |
70 |
|
|
fi |
71 |
|
|
|
72 |
|
|
perl_upstream=`wget -O - -o /dev/null http://tokyocabinet.sourceforge.net/perlpkg/ | grep tar.gz | cut -d\" -f8 | tail -1` |
73 |
|
|
if [ -z "$perl_ver" ] ; then |
74 |
|
|
wget -nH -nd -m http://tokyocabinet.sourceforge.net/perlpkg/$perl_upstream |
75 |
|
|
extract "$perl_upstream" |
76 |
|
|
else |
77 |
|
|
extract `ls -m $perl_upstream | head -1` |
78 |
|
|
fi |