annotate TOOLS/install-w32codecs.sh @ 25225:51c23a18a17b

First try to mark some things in m_config correctly as const
author reimar
date Sun, 02 Dec 2007 15:35:58 +0000
parents 0432c831819d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
1 #!/bin/sh
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
2 set -e
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
3
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
4 # This script will download binary codecs for MPlayer unto a Debian system.
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
5
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
6 # Author: thuglife, mennucc1
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
7 #
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
8
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
9 CODECDIR=/usr/lib/codecs
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
10 PREFDIR=/var/lib/mplayer/prefs
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
11 MYSITE='http://people.debian.org/~mennucc1/mplayer'
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
12
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
13 dpkgarch=$(dpkg --print-installation-architecture)
15592
aadde9ec9058 Add a variable for the codec directory and set it to /usr/lib/codecs instead
diego
parents: 15586
diff changeset
14
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
15 [ -d $PREFDIR ] || mkdir -v $PREFDIR
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
16 [ -d $CODECDIR ] || mkdir -v $CODECDIR
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
17 cd $CODECDIR
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
18 [ -d mplayer_binary_codecs ] || mkdir -v mplayer_binary_codecs
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
19
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
20
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
21 choosemirror ()
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
22 {
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
23 cd $PREFDIR
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
24
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
25 #if [ ! -r mirrors ] || find mirrors -mtime +20 ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
26 echo Downloading mirrors list..
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
27 wget -nv -c -N $MYSITE/mirrors || true
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
28 #fi
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
29 if [ ! -r bestsites ] || [ mirrors -nt bestsites ] || \
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
30 find bestsites -mtime +20 > /dev/null ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
31 if which netselect > /dev/null ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
32 echo Choosing best mirrors using netselect....
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
33 netselect -s 5 $( cat mirrors ) | awk '{print $2}' > bestsites
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
34 elif which fping > /dev/null ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
35 fping -C 1 $( sed 's#.*//##;s#/.*##' mirrors ) 2>&1 | \
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
36 egrep -v 'bytes.*loss' | sort -n -k3 | \
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
37 grep -v ': *-' | awk '/:/{print $1}' | head -5 > bestsites
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
38 else
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
39 echo "(If you install 'netselect', it will select the best mirror for you"
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
40 echo " you may wish to stop this script and rerun after installation)"
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
41 sleep 5
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
42 head -3 mirrors > bestsites
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
43 fi
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
44 fi
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
45 }
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
46
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
47
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
48
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
49 INSTALL () {
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
50 filename="$3"
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
51 dir="$2"
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
52 url="$1"
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
53
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
54 cd $CODECDIR/mplayer_binary_codecs
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
55
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
56 if [ -r $filename ] ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
57 cp $filename $filename.bak
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
58 fi
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
59
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
60 if [ "$url" = @MAINSITE@ ] ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
61 cat $PREFDIR/bestsites | while read mainsite ; do
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
62 echo Downloading $filename from $mainsite ...
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
63 wget -v -c -N $mainsite/$dir/$filename || true
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
64 if [ -r "$filename" ] ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
65 UNPACK "$filename"
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
66 [ -r $filename.bak ] && rm $filename.bak
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
67 return 0
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
68 fi
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
69 done
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
70 else
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
71 wget -v -c -N $url/$dir/$filename || true
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
72 if [ -r "$filename" ] ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
73 UNPACK "$filename"
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
74 [ -r $filename.bak ] && rm $filename.bak
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
75 return 0
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
76 fi
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
77 fi
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
78 }
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
79
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
80
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
81
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
82
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
83 UNPACK ()
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
84 {
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
85 filename="$1"
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
86 if [ ! -r $filename.bak ] || ! cmp $filename.bak $filename ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
87 echo Installing $filename ...
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
88 if [ -r $filename.list ] ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
89 tr '\n' '\000' < $filename.list | xargs -r0 rm || true
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
90 UNLINK $filename.list
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
91 rm $filename.list
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
92 fi
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
93
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
94 case "$filename" in
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
95 *.tar.gz)
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
96 tar xvzf $filename > $filename.list
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
97 #rm $filename
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
98 ;;
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
99 *.tgz)
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
100 tar xvzf $filename > $filename.list
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
101 #rm $filename
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
102 ;;
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
103 *.tar.bz2)
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
104 tar --bzip2 -xvf $filename > $filename.list
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
105 #rm $filename
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
106 ;;
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
107 esac
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
108 LINK $filename.list
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
109 echo "Installed $filename Succesfully!"
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
110 fi
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
111 }
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
112
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
113 LINK () {
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
114 cd $CODECDIR/
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
115 cat $CODECDIR/mplayer_binary_codecs/$1 | while read f ; do
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
116 ln -sbf mplayer_binary_codecs/"$f" .
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
117 done
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
118 }
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
119
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
120 UNLINK () {
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
121 ### FIXME
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
122 # cd $CODECDIR
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
123 # cat $CODECDIR/mplayer_binary_codecs/$1 | while f do
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
124 # ln -sbf mplayer_binary_codecs/"$f"
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
125 # done
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
126 if which symlinks > /dev/null ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
127 symlinks -d $CODECDIR
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
128 fi
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
129 }
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
130
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
131 if [ `whoami` != root ]; then
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
132 echo "You must be 'root' to use this script. Login as root first!"
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
133 exit 1
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
134 fi
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
135
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
136 case "$1" in
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
137 install)
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
138 choosemirror
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
139 cd $PREFDIR
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
140 #if [ ! -r codecs_list ] || find codecs_list -mtime +20 ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
141 echo 'Getting codecs list ...'
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
142 wget -nv -c -N $MYSITE/codecs_list || true
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
143 #fi
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
144
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
145 if grep -q "^$dpkgarch" $PREFDIR/codecs_list ] ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
146 egrep -v "^[[:space:]]*(#|$)" $PREFDIR/codecs_list | \
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
147 while read arch url dir file info ; do
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
148 if [ "$dpkgarch" = "$arch" ]; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
149 echo Installing $file $info...
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
150 INSTALL "$url" "$dir" "$file"
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
151 n=1
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
152 fi
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
153 done
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
154 else
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
155 echo "Sorry, no codecs for your arch '$dpkgarch'. Sorry dude :("
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
156 exit 1
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
157 fi
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
158 ;;
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
159
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
160 uninstall)
20831
0432c831819d typo, wrong variable name
diego
parents: 20450
diff changeset
161 cd $CODECDIR/
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
162 rm -rf mplayer_binary_codecs
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
163 #FIXME we need a better clean system
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
164 if which symlinks > /dev/null ; then
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
165 symlinks -d .
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
166 else
20831
0432c831819d typo, wrong variable name
diego
parents: 20450
diff changeset
167 echo "please install the package 'symlinks' and run 'symlinks -d $CODECDIR' "
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
168 fi
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
169 echo "Uninstalled Succesfully!"
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
170 ;;
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
171
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
172 *)
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
173 echo "Usage: {install|uninstall}"
20831
0432c831819d typo, wrong variable name
diego
parents: 20450
diff changeset
174 echo "This program will install binary codecs for MPlayer."
20450
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
175 exit 1
c53da7ea44a0 Sync with Debian package.
diego
parents: 15704
diff changeset
176 ;;
15586
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
177
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
178 esac
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
179
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
180
34cf1cf85ee3 old scripts from early debian package
alex
parents:
diff changeset
181 exit 0