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
48 test -s repomd.xml && repomdxml2solv -q type < repomd.xml
53 *.gz) gzip -dc "$1" ;;
54 *.bz2) bzip2 -dc "$1" ;;
55 *.lzma) lzma -dc "$1" ;;
62 if test -s "$1.xz" ; then
64 elif test -s "$1.lzma" ; then
66 elif test -s "$1.bz2" ; then
68 elif test -s "$1.gz" ; then
73 susetags_findfile_cat() {
74 if test -s "$1.xz" ; then
76 elif test -s "$1.lzma" ; then
78 elif test -s "$1.bz2" ; then
80 elif test -s "$1.gz" ; then
82 elif test -s "$1" ; then
87 # signal an error if there is a problem
92 parser_options=${PARSER_OPTIONS:-}
99 if test "$1" = "-o" ; then
103 elif test "$1" = "-R" ; then
108 elif test "$1" = "-X" ; then
111 elif test "$1" = "-A" ; then
121 if test -z "$repotype" ; then
122 # autodetect repository type
123 if test -d repodata -o -f repomd.xml; then
125 elif test_susetags ; then
132 if test "$repotype" = rpmmd ; then
133 test -d repodata && {
134 cd repodata || exit 2
138 primxml=`repomd_findfile primary primary.xml`
139 if test -n "$primxml" -a -s "$primxml" ; then
140 primfile=`mktemp` || exit 3
142 # fake tag to combine primary.xml and extensions
143 # like susedata.xml, other.xml, filelists.xml
145 if test -f $primxml ; then
146 repomd_decompress $primxml
150 susedataxml=`repomd_findfile susedata susedata.xml`
151 if test -f "$susedataxml" ; then
152 repomd_decompress "$susedataxml"
154 # all the languages as well
155 for t in `repomd_types` ; do
158 susedataxml=`repomd_findfile "$t" "$t.xml"`
159 if test -f "$susedataxml" ; then
160 repomd_decompress "$susedataxml"
166 ) | sed 's/<?xml[^>]*>//g' | sed '1i\<?xml version="1.0" encoding="UTF-8"?>' | rpmmd2solv $parser_options > $primfile || exit 4
170 prodxml=`repomd_findfile products products.xml`
171 if test -z "$prodxml" ; then
172 prodxml=`repomd_findfile product product.xml`
174 if test -n "$prodxml" -a -s "$prodxml" ; then
175 prodfile=`mktemp` || exit 3
176 repomd_decompress "$prodxml" | rpmmd2solv $parser_options > $prodfile || exit 4
180 patternxml=`repomd_findfile 'patterns' patterns.xml`
181 if test -n "$patternxml" -a -s "$patternxml" ; then
182 patternfile=`mktemp` || exit 3
183 repomd_decompress "$patternxml" | rpmmd2solv $parser_options > $patternfile || exit 4
186 # This contains repomd.xml
187 # for now we only read some keys like timestamp
189 repomdxml=`repomd_findfile '' repomd.xml`
190 if test -n "$repomdxml" -a -s "$repomdxml" ; then
191 repomdfile=`mktemp` || exit 3
192 repomd_decompress "$repomdxml" | repomdxml2solv $parser_options > $repomdfile || exit 4
195 # This contains suseinfo.xml, which is an extension to repomd.xml
196 # for now we only read some keys like expiration and products
198 suseinfoxml=`repomd_findfile suseinfo suseinfo.xml`
199 if test -n "$suseinfoxml" -a -s "$suseinfoxml" ; then
200 suseinfofile=`mktemp` || exit 3
201 repomd_decompress "$suseinfoxml" | repomdxml2solv $parser_options > $suseinfofile || exit 4
204 # This contains a updateinfo.xml* and maybe patches
206 updateinfoxml=`repomd_findfile updateinfo updateinfo.xml`
207 if test -n "$updateinfoxml" -a -s "$updateinfoxml" ; then
208 updateinfofile=`mktemp` || exit 3
209 repomd_decompress "$updateinfoxml" | updateinfoxml2solv $parser_options > $updateinfofile || exit 4
212 # This contains a deltainfo.xml*
214 deltainfoxml=`repomd_findfile deltainfo deltainfo.xml`
215 if test -z "$deltainfoxml"; then
216 deltainfoxml=`repomd_findfile prestodelta prestodelta.xml`
218 if test -n "$deltainfoxml" -a -s "$deltainfoxml" ; then
219 deltainfofile=`mktemp` || exit 3
220 repomd_decompress "$deltainfoxml" | deltainfoxml2solv $parser_options > $deltainfofile || exit 4
223 # This contains appdata
226 if test -x /usr/bin/appdata2solv ; then
227 appdataxml=`repomd_findfile appdata appdata.xml`
229 if test -n "$appdataxml" -a -s "$appdataxml" ; then
230 appdatafile=`mktemp` || exit 3
231 repomd_decompress "$appdataxml" | appdata2solv $parser_options > $appdatafile || exit 4
234 # Now merge primary, patches, updateinfo, and deltainfo
235 mergesolv $addautooption $repomdfile $suseinfofile $primfile $prodfile $patternfile $updateinfofile $deltainfofile $appdatafile
236 rm -f $repomdfile $suseinfofile $primfile $patternfile $prodfile $updateinfofile $deltainfofile $appdatafile
238 elif test "$repotype" = susetags ; then
240 DESCR=$(get_DESCRDIR)
241 cd ${DESCR} || exit 2
244 if test -x /usr/bin/appdata2solv ; then
245 appdataxml=`susetags_findfile appdata.xml`
247 if test -n "$appdataxml" ; then
248 appdatafile=`mktemp` || exit 3
249 repomd_decompress "$appdataxml" | appdata2solv $parser_options > $appdatafile || exit 4
250 parser_options="-M $appdatafile $parser_options"
254 susetags_findfile_cat packages
257 susetags_findfile_cat packages.DU
259 # Now default language
260 susetags_findfile_cat packages.en
263 susetags_findfile_cat packages.DL
265 # Now patterns. Not simply those files matching *.pat{,.gz,bz2},
266 # but only those mentioned in the file 'patterns'
267 if test -f patterns ; then
268 for i in `cat patterns`; do
269 if test -s "$i" ; then
270 repomd_decompress "$i"
275 # Now all other packages.{lang}. Needs to come last as it switches
276 # languages for all following susetags files
277 for i in packages.* ; do
279 *.gz|*.bz2|*.xz|*.lzma) name="${i%.*}" ;;
283 # ignore files we handled already
284 *.DU | *.en | *.FL | *.DL | packages ) continue ;;
286 suff=${name#packages.}
288 repomd_decompress "$i"
292 ) | susetags2solv $addautooption -c "${olddir}/content" $parser_options || exit 4
293 test -n "$appdatafile" && rm -f "$appdatafile"
295 elif test "$repotype" = plaindir ; then
296 find * -name .\* -prune -o $findopt -name \*.delta.rpm -o -name \*.patch.rpm -o -name \*.rpm -a -type f -print0 | rpms2solv $addautooption -0 -m -
298 echo "unknown repository type '$repotype'" >&2