unsigned int refmask, h;
int asolv;
Repodata *repodata;
+ char dbpath[PATH_MAX];
if (repo->start != repo->end)
abort(); /* FIXME: rpmdbid */
if (!ref)
{
- if (db->open(db, 0, "/var/lib/rpm/Packages", 0, DB_HASH, DB_RDONLY, 0664))
+ snprintf(dbpath, PATH_MAX, "%s/var/lib/rpm/Packages", rootdir);
+ if (db->open(db, 0, dbpath, 0, DB_HASH, DB_RDONLY, 0664))
{
- perror("db->open /var/lib/rpm/Packages");
+ perror("db->open var/lib/rpm/Packages");
exit(1);
}
if (db->get_byteswapped(db, &byteswapped))
}
else
{
- if (db->open(db, 0, "/var/lib/rpm/Name", 0, DB_HASH, DB_RDONLY, 0664))
+ snprintf(dbpath, PATH_MAX, "%s/var/lib/rpm/Name", rootdir);
+ if (db->open(db, 0, dbpath, 0, DB_HASH, DB_RDONLY, 0664))
{
- perror("db->open /var/lib/rpm/Name");
+ perror("db->open var/lib/rpm/Name");
exit(1);
}
if (db->get_byteswapped(db, &byteswapped))
perror("db_create");
exit(1);
}
- if (db->open(db, 0, "/var/lib/rpm/Packages", 0, DB_HASH, DB_RDONLY, 0664))
+ snprintf(dbpath, PATH_MAX, "%s/var/lib/rpm/Packages", rootdir);
+ if (db->open(db, 0, dbpath, 0, DB_HASH, DB_RDONLY, 0664))
{
- perror("db->open /var/lib/rpm/Packages");
+ perror("db->open var/lib/rpm/Packages");
exit(1);
}
if (db->get_byteswapped(db, &byteswapped))
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "pool.h"
#include "repo.h"
Pool *pool = pool_create();
Repo *repo, *ref = 0;
FILE *fp;
+ Pool *refpool;
+ int g;
+ const char *root = "/";
- if (argc != 1)
- {
- Pool *refpool = pool;
- if ((fp = fopen(argv[1], "r")) == NULL)
- {
- perror(argv[1]);
- exit(0);
- }
- ref = repo_create(refpool, "ref");
- repo_add_solv(ref, fp);
- fclose(fp);
- }
-
+ while ((g = getopt (argc, argv, "-r:")) >= 0)
+ switch (g)
+ {
+ case 'r': root = optarg; break;
+ case 1:
+ refpool = pool;
+ if ((fp = fopen(argv[1], "r")) == NULL)
+ {
+ perror(argv[1]);
+ exit(0);
+ }
+ ref = repo_create(refpool, "ref");
+ repo_add_solv(ref, fp);
+ fclose(fp);
+ }
+
repo = repo_create(pool, "installed");
- repo_add_rpmdb(repo, ref, "/");
+ repo_add_rpmdb(repo, ref, root);
if (ref)
{
if (ref->pool != pool)