[MPlayer-dev-eng] TOOLS/binary_codecs.sh update

Reinhard Tartler siretart at tauware.de
Wed Oct 13 17:53:58 CEST 2010


hi,

The original author of TOOLS/binary_codecs.sh proposed three changes,
two of which I found clear and easy to understand and committed it. The
last one made me think. I'm talking about this change:

Index: binary_codecs.sh
===================================================================
--- binary_codecs.sh	(Revision 32485)
+++ binary_codecs.sh	(Arbeitskopie)
@@ -20,6 +20,36 @@
 cd $CODECDIR
 [ -d mplayer_binary_codecs ] || mkdir -v mplayer_binary_codecs
 
+mywget ()
+{
+    # note the the URL must be the first option
+    t=`tempfile`
+    #check that we are not redirected
+    if LANG=C LC_ALL=C LC_MESSAGES=C wget --spider -S -o $t "$1" ; then
+       if egrep -qx ' *HTTP.* 302 Found' $t ; then
+         echo Error, there is an unexpected redirection, for the
+         echo URL "$1" 
+         echo that is redirected to
+	 grep Location $t | head -n 1 
+         echo See more info in the log in $t
+         echo 
+         return 1
+       else
+         rm $t
+       fi
+    else
+       echo Errors while checking URL "$1" 
+       echo See the log in  $t
+       return 1
+    fi
+    url="$1"
+    shift
+    if wget "$@" "$url" ; then 
+     return 0
+    else
+     return 1
+    fi
+}
 
 choosemirror ()
 {
@@ -27,7 +57,7 @@
 
   #if [ ! -r mirrors ] || find mirrors -mtime +20 ; then
     echo "Downloading mirrors list"
-    wget -nv -c -N $MYSITE/mirrors || true
+    mywget $MYSITE/mirrors -nv -c -N  || true
   #fi
   if [ ! -r bestsites ] || [ mirrors -nt bestsites ] || \
     find bestsites -mtime +20 | grep -q bestsites ; then
@@ -65,15 +95,13 @@
     test -r $list || list=$PREFDIR/mirrors
     cat $list | while read mainsite ; do
       echo Downloading $filename from $mainsite ...
-      wget -c -N $mainsite/$dir/$filename || true
-      if [ -r "$filename" ] ; then
+      if mywget $mainsite/$dir/$filename -c -N && [ -r "$filename" ] ; then
         UNPACK "$filename"
         return 0
       fi
     done
   else
-    wget -c -N $url/$dir/$filename || true
-    if [ -r "$filename" ] ; then
+    if mywget  $url/$dir/$filename -c -N && [ -r "$filename" ] ; then
       UNPACK "$filename"
       return 0
     fi
@@ -159,13 +187,13 @@
     cd $PREFDIR
     #if [ ! -r codecs_list ] || find codecs_list -mtime +20 ; then
       echo "Getting codecs list"
-      wget -nv -c -N $MYSITE/codecs_list || true
+      mywget $MYSITE/codecs_list -nv -c -N  || true
     #fi
 
     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
+    if mywget http://www.mplayerhq.hu/MPlayer/releases/codecs/MD5SUMS -nv -N  ; then
       [ -r MD5SUMS.bak ] && rm MD5SUMS.bak
     else
       echo "failed"


My thoughts:

 - I haven't tested it myself yet, but if it works (I suppose it does),
   I'm inclined to include it
 - is that mywget approach somewhat sane?
 - should we host the files at
   http://people.debian.org/~mennucc1/mplayer/ somewhere on mplayerhq.hu
   instead? I mean we are in a good position to keep them
   up-to-date. OTOH, this is a debian/ubuntu specific service, so before
   doing this, I'd like to hear some comments on this.

-- 
Gruesse/greetings,
Reinhard Tartler, KeyID 945348A4


More information about the MPlayer-dev-eng mailing list