2005-05-29 13:46:57 +00:00
|
|
|
#!/bin/sh
|
2006-10-27 14:57:10 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# This script will download binary codecs for MPlayer unto a Debian system.
|
2005-05-29 13:46:57 +00:00
|
|
|
|
|
|
|
# Author: thuglife, mennucc1
|
|
|
|
#
|
|
|
|
|
2006-10-27 14:57:10 +00:00
|
|
|
CODECDIR=/usr/lib/codecs
|
|
|
|
PREFDIR=/var/lib/mplayer/prefs
|
|
|
|
MYSITE='http://people.debian.org/~mennucc1/mplayer'
|
|
|
|
|
|
|
|
dpkgarch=$(dpkg --print-installation-architecture)
|
|
|
|
|
|
|
|
[ -d $PREFDIR ] || mkdir -v $PREFDIR
|
|
|
|
[ -d $CODECDIR ] || mkdir -v $CODECDIR
|
|
|
|
cd $CODECDIR
|
|
|
|
[ -d mplayer_binary_codecs ] || mkdir -v mplayer_binary_codecs
|
|
|
|
|
|
|
|
|
|
|
|
choosemirror ()
|
|
|
|
{
|
|
|
|
cd $PREFDIR
|
|
|
|
|
|
|
|
#if [ ! -r mirrors ] || find mirrors -mtime +20 ; then
|
|
|
|
echo Downloading mirrors list..
|
|
|
|
wget -nv -c -N $MYSITE/mirrors || true
|
|
|
|
#fi
|
|
|
|
if [ ! -r bestsites ] || [ mirrors -nt bestsites ] || \
|
|
|
|
find bestsites -mtime +20 > /dev/null ; then
|
|
|
|
if which netselect > /dev/null ; then
|
|
|
|
echo Choosing best mirrors using netselect....
|
|
|
|
netselect -s 5 $( cat mirrors ) | awk '{print $2}' > bestsites
|
|
|
|
elif which fping > /dev/null ; then
|
|
|
|
fping -C 1 $( sed 's#.*//##;s#/.*##' mirrors ) 2>&1 | \
|
|
|
|
egrep -v 'bytes.*loss' | sort -n -k3 | \
|
|
|
|
grep -v ': *-' | awk '/:/{print $1}' | head -5 > bestsites
|
|
|
|
else
|
|
|
|
echo "(If you install 'netselect', it will select the best mirror for you"
|
|
|
|
echo " you may wish to stop this script and rerun after installation)"
|
|
|
|
sleep 5
|
|
|
|
head -3 mirrors > bestsites
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
2005-05-29 13:46:57 +00:00
|
|
|
|
|
|
|
|
2005-05-29 23:33:13 +00:00
|
|
|
|
2006-10-27 14:57:10 +00:00
|
|
|
INSTALL () {
|
|
|
|
filename="$3"
|
|
|
|
dir="$2"
|
|
|
|
url="$1"
|
2005-05-29 13:46:57 +00:00
|
|
|
|
2006-10-27 14:57:10 +00:00
|
|
|
cd $CODECDIR/mplayer_binary_codecs
|
2005-05-29 13:46:57 +00:00
|
|
|
|
2006-10-27 14:57:10 +00:00
|
|
|
if [ -r $filename ] ; then
|
|
|
|
cp $filename $filename.bak
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$url" = @MAINSITE@ ] ; then
|
|
|
|
cat $PREFDIR/bestsites | while read mainsite ; do
|
|
|
|
echo Downloading $filename from $mainsite ...
|
|
|
|
wget -v -c -N $mainsite/$dir/$filename || true
|
|
|
|
if [ -r "$filename" ] ; then
|
|
|
|
UNPACK "$filename"
|
|
|
|
[ -r $filename.bak ] && rm $filename.bak
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
wget -v -c -N $url/$dir/$filename || true
|
|
|
|
if [ -r "$filename" ] ; then
|
|
|
|
UNPACK "$filename"
|
|
|
|
[ -r $filename.bak ] && rm $filename.bak
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UNPACK ()
|
|
|
|
{
|
|
|
|
filename="$1"
|
|
|
|
if [ ! -r $filename.bak ] || ! cmp $filename.bak $filename ; then
|
|
|
|
echo Installing $filename ...
|
|
|
|
if [ -r $filename.list ] ; then
|
|
|
|
tr '\n' '\000' < $filename.list | xargs -r0 rm || true
|
|
|
|
UNLINK $filename.list
|
|
|
|
rm $filename.list
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$filename" in
|
2005-05-29 13:46:57 +00:00
|
|
|
*.tar.gz)
|
2006-10-27 14:57:10 +00:00
|
|
|
tar xvzf $filename > $filename.list
|
|
|
|
#rm $filename
|
|
|
|
;;
|
2005-05-29 13:46:57 +00:00
|
|
|
*.tgz)
|
2006-10-27 14:57:10 +00:00
|
|
|
tar xvzf $filename > $filename.list
|
|
|
|
#rm $filename
|
|
|
|
;;
|
2005-05-29 13:46:57 +00:00
|
|
|
*.tar.bz2)
|
2006-10-27 14:57:10 +00:00
|
|
|
tar --bzip2 -xvf $filename > $filename.list
|
|
|
|
#rm $filename
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
LINK $filename.list
|
|
|
|
echo "Installed $filename Succesfully!"
|
|
|
|
fi
|
2005-05-29 13:46:57 +00:00
|
|
|
}
|
|
|
|
|
2006-10-27 14:57:10 +00:00
|
|
|
LINK () {
|
|
|
|
cd $CODECDIR/
|
|
|
|
cat $CODECDIR/mplayer_binary_codecs/$1 | while read f ; do
|
|
|
|
ln -sbf mplayer_binary_codecs/"$f" .
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
UNLINK () {
|
|
|
|
### FIXME
|
|
|
|
# cd $CODECDIR
|
|
|
|
# cat $CODECDIR/mplayer_binary_codecs/$1 | while f do
|
|
|
|
# ln -sbf mplayer_binary_codecs/"$f"
|
|
|
|
# done
|
|
|
|
if which symlinks > /dev/null ; then
|
|
|
|
symlinks -d $CODECDIR
|
|
|
|
fi
|
|
|
|
}
|
2005-05-29 13:46:57 +00:00
|
|
|
|
|
|
|
if [ `whoami` != root ]; then
|
2006-10-27 14:57:10 +00:00
|
|
|
echo "You must be 'root' to use this script. Login as root first!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-05-29 13:46:57 +00:00
|
|
|
|
|
|
|
case "$1" in
|
2006-10-27 14:57:10 +00:00
|
|
|
install)
|
|
|
|
choosemirror
|
|
|
|
cd $PREFDIR
|
|
|
|
#if [ ! -r codecs_list ] || find codecs_list -mtime +20 ; then
|
|
|
|
echo 'Getting codecs list ...'
|
|
|
|
wget -nv -c -N $MYSITE/codecs_list || true
|
|
|
|
#fi
|
|
|
|
|
|
|
|
if grep -q "^$dpkgarch" $PREFDIR/codecs_list ] ; then
|
|
|
|
egrep -v "^[[:space:]]*(#|$)" $PREFDIR/codecs_list | \
|
|
|
|
while read arch url dir file info ; do
|
|
|
|
if [ "$dpkgarch" = "$arch" ]; then
|
|
|
|
echo Installing $file $info...
|
|
|
|
INSTALL "$url" "$dir" "$file"
|
|
|
|
n=1
|
|
|
|
fi
|
|
|
|
done
|
2005-05-29 13:46:57 +00:00
|
|
|
else
|
2006-10-27 14:57:10 +00:00
|
|
|
echo "Sorry, no codecs for your arch '$dpkgarch'. Sorry dude :("
|
2005-05-29 13:46:57 +00:00
|
|
|
exit 1
|
2006-10-27 14:57:10 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
uninstall)
|
2006-11-10 19:21:02 +00:00
|
|
|
cd $CODECDIR/
|
2006-10-27 14:57:10 +00:00
|
|
|
rm -rf mplayer_binary_codecs
|
|
|
|
#FIXME we need a better clean system
|
|
|
|
if which symlinks > /dev/null ; then
|
|
|
|
symlinks -d .
|
|
|
|
else
|
2006-11-10 19:21:02 +00:00
|
|
|
echo "please install the package 'symlinks' and run 'symlinks -d $CODECDIR' "
|
2006-10-27 14:57:10 +00:00
|
|
|
fi
|
|
|
|
echo "Uninstalled Succesfully!"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Usage: {install|uninstall}"
|
2006-11-10 19:21:02 +00:00
|
|
|
echo "This program will install binary codecs for MPlayer."
|
2006-10-27 14:57:10 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
2005-05-29 13:46:57 +00:00
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
exit 0
|