case $1 in
*.gz) gzip -dc "$1" ;;
*.bz2) bzip2 -dc "$1" ;;
+ *.lzma) lzma -dc "$1" ;;
+ *.xz) xz -dc "$1" ;;
*) cat "$1" ;;
esac
}
+susetags_findfile_cat() {
+ if test -s "$1.xz" ; then
+ xz -dc "$1.xz"
+ elif test -s "$1.lzma" ; then
+ lzma -dc "$1.lzma"
+ elif test -s "$1.bz2" ; then
+ bzip2 -dc "$1.bz2"
+ elif test -s "$1.gz" ; then
+ gzip -dc "$1.gz"
+ elif test -s "$1" ; then
+ cat "$1"
+ fi
+}
+
# signal an error if there is a problem
set -e
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
fi
if test "$repotype" = rpmmd ; then
- cd repodata || exit 2
+ test -d repodata && {
+ cd repodata || exit 2
+ }
primfile=
primxml=`repomd_findfile primary primary.xml`
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
fi
prodfile=
- if test -f product.xml; then
- prodfile=`mktemp` || exit 3
- (
- echo '<products>'
- for i in product*.xml*; do
- repomd_decompress $i
- done
- echo '</products>'
- ) | grep -v '\?xml' | rpmmd2solv $parser_options > $prodfile || exit 4
+ prodxml=`repomd_findfile products products.xml`
+ if test -z "$prodxml" ; then
+ prodxml=`repomd_findfile product product.xml`
+ fi
+ if test -n "$prodxml" -a -s "$prodxml" ; then
+ prodfile=`mktemp` || exit 3
+ repomd_decompress "$prodxml" | rpmmd2solv $parser_options > $prodfile || exit 4
fi
patternfile=
- patternxml=`repomd_findfile '' patterns.xml`
+ patternxml=`repomd_findfile 'patterns' patterns.xml`
if test -n "$patternxml" -a -s "$patternxml" ; then
patternfile=`mktemp` || exit 3
repomd_decompress "$patternxml" | rpmmd2solv $parser_options > $patternfile || exit 4
# This contains suseinfo.xml, which is an extension to repomd.xml
# for now we only read some keys like expiration and products
suseinfofile=
- suseinfoxml=`repomd_findfile '' suseinfo.xml`
+ suseinfoxml=`repomd_findfile suseinfo suseinfo.xml`
if test -n "$suseinfoxml" -a -s "$suseinfoxml" ; then
suseinfofile=`mktemp` || exit 3
repomd_decompress "$suseinfoxml" | repomdxml2solv $parser_options > $suseinfofile || exit 4
# This contains a deltainfo.xml*
deltainfofile=
deltainfoxml=`repomd_findfile deltainfo deltainfo.xml`
+ if test -z "$deltainfoxml"; then
+ deltainfoxml=`repomd_findfile prestodelta prestodelta.xml`
+ fi
if test -n "$deltainfoxml" -a -s "$deltainfoxml" ; then
deltainfofile=`mktemp` || exit 3
repomd_decompress "$deltainfoxml" | deltainfoxml2solv $parser_options > $deltainfofile || exit 4
cd ${DESCR} || exit 2
(
# First packages
- if test -s packages.gz; then
- gzip -dc packages.gz
- elif test -s packages.bz2; then
- bzip2 -dc packages.bz2
- elif test -s packages; then
- cat packages
- fi
+ susetags_findfile_cat packages
# DU
- if test -s packages.DU.gz; then
- gzip -dc packages.DU.gz
- elif test -s packages.DU.bz2; then
- bzip2 -dc packages.DU.bz2
- elif test -s packages.DU; then
- cat packages.DU
- fi
+ susetags_findfile_cat packages.DU
# Now default language
- if test -s packages.en.gz; then
- gzip -dc packages.en.gz
- elif test -s packages.en.bz2; then
- bzip2 -dc packages.en.bz2
- elif test -s packages.en; then
- cat packages.en
- fi
+ susetags_findfile_cat packages.en
# Now patterns. Not simply those files matching *.pat{,.gz,bz2},
# but only those mentioned in the file 'patterns'
- if test -f patterns; then
+ if test -f patterns ; then
for i in `cat patterns`; do
- test -s "$i" || continue
- case $i in
- *.gz) gzip -dc "$i" ;;
- *.bz2) bzip2 -dc "$i" ;;
- *) cat "$i" ;;
- esac
+ if test -s "$i" ; then
+ repomd_decompress "$i"
+ fi
done
fi
# Now all other packages.{lang}. Needs to come last as it switches
# languages for all following susetags files
- for i in packages.*; do
+ for i in packages.* ; do
case $i in
- *.gz) name="${i%.gz}" ; prog="gzip -dc" ;;
- *.bz2) name="${i%.bz2}" ; prog="bzip2 -dc" ;;
- *) name="$i"; prog=cat ;;
+ *.gz|*.bz2|*.xz|*.lzma) name="${i%.*}" ;;
+ *) name="$i" ;;
esac
case $name in
# ignore files we handled already
*)
suff=${name#packages.}
echo "=Lan: $suff"
- $prog "$i" ;;
+ repomd_decompress "$i"
esac
done