sqcp plays with ffqclp in ffmpeg
[mplayer/glamo.git] / TOOLS / binary_codecs.sh
blobc4ab61cf4b550270f4f8f2f1a9c7a5323441e722
1 #!/bin/sh
2 set -e
4 # This script will download binary codecs for MPlayer unto a Debian system.
6 # Author: thuglife, mennucc1
9 CODECDIR=/usr/lib/codecs
10 PREFDIR=/var/lib/mplayer/prefs
11 MYSITE='http://people.debian.org/~mennucc1/mplayer'
13 dpkgarch=$(dpkg --print-installation-architecture)
15 [ -d $PREFDIR ] || mkdir -v $PREFDIR
16 [ -d $CODECDIR ] || mkdir -v $CODECDIR
17 cd $CODECDIR
18 [ -d mplayer_binary_codecs ] || mkdir -v mplayer_binary_codecs
21 choosemirror ()
23 cd $PREFDIR
25 #if [ ! -r mirrors ] || find mirrors -mtime +20 ; then
26 echo Downloading mirrors list..
27 wget -nv -c -N $MYSITE/mirrors || true
28 #fi
29 if [ ! -r bestsites ] || [ mirrors -nt bestsites ] || \
30 find bestsites -mtime +20 > /dev/null ; then
31 if which netselect > /dev/null ; then
32 echo Choosing best mirrors using netselect....
33 netselect -s 5 $( cat mirrors ) | awk '{print $2}' > bestsites
34 elif which fping > /dev/null ; then
35 fping -C 1 $( sed 's#.*//##;s#/.*##' mirrors ) 2>&1 | \
36 egrep -v 'bytes.*loss' | sort -n -k3 | \
37 grep -v ': *-' | awk '/:/{print $1}' | head -5 > bestsites
38 else
39 echo "(If you install 'netselect', it will select the best mirror for you"
40 echo " you may wish to stop this script and rerun after installation)"
41 sleep 5
42 head -3 mirrors > bestsites
49 INSTALL () {
50 filename="$3"
51 dir="$2"
52 url="$1"
54 cd $CODECDIR/mplayer_binary_codecs
56 if [ -r $filename ] ; then
57 cp $filename $filename.bak
60 if [ "$url" = @MAINSITE@ ] ; then
61 cat $PREFDIR/bestsites | while read mainsite ; do
62 echo Downloading $filename from $mainsite ...
63 wget -v -c -N $mainsite/$dir/$filename || true
64 if [ -r "$filename" ] ; then
65 UNPACK "$filename"
66 [ -r $filename.bak ] && rm $filename.bak
67 return 0
69 done
70 else
71 wget -v -c -N $url/$dir/$filename || true
72 if [ -r "$filename" ] ; then
73 UNPACK "$filename"
74 [ -r $filename.bak ] && rm $filename.bak
75 return 0
83 UNPACK ()
85 filename="$1"
86 if [ ! -r $filename.bak ] || ! cmp $filename.bak $filename ; then
87 echo Installing $filename ...
88 if [ -r $filename.list ] ; then
89 tr '\n' '\000' < $filename.list | xargs -r0 rm || true
90 UNLINK $filename.list
91 rm $filename.list
94 case "$filename" in
95 *.tar.gz)
96 tar xvzf $filename > $filename.list
97 #rm $filename
99 *.tgz)
100 tar xvzf $filename > $filename.list
101 #rm $filename
103 *.tar.bz2)
104 tar --bzip2 -xvf $filename > $filename.list
105 #rm $filename
107 esac
108 LINK $filename.list
109 echo "Installed $filename Succesfully!"
113 LINK () {
114 cd $CODECDIR/
115 cat $CODECDIR/mplayer_binary_codecs/$1 | while read f ; do
116 ln -sbf mplayer_binary_codecs/"$f" .
117 done
120 UNLINK () {
121 ### FIXME
122 # cd $CODECDIR
123 # cat $CODECDIR/mplayer_binary_codecs/$1 | while f do
124 # ln -sbf mplayer_binary_codecs/"$f"
125 # done
126 if which symlinks > /dev/null ; then
127 symlinks -d $CODECDIR
131 if [ `whoami` != root ]; then
132 echo "You must be 'root' to use this script. Login as root first!"
133 exit 1
136 case "$1" in
137 install)
138 choosemirror
139 cd $PREFDIR
140 #if [ ! -r codecs_list ] || find codecs_list -mtime +20 ; then
141 echo 'Getting codecs list ...'
142 wget -nv -c -N $MYSITE/codecs_list || true
145 if grep -q "^$dpkgarch" $PREFDIR/codecs_list ] ; then
146 egrep -v "^[[:space:]]*(#|$)" $PREFDIR/codecs_list | \
147 while read arch url dir file info ; do
148 if [ "$dpkgarch" = "$arch" ]; then
149 echo Installing $file $info...
150 INSTALL "$url" "$dir" "$file"
153 done
154 else
155 echo "Sorry, no codecs for your arch '$dpkgarch'. Sorry dude :("
156 exit 1
160 uninstall)
161 cd $CODECDIR/
162 rm -rf mplayer_binary_codecs
163 #FIXME we need a better clean system
164 if which symlinks > /dev/null ; then
165 symlinks -d .
166 else
167 echo "please install the package 'symlinks' and run 'symlinks -d $CODECDIR' "
169 echo "Uninstalled Succesfully!"
173 echo "Usage: {install|uninstall}"
174 echo "This program will install binary codecs for MPlayer."
175 exit 1
178 esac
181 exit 0