本文整理汇总了C++中pkgdb_it_free函数的典型用法代码示例。如果您正苦于以下问题:C++ pkgdb_it_free函数的具体用法?C++ pkgdb_it_free怎么用?C++ pkgdb_it_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pkgdb_it_free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pkgs_providing_lib
static int
pkgs_providing_lib(struct pkgdb *db, const char *libname)
{
struct pkgdb_it *it = NULL;
struct pkg *pkg = NULL;
const char *name, *version;
int ret = EPKG_OK;
int count = 0;
if ((it = pkgdb_query_shlib_provided(db, libname)) == NULL) {
return (EPKG_FATAL);
}
while ((ret = pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC)) == EPKG_OK) {
if (count == 0)
printf("%s is provided by the following packages:\n",
libname);
count++;
pkg_get(pkg, PKG_NAME, &name, PKG_VERSION, &version);
printf("%s-%s\n", name, version);
}
if (ret == EPKG_END) {
if (count == 0)
printf("No packages provide %s.\n", libname);
ret = EPKG_OK;
}
pkg_free(pkg);
pkgdb_it_free(it);
return (ret);
}
开发者ID:DarknessWarrior,项目名称:pkg,代码行数:33,代码来源:shlib.c
示例2: check_summary
static void
check_summary(struct pkgdb *db, struct deps_head *dh)
{
struct deps_entry *e = NULL;
struct pkg *pkg = NULL;
struct pkgdb_it *it = NULL;
bool fixed = true;
assert(db != NULL);
printf(">>> Summary of actions performed:\n\n");
STAILQ_FOREACH(e, dh, next) {
if ((it = pkgdb_query(db, e->origin, MATCH_EXACT)) == NULL)
return;
if (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) != EPKG_OK) {
fixed = false;
printf("%s dependency failed to be fixed\n", e->origin);
} else
printf("%s dependency has been fixed\n", e->origin);
pkgdb_it_free(it);
}
if (fixed) {
printf("\n>>> Missing dependencies were fixed successfully.\n");
} else {
printf("\n>>> There are still missing dependencies.\n");
printf(">>> You are advised to try fixing them manually.\n");
printf("\n>>> Also make sure to check 'pkg updating' for known issues.\n");
}
pkg_free(pkg);
}
开发者ID:HonestQiao,项目名称:pkgng,代码行数:35,代码来源:check.c
示例3: pkg_jobs_universe_process_provides_requires
static int
pkg_jobs_universe_process_provides_requires(struct pkg_jobs_universe *universe,
struct pkg *pkg)
{
struct pkg_job_provide *pr;
struct pkgdb_it *it;
char *buf = NULL;
int rc;
while (pkg_requires(pkg, &buf) == EPKG_OK) {
HASH_FIND_STR(universe->provides, buf, pr);
if (pr != NULL)
continue;
/* Check for local provides */
it = pkgdb_query_provide(universe->j->db, buf);
if (it != NULL) {
rc = pkg_jobs_universe_handle_provide(universe, it, buf, false, pkg);
pkgdb_it_free(it);
if (rc != EPKG_OK) {
pkg_debug(1, "cannot find local packages that provide %s "
"required for %s",
buf, pkg->name);
}
}
/* Not found, search in the repos */
it = pkgdb_repo_provide(universe->j->db,
buf, universe->j->reponame);
if (it != NULL) {
rc = pkg_jobs_universe_handle_provide(universe, it, buf, false, pkg);
pkgdb_it_free(it);
if (rc != EPKG_OK) {
pkg_debug(1, "cannot find remote packages that provide %s "
"required for %s",
buf, pkg->name);
return (rc);
}
}
}
return (EPKG_OK);
}
开发者ID:HardenedBSD,项目名称:pkg,代码行数:46,代码来源:pkg_jobs_universe.c
示例4: test_depends
static int
test_depends(void *actdata, struct pkg *pkg, const char *fpath,
const char *name, bool is_shlib)
{
struct pkgdb *db = actdata;
struct pkg_dep *dep = NULL;
struct pkgdb_it *it = NULL;
struct pkg *d;
const char *deporigin, *depname, *depversion;
const char *pkgname, *pkgversion;
bool deplocked;
char pathbuf[MAXPATHLEN];
assert(db != NULL);
switch(filter_system_shlibs(name, pathbuf, sizeof(pathbuf))) {
case EPKG_OK: /* A non-system library */
break;
case EPKG_END: /* A system library */
return (EPKG_OK);
default:
/* Ignore link resolution errors if we're analysing a
shared library. */
if (is_shlib)
return (EPKG_OK);
pkg_get(pkg, PKG_NAME, &pkgname, PKG_VERSION, &pkgversion);
warnx("(%s-%s) %s - shared library %s not found",
pkgname, pkgversion, fpath, name);
return (EPKG_FATAL);
}
pkg_addshlib_required(pkg, name);
if ((it = pkgdb_query_which(db, pathbuf, false)) == NULL)
return (EPKG_OK);
d = NULL;
if (pkgdb_it_next(it, &d, PKG_LOAD_BASIC) == EPKG_OK) {
pkg_get(d, PKG_ORIGIN, &deporigin,
PKG_NAME, &depname,
PKG_VERSION, &depversion,
PKG_LOCKED, &deplocked);
dep = pkg_dep_lookup(pkg, deporigin);
if (dep == NULL) {
pkg_debug(1, "Autodeps: adding unlisted depends (%s): %s-%s",
pathbuf, depname, depversion);
pkg_adddep(pkg, depname, deporigin, depversion,
deplocked);
}
pkg_free(d);
}
pkgdb_it_free(it);
return (EPKG_OK);
}
开发者ID:namore,项目名称:pkg,代码行数:58,代码来源:pkg_elf.c
示例5: fix_deps
static int
fix_deps(struct pkgdb *db, struct deps_head *dh, int nbpkgs, bool yes)
{
struct pkg *pkg = NULL;
struct pkgdb_it *it = NULL;
struct pkg_jobs *jobs = NULL;
struct deps_entry *e = NULL;
char **pkgs = NULL;
int i = 0;
assert(db != NULL);
assert(nbpkgs > 0);
if ((pkgs = calloc(nbpkgs, MAXPATHLEN + 1)) == NULL)
err(1, "calloc()");
STAILQ_FOREACH(e, dh, next)
pkgs[i++] = e->origin;
if (pkgdb_open(&db, PKGDB_REMOTE) != EPKG_OK)
return (EPKG_ENODB);
if (pkg_jobs_new(&jobs, PKG_JOBS_INSTALL, db) != EPKG_OK)
free(pkgs);
if ((it = pkgdb_query_installs(db, MATCH_EXACT, nbpkgs, pkgs, NULL, false)) == NULL) {
free(pkgs);
pkg_jobs_free(jobs);
}
while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC|PKG_LOAD_DEPS) == EPKG_OK) {
pkg_jobs_add(jobs, pkg);
pkg = NULL;
}
if (pkg_jobs_is_empty(jobs)) {
printf("\n>>> Unable to find packages for installation.\n\n");
return (EPKG_FATAL);
}
/* print a summary before applying the jobs */
pkg = NULL;
print_jobs_summary(jobs, PKG_JOBS_INSTALL, "The following packages will be installed:\n\n");
if (yes == false)
yes = query_yesno("\n>>> Try to fix the missing dependencies [y/N]: ");
if (yes == true)
pkg_jobs_apply(jobs, 0);
free(pkgs);
pkg_free(pkg);
pkg_jobs_free(jobs);
pkgdb_it_free(it);
return (EPKG_OK);
}
开发者ID:baloo,项目名称:pkgng,代码行数:58,代码来源:check.c
示例6: pkg_create_matches
static int
pkg_create_matches(int argc, char **argv, match_t match, pkg_formats fmt, const char * const outdir, const char * const rootdir)
{
int i, ret = EPKG_OK, retcode = EPKG_OK;
struct pkgdb *db = NULL;
struct pkgdb_it *it = NULL;
struct pkg *pkg = NULL;
int query_flags = PKG_LOAD_DEPS | PKG_LOAD_CONFLICTS | PKG_LOAD_FILES | PKG_LOAD_CATEGORIES |
PKG_LOAD_DIRS | PKG_LOAD_SCRIPTS | PKG_LOAD_OPTIONS |
PKG_LOAD_MTREE | PKG_LOAD_LICENSES;
if (pkgdb_open(&db, PKGDB_DEFAULT) != EPKG_OK) {
pkgdb_close(db);
return (EX_IOERR);
}
if (match != MATCH_ALL) {
for (i = 0;i < argc; i++) {
if ((it = pkgdb_query(db, argv[i], match)) == NULL) {
goto cleanup;
}
while ((ret = pkgdb_it_next(it, &pkg, query_flags)) == EPKG_OK) {
printf("Creating package for %s-%s\n", pkg_get(pkg, PKG_NAME),
pkg_get(pkg, PKG_VERSION));
if (pkg_create_installed(outdir, fmt, rootdir, pkg) != EPKG_OK) {
retcode++;
}
}
}
} else {
if ((it = pkgdb_query(db, NULL, match)) == NULL) {
goto cleanup;
}
while ((ret = pkgdb_it_next(it, &pkg, query_flags)) == EPKG_OK) {
printf("Creating package for %s-%s\n", pkg_get(pkg, PKG_NAME),
pkg_get(pkg, PKG_VERSION));
if (pkg_create_installed(outdir, fmt, rootdir, pkg) != EPKG_OK) {
retcode++;
}
}
}
cleanup:
if (ret != EPKG_END) {
retcode++;
}
pkg_free(pkg);
pkgdb_it_free(it);
pkgdb_close(db);
return (retcode);
}
开发者ID:dnaeon,项目名称:pkgng,代码行数:53,代码来源:create.c
示例7: pkg_jobs_universe_get_remote
static pkg_chain_t *
pkg_jobs_universe_get_remote(struct pkg_jobs_universe *universe,
const char *uid, unsigned flag)
{
struct pkg *pkg = NULL;
pkg_chain_t *result = NULL;
struct pkgdb_it *it;
struct pkg_job_universe_item *unit, *cur, *found;
if (flag == 0) {
flag = PKG_LOAD_BASIC|PKG_LOAD_DEPS|PKG_LOAD_OPTIONS|
PKG_LOAD_PROVIDES|PKG_LOAD_REQUIRES|
PKG_LOAD_SHLIBS_REQUIRED|PKG_LOAD_SHLIBS_PROVIDED|
PKG_LOAD_ANNOTATIONS|PKG_LOAD_CONFLICTS;
}
HASH_FIND(hh, universe->items, uid, strlen(uid), unit);
if (unit != NULL && unit->pkg->type != PKG_INSTALLED) {
/* Search local in a universe chain */
cur = unit;
found = NULL;
do {
if (cur->pkg->type != PKG_INSTALLED) {
found = cur;
break;
}
cur = cur->prev;
} while (cur != unit);
if (found) {
/* Assume processed */
return (NULL);
}
}
if ((it = pkgdb_repo_query(universe->j->db, uid, MATCH_EXACT,
universe->j->reponame)) == NULL)
return (NULL);
while (pkgdb_it_next(it, &pkg, flag) == EPKG_OK) {
if (result == NULL)
result = calloc(1, sizeof(pkg_chain_t));
kv_prepend(typeof(pkg), *result, pkg);
pkg = NULL;
}
pkgdb_it_free(it);
return (result);
}
开发者ID:HardenedBSD,项目名称:pkg,代码行数:50,代码来源:pkg_jobs_universe.c
示例8: pkg_jobs_universe_get_local
struct pkg *
pkg_jobs_universe_get_local(struct pkg_jobs_universe *universe,
const char *uid, unsigned flag)
{
struct pkg *pkg = NULL;
struct pkgdb_it *it;
struct pkg_job_universe_item *unit, *cur, *found;
if (flag == 0) {
if (!IS_DELETE(universe->j))
flag = PKG_LOAD_BASIC|PKG_LOAD_DEPS|PKG_LOAD_RDEPS|PKG_LOAD_OPTIONS|
PKG_LOAD_REQUIRES|PKG_LOAD_PROVIDES|
PKG_LOAD_SHLIBS_REQUIRED|PKG_LOAD_SHLIBS_PROVIDED|PKG_LOAD_ANNOTATIONS|
PKG_LOAD_CONFLICTS;
else
flag = PKG_LOAD_BASIC|PKG_LOAD_RDEPS|PKG_LOAD_DEPS|PKG_LOAD_ANNOTATIONS;
}
HASH_FIND(hh, universe->items, uid, strlen(uid), unit);
if (unit != NULL) {
/* Search local in a universe chain */
cur = unit;
found = NULL;
do {
if (cur->pkg->type == PKG_INSTALLED) {
found = cur;
break;
}
cur = cur->prev;
} while (cur != unit);
if (found) {
pkgdb_ensure_loaded(universe->j->db, unit->pkg, flag);
return (unit->pkg);
}
}
if ((it = pkgdb_query(universe->j->db, uid, MATCH_EXACT)) == NULL)
return (NULL);
if (pkgdb_it_next(it, &pkg, flag) != EPKG_OK)
pkg = NULL;
pkgdb_it_free(it);
return (pkg);
}
开发者ID:HardenedBSD,项目名称:pkg,代码行数:47,代码来源:pkg_jobs_universe.c
示例9: exec_which
int
exec_which(int argc, char **argv)
{
struct pkgdb *db;
struct pkgdb_it *it;
struct pkg *pkg = NULL;
char pathabs[MAXPATHLEN + 1];
int ret = EPKG_OK, retcode = EPKG_OK;
const char *name, *version;
if (argc != 2) {
usage_which();
return (EX_USAGE);
}
if (pkgdb_open(&db, PKGDB_DEFAULT) != EPKG_OK) {
pkgdb_close(db);
return (EX_IOERR);
}
absolutepath(argv[1], pathabs, sizeof(pathabs));
if ((it = pkgdb_query_which(db, pathabs)) == NULL) {
return (EX_IOERR);
}
if (( ret = pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC)) == EPKG_OK) {
retcode = EPKG_OK;
pkg_get(pkg, PKG_NAME, &name, PKG_VERSION, &version);
printf("%s was installed by package %s-%s\n", pathabs, name, version);
} else if (ret != EPKG_END) {
retcode = EPKG_WARN;
} else {
printf("%s was not found in the database\n", pathabs);
retcode = EPKG_WARN;
}
pkg_free(pkg);
pkgdb_it_free(it);
pkgdb_close(db);
return (retcode);
}
开发者ID:infofarmer,项目名称:pkgng,代码行数:43,代码来源:which.c
示例10: main
int
main(int argc, char **argv)
{
struct pkgdb *db;
int err;
if (argc != 2) {
fprintf(stderr, "usage: %s packagename\n", argv[0]);
return 1;
}
db = NULL;
err = pkg_init(NULL);
if (err == EPKG_OK)
err = getdb(&db);
else
fprintf(stderr, "could not parse config file\n");
if (err == EPKG_OK) {
struct pkgdb_it *it;
it = pkgdb_query(db, argv[1], MATCH_EXACT);
if (it == NULL)
printf("no local matches!\n");
else handle_it(it);
it = pkgdb_rquery(db, argv[1], MATCH_EXACT, NULL);
if (it == NULL)
printf("no remote matches!\n");
else handle_it(it);
printf("shutting down\n");
pkgdb_it_free(it);
pkgdb_close(db);
pkg_shutdown();
printf("shutdown\n");
}
}
开发者ID:CaptainHayashi,项目名称:pkgng-packagekit,代码行数:39,代码来源:querytest.c
示例11: exec_query
//.........这里部分代码省略.........
argv += optind;
if (argc == 0) {
usage_query();
return (EX_USAGE);
}
/* Default to all packages if no pkg provided */
if (argc == 1 && pkgname == NULL && condition == NULL && match == MATCH_EXACT) {
match = MATCH_ALL;
} else if ((argc == 1) ^ (match == MATCH_ALL) && pkgname == NULL && condition == NULL) {
usage_query();
return (EX_USAGE);
}
if (analyse_query_string(argv[0], accepted_query_flags, q_flags_len, &query_flags, &multiline) != EPKG_OK)
return (EX_USAGE);
if (pkgname != NULL) {
pkg_manifest_keys_new(&keys);
if (pkg_open(&pkg, pkgname, keys, 0) != EPKG_OK) {
return (EX_IOERR);
}
pkg_manifest_keys_free(keys);
print_query(pkg, argv[0], multiline);
pkg_free(pkg);
return (EX_OK);
}
if (condition != NULL) {
sqlcond = sbuf_new_auto();
if (format_sql_condition(condition, sqlcond, false) != EPKG_OK) {
sbuf_delete(sqlcond);
return (EX_USAGE);
}
sbuf_finish(sqlcond);
}
ret = pkgdb_access(PKGDB_MODE_READ, PKGDB_DB_LOCAL);
if (ret == EPKG_ENOACCESS) {
warnx("Insufficient privilege to query package database");
return (EX_NOPERM);
} else if (ret == EPKG_ENODB) {
if (!quiet)
warnx("No packages installed");
return (EX_OK);
} else if (ret != EPKG_OK)
return (EX_IOERR);
ret = pkgdb_open(&db, PKGDB_DEFAULT);
if (ret != EPKG_OK)
return (EX_IOERR);
if (match == MATCH_ALL || match == MATCH_CONDITION) {
const char *condition_sql = NULL;
if (match == MATCH_CONDITION && sqlcond)
condition_sql = sbuf_data(sqlcond);
if ((it = pkgdb_query(db, condition_sql, match)) == NULL)
return (EX_IOERR);
while ((ret = pkgdb_it_next(it, &pkg, query_flags)) == EPKG_OK)
print_query(pkg, argv[0], multiline);
if (ret != EPKG_END)
retcode = EX_SOFTWARE;
pkgdb_it_free(it);
} else {
int nprinted = 0;
for (i = 1; i < argc; i++) {
pkgname = argv[i];
if ((it = pkgdb_query(db, pkgname, match)) == NULL)
return (EX_IOERR);
while ((ret = pkgdb_it_next(it, &pkg, query_flags)) == EPKG_OK) {
nprinted++;
print_query(pkg, argv[0], multiline);
}
if (ret != EPKG_END) {
retcode = EX_SOFTWARE;
break;
}
pkgdb_it_free(it);
}
if (nprinted == 0 && retcode == EX_OK) {
/* ensure to return a non-zero status when no package
were found. */
retcode = EX_UNAVAILABLE;
}
}
pkg_free(pkg);
pkgdb_close(db);
return (retcode);
}
开发者ID:afb,项目名称:pkgng,代码行数:101,代码来源:query.c
示例12: exec_query
int
exec_query(int argc, char **argv)
{
struct pkgdb *db = NULL;
struct pkgdb_it *it = NULL;
struct pkg *pkg = NULL;
char *pkgname = NULL;
int query_flags = PKG_LOAD_BASIC;
match_t match = MATCH_EXACT;
int ch;
int ret = EPKG_OK;
int retcode = EXIT_SUCCESS;
int i;
char multiline = 0;
while ((ch = getopt(argc, argv, "agxXf:")) != -1) {
switch (ch) {
case 'a':
match = MATCH_ALL;
break;
case 'g':
match = MATCH_GLOB;
break;
case 'x':
match = MATCH_REGEX;
break;
case 'X':
match = MATCH_EREGEX;
break;
case 'f':
pkgname = optarg;
break;
default:
usage_query();
return (EX_USAGE);
}
}
argc -= optind;
argv += optind;
if (argc == 0) {
usage_query();
return (EX_USAGE);
}
if ((argc == 1) ^ (match == MATCH_ALL) && pkgname == NULL) {
usage_query();
return (EX_USAGE);
}
if (analyse_query_string(argv[0], &query_flags, &multiline) != EPKG_OK)
return (EX_USAGE);
if (pkgname != NULL) {
if (pkg_open(&pkg, pkgname, NULL) != EPKG_OK) {
return (1);
}
print_query(pkg, argv[0], multiline);
pkg_free(pkg);
return (0);
}
if (pkgdb_open(&db, PKGDB_DEFAULT) != EPKG_OK)
return (EX_IOERR);
if (match == MATCH_ALL) {
if ((it = pkgdb_query(db, NULL, match)) == NULL)
return (EX_IOERR);
while ((ret = pkgdb_it_next(it, &pkg, query_flags)) == EPKG_OK)
print_query(pkg, argv[0], multiline);
if (ret != EPKG_END)
retcode = EX_SOFTWARE;
pkgdb_it_free(it);
} else {
for (i = 1; i < argc; i++) {
pkgname = argv[i];
if ((it = pkgdb_query(db, pkgname, match)) == NULL)
return (EX_IOERR);
while ((ret = pkgdb_it_next(it, &pkg, query_flags)) == EPKG_OK)
print_query(pkg, argv[0], multiline);
if (ret != EPKG_END) {
retcode = EX_SOFTWARE;
break;
}
pkgdb_it_free(it);
}
}
pkg_free(pkg);
pkgdb_close(db);
//.........这里部分代码省略.........
开发者ID:culot,项目名称:pkgng,代码行数:101,代码来源:query.c
示例13: exec_set
//.........这里部分代码省略.........
}
if (pkgdb_open(&db, PKGDB_DEFAULT) != EPKG_OK) {
free(newvalue);
return (EX_IOERR);
}
if (pkgdb_obtain_lock(db, PKGDB_LOCK_EXCLUSIVE) != EPKG_OK) {
pkgdb_close(db);
free(newvalue);
warnx("Cannot get an exclusive lock on a database, it is locked by another process");
return (EX_TEMPFAIL);
}
if (pkgdb_transaction_begin(db, NULL) != EPKG_OK) {
pkgdb_close(db);
free(newvalue);
warnx("Cannot start transaction for update");
return (EX_TEMPFAIL);
}
if (oldvalue != NULL) {
match = MATCH_ALL;
if ((it = pkgdb_query(db, oldvalue, MATCH_EXACT)) == NULL) {
retcode = EX_IOERR;
goto cleanup;
}
if (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) != EPKG_OK) {
pkg = NULL;
/* fprintf(stderr, "%s not installed\n", oldorigin);
free(oldorigin);
pkgdb_it_free(it);
pkgdb_close(db);
return (EX_SOFTWARE);*/
}
rc = yes;
if (!yes) {
if (pkg != NULL)
rc = query_yesno(false, "Change %S from %S to %S for %n-%v? ",
changed, oldvalue, newvalue, pkg, pkg);
else
rc = query_yesno(false, "Change %S from %S to %S for all dependencies? ",
changed, oldvalue, newvalue);
}
if (pkg != NULL && rc) {
if (pkgdb_set(db, pkg, field, newvalue) != EPKG_OK) {
retcode = EX_IOERR;
goto cleanup;
}
}
pkgdb_it_free(it);
}
i = 0;
do {
bool saved_rc = rc;
if ((it = pkgdb_query(db, argv[i], match)) == NULL) {
retcode = EX_IOERR;
goto cleanup;
}
while (pkgdb_it_next(it, &pkg, loads) == EPKG_OK) {
if ((sets & AUTOMATIC) == AUTOMATIC) {
开发者ID:dlandry,项目名称:GitEducation,代码行数:67,代码来源:set.c
示例14: exec_search
//.........这里部分代码省略.........
break;
case 'L':
label = search_label_opt(optarg);
break;
case 'o': /* Same as -L origin */
label = search_label_opt("origin");
break;
case 'p': /* Same as -Q prefix */
opt |= modifier_opt("prefix");
break;
case 'q':
quiet = true;
break;
case 'Q':
opt |= modifier_opt(optarg);
break;
case 'r':
reponame = optarg;
break;
case 'S':
search = search_label_opt(optarg);
break;
case 's': /* Same as -Q size */
opt |= modifier_opt("size");
break;
case 'x':
match = MATCH_REGEX;
break;
default:
usage_search();
return (EX_USAGE);
}
}
argc -= optind;
argv += optind;
if (argc != 1) {
usage_search();
return (EX_USAGE);
}
pattern = argv[0];
if (pattern[0] == '\0') {
fprintf(stderr, "Pattern must not be empty!\n");
return (EX_USAGE);
}
if (search == FIELD_NONE) {
if (strchr(pattern, '/') != NULL)
search = FIELD_ORIGIN;
else
search = FIELD_NAMEVER; /* Default search */
}
if (label == FIELD_NONE)
label = search; /* By default, show what was searched */
switch(label) {
case FIELD_NONE:
break; /* should never happen */
case FIELD_ORIGIN:
opt |= INFO_TAG_ORIGIN;
break;
case FIELD_NAME:
opt |= INFO_TAG_NAME;
break;
case FIELD_NAMEVER:
opt |= INFO_TAG_NAMEVER;
break;
case FIELD_COMMENT:
opt |= INFO_TAG_NAMEVER|INFO_COMMENT;
break;
case FIELD_DESC:
opt |= INFO_TAG_NAMEVER|INFO_DESCR;
break;
}
if (pkgdb_open(&db, PKGDB_REMOTE) != EPKG_OK)
return (EX_IOERR);
if ((it = pkgdb_search(db, pattern, match, search, search,
reponame)) == NULL) {
pkgdb_close(db);
return (EX_IOERR);
}
flags = info_flags(opt);
while ((ret = pkgdb_it_next(it, &pkg, flags)) == EPKG_OK) {
print_info(pkg, opt);
atleastone = true;
}
pkg_free(pkg);
pkgdb_it_free(it);
pkgdb_close(db);
if (!atleastone)
ret = EPKG_FATAL;
return ((ret == EPKG_OK || ret == EPKG_END) ? EX_OK : EX_SOFTWARE);
}
开发者ID:aklv,项目名称:pkgng,代码行数:101,代码来源:search.c
示例15: pkg_update_incremental
//.........这里部分代码省略.........
origin = strsep(&p, ":");
digest = strsep(&p, ":");
offset = strsep(&p, ":");
if (origin == NULL || digest == NULL ||
offset == NULL) {
pkg_emit_error("invalid digest file format");
assert(0);
rc = EPKG_FATAL;
goto cleanup;
}
errno = 0;
num_offset = (long)strtoul(offset, NULL, 10);
if (errno != 0) {
pkg_emit_errno("strtoul", "digest format error");
rc = EPKG_FATAL;
goto cleanup;
}
processed++;
HASH_FIND_STR(ldel, __DECONST(char *, origin), item);
if (item == NULL) {
added++;
pkg_update_increment_item_new(&ladd, origin, digest, num_offset);
} else {
if (strcmp(digest, item->digest) == 0) {
free(item->origin);
free(item->digest);
HASH_DEL(ldel, item);
free(item);
item = NULL;
} else {
free(item->origin);
free(item->digest);
HASH_DEL(ldel, item);
free(item);
item = NULL;
pkg_update_increment_item_new(&ladd, origin, digest, num_offset);
updated++;
}
}
}
rc = EPKG_OK;
pkg_debug(1, "Pkgrepo, removing old entries for '%s'", name);
removed = HASH_COUNT(ldel) - updated;
HASH_ITER(hh, ldel, item, tmp_item) {
if (rc == EPKG_OK) {
rc = pkgdb_repo_remove_package(item->origin);
}
free(item->origin);
free(item->digest);
HASH_DEL(ldel, item);
free(item);
}
pkg_config_string(PKG_CONFIG_ABI, &myarch);
pkg_debug(1, "Pkgrepo, pushing new entries for '%s'", name);
pkg = NULL;
if (len > 0 && len < SSIZE_MAX) {
map = mmap(NULL, len, PROT_READ, MAP_SHARED, fileno(fmanifest), 0);
fclose(fmanifest);
}
HASH_ITER(hh, ladd, item, tmp_item) {
if (rc == EPKG_OK) {
if (map != MAP_FAILED) {
rc = pkg_add_from_manifest(NULL, map + item->offset, item->origin,
len - item->offset, item->digest, myarch, sqlite, &parser, &pkg);
} else {
rc = pkg_add_from_manifest(fmanifest, NULL, item->origin,
item->offset, item->digest, myarch, sqlite, &parser, &pkg);
}
}
free(item->origin);
free(item->digest);
HASH_DEL(ladd, item);
free(item);
}
pkg_manifest_parser_free(parser);
pkg_emit_incremental_update(updated, removed, added, processed);
cleanup:
if (pkg != NULL)
pkg_free(pkg);
if (it != NULL)
pkgdb_it_free(it);
if (pkgdb_repo_close(sqlite, rc == EPKG_OK) != EPKG_OK)
rc = EPKG_FATAL;
if (map == MAP_FAILED && fmanifest)
fclose(fmanifest);
if (fdigests)
fclose(fdigests);
if (map != MAP_FAILED)
munmap(map, len);
return (rc);
}
开发者ID:renchap,项目名称:pkg,代码行数:101,代码来源:update.c
示例16: exec_search
//.........这里部分代码省略.........
argc -= optind;
argv += optind;
if (argc != 1) {
usage_search();
return (EX_USAGE);
}
pattern = argv[0];
if (pattern[0] == '\0') {
fprintf(stderr, "Pattern must not be empty.\n");
return (EX_USAGE);
}
if (search == FIELD_NONE) {
if (strchr(pattern, '/') != NULL)
search = FIELD_ORIGIN;
else
search = FIELD_NAMEVER; /* Default search */
}
if (label == FIELD_NONE)
label = search; /* By default, show what was searched */
switch(label) {
case FIELD_NONE:
break; /* should never happen */
case FIELD_ORIGIN:
opt |= INFO_TAG_ORIGIN|INFO_COMMENT;
break;
case FIELD_NAME:
opt |= INFO_TAG_NAME|INFO_COMMENT;
break;
case FIELD_NAMEVER:
opt |= INFO_TAG_NAMEVER|INFO_COMMENT;
break;
case FIELD_COMMENT:
opt |= INFO_TAG_NAMEVER|INFO_COMMENT;
break;
case FIELD_DESC:
opt |= INFO_TAG_NAMEVER|INFO_DESCR;
break;
}
if (quiet) {
opt = INFO_TAG_NAMEVER;
quiet = false;
}
ret = pkgdb_access(PKGDB_MODE_READ, PKGDB_DB_REPO);
switch(ret) {
case EPKG_ENOACCESS:
warnx("Insufficient privileges to query the package database");
return (EX_NOPERM);
case EPKG_ENODB:
if (!auto_update) {
warnx("Unable to open remote repository catalogues. Try running '%s update' first.", getprogname());
return (EX_IOERR);
}
break;
case EPKG_OK:
break;
default:
return (EX_IOERR);
}
/* first update the remote repositories if needed */
old_quiet = quiet;
quiet = true;
if (auto_update && (ret = pkgcli_update(false, false, reponame)) != EPKG_OK)
return (ret);
quiet = old_quiet;
if (pkgdb_open_all(&db, PKGDB_REMOTE, reponame) != EPKG_OK)
return (EX_IOERR);
if ((it = pkgdb_repo_search(db, pattern, match, search, search,
reponame)) == NULL) {
pkgdb_close(db);
return (EX_IOERR);
}
if (opt & INFO_RAW) {
if ((opt & (INFO_RAW_JSON|INFO_RAW_JSON_COMPACT)) == 0)
opt |= INFO_RAW_YAML;
}
flags = info_flags(opt, true);
while ((ret = pkgdb_it_next(it, &pkg, flags)) == EPKG_OK) {
print_info(pkg, opt);
atleastone = true;
}
pkg_free(pkg);
pkgdb_it_free(it);
pkgdb_close(db);
if (!atleastone)
ret = EPKG_FATAL;
return ((ret == EPKG_OK || ret == EPKG_END) ? EX_OK : EX_SOFTWARE);
}
开发者ID:dlandry,项目名称:GitEducation,代码行数:101,代码来源:search.c
示例17: exec_fetch
int
exec_fetch(int argc, char **argv)
{
struct pkg *pkg = NULL;
struct pkgdb_it *it = NULL;
struct pkgdb *db = NULL;
struct pkg_jobs *jobs = NULL;
const char *reponame = NULL;
int retcode = EXIT_FAILURE;
int ch;
int flags = PKG_LOAD_BASIC;
bool yes = false;
bool auto_update = true;
match_t match = MATCH_EXACT;
while ((ch = getopt(argc, argv, "ygxXr:qaLd")) != -1) {
switch (ch) {
case 'y':
yes = true;
break;
case 'a':
match = MATCH_ALL;
break;
case 'g':
match = MATCH_GLOB;
break;
case 'x':
match = MATCH_REGEX;
break;
case 'X':
match = MATCH_EREGEX;
break;
case 'r':
reponame = optarg;
break;
case 'q':
quiet = true;
break;
case 'L':
auto_update = false;
break;
case 'd':
flags |= PKG_LOAD_DEPS;
break;
default:
usage_fetch();
return (EX_USAGE);
}
}
argc -= optind;
argv += optind;
if (argc < 1 && match != MATCH_ALL) {
usage_fetch();
return (EX_USAGE);
}
/* TODO: Allow the user to specify an output directory via -o outdir */
if (geteuid() != 0) {
warnx("Fetching packages can only be done as root");
return (EX_NOPERM);
}
/* first update the remote repositories if needed */
if (auto_update && (retcode = pkgcli_update()) != EPKG_OK)
return (retcode);
if (pkgdb_open(&db, PKGDB_REMOTE) != EPKG_OK) {
return (EX_IOERR);
}
if (pkg_jobs_new(&jobs, PKG_JOBS_FETCH, db) != EPKG_OK) {
goto cleanup;
}
if ((it = pkgdb_query_fetch(db, match, argc, argv, reponame, flags)) == NULL)
goto cleanup;
while (pkgdb_it_next(it, &pkg, flags) == EPKG_OK) {
pkg_jobs_add(jobs, pkg);
pkg = NULL;
}
pkgdb_it_free(it);
if (pkg_jobs_is_empty(jobs))
goto cleanup;
if (!quiet) {
print_jobs_summary(jobs, PKG_JOBS_FETCH, "The following packages will be fetched:\n\n");
if (!yes)
pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
if (!yes)
yes = query_yesno("\nProceed with fetching packages [y/N]: ");
}
if (yes)
if (pkg_jobs_apply(jobs, 0) != EPKG_OK)
goto cleanup;
//.........这里部分代码省略.........
开发者ID:baloo,项目名称:pkgng,代码行数:101,代码来源:fetch.c
示例18: exec_check
//.........这里部分代码省略.........
break;
case 's':
checksums = true;
flags |= PKG_LOAD_FILES;
break;
case 'r':
recompute = true;
flags |= PKG_LOAD_FILES;
if (geteuid() != 0)
errx(EX_USAGE, "recomputing the checksums"
" and size can only be done as root");
break;
case 'v':
verbose = 1;
break;
default:
usage_check();
return (EX_USAGE);
}
}
argc -= optind;
argv += optind;
/* Default to all packages if no pkg provided */
if (argc == 0 && (dcheck || checksums || recompute || reanalyse_shlibs)) {
match = MATCH_ALL;
} else if ((argc == 0 && match != MATCH_ALL) || !(dcheck || checksums || recompute || reanalyse_shlibs)) {
usage_check();
return (EX_USAGE);
}
ret = pkgdb_open(&db, PKGDB_DEFAULT);
if (ret == EPKG_ENODB) {
if (geteuid() == 0)
return (EX_IOERR);
return (EX_OK);
}
if (ret != EPKG_OK)
return (EX_IOERR);
i = 0;
do {
if ((it = pkgdb_query(db, argv[i], match)) == NULL) {
pkgdb_close(db);
return (EX_IOERR);
}
while (pkgdb_it_next(it, &pkg, flags) == EPKG_OK) {
const char *pkgname = NULL;
pkg_get(pkg, PKG_NAME, &pkgname);
/* check for missing dependencies */
if (dcheck) {
if (verbose)
printf("Checking dependencies: %s\n", pkgname);
nbpkgs += check_deps(db, pkg, &dh);
}
if (checksums) {
if (verbose)
printf("Checking checksums: %s\n", pkgname);
pkg_test_filesum(pkg);
}
if (recompute) {
if (verbose)
printf("Recomputing size and checksums: %s\n", pkgname);
pkg_recompute(db, pkg);
}
if (reanalyse_shlibs) {
if (verbose)
printf("Reanalyzing files for shlibs: %s\n", pkgname);
if (pkgdb_reanalyse_shlibs(db, pkg) != EPKG_OK)
printf("Failed to reanalyse for shlibs: %s\n", pkgname);
}
}
if (geteuid() == 0 && nbpkgs > 0) {
if (yes == false)
pkg_config_bool(PKG_CONFIG_ASSUME_ALWAYS_YES, &yes);
printf("\n>>> Missing package dependencies were detected.\n");
printf(">>> Found %d issue(s) in total with your package database.\n\n", nbpkgs);
ret = fix_deps(db, &dh, nbpkgs, yes);
if (ret == EPKG_OK)
check_summary(db, &dh);
else if (ret == EPKG_ENODB) {
db = NULL;
return (EX_IOERR);
}
}
pkgdb_it_free(it);
i++;
} while (i < argc);
deps_free(&dh);
pkg_free(pkg);
pkgdb_close(db);
return (EX_OK);
}
开发者ID:HonestQiao,项目名称:pkgng,代码行数:101,代码来源:check.c
示例19: pkg_repo_binary_it_free
static void
pkg_repo_binary_it_free(struct pkg_repo_it *it)
{
pkgdb_it_free(it->data);
free(it);
}
开发者ID:baitisj,项目名称:pkg,代码行数:6,代码来源:query.c
示例20: exec_set
//.........这里部分代码省略.........
return (EX_OK);
if (!quiet)
warnx("No packages installed. Nothing to do!");
return (EX_OK);
} else if (retcode == EPKG_ENOACCESS) {
warnx("Insufficient privileges to modify the package database");
return (EX_NOPERM);
} else if (retcode != EPKG_OK) {
warnx("Error accessing package database");
return (EX_SOFTWARE);
}
if (pkgdb_open(&db, PKGDB_DEFAULT) != EPKG_OK)
return (EX_IOERR);
if (pkgdb_obtain_lock(db, PKGDB_LOCK_EXCLUSIVE, 0, 0) != EPKG_OK) {
pkgdb_close(db);
warnx("Cannot get an exclusive lock on a database, it is locked by another process");
return (EX_TEMPFAIL);
}
if (oldorigin != NULL) {
match = MATCH_ALL;
if ((it = pkgdb_query(db, oldorigin, MATCH_EXACT)) == NULL) {
retcode = EX_IOERR;
goto cleanup;
}
if (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) != EPKG_OK) {
pkg = NULL;
/* fprintf(stderr, "%s not installed\n", oldorigin);
free(oldorigin);
pkgdb_it_free(it);
pkgdb_close(db);
return (EX_SOFTWARE);*/
}
if (!yes) {
if (pkg != NULL)
yes = query_yesno(false, "Change origin from %S to %S for %n-%v? [y/N]: ",
oldorigin, neworigin, pkg, pkg);
else
yes = query_yesno(false, "Change origin from %S to %S for all dependencies? "
"[y/N]: ", oldorigin, neworigin);
}
if (pkg != NULL && yes) {
if (pkgdb_set(db, pkg, PKG_SET_ORIGIN, neworigin) != EPKG_OK) {
retcode = EX_IOERR;
goto cleanup;
}
}
pkgdb_it_free(it);
}
i = 0;
do {
bool save_yes = yes;
if ((it = pkgdb_query(db, argv[i], match)) == NULL) {
retcode = EX_IOERR;
goto cleanup;
}
while (pkgdb_it_next(it, &pkg, loads) == EPKG_OK) {
if ((sets & AUTOMATIC) == AUTOMATIC) {
pkg_get(pkg, PKG_AUTOMATIC, &automatic);
开发者ID:rakhij,项目名称:pkg,代码行数:67,代码来源:set.c
注:本文中的pkgdb_it_free函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论