Imported Upstream version 0.6.19
[platform/upstream/libsolv.git] / tools / repo2solv.sh
index c3f968a..49b623a 100755 (executable)
@@ -28,7 +28,7 @@ repomd_findfile() {
   local p=$2
   local f
   if test -n "$t" -a -s repomd.xml ; then
-    f=`repomdxml2solv -q $t:location < repomd.xml 2>/dev/null`
+    f=`repomdxml2solv -q "$t:location" < repomd.xml 2>/dev/null`
     f=${f##*/}
     if test -f "$f" ; then
       echo "$f"
@@ -44,6 +44,10 @@ repomd_findfile() {
   fi
 }
 
+repomd_types() {
+  test -s repomd.xml && repomdxml2solv -q type < repomd.xml
+}
+
 repomd_decompress() {
   case $1 in
    *.gz) gzip -dc "$1" ;;
@@ -104,6 +108,8 @@ while true ; do
   elif test "$1" = "-X" ; then
     addautooption=-X
     shift
+  elif test "$1" = "-A" ; then
+    shift
   else
     break
   fi
@@ -145,8 +151,19 @@ if test "$repotype" = rpmmd ; then
      if test -f "$susedataxml" ; then
        repomd_decompress "$susedataxml"
      fi
+     # all the languages as well
+     for t in `repomd_types` ; do
+       case "$t" in
+           susedata.*)
+               susedataxml=`repomd_findfile "$t" "$t.xml"`
+               if test -f "$susedataxml" ; then
+                   repomd_decompress "$susedataxml"
+               fi
+           ;;
+       esac
+     done
      echo '</rpmmd>'
-    ) | grep -v '\?xml' |  sed '1i\<?xml version="1.0" encoding="UTF-8"?>' | rpmmd2solv $parser_options > $primfile || exit 4
+    ) | sed 's/<?xml[^>]*>//g' | sed '1i\<?xml version="1.0" encoding="UTF-8"?>' | rpmmd2solv $parser_options > $primfile || exit 4
   fi
 
   prodfile=
@@ -204,8 +221,11 @@ if test "$repotype" = rpmmd ; then
   fi
 
   # This contains appdata
+  appdataxml=
   appdatafile=
-  appdataxml=`repomd_findfile appdata appdata.xml`
+  if test -x /usr/bin/appdata2solv ; then
+      appdataxml=`repomd_findfile appdata appdata.xml`
+  fi
   if test -n "$appdataxml" -a -s "$appdataxml" ; then
       appdatafile=`mktemp` || exit 3
       repomd_decompress "$appdataxml" | appdata2solv $parser_options > $appdatafile || exit 4
@@ -219,8 +239,11 @@ elif test "$repotype" = susetags ; then
   olddir=`pwd`
   DESCR=$(get_DESCRDIR)
   cd ${DESCR} || exit 2
+  appdataxml=
   appdatafile=
-  appdataxml=`susetags_findfile appdata.xml`
+  if test -x /usr/bin/appdata2solv ; then
+      appdataxml=`susetags_findfile appdata.xml`
+  fi
   if test -n "$appdataxml" ; then
       appdatafile=`mktemp` || exit 3
       repomd_decompress "$appdataxml" | appdata2solv $parser_options > $appdatafile || exit 4
@@ -236,6 +259,9 @@ elif test "$repotype" = susetags ; then
     # Now default language
     susetags_findfile_cat packages.en
 
+    # DL (delta rpms)
+    susetags_findfile_cat packages.DL
+
     # Now patterns.  Not simply those files matching *.pat{,.gz,bz2},
     # but only those mentioned in the file 'patterns'
     if test -f patterns ; then
@@ -255,7 +281,7 @@ elif test "$repotype" = susetags ; then
       esac
       case $name in
        # ignore files we handled already
-       *.DU | *.en | *.FL | packages ) continue ;;
+       *.DU | *.en | *.FL | *.DL | packages ) continue ;;
        *)
          suff=${name#packages.}
          echo "=Lan: $suff"