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 if test -s content; then
9 DESCR=`grep DESCRDIR content | cut -d ' ' -f 2`
10 if test -z $DESCR; then
11 DESCR=suse/setup/descr
20 # signal an error if there is a problem
25 parser_options=${PARSER_OPTIONS:-}
31 if test "$1" = "-o" ; then
35 elif test "$1" = "-R" ; then
48 if test -z "$repotype" ; then
49 # autodetect repository type
50 if test -d repodata ; then
52 elif test_susetags ; then
59 if test "$repotype" = rpmmd ; then
63 if test -f primary.xml || test -f primary.xml.gz || test -f primary.xml.bz2 ; then
64 primfile=`mktemp` || exit 3
66 # fake tag to combine primary.xml and extensions
67 # like susedata.xml, other.xml, filelists.xml
69 for i in primary.xml* susedata.xml*; do
70 test -s "$i" || continue
73 *.bz2) bzip2 -dc "$i";;
81 for i in susedata.xml*; do
82 test -s "$i" || continue
85 *.bz2) bzip2 -dc "$i";;
92 ) | grep -v '\?xml' | sed '1i\<?xml version="1.0" encoding="UTF-8"?>' | rpmmd2solv $parser_options > $primfile || exit 4
96 if test -f product.xml; then
97 prodfile=`mktemp` || exit 3
100 for i in product*.xml*; do
102 *.gz) gzip -dc "$i" ;;
103 *.bz2) bzip2 -dc "$i" ;;
108 ) | grep -v '\?xml' | rpmmd2solv $parser_options > $prodfile || exit 4
112 patternfile="/nonexist"
113 for i in patterns.xml*; do
114 test -s "$i" || continue
116 *.gz) cmd='gzip -dc' ;;
117 *.bz2) cmd='bzip2 -dc' ;;
122 if test -n "$cmd" ; then
123 patternfile=`mktemp` || exit 3
124 $cmd "$i" | rpmmd2solv $parser_options > $patternfile || exit 4
127 # This contains repomd.xml
128 # for now we only read some keys like timestamp
130 for i in repomd.xml*; do
131 test -s "$i" || continue
133 *.gz) cmd="gzip -dc" ;;
134 *.bz2) cmd="bzip2 -dc" ;;
137 # only check the first repomd.xml*, in case there are more
140 repomdfile="/nonexist"
141 if test -n "$cmd"; then
142 # we have some repomd.xml*
143 repomdfile=`mktemp` || exit 3
144 $cmd "$i" | repomdxml2solv $parser_options > $repomdfile || exit 4
147 # This contains suseinfo.xml, which is extensions to repomd.xml
148 # for now we only read some keys like expiration and products
150 for i in suseinfo.xml*; do
151 test -s "$i" || continue
153 *.gz) cmd="gzip -dc" ;;
154 *.bz2) cmd="bzip2 -dc" ;;
157 # only check the first suseinfo.xml*, in case there are more
160 suseinfofile="/nonexist"
161 if test -n "$cmd"; then
162 # we have some suseinfo.xml*
163 suseinfofile=`mktemp` || exit 3
164 $cmd "$i" | repomdxml2solv $parser_options > $suseinfofile || exit 4
167 # This contains a updateinfo.xml* and maybe patches
169 for i in updateinfo.xml*; do
170 test -s "$i" || continue
172 *.gz) cmd="gzip -dc" ;;
173 *.bz2) cmd="bzip2 -dc" ;;
176 # only check the first updateinfo.xml*, in case there are more
179 updateinfofile="/nonexist"
180 if test -n "$cmd"; then
181 # we have some updateinfo.xml*
182 updateinfofile=`mktemp` || exit 3
183 $cmd "$i" | updateinfoxml2solv $parser_options > $updateinfofile || exit 4
186 patchfile="/nonexist"
187 if test -f patches.xml; then
188 patchfile=`mktemp` || exit 3
191 for i in patch-*.xml*; do
193 *.gz) gzip -dc "$i" ;;
194 *.bz2) bzip2 -dc "$i" ;;
199 ) | grep -v '\?xml' | patchxml2solv $parser_options > $patchfile || exit 4
202 # This contains a deltainfo.xml*
204 for i in deltainfo.xml*; do
205 test -s "$i" || continue
207 *.gz) cmd="gzip -dc" ;;
208 *.bz2) cmd="bzip2 -dc" ;;
211 # only check the first deltainfo.xml*, in case there are more
214 deltainfofile="/nonexist"
215 if test -n "$cmd"; then
216 # we have some deltainfo.xml*
217 deltainfofile=`mktemp` || exit 3
218 $cmd "$i" | deltainfoxml2solv $parser_options > $deltainfofile || exit 4
221 # Now merge primary, patches, updateinfo, and deltainfo
222 if test -s $repomdfile; then
223 m_repomdfile=$repomdfile
225 if test -s $suseinfofile; then
226 m_suseinfofile=$suseinfofile
228 if test -s $primfile; then
231 if test -s $patternfile; then
232 m_patternfile=$patternfile
234 if test -s $prodfile; then
237 if test -s $patchfile; then
238 m_patchfile=$patchfile
240 if test -s $updateinfofile; then
241 m_updateinfofile=$updateinfofile
243 if test -s $deltainfofile; then
244 m_deltainfofile=$deltainfofile
246 mergesolv $m_repomdfile $m_suseinfofile $m_primfile $m_prodfile $m_patternfile $m_patchfile $m_updateinfofile $m_deltainfofile
247 rm -f $repomdfile $suseinfofile $primfile $patternfile $prodfile $patchfile $updateinfofile $deltainfofile
249 elif test "$repotype" = susetags ; then
251 DESCR=`grep DESCRDIR content | cut -d ' ' -f 2`
252 if test -z $DESCR; then
253 DESCR=suse/setup/descr
255 cd ${DESCR} || exit 2
258 if test -s packages.gz; then
260 elif test -s packages.bz2; then
261 bzip2 -dc packages.bz2
262 elif test -s packages; then
267 if test -s packages.DU.gz; then
268 gzip -dc packages.DU.gz
269 elif test -s packages.DU.bz2; then
270 bzip2 -dc packages.DU.bz2
271 elif test -s packages.DU; then
275 # Now default language
276 if test -s packages.en.gz; then
277 gzip -dc packages.en.gz
278 elif test -s packages.en.bz2; then
279 bzip2 -dc packages.en.bz2
280 elif test -s packages.en; then
284 # Now patterns. Not simply those files matching *.pat{,.gz,bz2},
285 # but only those mentioned in the file 'patterns'
286 if test -f patterns; then
287 for i in `cat patterns`; do
288 test -s "$i" || continue
290 *.gz) gzip -dc "$i" ;;
291 *.bz2) bzip2 -dc "$i" ;;
297 # Now all other packages.{lang}. Needs to come last as it switches
298 # languages for all following susetags files
299 for i in packages.*; do
301 *.gz) name="${i%.gz}" ; prog="gzip -dc" ;;
302 *.bz2) name="${i%.bz2}" ; prog="bzip2 -dc" ;;
303 *) name="$i"; prog=cat ;;
306 # ignore files we handled already
307 *.DU | *.en | *.FL | packages ) continue ;;
309 suff=${name#packages.}
315 ) | susetags2solv -c "${olddir}/content" $parser_options || exit 4
317 elif test "$repotype" = plaindir ; then
318 find * -name .\* -prune -o $findopt -name \*.delta.rpm -o -name \*.patch.rpm -o -name \*.rpm -a -type f -print0 | rpms2solv -0 -m -
320 echo "unknown repository type '$repotype'" >&2