From: Michael Matz Date: Mon, 15 Oct 2007 02:58:32 +0000 (+0000) Subject: Simple shell script accepting a directory with local repository data, X-Git-Tag: BASE-SuSE-Code-12_1-Branch~308^2~925 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd66530c72c759caf10d25878a97f976fd048121;p=thirdparty%2Flibsolv.git Simple shell script accepting a directory with local repository data, detecting which type the repo is, and emitting exactly one SOLV file for the whole thing. --- diff --git a/tools/repo2solv.sh b/tools/repo2solv.sh new file mode 100755 index 00000000..3a7baa86 --- /dev/null +++ b/tools/repo2solv.sh @@ -0,0 +1,83 @@ +#! /bin/sh +# repo2solv +# +# give it a directory of a local mirror of a repo and this +# tries to detect the repo type and generate one SOLV file on stdout + +LANG=C + +dir="$1" +cd "$dir" || exit 1 +if test -d repodata; then + cd repodata || exit 2 + + # This contains a primary.xml* and maybe patches + for i in primary.xml*; do + case $i in + *.gz) cmd="gzip -dc" ;; + *.bz2) cmd="bzip2 -dc" ;; + *) cmd="cat" ;; + esac + # only check the first primary.xml*, in case there are more + break + done + primfile="/nonexist" + if test -n "$cmd"; then + # we have some primary.xml* + primfile=`mktemp` || exit 3 + $cmd $i | rpmmd2solv > $primfile + fi + + patchfile="/nonexist" + if test -f patches.xml; then + patchfile=`mktemp` || exit 3 + ( + echo '' + for i in patch-*.xml*; do + case $i in + *.gz) gzip -dc "$i" ;; + *.bz2) bzip2 -dc "$i" ;; + *) cat "$i" ;; + esac + done + echo '' + ) | grep -v '\?xml' | patchxml2solv > $patchfile + fi + + # Now merge primary and patches + if test -s $primfile && test -s $patchfile; then + mergesolv $primfile $patchfile + elif test -s $primfile; then + cat $primfile + elif test -s $patchfile; then + cat $patchfile + fi + rm -f $primfile $patchfile +elif test -d suse/setup/descr; then + cd suse/setup/descr || exit 2 + ( + # First packages + if test -s packages.gz; then + gzip -dc packages.gz + elif test -s packages.bz2; then + bzip2 -dc packages.bz2 + elif test -s packages; then + cat packages + fi + + # XXX need to do something with packages.DU and packages.{lang} + + # Now patterns. Not simply those files matching *.pat{,.gz,bz2}, + # but only those mentioned in the file 'patterns' + if test -f patterns; then + for i in `cat patterns`; do + test -s "$i" || continue + case $i in + *.gz) gzip -dc "$i" ;; + *.bz2) bzip2 -dc "$i" ;; + *) cat "$i" ;; + esac + done + fi + ) | susetags2solv +fi