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" ;;
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
69 susetags_findfile_cat() {
70 if test -s "$1.xz" ; then
72 elif test -s "$1.lzma" ; then
74 elif test -s "$1.bz2" ; then
76 elif test -s "$1.gz" ; then
78 elif test -s "$1" ; then
83 # signal an error if there is a problem
88 parser_options=${PARSER_OPTIONS:-}
95 if test "$1" = "-o" ; then
99 elif test "$1" = "-R" ; then
104 elif test "$1" = "-X" ; then
107 elif test "$1" = "-A" ; then
117 if test -z "$repotype" ; then
118 # autodetect repository type
119 if test -d repodata -o -f repomd.xml; then
121 elif test_susetags ; then
128 if test "$repotype" = rpmmd ; then
129 test -d repodata && {
130 cd repodata || exit 2
134 primxml=`repomd_findfile primary primary.xml`
135 if test -n "$primxml" -a -s "$primxml" ; then
136 primfile=`mktemp` || exit 3
138 # fake tag to combine primary.xml and extensions
139 # like susedata.xml, other.xml, filelists.xml
141 if test -f $primxml ; then
142 repomd_decompress $primxml
146 susedataxml=`repomd_findfile susedata susedata.xml`
147 if test -f "$susedataxml" ; then
148 repomd_decompress "$susedataxml"
151 ) | grep -v '\?xml' | sed '1i\<?xml version="1.0" encoding="UTF-8"?>' | rpmmd2solv $parser_options > $primfile || exit 4
155 prodxml=`repomd_findfile products products.xml`
156 if test -z "$prodxml" ; then
157 prodxml=`repomd_findfile product product.xml`
159 if test -n "$prodxml" -a -s "$prodxml" ; then
160 prodfile=`mktemp` || exit 3
161 repomd_decompress "$prodxml" | rpmmd2solv $parser_options > $prodfile || exit 4
165 patternxml=`repomd_findfile 'patterns' patterns.xml`
166 if test -n "$patternxml" -a -s "$patternxml" ; then
167 patternfile=`mktemp` || exit 3
168 repomd_decompress "$patternxml" | rpmmd2solv $parser_options > $patternfile || exit 4
171 # This contains repomd.xml
172 # for now we only read some keys like timestamp
174 repomdxml=`repomd_findfile '' repomd.xml`
175 if test -n "$repomdxml" -a -s "$repomdxml" ; then
176 repomdfile=`mktemp` || exit 3
177 repomd_decompress "$repomdxml" | repomdxml2solv $parser_options > $repomdfile || exit 4
180 # This contains suseinfo.xml, which is an extension to repomd.xml
181 # for now we only read some keys like expiration and products
183 suseinfoxml=`repomd_findfile suseinfo suseinfo.xml`
184 if test -n "$suseinfoxml" -a -s "$suseinfoxml" ; then
185 suseinfofile=`mktemp` || exit 3
186 repomd_decompress "$suseinfoxml" | repomdxml2solv $parser_options > $suseinfofile || exit 4
189 # This contains a updateinfo.xml* and maybe patches
191 updateinfoxml=`repomd_findfile updateinfo updateinfo.xml`
192 if test -n "$updateinfoxml" -a -s "$updateinfoxml" ; then
193 updateinfofile=`mktemp` || exit 3
194 repomd_decompress "$updateinfoxml" | updateinfoxml2solv $parser_options > $updateinfofile || exit 4
197 # This contains a deltainfo.xml*
199 deltainfoxml=`repomd_findfile deltainfo deltainfo.xml`
200 if test -z "$deltainfoxml"; then
201 deltainfoxml=`repomd_findfile prestodelta prestodelta.xml`
203 if test -n "$deltainfoxml" -a -s "$deltainfoxml" ; then
204 deltainfofile=`mktemp` || exit 3
205 repomd_decompress "$deltainfoxml" | deltainfoxml2solv $parser_options > $deltainfofile || exit 4
208 # This contains appdata
211 if test -x /usr/bin/appdata2solv ; then
212 appdataxml=`repomd_findfile appdata appdata.xml`
214 if test -n "$appdataxml" -a -s "$appdataxml" ; then
215 appdatafile=`mktemp` || exit 3
216 repomd_decompress "$appdataxml" | appdata2solv $parser_options > $appdatafile || exit 4
219 # Now merge primary, patches, updateinfo, and deltainfo
220 mergesolv $addautooption $repomdfile $suseinfofile $primfile $prodfile $patternfile $updateinfofile $deltainfofile $appdatafile
221 rm -f $repomdfile $suseinfofile $primfile $patternfile $prodfile $updateinfofile $deltainfofile $appdatafile
223 elif test "$repotype" = susetags ; then
225 DESCR=$(get_DESCRDIR)
226 cd ${DESCR} || exit 2
229 if test -x /usr/bin/appdata2solv ; then
230 appdataxml=`susetags_findfile appdata.xml`
232 if test -n "$appdataxml" ; then
233 appdatafile=`mktemp` || exit 3
234 repomd_decompress "$appdataxml" | appdata2solv $parser_options > $appdatafile || exit 4
235 parser_options="-M $appdatafile $parser_options"
239 susetags_findfile_cat packages
242 susetags_findfile_cat packages.DU
244 # Now default language
245 susetags_findfile_cat packages.en
247 # Now patterns. Not simply those files matching *.pat{,.gz,bz2},
248 # but only those mentioned in the file 'patterns'
249 if test -f patterns ; then
250 for i in `cat patterns`; do
251 if test -s "$i" ; then
252 repomd_decompress "$i"
257 # Now all other packages.{lang}. Needs to come last as it switches
258 # languages for all following susetags files
259 for i in packages.* ; do
261 *.gz|*.bz2|*.xz|*.lzma) name="${i%.*}" ;;
265 # ignore files we handled already
266 *.DU | *.en | *.FL | packages ) continue ;;
268 suff=${name#packages.}
270 repomd_decompress "$i"
274 ) | susetags2solv $addautooption -c "${olddir}/content" $parser_options || exit 4
275 test -n "$appdatafile" && rm -f "$appdatafile"
277 elif test "$repotype" = plaindir ; then
278 find * -name .\* -prune -o $findopt -name \*.delta.rpm -o -name \*.patch.rpm -o -name \*.rpm -a -type f -print0 | rpms2solv $addautooption -0 -m -
280 echo "unknown repository type '$repotype'" >&2