4 # this is a shell implementation of repo2solv that makes use of
5 # the different parser utilities
7 # give it a directory of a local mirror of a repo and this
8 # tries to detect the repo type and generate one SOLV file on stdout
11 local d=$(grep '^DESCRDIR' content | sed 's/^DESCRDIR[[:space:]]\+\(.*[^[:space:]]\)[[:space:]]*$/\1/')
20 if test -s content; then
33 if test -n "$t" -a -s repomd.xml ; then
34 f=`repomdxml2solv -q "$t:location" < repomd.xml 2>/dev/null`
36 if test -f "$f" ; then
41 if test -f "$p.bz2" ; then
43 elif test -f "$p.gz" ; then
45 elif test -f "$p" ; then
51 test -s repomd.xml && repomdxml2solv -q type < repomd.xml
56 *.gz) gzip -dc "$1" ;;
57 *.bz2) bzip2 -dc "$1" ;;
58 *.lzma) lzma -dc "$1" ;;
65 if test -s "$1.xz" ; then
67 elif test -s "$1.lzma" ; then
69 elif test -s "$1.bz2" ; then
71 elif test -s "$1.gz" ; then
76 susetags_findfile_cat() {
77 if test -s "$1.xz" ; then
79 elif test -s "$1.lzma" ; then
81 elif test -s "$1.bz2" ; then
83 elif test -s "$1.gz" ; then
85 elif test -s "$1" ; then
90 # signal an error if there is a problem
95 parser_options=${PARSER_OPTIONS:-}
102 if test "$1" = "-o" ; then
106 elif test "$1" = "-R" ; then
111 elif test "$1" = "-X" ; then
114 elif test "$1" = "-A" ; then
124 if test -z "$repotype" ; then
125 # autodetect repository type
126 if test -d repodata -o -f repomd.xml; then
128 elif test_susetags ; then
135 if test "$repotype" = rpmmd ; then
136 test -d repodata && {
137 cd repodata || exit 2
141 primxml=`repomd_findfile primary primary.xml`
142 if test -n "$primxml" -a -s "$primxml" ; then
143 primfile=`mktemp` || exit 3
145 # fake tag to combine primary.xml and extensions
146 # like susedata.xml, other.xml, filelists.xml
148 if test -f $primxml ; then
149 repomd_decompress $primxml
153 susedataxml=`repomd_findfile susedata susedata.xml`
154 if test -f "$susedataxml" ; then
155 repomd_decompress "$susedataxml"
157 # all the languages as well
158 for t in `repomd_types` ; do
161 susedataxml=`repomd_findfile "$t" "$t.xml"`
162 if test -f "$susedataxml" ; then
163 repomd_decompress "$susedataxml"
169 ) | sed 's/<?xml[^>]*>//g' | sed '1i\<?xml version="1.0" encoding="UTF-8"?>' | rpmmd2solv $parser_options > $primfile || exit 4
173 prodxml=`repomd_findfile products products.xml`
174 if test -z "$prodxml" ; then
175 prodxml=`repomd_findfile product product.xml`
177 if test -n "$prodxml" -a -s "$prodxml" ; then
178 prodfile=`mktemp` || exit 3
179 repomd_decompress "$prodxml" | rpmmd2solv $parser_options > $prodfile || exit 4
183 patternxml=`repomd_findfile 'patterns' patterns.xml`
184 if test -n "$patternxml" -a -s "$patternxml" ; then
185 patternfile=`mktemp` || exit 3
186 repomd_decompress "$patternxml" | rpmmd2solv $parser_options > $patternfile || exit 4
189 # This contains repomd.xml
190 # for now we only read some keys like timestamp
192 repomdxml=`repomd_findfile '' repomd.xml`
193 if test -n "$repomdxml" -a -s "$repomdxml" ; then
194 repomdfile=`mktemp` || exit 3
195 repomd_decompress "$repomdxml" | repomdxml2solv $parser_options > $repomdfile || exit 4
198 # This contains suseinfo.xml, which is an extension to repomd.xml
199 # for now we only read some keys like expiration and products
201 suseinfoxml=`repomd_findfile suseinfo suseinfo.xml`
202 if test -n "$suseinfoxml" -a -s "$suseinfoxml" ; then
203 suseinfofile=`mktemp` || exit 3
204 repomd_decompress "$suseinfoxml" | repomdxml2solv $parser_options > $suseinfofile || exit 4
207 # This contains a updateinfo.xml* and maybe patches
209 updateinfoxml=`repomd_findfile updateinfo updateinfo.xml`
210 if test -n "$updateinfoxml" -a -s "$updateinfoxml" ; then
211 updateinfofile=`mktemp` || exit 3
212 repomd_decompress "$updateinfoxml" | updateinfoxml2solv $parser_options > $updateinfofile || exit 4
215 # This contains a deltainfo.xml*
217 deltainfoxml=`repomd_findfile deltainfo deltainfo.xml`
218 if test -z "$deltainfoxml"; then
219 deltainfoxml=`repomd_findfile prestodelta prestodelta.xml`
221 if test -n "$deltainfoxml" -a -s "$deltainfoxml" ; then
222 deltainfofile=`mktemp` || exit 3
223 repomd_decompress "$deltainfoxml" | deltainfoxml2solv $parser_options > $deltainfofile || exit 4
226 # This contains appdata
229 if test -x /usr/bin/appdata2solv ; then
230 appdataxml=`repomd_findfile appdata appdata.xml`
232 if test -n "$appdataxml" -a -s "$appdataxml" ; then
233 appdatafile=`mktemp` || exit 3
234 repomd_decompress "$appdataxml" | appdata2solv $parser_options > $appdatafile || exit 4
237 # Now merge primary, patches, updateinfo, and deltainfo
238 mergesolv $addautooption $repomdfile $suseinfofile $primfile $prodfile $patternfile $updateinfofile $deltainfofile $appdatafile
239 rm -f $repomdfile $suseinfofile $primfile $patternfile $prodfile $updateinfofile $deltainfofile $appdatafile
241 elif test "$repotype" = susetags ; then
243 DESCR=$(get_DESCRDIR)
244 cd ${DESCR} || exit 2
247 if test -x /usr/bin/appdata2solv ; then
248 appdataxml=`susetags_findfile appdata.xml`
250 if test -n "$appdataxml" ; then
251 appdatafile=`mktemp` || exit 3
252 repomd_decompress "$appdataxml" | appdata2solv $parser_options > $appdatafile || exit 4
253 parser_options="-M $appdatafile $parser_options"
257 susetags_findfile_cat packages
260 susetags_findfile_cat packages.DU
262 # Now default language
263 susetags_findfile_cat packages.en
266 susetags_findfile_cat packages.DL
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 if test -s "$i" ; then
273 repomd_decompress "$i"
278 # Now all other packages.{lang}. Needs to come last as it switches
279 # languages for all following susetags files
280 for i in packages.* ; do
282 *.gz|*.bz2|*.xz|*.lzma) name="${i%.*}" ;;
286 # ignore files we handled already
287 *.DU | *.en | *.FL | *.DL | packages ) continue ;;
289 suff=${name#packages.}
291 repomd_decompress "$i"
295 ) | susetags2solv $addautooption -c "${olddir}/content" $parser_options || exit 4
296 test -n "$appdatafile" && rm -f "$appdatafile"
298 elif test "$repotype" = plaindir ; then
299 find * -name .\* -prune -o $findopt -name \*.delta.rpm -o -name \*.patch.rpm -o -name \*.rpm -a -type f -print0 | rpms2solv $addautooption -0 -m -
301 echo "unknown repository type '$repotype'" >&2