diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-05-08 23:50:26 +0300 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-05-08 23:50:26 +0300 |
commit | 1db1773ec27fc4e7c9d44ad02ccfa7eaf364ce07 (patch) | |
tree | c5e99bfe0e69cd37fb8ac70fadf00ce54a1cbe3c /TOOLS/binary_codecs.sh | |
parent | f2864e9a072f53c38a04dd7c44392521777dc908 (diff) | |
parent | 86c9fb2e8930de031807513c9b93d47394d2d2fa (diff) | |
download | mpv-1db1773ec27fc4e7c9d44ad02ccfa7eaf364ce07.tar.bz2 mpv-1db1773ec27fc4e7c9d44ad02ccfa7eaf364ce07.tar.xz |
Merge svn changes up to r29277
Diffstat (limited to 'TOOLS/binary_codecs.sh')
-rwxr-xr-x | TOOLS/binary_codecs.sh | 110 |
1 files changed, 77 insertions, 33 deletions
diff --git a/TOOLS/binary_codecs.sh b/TOOLS/binary_codecs.sh index c4ab61cf4b..410bede0f5 100755 --- a/TOOLS/binary_codecs.sh +++ b/TOOLS/binary_codecs.sh @@ -1,9 +1,12 @@ #!/bin/sh set -e +# avoid insecure tempfile creation +umask 0022 + # This script will download binary codecs for MPlayer unto a Debian system. -# Author: thuglife, mennucc1 +# Author: thuglife, mennucc1 # CODECDIR=/usr/lib/codecs @@ -22,23 +25,24 @@ choosemirror () { cd $PREFDIR - #if [ ! -r mirrors ] || find mirrors -mtime +20 ; then - echo Downloading mirrors list.. + #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 + find bestsites -mtime +20 | grep -q bestsites ; then + if which netselect > /dev/null ; then + echo Choosing best mirrors using netselect + netselect -s 5 -t 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 + fping -C 1 $( sed 's#.*//##;s#/.*##' mirrors ) 2>&1 | \ + egrep -v 'bytes.*loss' | sort -n -k3 | \ + grep -v ': *-' | awk '/:/{print $1}' | head -5 | ( while read mainsite ; do + grep $mainsite $PREFDIR/mirrors ; done ) > bestsites else - echo "(If you install 'netselect', it will select the best mirror for you" + echo "(If you install 'netselect' or 'fping', it will select the best mirror for you" echo " you may wish to stop this script and rerun after installation)" - sleep 5 + sleep 3 head -3 mirrors > bestsites fi fi @@ -54,24 +58,22 @@ INSTALL () { cd $CODECDIR/mplayer_binary_codecs if [ -r $filename ] ; then - cp $filename $filename.bak + cp $filename $filename.bak fi - if [ "$url" = @MAINSITE@ ] ; then - cat $PREFDIR/bestsites | while read mainsite ; do + if [ "$url" = @MAINSITE@ ] ; then + cat $PREFDIR/bestsites | while read mainsite ; do echo Downloading $filename from $mainsite ... - wget -v -c -N $mainsite/$dir/$filename || true + wget -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 + wget -c -N $url/$dir/$filename || true + if [ -r "$filename" ] ; then UNPACK "$filename" - [ -r $filename.bak ] && rm $filename.bak return 0 fi fi @@ -83,28 +85,41 @@ INSTALL () { 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 + if [ -r $filename.bak ] && cmp $filename.bak $filename && [ -r $filename.list ] ; then + echo It appears that $filename was already succesfully installed + [ -r $filename.bak ] && rm $filename.bak + else + if grep -q " $filename$" $PREFDIR/MD5SUMS ; then + echo Checking MD5 for $filename + grep " $filename$" $PREFDIR/MD5SUMS | md5sum -c - + else + echo Warning: no MD5 for $filename were found. Hit enter to continue. + read dummy + fi + echo Installing $filename ... + if [ -r $filename.list ] ; then + tr '\n' '\000' < $filename.list | xargs -r0 rm || true UNLINK $filename.list rm $filename.list fi + tarfail () { echo FAILED $filename ; rm $filename.list ; exit 1 ; } + case "$filename" in *.tar.gz) - tar xvzf $filename > $filename.list + tar xvzf $filename > $filename.list || tarfail #rm $filename ;; *.tgz) - tar xvzf $filename > $filename.list + tar xvzf $filename > $filename.list || tarfail #rm $filename ;; *.tar.bz2) - tar --bzip2 -xvf $filename > $filename.list + tar --bzip2 -xvf $filename > $filename.list || tarfail #rm $filename ;; esac + [ -r $filename.bak ] && rm $filename.bak LINK $filename.list echo "Installed $filename Succesfully!" fi @@ -135,22 +150,51 @@ fi case "$1" in install) + if test -x /bin/bzip2 || test -x /usr/bin/bzip2 ; then : ; else + echo You need to install bzip2 + exit 1 + fi choosemirror cd $PREFDIR - #if [ ! -r codecs_list ] || find codecs_list -mtime +20 ; then - echo 'Getting codecs list ...' + #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 + cd $PREFDIR + echo Downloading MD5 sums from main site + [ -r MD5SUMS ] && mv MD5SUMS MD5SUMS.bak + if wget -nv -N http://www.mplayerhq.hu/MPlayer/releases/codecs/MD5SUMS ; then + [ -r MD5SUMS.bak ] && rm MD5SUMS.bak + else + echo "failed" + if [ -r MD5SUMS.bak ] ; then + echo "trying to use backup" + mv MD5SUMS.bak MD5SUMS + fi + 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 + echo Downloading and installing $file $info... + INSTALL "$url" "$dir" "$file" fi done + needlibstd=no + test "$dpkgarch" = "powerpc" && needlibstd=yes + test "$dpkgarch" = "i386" && needlibstd=yes + if test "$needlibstd" = "yes" && ! test -r /usr/lib/libstdc++.so.5 ; then + echo "Warning: you need to install libstdc++ 5 libraries" + echo -n "Do it now? " + read R + case $R in + y*) apt-get install libstdc++5 ;; + *) echo "If you change your mind, use the command" + echo " apt-get install libstdc++5" ;; + esac + fi else echo "Sorry, no codecs for your arch '$dpkgarch'. Sorry dude :(" exit 1 |