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" ;;
55 # signal an error if there is a problem
60 parser_options=${PARSER_OPTIONS:-}
66 if test "$1" = "-o" ; then
70 elif test "$1" = "-R" ; then
83 if test -z "$repotype" ; then
84 # autodetect repository type
85 if test -d repodata ; then
87 elif test_susetags ; then
94 if test "$repotype" = rpmmd ; then
98 primxml=`repomd_findfile primary primary.xml`
99 if test -n "$primxml" -a -s "$primxml" ; then
100 primfile=`mktemp` || exit 3
102 # fake tag to combine primary.xml and extensions
103 # like susedata.xml, other.xml, filelists.xml
105 if test -f $primxml ; then
106 repomd_decompress $primxml
110 susedataxml=`repomd_findfile susedata susedata.xml`
111 if test -f $susedataxml ; then
112 repomd_decompress $susedataxml
115 ) | grep -v '\?xml' | sed '1i\<?xml version="1.0" encoding="UTF-8"?>' | rpmmd2solv $parser_options > $primfile || exit 4
119 prodxml=`repomd_findfile products products.xml`
120 if test -z "$prodxml" ; then
121 prodxml=`repomd_findfile product product.xml`
123 if test -n "$prodxml" -a -s "$prodxml" ; then
124 prodfile=`mktemp` || exit 3
127 repomd_decompress "$prodxml"
129 ) | grep -v '\?xml' | rpmmd2solv $parser_options > $prodfile || exit 4
133 patternxml=`repomd_findfile 'patterns' patterns.xml`
134 if test -n "$patternxml" -a -s "$patternxml" ; then
135 patternfile=`mktemp` || exit 3
136 repomd_decompress "$patternxml" | rpmmd2solv $parser_options > $patternfile || exit 4
139 # This contains repomd.xml
140 # for now we only read some keys like timestamp
142 repomdxml=`repomd_findfile '' repomd.xml`
143 if test -n "$repomdxml" -a -s "$repomdxml" ; then
144 repomdfile=`mktemp` || exit 3
145 repomd_decompress "$repomdxml" | repomdxml2solv $parser_options > $repomdfile || exit 4
148 # This contains suseinfo.xml, which is an extension to repomd.xml
149 # for now we only read some keys like expiration and products
151 suseinfoxml=`repomd_findfile suseinfo suseinfo.xml`
152 if test -n "$suseinfoxml" -a -s "$suseinfoxml" ; then
153 suseinfofile=`mktemp` || exit 3
154 repomd_decompress "$suseinfoxml" | repomdxml2solv $parser_options > $suseinfofile || exit 4
157 # This contains a updateinfo.xml* and maybe patches
159 updateinfoxml=`repomd_findfile updateinfo updateinfo.xml`
160 if test -n "$updateinfoxml" -a -s "$updateinfoxml" ; then
161 updateinfofile=`mktemp` || exit 3
162 repomd_decompress "$updateinfoxml" | updateinfoxml2solv $parser_options > $updateinfofile || exit 4
165 # This contains a deltainfo.xml*
167 deltainfoxml=`repomd_findfile deltainfo deltainfo.xml`
168 if test -z "$deltainfoxml"; then
169 deltainfoxml=`repomd_findfile prestodelta prestodelta.xml`
171 if test -n "$deltainfoxml" -a -s "$deltainfoxml" ; then
172 deltainfofile=`mktemp` || exit 3
173 repomd_decompress "$deltainfoxml" | deltainfoxml2solv $parser_options > $deltainfofile || exit 4
176 # Now merge primary, patches, updateinfo, and deltainfo
177 mergesolv $repomdfile $suseinfofile $primfile $prodfile $patternfile $updateinfofile $deltainfofile
178 rm -f $repomdfile $suseinfofile $primfile $patternfile $prodfile $updateinfofile $deltainfofile
180 elif test "$repotype" = susetags ; then
182 DESCR=$(get_DESCRDIR)
183 cd ${DESCR} || exit 2
186 if test -s packages.gz; then
188 elif test -s packages.bz2; then
189 bzip2 -dc packages.bz2
190 elif test -s packages; then
195 if test -s packages.DU.gz; then
196 gzip -dc packages.DU.gz
197 elif test -s packages.DU.bz2; then
198 bzip2 -dc packages.DU.bz2
199 elif test -s packages.DU; then
203 # Now default language
204 if test -s packages.en.gz; then
205 gzip -dc packages.en.gz
206 elif test -s packages.en.bz2; then
207 bzip2 -dc packages.en.bz2
208 elif test -s packages.en; then
212 # Now patterns. Not simply those files matching *.pat{,.gz,bz2},
213 # but only those mentioned in the file 'patterns'
214 if test -f patterns; then
215 for i in `cat patterns`; do
216 test -s "$i" || continue
218 *.gz) gzip -dc "$i" ;;
219 *.bz2) bzip2 -dc "$i" ;;
225 # Now all other packages.{lang}. Needs to come last as it switches
226 # languages for all following susetags files
227 for i in packages.*; do
229 *.gz) name="${i%.gz}" ; prog="gzip -dc" ;;
230 *.bz2) name="${i%.bz2}" ; prog="bzip2 -dc" ;;
231 *) name="$i"; prog=cat ;;
234 # ignore files we handled already
235 *.DU | *.en | *.FL | packages ) continue ;;
237 suff=${name#packages.}
243 ) | susetags2solv -c "${olddir}/content" $parser_options || exit 4
245 elif test "$repotype" = plaindir ; then
246 find * -name .\* -prune -o $findopt -name \*.delta.rpm -o -name \*.patch.rpm -o -name \*.rpm -a -type f -print0 | rpms2solv -0 -m -
248 echo "unknown repository type '$repotype'" >&2