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" ;;
51 *.lzma) lzma -dc "$1" ;;
57 susetags_findfile_cat() {
58 if test -s "$1.xz" ; then
60 elif test -s "$1.lzma" ; then
62 elif test -s "$1.bz2" ; then
64 elif test -s "$1.gz" ; then
66 elif test -s "$1" ; then
71 # signal an error if there is a problem
76 parser_options=${PARSER_OPTIONS:-}
82 if test "$1" = "-o" ; then
86 elif test "$1" = "-R" ; then
99 if test -z "$repotype" ; then
100 # autodetect repository type
101 if test -d repodata -o -f repomd.xml; then
103 elif test_susetags ; then
110 if test "$repotype" = rpmmd ; then
111 test -d repodata && {
112 cd repodata || exit 2
116 primxml=`repomd_findfile primary primary.xml`
117 if test -n "$primxml" -a -s "$primxml" ; then
118 primfile=`mktemp` || exit 3
120 # fake tag to combine primary.xml and extensions
121 # like susedata.xml, other.xml, filelists.xml
123 if test -f $primxml ; then
124 repomd_decompress $primxml
128 susedataxml=`repomd_findfile susedata susedata.xml`
129 if test -f "$susedataxml" ; then
130 repomd_decompress "$susedataxml"
133 ) | grep -v '\?xml' | sed '1i\<?xml version="1.0" encoding="UTF-8"?>' | rpmmd2solv $parser_options > $primfile || exit 4
137 prodxml=`repomd_findfile products products.xml`
138 if test -z "$prodxml" ; then
139 prodxml=`repomd_findfile product product.xml`
141 if test -n "$prodxml" -a -s "$prodxml" ; then
142 prodfile=`mktemp` || exit 3
143 repomd_decompress "$prodxml" | rpmmd2solv $parser_options > $prodfile || exit 4
147 patternxml=`repomd_findfile 'patterns' patterns.xml`
148 if test -n "$patternxml" -a -s "$patternxml" ; then
149 patternfile=`mktemp` || exit 3
150 repomd_decompress "$patternxml" | rpmmd2solv $parser_options > $patternfile || exit 4
153 # This contains repomd.xml
154 # for now we only read some keys like timestamp
156 repomdxml=`repomd_findfile '' repomd.xml`
157 if test -n "$repomdxml" -a -s "$repomdxml" ; then
158 repomdfile=`mktemp` || exit 3
159 repomd_decompress "$repomdxml" | repomdxml2solv $parser_options > $repomdfile || exit 4
162 # This contains suseinfo.xml, which is an extension to repomd.xml
163 # for now we only read some keys like expiration and products
165 suseinfoxml=`repomd_findfile suseinfo suseinfo.xml`
166 if test -n "$suseinfoxml" -a -s "$suseinfoxml" ; then
167 suseinfofile=`mktemp` || exit 3
168 repomd_decompress "$suseinfoxml" | repomdxml2solv $parser_options > $suseinfofile || exit 4
171 # This contains a updateinfo.xml* and maybe patches
173 updateinfoxml=`repomd_findfile updateinfo updateinfo.xml`
174 if test -n "$updateinfoxml" -a -s "$updateinfoxml" ; then
175 updateinfofile=`mktemp` || exit 3
176 repomd_decompress "$updateinfoxml" | updateinfoxml2solv $parser_options > $updateinfofile || exit 4
179 # This contains a deltainfo.xml*
181 deltainfoxml=`repomd_findfile deltainfo deltainfo.xml`
182 if test -z "$deltainfoxml"; then
183 deltainfoxml=`repomd_findfile prestodelta prestodelta.xml`
185 if test -n "$deltainfoxml" -a -s "$deltainfoxml" ; then
186 deltainfofile=`mktemp` || exit 3
187 repomd_decompress "$deltainfoxml" | deltainfoxml2solv $parser_options > $deltainfofile || exit 4
190 # Now merge primary, patches, updateinfo, and deltainfo
191 mergesolv $repomdfile $suseinfofile $primfile $prodfile $patternfile $updateinfofile $deltainfofile
192 rm -f $repomdfile $suseinfofile $primfile $patternfile $prodfile $updateinfofile $deltainfofile
194 elif test "$repotype" = susetags ; then
196 DESCR=$(get_DESCRDIR)
197 cd ${DESCR} || exit 2
200 susetags_findfile_cat packages
203 susetags_findfile_cat packages.DU
205 # Now default language
206 susetags_findfile_cat packages.en
208 # Now patterns. Not simply those files matching *.pat{,.gz,bz2},
209 # but only those mentioned in the file 'patterns'
210 if test -f patterns ; then
211 for i in `cat patterns`; do
212 if test -s "$i" ; then
213 repomd_decompress "$i"
218 # Now all other packages.{lang}. Needs to come last as it switches
219 # languages for all following susetags files
220 for i in packages.* ; do
222 *.gz|*.bz2|*.xz|*.lzma) name="${i%.*}" ;;
226 # ignore files we handled already
227 *.DU | *.en | *.FL | packages ) continue ;;
229 suff=${name#packages.}
231 repomd_decompress "$i"
235 ) | susetags2solv -c "${olddir}/content" $parser_options || exit 4
237 elif test "$repotype" = plaindir ; then
238 find * -name .\* -prune -o $findopt -name \*.delta.rpm -o -name \*.patch.rpm -o -name \*.rpm -a -type f -print0 | rpms2solv -0 -m -
240 echo "unknown repository type '$repotype'" >&2