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
18 [ -d mplayer_binary_codecs
] || mkdir
-v mplayer_binary_codecs
25 #if [ ! -r mirrors ] || find mirrors -mtime +20 ; then
26 echo Downloading mirrors list..
27 wget
-nv -c -N $MYSITE/mirrors || true
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
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)"
42 head -3 mirrors
> bestsites
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
66 [ -r $filename.bak
] && rm $filename.bak
71 wget
-v -c -N $url/$dir/$filename || true
72 if [ -r "$filename" ] ; then
74 [ -r $filename.bak
] && rm $filename.bak
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
96 tar xvzf
$filename > $filename.list
100 tar xvzf
$filename > $filename.list
104 tar --bzip2 -xvf $filename > $filename.list
109 echo "Installed $filename Succesfully!"
115 cat $CODECDIR/mplayer_binary_codecs
/$1 |
while read f
; do
116 ln -sbf mplayer_binary_codecs
/"$f" .
123 # cat $CODECDIR/mplayer_binary_codecs/$1 | while f do
124 # ln -sbf mplayer_binary_codecs/"$f"
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!"
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"
155 echo "Sorry, no codecs for your arch '$dpkgarch'. Sorry dude :("
162 rm -rf mplayer_binary_codecs
163 #FIXME we need a better clean system
164 if which symlinks
> /dev
/null
; then
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."