comparison TOOLS/install-w32codecs.sh @ 20450:c53da7ea44a0

Sync with Debian package.
author diego
date Fri, 27 Oct 2006 14:57:10 +0000
parents 1e2056c6bd74
children 0432c831819d
comparison
equal deleted inserted replaced
20449:ba8b5e0e9b56 20450:c53da7ea44a0
1 #!/bin/sh 1 #!/bin/sh
2 set -e
3
4 # This script will download binary codecs for MPlayer unto a Debian system.
2 5
3 # Author: thuglife, mennucc1 6 # Author: thuglife, mennucc1
4 # 7 #
5 8
6 set -e 9 CODECDIR=/usr/lib/codecs
10 PREFDIR=/var/lib/mplayer/prefs
11 MYSITE='http://people.debian.org/~mennucc1/mplayer'
7 12
8 arch=$(dpkg --print-installation-architecture) 13 dpkgarch=$(dpkg --print-installation-architecture)
9 14
10 codecsdir=/usr/lib/codecs 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
11 19
12 [ -d $codecsdir ] || mkdir -v $codecsdir
13 cd $codecsdir
14 [ -d mplayer_win32_codecs ] || mkdir -v mplayer_win32_codecs
15
16 INSTALL () {
17 filename="$1"
18 site="$2"
19 url="$site/$filename"
20 20
21 cd $codecsdir/mplayer_win32_codecs 21 choosemirror ()
22 {
23 cd $PREFDIR
22 24
23 if [ -r $filename.list ] ; then 25 #if [ ! -r mirrors ] || find mirrors -mtime +20 ; then
24 #if we stop the script, we don't want to redownload things 26 echo Downloading mirrors list..
25 #fixme we should check timestamps 27 wget -nv -c -N $MYSITE/mirrors || true
26 echo You have already downloaded and installed $filename. 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
27 else 38 else
28 wget $url || return 1 39 echo "(If you install 'netselect', it will select the best mirror for you"
29 case "$filename" in 40 echo " you may wish to stop this script and rerun after installation)"
30 *.tar.gz) 41 sleep 5
31 tar xvzf $filename > $filename.list 42 head -3 mirrors > bestsites
32 rm $filename
33 ;;
34 *.tgz)
35 tar xvzf $filename > $filename.list
36 rm $filename
37 ;;
38 *.tar.bz2)
39 tar --bzip2 -xvf $filename > $filename.list
40 rm $filename
41 ;;
42 esac
43 cd ..
44 ln -sbf mplayer_win32_codecs/*/* .
45 echo "Installed Succesfully!"
46 fi 43 fi
44 fi
47 } 45 }
48 46
49 47
48
49 INSTALL () {
50 filename="$3"
51 dir="$2"
52 url="$1"
53
54 cd $CODECDIR/mplayer_binary_codecs
55
56 if [ -r $filename ] ; then
57 cp $filename $filename.bak
58 fi
59
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
68 fi
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
76 fi
77 fi
78 }
79
80
81
82
83 UNPACK ()
84 {
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
92 fi
93
94 case "$filename" in
95 *.tar.gz)
96 tar xvzf $filename > $filename.list
97 #rm $filename
98 ;;
99 *.tgz)
100 tar xvzf $filename > $filename.list
101 #rm $filename
102 ;;
103 *.tar.bz2)
104 tar --bzip2 -xvf $filename > $filename.list
105 #rm $filename
106 ;;
107 esac
108 LINK $filename.list
109 echo "Installed $filename Succesfully!"
110 fi
111 }
112
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
118 }
119
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
128 fi
129 }
130
50 if [ `whoami` != root ]; then 131 if [ `whoami` != root ]; then
51 echo "You must be root to start this script. Login as root first!" 132 echo "You must be 'root' to use this script. Login as root first!"
52 exit 1 133 exit 1
53 else 134 fi
54 135
55 case "$1" in 136 case "$1" in
56 install) 137 install)
57 if [ "$arch" = "i386" ]; then 138 choosemirror
58 139 cd $PREFDIR
59 mainurl='' 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
143 #fi
60 144
61 pref=$codecsdir/mplayer_win32_codecs/bestsite 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"
151 n=1
152 fi
153 done
154 else
155 echo "Sorry, no codecs for your arch '$dpkgarch'. Sorry dude :("
156 exit 1
157 fi
158 ;;
62 159
63 #distribute the load 160 uninstall)
64 if [ -r $pref ] ; then 161 cd $DIR/
65 mainurl=`cat $pref ` 162 rm -rf mplayer_binary_codecs
66 else 163 #FIXME we need a better clean system
67 if [ -f /usr/bin/netselect ] ; then 164 if which symlinks > /dev/null ; then
68 echo Choosing best mirror using netselect.... 165 symlinks -d .
69 /usr/bin/netselect \
70 http://www1.mplayerhq.hu/MPlayer/releases/codecs/ \
71 http://www2.mplayerhq.hu/MPlayer/releases/codecs/ \
72 http://ftp.lug.udel.edu/MPlayer/releases/codecs/ \
73 | awk '{print $2}' > $pref
74 mainurl=`cat $pref `
75 else 166 else
76 echo "(If you install 'netselect', it will select the best mirror for you." 167 echo "please install the package 'symlinks' and run 'symlinks -d $DIR' "
77 echo " You may wish to stop this script and rerun after installation.)"
78 sleep 2
79 fi 168 fi
80 fi 169 echo "Uninstalled Succesfully!"
170 ;;
81 171
82 #sanity check, in case netselect fails 172 *)
83 mainhost=`echo $mainurl | sed 's|http://||;s|ftp://||;s|/.*||g'` 173 echo "Usage: {install|uninstall}"
84 echo Test if $mainhost exists and is ping-able... 174 echo "This program will install binary codecs for mplayer"
85 if [ "$mainurl" = '' ] || ! ping -c1 "$mainhost" > /dev/null ; then 175 exit 1
86 domain=`hostname -f | sed 's/.*\.//g' ` 176 ;;
87 mainurl=http://www1.mplayerhq.hu/MPlayer/releases/codecs/
88 if [ "$domain" = 'edu' -o "$domain" = 'com' ] ; then
89 mainurl=http://ftp.lug.udel.edu/MPlayer/releases/codecs/
90 fi
91 if [ "$domain" = 'de' -o "$domain" = 'it' ] ; then
92 mainurl=http://www2.mplayerhq.hu/MPlayer/releases/codecs/
93 fi
94 fi
95
96 #INSTALL win32.tar.gz http://ers.linuxforum.hu/
97
98 INSTALL win32codecs-lite.tar.bz2 $mainurl
99 #INSTALL w32codec.tar.bz2 http://www.mplayerhq.hu/MPlayer/releases/
100 INSTALL rp9codecs.tar.bz2 $mainurl
101 INSTALL qt6dlls.tar.bz2 $mainurl
102 elif [ "$arch" = "alpha" ]; then
103 INSTALL rp8codecs-alpha.tar.bz2 $mainurl
104 elif [ "$arch" = "powerpc" ]; then
105 INSTALL rp8codecs-ppc.tar.bz2 $mainurl
106 INSTALL xanimdlls-ppc.tar.bz2 $mainurl
107 else
108 echo "Sorry, no codecs for your arch. Sorry dude :("
109 exit 1
110
111 fi
112
113 ;;
114
115 uninstall)
116 cd $codecsdir
117 rm -rf mplayer_win32_codecs
118 #FIXME we need a better clean system
119 if [ -r /usr/bin/symlinks ] ; then
120 symlinks -d .
121 else
122 echo "Please install the package 'symlinks' and run 'symlinks -d $codecsdir'."
123 fi
124 echo "Uninstalled Succesfully!"
125
126 ;;
127
128 *)
129 echo "Usage: {install|uninstall}"
130 exit 1
131
132 ;;
133 177
134 esac 178 esac
135 179
136 180
137 exit 0 181 exit 0
138
139 fi
140