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:]]*$/\1/')
17 if test -s content; then
26 # signal an error if there is a problem
31 parser_options=${PARSER_OPTIONS:-}
37 if test "$1" = "-o" ; then
41 elif test "$1" = "-R" ; then
54 if test -z "$repotype" ; then
55 # autodetect repository type
56 if test -d repodata ; then
58 elif test_susetags ; then
65 if test "$repotype" = rpmmd ; then
69 if test -f primary.xml || test -f primary.xml.gz || test -f primary.xml.bz2 ; then
70 primfile=`mktemp` || exit 3
72 # fake tag to combine primary.xml and extensions
73 # like susedata.xml, other.xml, filelists.xml
75 for i in primary.xml* susedata.xml*; do
76 test -s "$i" || continue
79 *.bz2) bzip2 -dc "$i";;
87 for i in susedata.xml*; do
88 test -s "$i" || continue
91 *.bz2) bzip2 -dc "$i";;
98 ) | grep -v '\?xml' | sed '1i\<?xml version="1.0" encoding="UTF-8"?>' | rpmmd2solv $parser_options > $primfile || exit 4
102 if test -f product.xml; then
103 prodfile=`mktemp` || exit 3
106 for i in product*.xml*; do
108 *.gz) gzip -dc "$i" ;;
109 *.bz2) bzip2 -dc "$i" ;;
114 ) | grep -v '\?xml' | rpmmd2solv $parser_options > $prodfile || exit 4
118 patternfile="/nonexist"
119 for i in patterns.xml*; do
120 test -s "$i" || continue
122 *.gz) cmd='gzip -dc' ;;
123 *.bz2) cmd='bzip2 -dc' ;;
128 if test -n "$cmd" ; then
129 patternfile=`mktemp` || exit 3
130 $cmd "$i" | rpmmd2solv $parser_options > $patternfile || exit 4
133 # This contains repomd.xml
134 # for now we only read some keys like timestamp
136 for i in repomd.xml*; do
137 test -s "$i" || continue
139 *.gz) cmd="gzip -dc" ;;
140 *.bz2) cmd="bzip2 -dc" ;;
143 # only check the first repomd.xml*, in case there are more
146 repomdfile="/nonexist"
147 if test -n "$cmd"; then
148 # we have some repomd.xml*
149 repomdfile=`mktemp` || exit 3
150 $cmd "$i" | repomdxml2solv $parser_options > $repomdfile || exit 4
153 # This contains suseinfo.xml, which is extensions to repomd.xml
154 # for now we only read some keys like expiration and products
156 for i in suseinfo.xml*; do
157 test -s "$i" || continue
159 *.gz) cmd="gzip -dc" ;;
160 *.bz2) cmd="bzip2 -dc" ;;
163 # only check the first suseinfo.xml*, in case there are more
166 suseinfofile="/nonexist"
167 if test -n "$cmd"; then
168 # we have some suseinfo.xml*
169 suseinfofile=`mktemp` || exit 3
170 $cmd "$i" | repomdxml2solv $parser_options > $suseinfofile || exit 4
173 # This contains a updateinfo.xml* and maybe patches
175 for i in updateinfo.xml*; do
176 test -s "$i" || continue
178 *.gz) cmd="gzip -dc" ;;
179 *.bz2) cmd="bzip2 -dc" ;;
182 # only check the first updateinfo.xml*, in case there are more
185 updateinfofile="/nonexist"
186 if test -n "$cmd"; then
187 # we have some updateinfo.xml*
188 updateinfofile=`mktemp` || exit 3
189 $cmd "$i" | updateinfoxml2solv $parser_options > $updateinfofile || exit 4
192 patchfile="/nonexist"
193 if test -f patches.xml; then
194 patchfile=`mktemp` || exit 3
197 for i in patch-*.xml*; do
199 *.gz) gzip -dc "$i" ;;
200 *.bz2) bzip2 -dc "$i" ;;
205 ) | grep -v '\?xml' | patchxml2solv $parser_options > $patchfile || exit 4
208 # This contains a deltainfo.xml*
210 for i in deltainfo.xml*; do
211 test -s "$i" || continue
213 *.gz) cmd="gzip -dc" ;;
214 *.bz2) cmd="bzip2 -dc" ;;
217 # only check the first deltainfo.xml*, in case there are more
220 deltainfofile="/nonexist"
221 if test -n "$cmd"; then
222 # we have some deltainfo.xml*
223 deltainfofile=`mktemp` || exit 3
224 $cmd "$i" | deltainfoxml2solv $parser_options > $deltainfofile || exit 4
227 # Now merge primary, patches, updateinfo, and deltainfo
228 if test -s $repomdfile; then
229 m_repomdfile=$repomdfile
231 if test -s $suseinfofile; then
232 m_suseinfofile=$suseinfofile
234 if test -s $primfile; then
237 if test -s $patternfile; then
238 m_patternfile=$patternfile
240 if test -s $prodfile; then
243 if test -s $patchfile; then
244 m_patchfile=$patchfile
246 if test -s $updateinfofile; then
247 m_updateinfofile=$updateinfofile
249 if test -s $deltainfofile; then
250 m_deltainfofile=$deltainfofile
252 mergesolv $m_repomdfile $m_suseinfofile $m_primfile $m_prodfile $m_patternfile $m_patchfile $m_updateinfofile $m_deltainfofile
253 rm -f $repomdfile $suseinfofile $primfile $patternfile $prodfile $patchfile $updateinfofile $deltainfofile
255 elif test "$repotype" = susetags ; then
257 DESCR=$(get_DESCRDIR)
258 cd ${DESCR} || exit 2
261 if test -s packages.gz; then
263 elif test -s packages.bz2; then
264 bzip2 -dc packages.bz2
265 elif test -s packages; then
270 if test -s packages.DU.gz; then
271 gzip -dc packages.DU.gz
272 elif test -s packages.DU.bz2; then
273 bzip2 -dc packages.DU.bz2
274 elif test -s packages.DU; then
278 # Now default language
279 if test -s packages.en.gz; then
280 gzip -dc packages.en.gz
281 elif test -s packages.en.bz2; then
282 bzip2 -dc packages.en.bz2
283 elif test -s packages.en; then
287 # Now patterns. Not simply those files matching *.pat{,.gz,bz2},
288 # but only those mentioned in the file 'patterns'
289 if test -f patterns; then
290 for i in `cat patterns`; do
291 test -s "$i" || continue
293 *.gz) gzip -dc "$i" ;;
294 *.bz2) bzip2 -dc "$i" ;;
300 # Now all other packages.{lang}. Needs to come last as it switches
301 # languages for all following susetags files
302 for i in packages.*; do
304 *.gz) name="${i%.gz}" ; prog="gzip -dc" ;;
305 *.bz2) name="${i%.bz2}" ; prog="bzip2 -dc" ;;
306 *) name="$i"; prog=cat ;;
309 # ignore files we handled already
310 *.DU | *.en | *.FL | packages ) continue ;;
312 suff=${name#packages.}
318 ) | susetags2solv -c "${olddir}/content" $parser_options || exit 4
320 elif test "$repotype" = plaindir ; then
321 find * -name .\* -prune -o $findopt -name \*.delta.rpm -o -name \*.patch.rpm -o -name \*.rpm -a -type f -print0 | rpms2solv -0 -m -
323 echo "unknown repository type '$repotype'" >&2