2 * Copyright (c) 2007, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
11 * Reads rpm database (and evtl. more, like product metadata) to build
12 * a .solv file of 'installed' solvables.
16 #include <sys/types.h>
26 #include "repo_rpmdb.h"
27 #include "repo_products.h"
28 #include "repo_solv.h"
29 #include "common_write.h"
32 main(int argc, char **argv)
34 Pool *pool = pool_create();
43 const char *basefile = 0;
44 const char *proddir = 0;
50 while ((c = getopt (argc, argv, "nxb:r:p:")) >= 0)
79 refpool = pool_create();
82 if ((fp = fopen(argv[optind], "r")) == NULL)
87 ref = repo_create(refpool, "ref");
88 repo_add_solv(ref, fp);
89 repo_disable_paging(ref);
94 * create 'installed' repository
100 repo = repo_create(pool, "installed");
101 repodata = repo_add_repodata(repo, 0);
104 repo_add_rpmdb(repo, repodata, ref, root);
106 if (proddir && *proddir)
108 /* if <root> given, not '/', and proddir does not start with <root> */
111 int rootlen = strlen(root);
112 if (strncmp(root, proddir, rootlen))
115 buf = (char *)sat_malloc(rootlen + strlen(proddir) + 2); /* + '/' + \0 */
117 if (root[rootlen-1] != '/'
120 strcpy(buf+rootlen, "/");
123 strcpy(buf+rootlen, proddir);
128 repo_add_products(repo, repodata, proddir);
132 repodata_internalize(repodata);
136 if (ref->pool != pool)
137 pool_free(ref->pool);
143 tool_write(repo, basefile, 0);