From: Klaus Kaempf Date: Fri, 15 Feb 2008 16:31:01 +0000 (+0000) Subject: add help to rpmmd2solv and patchxml2solv X-Git-Tag: BASE-SuSE-Code-12_1-Branch~308^2~602 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43d3099eded1d589a88dbb598ee1df501430ef18;p=thirdparty%2Flibsolv.git add help to rpmmd2solv and patchxml2solv prepare all tools and scripts for command line switches --- diff --git a/tools/patchxml2solv.c b/tools/patchxml2solv.c index 987bf237..d9f944a2 100644 --- a/tools/patchxml2solv.c +++ b/tools/patchxml2solv.c @@ -17,12 +17,59 @@ #include "repo_patchxml.h" #include "common_write.h" +static void +usage(const char *err) +{ + if (err) + fprintf(stderr, "\n** Error:\n %s\n", err); + fprintf(stderr, "\nUsage:\n" + "patchxml2solv [-a][-h][-k][-n ]\n" + " reads a 'patchxml' file from and writes a .solv file to \n" + " -h : print help & exit\n" + " -k : don't mix kinds (experimental!)\n" + " -n : save attributes as .attr\n" + ); + exit(0); +} + int main(int argc, char **argv) { + int flags = 0; + char *attrname = 0; + Pool *pool = pool_create(); Repo *repo = repo_create(pool, ""); - repo_add_patchxml(repo, stdin); + + argv++; + argc--; + while (argc--) + { + const char *s = argv[0]; + if (*s++ == '-') + while (*s) + switch (*s++) + { + case 'h': usage(NULL); break; + case 'n': + if (argc) + { + attrname = argv[1]; + argv++; + argc--; + } + else + usage("argument required for '-n'"); + break; + case 'k': + flags |= PATCHXML_KINDS_SEPARATELY; + break; + default : break; + } + argv++; + } + + repo_add_patchxml(repo, stdin, flags); tool_write(repo, 0, 0); pool_free(pool); exit(0); diff --git a/tools/repo2solv.sh b/tools/repo2solv.sh index 1e7da830..bcf03187 100755 --- a/tools/repo2solv.sh +++ b/tools/repo2solv.sh @@ -25,7 +25,7 @@ if test -d repodata; then if test -n "$cmd"; then # we have some primary.xml* primfile=`mktemp` || exit 3 - $cmd $i | rpmmd2solv > $primfile + $cmd $i | rpmmd2solv $(PARSER_OPTIONS) > $primfile fi patchfile="/nonexist" @@ -41,7 +41,7 @@ if test -d repodata; then esac done echo '' - ) | grep -v '\?xml' | patchxml2solv > $patchfile + ) | grep -v '\?xml' | patchxml2solv $(PARSER_OPTIONS) > $patchfile fi # Now merge primary and patches @@ -89,6 +89,6 @@ elif test -d suse/setup/descr && test -s content; then esac done fi - ) | susetags2solv -c "${olddir}/content" + ) | susetags2solv -c "${olddir}/content" $(PARSER_OPTIONS) cd "$olddir" fi diff --git a/tools/repo_patchxml.c b/tools/repo_patchxml.c index 1078134e..614f50ad 100644 --- a/tools/repo_patchxml.c +++ b/tools/repo_patchxml.c @@ -613,7 +613,7 @@ characterData(void *userData, const XML_Char *s, int len) #define BUFF_SIZE 8192 void -repo_add_patchxml(Repo *repo, FILE *fp) +repo_add_patchxml(Repo *repo, FILE *fp, int flags) { Pool *pool = repo->pool; struct parsedata pd; diff --git a/tools/repo_patchxml.h b/tools/repo_patchxml.h index ac29013c..d2589277 100644 --- a/tools/repo_patchxml.h +++ b/tools/repo_patchxml.h @@ -5,4 +5,6 @@ * for further information */ -extern void repo_add_patchxml(Repo *repo, FILE *fp); +#define PATCHXML_KINDS_SEPARATELY 1 + +extern void repo_add_patchxml(Repo *repo, FILE *fp, int flags); diff --git a/tools/repo_rpmmd.c b/tools/repo_rpmmd.c index f2852ade..fe88af5e 100644 --- a/tools/repo_rpmmd.c +++ b/tools/repo_rpmmd.c @@ -742,7 +742,7 @@ characterData(void *userData, const XML_Char *s, int len) #define BUFF_SIZE 8192 void -repo_add_rpmmd(Repo *repo, FILE *fp) +repo_add_rpmmd(Repo *repo, FILE *fp, int flags) { Pool *pool = repo->pool; struct parsedata pd; diff --git a/tools/repo_rpmmd.h b/tools/repo_rpmmd.h index dc2b86cc..96dcd66a 100644 --- a/tools/repo_rpmmd.h +++ b/tools/repo_rpmmd.h @@ -5,4 +5,6 @@ * for further information */ -extern void repo_add_rpmmd(Repo *repo, FILE *fp); +#define RPMMD_KINDS_SEPARATELY 1 + +extern void repo_add_rpmmd(Repo *repo, FILE *fp, int flags); diff --git a/tools/rpmmd2solv.c b/tools/rpmmd2solv.c index eee17ee4..a4a12807 100644 --- a/tools/rpmmd2solv.c +++ b/tools/rpmmd2solv.c @@ -17,12 +17,59 @@ #include "repo_rpmmd.h" #include "common_write.h" +static void +usage(const char *err) +{ + if (err) + fprintf(stderr, "\n** Error:\n %s\n", err); + fprintf(stderr, "\nUsage:\n" + "rpmmd2solv [-a][-h][-k][-n ]\n" + " reads a 'rpmmd' repository from and writes a .solv file to \n" + " -h : print help & exit\n" + " -k : don't mix kinds (experimental!)\n" + " -n : save attributes as .attr\n" + ); + exit(0); +} + + int main(int argc, char **argv) { + int flags = 0; + char *attrname = 0; + Pool *pool = pool_create(); Repo *repo = repo_create(pool, ""); - repo_add_rpmmd(repo, stdin); + + argv++; + argc--; + while (argc--) + { + const char *s = argv[0]; + if (*s++ == '-') + while (*s) + switch (*s++) + { + case 'h': usage(NULL); break; + case 'n': + if (argc) + { + attrname = argv[1]; + argv++; + argc--; + } + else + usage("argument required for '-n'"); + break; + case 'k': + flags |= RPMMD_KINDS_SEPARATELY; + break; + default : break; + } + argv++; + } + repo_add_rpmmd(repo, stdin, flags); tool_write(repo, 0, 0); pool_free(pool); exit(0);