diff options
author | dinesh <dinesh@dinesh-laptop> | 2008-08-05 22:55:19 +0530 |
---|---|---|
committer | dinesh <dinesh@dinesh-laptop> | 2008-08-05 22:55:19 +0530 |
commit | 2e0ef31d8963eb146337093252d6ae28d2b18813 (patch) | |
tree | d4556ad4e8bbe962f0ce305109b52d374fa73c95 | |
parent | 338b91f5d9f391a29f43568872e4406438ff2af8 (diff) |
commiting create_dep_tar uses get_deps as of now
-rw-r--r-- | tools/Makefile | 8 | ||||
-rw-r--r-- | tools/create_dep_tar.c | 45 |
2 files changed, 50 insertions, 3 deletions
diff --git a/tools/Makefile b/tools/Makefile index a312e5dd..141eb326 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,10 +1,12 @@ tools/ccan_depends: tools/ccan_depends.o tools/depends.o ccan/string/string.o ccan/talloc/talloc.o ccan/noerr/noerr.o -tools/run_tests: tools/run_tests.o tools/depends.o ccan/tap/tap.o ccan/string/string.o ccan/talloc/talloc.o +tools/run_tests: tools/run_tests.o tools/depends.o ccan/tap/tap.o ccan/string/string.o ccan/noerr/noerr.o ccan/talloc/talloc.o -tools/doc_extract: tools/doc_extract.o ccan/string/string.o ccan/talloc/talloc.o +tools/doc_extract: tools/doc_extract.o ccan/string/string.o ccan/noerr/noerr.o ccan/talloc/talloc.o -tools/namespacize: tools/namespacize.o tools/depends.o ccan/string/string.o ccan/talloc/talloc.o +tools/namespacize: tools/namespacize.o tools/depends.o ccan/string/string.o ccan/noerr/noerr.o ccan/talloc/talloc.o + +tools/create_dep_tar: tools/create_dep_tar.o tools/depends.o ccan/string/string.o ccan/noerr/noerr.o ccan/talloc/talloc.o tools/run_tests.o tools/namespacize.o tools/depends.o: tools/tools.h diff --git a/tools/create_dep_tar.c b/tools/create_dep_tar.c new file mode 100644 index 00000000..8247e57e --- /dev/null +++ b/tools/create_dep_tar.c @@ -0,0 +1,45 @@ +#include "tools.h" +#include <err.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include "ccan/string/string.h" +#include "ccan/talloc/talloc.h" + +#define TAR_CMD "tar cvvf " + +static void create_tar(char **deps, const char *dir) +{ + FILE *p; + char *cmd_args, *cmd, *module, *buffer; + + /* getting module name*/ + module = strrchr(dir, '/'); + module++; + + cmd_args = strjoin(NULL, deps, " "); + cmd = talloc_asprintf(NULL, TAR_CMD "%s/%s_dep.tar %s", dir, module, cmd_args); + + p = popen(cmd, "r"); + if (!p) + err(1, "Executing '%s'", cmd); + + buffer = grab_fd(NULL, fileno(p)); + if (!buffer) + err(1, "Reading from '%s'", cmd); + pclose(p); +} + +int main(int argc, char *argv[]) +{ + char **deps; + + if (argc != 2) + errx(1, "Usage: create_dep_tar <dir>\n" + "Create tar of all the ccan dependencies"); + + deps = get_deps(NULL, argv[1]); + if(deps != NULL) + create_tar(deps, argv[1]); + return 0; +} |