remove obsolete states, add support for product type, fix flags parsing
[platform/upstream/libsolv.git] / tools / repo2solv.sh
index e07755e..3f24e17 100755 (executable)
@@ -98,7 +98,7 @@ cd "$dir" || exit 1
 
 if test -z "$repotype" ; then
   # autodetect repository type
-  if test -d repodata ; then
+  if test -d repodata -o -f repomd.xml; then
     repotype=rpmmd
   elif test_susetags ; then
     repotype=susetags
@@ -108,7 +108,9 @@ if test -z "$repotype" ; then
 fi
 
 if test "$repotype" = rpmmd ; then
-  cd repodata || exit 2
+  test -d repodata && {
+    cd repodata || exit 2
+  }
 
   primfile=
   primxml=`repomd_findfile primary primary.xml`
@@ -124,8 +126,8 @@ if test "$repotype" = rpmmd ; then
         echo
      fi
      susedataxml=`repomd_findfile susedata susedata.xml`
-     if test -f $susedataxml ; then
-       repomd_decompress $susedataxml
+     if test -f "$susedataxml" ; then
+       repomd_decompress "$susedataxml"
      fi
      echo '</rpmmd>'
     ) | grep -v '\?xml' |  sed '1i\<?xml version="1.0" encoding="UTF-8"?>' | rpmmd2solv $parser_options > $primfile || exit 4
@@ -137,12 +139,8 @@ if test "$repotype" = rpmmd ; then
     prodxml=`repomd_findfile product product.xml`
   fi
   if test -n "$prodxml" -a -s "$prodxml" ; then
-    prodfile=`mktemp` || exit 3
-    (
-     echo '<products>'
-     repomd_decompress "$prodxml"
-     echo '</products>'
-    ) | grep -v '\?xml' | rpmmd2solv $parser_options > $prodfile || exit 4
+      prodfile=`mktemp` || exit 3
+      repomd_decompress "$prodxml" | rpmmd2solv $parser_options > $prodfile || exit 4
   fi
 
   patternfile=