4 # give it a directory of a local mirror of a repo and this
5 # tries to detect the repo type and generate one SOLV file on stdout
8 local d=$(grep '^DESCRDIR' content | sed 's/^DESCRDIR[[:space:]]\+\(.*[^[:space:]]\)[[:space:]]*$/\1/')
17 if test -s content; then
30 if test -n "$t" -a -s repomd.xml ; then
31 f=`repomdxml2solv -q $t:location < repomd.xml 2>/dev/null`
33 if test -f "$f" ; then
38 if test -f "$p.bz2" ; then
40 elif test -f "$p.gz" ; then
42 elif test -f "$p" ; then
49 *.gz) gzip -dc "$1" ;;
50 *.bz2) bzip2 -dc "$1" ;;
55 # signal an error if there is a problem
60 parser_options=${PARSER_OPTIONS:-}
66 if test "$1" = "-o" ; then
70 elif test "$1" = "-R" ; then
83 if test -z "$repotype" ; then
84 # autodetect repository type
85 if test -d repodata ; then
87 elif test_susetags ; then
94 if test "$repotype" = rpmmd ; then
98 primxml=`repomd_findfile primary primary.xml`
99 if test -n "$primxml" -a -s "$primxml" ; then
100 primfile=`mktemp` || exit 3
102 # fake tag to combine primary.xml and extensions
103 # like susedata.xml, other.xml, filelists.xml
105 if test -f $primxml ; then
106 repomd_decompress $primxml
110 susedataxml=`repomd_findfile susedata susedata.xml`
111 if test -f $susedataxml ; then
112 repomd_decompress $susedataxml
115 ) | grep -v '\?xml' | sed '1i\<?xml version="1.0" encoding="UTF-8"?>' | rpmmd2solv $parser_options > $primfile || exit 4
119 if test -f product.xml; then
120 prodfile=`mktemp` || exit 3
123 for i in product*.xml*; do
127 ) | grep -v '\?xml' | rpmmd2solv $parser_options > $prodfile || exit 4
131 patternxml=`repomd_findfile '' patterns.xml`
132 if test -n "$patternxml" -a -s "$patternxml" ; then
133 patternfile=`mktemp` || exit 3
134 repomd_decompress "$patternxml" | rpmmd2solv $parser_options > $patternfile || exit 4
137 # This contains repomd.xml
138 # for now we only read some keys like timestamp
140 repomdxml=`repomd_findfile '' repomd.xml`
141 if test -n "$repomdxml" -a -s "$repomdxml" ; then
142 repomdfile=`mktemp` || exit 3
143 repomd_decompress "$repomdxml" | repomdxml2solv $parser_options > $repomdfile || exit 4
146 # This contains suseinfo.xml, which is an extension to repomd.xml
147 # for now we only read some keys like expiration and products
149 suseinfoxml=`repomd_findfile '' suseinfo.xml`
150 if test -n "$suseinfoxml" -a -s "$suseinfoxml" ; then
151 suseinfofile=`mktemp` || exit 3
152 repomd_decompress "$suseinfoxml" | repomdxml2solv $parser_options > $suseinfofile || exit 4
155 # This contains a updateinfo.xml* and maybe patches
157 updateinfoxml=`repomd_findfile updateinfo updateinfo.xml`
158 if test -n "$updateinfoxml" -a -s "$updateinfoxml" ; then
159 updateinfofile=`mktemp` || exit 3
160 repomd_decompress "$updateinfoxml" | updateinfoxml2solv $parser_options > $updateinfofile || exit 4
163 # This contains a deltainfo.xml*
165 deltainfoxml=`repomd_findfile deltainfo deltainfo.xml`
166 if test -n "$deltainfoxml" -a -s "$deltainfoxml" ; then
167 deltainfofile=`mktemp` || exit 3
168 repomd_decompress "$deltainfoxml" | deltainfoxml2solv $parser_options > $deltainfofile || exit 4
171 # Now merge primary, patches, updateinfo, and deltainfo
172 mergesolv $repomdfile $suseinfofile $primfile $prodfile $patternfile $updateinfofile $deltainfofile
173 rm -f $repomdfile $suseinfofile $primfile $patternfile $prodfile $updateinfofile $deltainfofile
175 elif test "$repotype" = susetags ; then
177 DESCR=$(get_DESCRDIR)
178 cd ${DESCR} || exit 2
181 if test -s packages.gz; then
183 elif test -s packages.bz2; then
184 bzip2 -dc packages.bz2
185 elif test -s packages; then
190 if test -s packages.DU.gz; then
191 gzip -dc packages.DU.gz
192 elif test -s packages.DU.bz2; then
193 bzip2 -dc packages.DU.bz2
194 elif test -s packages.DU; then
198 # Now default language
199 if test -s packages.en.gz; then
200 gzip -dc packages.en.gz
201 elif test -s packages.en.bz2; then
202 bzip2 -dc packages.en.bz2
203 elif test -s packages.en; then
207 # Now patterns. Not simply those files matching *.pat{,.gz,bz2},
208 # but only those mentioned in the file 'patterns'
209 if test -f patterns; then
210 for i in `cat patterns`; do
211 test -s "$i" || continue
213 *.gz) gzip -dc "$i" ;;
214 *.bz2) bzip2 -dc "$i" ;;
220 # Now all other packages.{lang}. Needs to come last as it switches
221 # languages for all following susetags files
222 for i in packages.*; do
224 *.gz) name="${i%.gz}" ; prog="gzip -dc" ;;
225 *.bz2) name="${i%.bz2}" ; prog="bzip2 -dc" ;;
226 *) name="$i"; prog=cat ;;
229 # ignore files we handled already
230 *.DU | *.en | *.FL | packages ) continue ;;
232 suff=${name#packages.}
238 ) | susetags2solv -c "${olddir}/content" $parser_options || exit 4
240 elif test "$repotype" = plaindir ; then
241 find * -name .\* -prune -o $findopt -name \*.delta.rpm -o -name \*.patch.rpm -o -name \*.rpm -a -type f -print0 | rpms2solv -0 -m -
243 echo "unknown repository type '$repotype'" >&2