diff options
author | Michael Schroeder <mls@suse.de> | 2014-02-26 13:08:52 +0100 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2014-02-26 13:08:52 +0100 |
commit | 2a338a1b264d3043e715b4f1838c075753ce2fdb (patch) | |
tree | 0aba832ad556ca2e06c853af850fd614d945af7d | |
parent | 673b10389cfdea7282d2587a00a01c9b0cf713d9 (diff) | |
download | libsolv-2a338a1b264d3043e715b4f1838c075753ce2fdb.tar.gz libsolv-2a338a1b264d3043e715b4f1838c075753ce2fdb.tar.bz2 libsolv-2a338a1b264d3043e715b4f1838c075753ce2fdb.zip |
appdata2solv: add support for -d and -r options
-rw-r--r-- | tools/appdata2solv.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/tools/appdata2solv.c b/tools/appdata2solv.c index 129fbc3..a8753a1 100644 --- a/tools/appdata2solv.c +++ b/tools/appdata2solv.c @@ -20,6 +20,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include "pool.h" #include "repo.h" @@ -30,11 +31,46 @@ int main(int argc, char **argv) { Pool *pool = pool_create(); - Repo *repo = repo_create(pool, "<stdin>"); - if (repo_add_appdata(repo, stdin, 0)) + Repo *repo; + int c; + const char *appdatadir = 0; + const char *root = 0; + + while ((c = getopt(argc, argv, "hd:r:")) >= 0) + { + switch (c) + { + case 'd': + appdatadir = optarg; + break; + case 'r': + root = optarg; + break; + default: + fprintf(stderr, "usage: appdata2solv [-d appdatadir]"); + exit(c == 'h' ? 0 : 1); + } + } + + if (root) + pool_set_rootdir(pool, root); + + repo = repo_create(pool, "<stdin>"); + if (!appdatadir) + { + if (repo_add_appdata(repo, stdin, 0)) + { + fprintf(stderr, "appdata2solv: %s\n", pool_errstr(pool)); + exit(1); + } + } + else { - fprintf(stderr, "appdata2solv: %s\n", pool_errstr(pool)); - exit(1); + if (repo_add_appdata_dir(repo, appdatadir, REPO_USE_ROOTDIR)) + { + fprintf(stderr, "appdata2solv: %s\n", pool_errstr(pool)); + exit(1); + } } tool_write(repo, 0, 0); pool_free(pool); |