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
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 # This contains a deltainfo.xml*
194 for i in deltainfo.xml*; do
195 test -s "$i" || continue
197 *.gz) cmd="gzip -dc" ;;
198 *.bz2) cmd="bzip2 -dc" ;;
201 # only check the first deltainfo.xml*, in case there are more
204 deltainfofile="/nonexist"
205 if test -n "$cmd"; then
206 # we have some deltainfo.xml*
207 deltainfofile=`mktemp` || exit 3
208 $cmd "$i" | deltainfoxml2solv $parser_options > $deltainfofile || exit 4
211 # Now merge primary, patches, updateinfo, and deltainfo
212 if test -s $repomdfile; then
213 m_repomdfile=$repomdfile
215 if test -s $suseinfofile; then
216 m_suseinfofile=$suseinfofile
218 if test -s $primfile; then
221 if test -s $patternfile; then
222 m_patternfile=$patternfile
224 if test -s $prodfile; then
227 if test -s $updateinfofile; then
228 m_updateinfofile=$updateinfofile
230 if test -s $deltainfofile; then
231 m_deltainfofile=$deltainfofile
233 mergesolv $m_repomdfile $m_suseinfofile $m_primfile $m_prodfile $m_patternfile $m_updateinfofile $m_deltainfofile
234 rm -f $repomdfile $suseinfofile $primfile $patternfile $prodfile $updateinfofile $deltainfofile
236 elif test "$repotype" = susetags ; then
238 DESCR=$(get_DESCRDIR)
239 cd ${DESCR} || exit 2
242 if test -s packages.gz; then
244 elif test -s packages.bz2; then
245 bzip2 -dc packages.bz2
246 elif test -s packages; then
251 if test -s packages.DU.gz; then
252 gzip -dc packages.DU.gz
253 elif test -s packages.DU.bz2; then
254 bzip2 -dc packages.DU.bz2
255 elif test -s packages.DU; then
259 # Now default language
260 if test -s packages.en.gz; then
261 gzip -dc packages.en.gz
262 elif test -s packages.en.bz2; then
263 bzip2 -dc packages.en.bz2
264 elif test -s packages.en; then
268 # Now patterns. Not simply those files matching *.pat{,.gz,bz2},
269 # but only those mentioned in the file 'patterns'
270 if test -f patterns; then
271 for i in `cat patterns`; do
272 test -s "$i" || continue
274 *.gz) gzip -dc "$i" ;;
275 *.bz2) bzip2 -dc "$i" ;;
281 # Now all other packages.{lang}. Needs to come last as it switches
282 # languages for all following susetags files
283 for i in packages.*; do
285 *.gz) name="${i%.gz}" ; prog="gzip -dc" ;;
286 *.bz2) name="${i%.bz2}" ; prog="bzip2 -dc" ;;
287 *) name="$i"; prog=cat ;;
290 # ignore files we handled already
291 *.DU | *.en | *.FL | packages ) continue ;;
293 suff=${name#packages.}
299 ) | susetags2solv -c "${olddir}/content" $parser_options || exit 4
301 elif test "$repotype" = plaindir ; then
302 find * -name .\* -prune -o $findopt -name \*.delta.rpm -o -name \*.patch.rpm -o -name \*.rpm -a -type f -print0 | rpms2solv -0 -m -
304 echo "unknown repository type '$repotype'" >&2