From 00e9adf2df73a0df86fcb158fce3715f6a484f75 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 15 Feb 2017 09:57:32 +0100 Subject: checkAllRepos verbessert --- checkAllRepos | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'checkAllRepos') diff --git a/checkAllRepos b/checkAllRepos index fbe7c1bd5..c27d63bfb 100755 --- a/checkAllRepos +++ b/checkAllRepos @@ -2,27 +2,35 @@ usage() { >&2 echo 'Verwendung:' - >&2 echo "${ich} [-d|--download URL] [-a|--alle] [-s|--suche wonach] [-i|--intensiv] [-x|--exakt]" + >&2 echo "${ich}"' [-d|--download URL] [-a|--alle] [-s|--suche wonach] [-i|--intensiv] [-x|--exakt] [-l|--leise]' exit 1 } verpackung() { typ="$(file -bizL "$1")" case "${typ}" in + "application/x-tar; charset=binary") + ;; "application/x-tar; charset=binary compressed-encoding=application/x-xz; charset=binary") echo "-J" ;; + "application/x-tar; charset=binary compressed-encoding=application/x-bzip2; charset=binary") + echo "-j" + ;; "application/x-tar; charset=binary compressed-encoding=application/x-gzip; charset=binary" | \ "application/octet-stream; charset=binary compressed-encoding=application/x-gzip; charset=binary") echo "-z" ;; "ERROR: (null)" | \ "inode/x-empty; charset=binary") + return 1 ;; *) - >&2 echo "FEHLER: Unbekannter Verpackungstyp '${typ}'" + ${leise} || >&2 echo "FEHLER: Unbekannter Verpackungstyp '${typ}'" + return 1 ;; esac + return 0 } ich="$(readlink -f "$0")" @@ -30,11 +38,12 @@ pfad="$(dirname "${ich}")/.checkAllRepos" [ ! -d "${pfad}" ] && mkdir -p "${pfad}" eval set -- "$( - getopt -o ad:is:x \ + getopt -o ad:ils:x \ --long alle \ --long download: \ --long exakt \ --long intensiv \ + --long leise \ --long suche: \ -n "$(basename "$0")" \ -- "$@" \ @@ -46,10 +55,15 @@ unset downloads suchen alle=false exakt=false intensiv=false +leise=false +flag_l='' while true do case "$1" in + -a|--alle) + alle=true + ;; -d|--download) shift if [ -n "$1" ] @@ -57,15 +71,13 @@ do downloads[${#downloads[@]}]="$1" fi ;; - -a|--alle) - alle=true - ;; - -x|--exakt) - exakt=true - ;; -i|--intensiv) intensiv=true ;; + -l|--leise) + leise=true + flag_l="-l" + ;; -s|--suche) shift if [ -n "$1" ] @@ -73,6 +85,9 @@ do suchen[${#suchen[@]}]="$1" fi ;; + -x|--exakt) + exakt=true + ;; --) shift break @@ -107,21 +122,18 @@ then sed "s|^
 \[\([^]]*\)].*\sServer = \(\S\+\)\(\s.*\)\?\$|\1 \2/\1.db|" | \
     sed "s|^\(\S\+\)\s\+\(.*\)\$repo|\1 \2\1|; s|\$arch|x86_64|" | \
     sed "s|^\S\+\s\+||" | \
-    parallel -j0 "${ich} -d {}"
+    parallel -j0 "${ich} ${flag_l} -d {}"
 fi
 
 for ((i=0;i<${#downloads[@]};i++))
 do
   err=false
   ziel="${pfad}/${downloads[${i}]##*/}"
-  curl -o "${ziel}" "${downloads[${i}]}" 2> /dev/null || err=true
+  wget -O "${ziel}" "${downloads[${i}]}" 2> /dev/null || err=true
   if ! ${err}
   then
-    verp=$(verpackung "${ziel}")
-    if ! tar ${verp} -tf "${ziel}" &> /dev/null
+    if ! verp=$(verpackung "${ziel}") || ! tar ${verp} -tf "${ziel}" &> /dev/null
     then
-      [ -n "${verp}" ] && \
-        echo tar ${verp} -tf "${ziel}" || \
       err=true
     fi
   fi
@@ -129,7 +141,7 @@ do
   then
     rm -f "${ziel}"
   else
-    echo "${ziel##*/} erfolgreich heruntergeladen"
+    ${leise} || echo "${ziel##*/} erfolgreich heruntergeladen"
   fi
 done
 
@@ -139,7 +151,7 @@ do
   ${exakt} && suchName="^\(${suchName}\)-[^-]\+-[^-]\+\$"
   for db in ${pfad}/*.db
   do
-    if tar $(verpackung "${db}") -tf "${db}" | \
+    if tar $(verpackung "${db}") -tf "${db}" 2> /dev/null | \
       grep "/\$" |
       sed "s|/\$||" |
       grep -q "${suchName}"
@@ -153,10 +165,10 @@ do
     fi
     if ${intensiv}
     then
-      for pkg in $(tar $(verpackung "${db}") -tf "${db}" --wildcards "*/desc")
+      for pkg in $(tar $(verpackung "${db}") -tf "${db}" --wildcards "*/desc" 2> /dev/null)
       do
         inhalt="$(
-          tar $(verpackung "${db}") -Oxf "${db}" "${pkg}" | \
+          tar $(verpackung "${db}") -Oxf "${db}" "${pkg}" 2> /dev/null | \
             sed '
               :begin;
                 $!N;
-- 
cgit v1.2.3-70-g09d2