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" ;;
51 *.lzma) lzma -dc "$1" ;;
57 susetags_findfile_cat() {
58 if test -s "$1.xz" ; then
60 elif test -s "$1.lzma" ; then
62 elif test -s "$1.bz2" ; then
64 elif test -s "$1.gz" ; then
66 elif test -s "$1" ; then
71 # signal an error if there is a problem
76 parser_options=${PARSER_OPTIONS:-}
82 if test "$1" = "-o" ; then
86 elif test "$1" = "-R" ; then
99 if test -z "$repotype" ; then
100 # autodetect repository type
101 if test -d repodata ; then
103 elif test_susetags ; then
110 if test "$repotype" = rpmmd ; then
111 cd repodata || exit 2
114 primxml=`repomd_findfile primary primary.xml`
115 if test -n "$primxml" -a -s "$primxml" ; then
116 primfile=`mktemp` || exit 3
118 # fake tag to combine primary.xml and extensions
119 # like susedata.xml, other.xml, filelists.xml
121 if test -f $primxml ; then
122 repomd_decompress $primxml
126 susedataxml=`repomd_findfile susedata susedata.xml`
127 if test -f $susedataxml ; then
128 repomd_decompress $susedataxml
131 ) | grep -v '\?xml' | sed '1i\<?xml version="1.0" encoding="UTF-8"?>' | rpmmd2solv $parser_options > $primfile || exit 4
135 prodxml=`repomd_findfile products products.xml`
136 if test -z "$prodxml" ; then
137 prodxml=`repomd_findfile product product.xml`
139 if test -n "$prodxml" -a -s "$prodxml" ; then
140 prodfile=`mktemp` || exit 3
143 repomd_decompress "$prodxml"
145 ) | grep -v '\?xml' | rpmmd2solv $parser_options > $prodfile || exit 4
149 patternxml=`repomd_findfile 'patterns' patterns.xml`
150 if test -n "$patternxml" -a -s "$patternxml" ; then
151 patternfile=`mktemp` || exit 3
152 repomd_decompress "$patternxml" | rpmmd2solv $parser_options > $patternfile || exit 4
155 # This contains repomd.xml
156 # for now we only read some keys like timestamp
158 repomdxml=`repomd_findfile '' repomd.xml`
159 if test -n "$repomdxml" -a -s "$repomdxml" ; then
160 repomdfile=`mktemp` || exit 3
161 repomd_decompress "$repomdxml" | repomdxml2solv $parser_options > $repomdfile || exit 4
164 # This contains suseinfo.xml, which is an extension to repomd.xml
165 # for now we only read some keys like expiration and products
167 suseinfoxml=`repomd_findfile suseinfo suseinfo.xml`
168 if test -n "$suseinfoxml" -a -s "$suseinfoxml" ; then
169 suseinfofile=`mktemp` || exit 3
170 repomd_decompress "$suseinfoxml" | repomdxml2solv $parser_options > $suseinfofile || exit 4
173 # This contains a updateinfo.xml* and maybe patches
175 updateinfoxml=`repomd_findfile updateinfo updateinfo.xml`
176 if test -n "$updateinfoxml" -a -s "$updateinfoxml" ; then
177 updateinfofile=`mktemp` || exit 3
178 repomd_decompress "$updateinfoxml" | updateinfoxml2solv $parser_options > $updateinfofile || exit 4
181 # This contains a deltainfo.xml*
183 deltainfoxml=`repomd_findfile deltainfo deltainfo.xml`
184 if test -z "$deltainfoxml"; then
185 deltainfoxml=`repomd_findfile prestodelta prestodelta.xml`
187 if test -n "$deltainfoxml" -a -s "$deltainfoxml" ; then
188 deltainfofile=`mktemp` || exit 3
189 repomd_decompress "$deltainfoxml" | deltainfoxml2solv $parser_options > $deltainfofile || exit 4
192 # Now merge primary, patches, updateinfo, and deltainfo
193 mergesolv $repomdfile $suseinfofile $primfile $prodfile $patternfile $updateinfofile $deltainfofile
194 rm -f $repomdfile $suseinfofile $primfile $patternfile $prodfile $updateinfofile $deltainfofile
196 elif test "$repotype" = susetags ; then
198 DESCR=$(get_DESCRDIR)
199 cd ${DESCR} || exit 2
202 susetags_findfile_cat packages
205 susetags_findfile_cat packages.DU
207 # Now default language
208 susetags_findfile_cat packages.en
210 # Now patterns. Not simply those files matching *.pat{,.gz,bz2},
211 # but only those mentioned in the file 'patterns'
212 if test -f patterns ; then
213 for i in `cat patterns`; do
214 if test -s "$i" ; then
215 repomd_decompress "$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|*.bz2|*.xz|*.lzma) name="${i%.*}" ;;
228 # ignore files we handled already
229 *.DU | *.en | *.FL | packages ) continue ;;
231 suff=${name#packages.}
233 repomd_decompress "$i"
237 ) | susetags2solv -c "${olddir}/content" $parser_options || exit 4
239 elif test "$repotype" = plaindir ; then
240 find * -name .\* -prune -o $findopt -name \*.delta.rpm -o -name \*.patch.rpm -o -name \*.rpm -a -type f -print0 | rpms2solv -0 -m -
242 echo "unknown repository type '$repotype'" >&2