当前位置: 首页>>代码示例>>C++>>正文


C++ pkg_get函数代码示例

本文整理汇总了C++中pkg_get函数的典型用法代码示例。如果您正苦于以下问题:C++ pkg_get函数的具体用法?C++ pkg_get怎么用?C++ pkg_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pkg_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: do_add

static int
do_add(struct pkgdb *db, struct pkg *pkg, const char *tag, const char *value)
{
	const char	*pkgname, *pkgversion;
	int		 ret = EPKG_OK;


	if (yes || query_tty_yesno(false, "%n-%v: Add annotation tagged: %S with "
	               "value: %S? [y/N]: ", pkg, pkg, tag, value)) {

		ret = pkgdb_add_annotation(db, pkg, tag, value);
		if (ret == EPKG_OK) {
			if (!quiet)
				pkg_printf("%n-%v: added annotation tagged:"
				    " %S\n", pkg, pkg, tag);
		} else if (ret == EPKG_WARN) {
			if (!quiet) {
				pkg_get(pkg, PKG_NAME, &pkgname,
					PKG_VERSION, &pkgversion);
			
				warnx("%s-%s: Cannot add annotation tagged: "
				      "%s -- already exists", pkgname,
				      pkgversion, tag);
			}
		} else {
			pkg_get(pkg, PKG_NAME, &pkgname,
				PKG_VERSION, &pkgversion);

			warnx("%s-%s: Failed to add annotation tagged: %s",
			    pkgname, pkgversion, tag);
		}
	}
	return (ret);
}
开发者ID:dpl0,项目名称:pkg,代码行数:34,代码来源:annotate.c

示例2: pkg_create_archive

static struct packing *
pkg_create_archive(const char *outdir, struct pkg *pkg, pkg_formats format, int required_flags)
{
	char *pkg_path = NULL;
	struct packing *pkg_archive = NULL;

	/*
	 * Ensure that we have all the information we need
	 */
	if ((pkg->flags & required_flags) != required_flags) {
		printf("error: required flags not set\n");
		return NULL;
	}

	if (asprintf(&pkg_path, "%s/%s-%s", outdir, pkg_get(pkg, PKG_NAME), pkg_get(pkg, PKG_VERSION)) == -1) {
		perror("asprintf");
		return NULL; /* XXX do better */
	}
	if (packing_init(&pkg_archive, pkg_path, format) != EPKG_OK) {
		perror("packing_init");
		return NULL;
	}

	if (pkg_path != NULL)
		free(pkg_path);
	return pkg_archive;
}
开发者ID:flz,项目名称:pkgng,代码行数:27,代码来源:pkg_create.c

示例3: do_delete

static int
do_delete(struct pkgdb *db, struct pkg *pkg, const char *tag)
{
	const char	*pkgname, *pkgversion;
	int		 ret = EPKG_OK;

	if (yes || query_tty_yesno(false, "%n-%v: Delete annotation tagged: %S? "
			 "[y/N]: ", pkg, pkg, tag)) {
		ret = pkgdb_delete_annotation(db, pkg, tag);
		if (ret == EPKG_OK) {
			if (!quiet)
				pkg_printf("%n-%v: Deleted annotation "
				       "tagged: %S\n", pkg, pkg, tag);
		} else if (ret == EPKG_WARN) {
			if (!quiet) {
				pkg_get(pkg, PKG_NAME, &pkgname,
					PKG_VERSION, &pkgversion);

				warnx("%s-%s: Cannot delete annotation "
				     "tagged: %s -- because there is none",
				     pkgname, pkgversion, tag);
			}
		} else {
			pkg_get(pkg, PKG_NAME, &pkgname,
				PKG_VERSION, &pkgversion);

			warnx("%s-%s: Failed to delete annotation tagged: %s",
			     pkgname, pkgversion, tag);
		}
	}
	return (ret);
} 
开发者ID:dpl0,项目名称:pkg,代码行数:32,代码来源:annotate.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: pkg_script_run

int
pkg_script_run(struct pkg *pkg, pkg_script_t type)
{
	struct pkg_script *script = NULL;
	pkg_script_t stype;
	struct sbuf *script_cmd = sbuf_new_auto();
	size_t i;

	struct {
		const char *arg;
		const pkg_script_t b;
		const pkg_script_t a;
	} const map[] = {
		/* a implies b with argument arg */
		{"PRE-INSTALL",    PKG_SCRIPT_INSTALL,   PKG_SCRIPT_PRE_INSTALL},
		{"POST-INSTALL",   PKG_SCRIPT_INSTALL,   PKG_SCRIPT_POST_INSTALL},
		{"PRE-UPGRADE",    PKG_SCRIPT_UPGRADE,   PKG_SCRIPT_PRE_UPGRADE},
		{"POST-UPGRADE",   PKG_SCRIPT_UPGRADE,   PKG_SCRIPT_POST_UPGRADE},
		{"DEINSTALL",      PKG_SCRIPT_DEINSTALL, PKG_SCRIPT_PRE_DEINSTALL},
		{"POST-DEINSTALL", PKG_SCRIPT_DEINSTALL, PKG_SCRIPT_POST_DEINSTALL},
	};

	for (i = 0; i < sizeof(map) / sizeof(map[0]); i++) {
		if (map[i].a == type)
			break;
	}

	if (map[i].a != type)
		return (ERROR_BAD_ARG("type"));

	while (pkg_scripts(pkg, &script) == EPKG_OK) {

		stype = pkg_script_type(script);

		if (stype == map[i].a || stype == map[i].b) {
			sbuf_reset(script_cmd);
			sbuf_printf(script_cmd, "PKG_PREFIX=%s\nset -- %s-%s",
				pkg_get(pkg, PKG_PREFIX), pkg_get(pkg, PKG_NAME),
				pkg_get(pkg, PKG_VERSION));

			if (stype == map[i].b) {
				/* add arg **/
				sbuf_cat(script_cmd, " ");
				sbuf_cat(script_cmd, map[i].arg);
			}

			sbuf_cat(script_cmd, "\n");
			sbuf_cat(script_cmd, pkg_script_data(script));
			sbuf_finish(script_cmd);
			system(sbuf_data(script_cmd));

		}
	}

	sbuf_delete(script_cmd);

	return (EPKG_OK);
}
开发者ID:philpep,项目名称:pkgng,代码行数:58,代码来源:scripts.c

示例6: pkg_delete

int
pkg_delete(struct pkg *pkg, struct pkgdb *db, int force)
{
	struct pkg **rdeps;
	int i, ret;
	struct sbuf *rdep_msg;

	if (pkg == NULL)
		return (ERROR_BAD_ARG("pkg"));

	if (db == NULL)
		return (ERROR_BAD_ARG("db"));

	/*
	 * Ensure that we have all the informations we need
	 */
	if ((ret = pkgdb_loadrdeps(db, pkg)) != EPKG_OK)
		return (ret);
	if ((ret = pkgdb_loadfiles(db, pkg)) != EPKG_OK)
		return (ret);
	if ((ret = pkgdb_loadscripts(db, pkg)) != EPKG_OK)
		return (ret);
	if ((ret = pkgdb_loadmtree(db, pkg)) != EPKG_OK)
		return (ret);

	rdeps = pkg_rdeps(pkg);

	if (rdeps[0] != NULL) {
		rdep_msg = sbuf_new_auto();
		sbuf_printf(rdep_msg, "%s-%s is required by other packages:", pkg_get(pkg, PKG_NAME), pkg_get(pkg, PKG_VERSION));
		for (i = 0;rdeps[i] != NULL; i++) {
			sbuf_cat(rdep_msg, " ");
			sbuf_printf(rdep_msg, "%s-%s", pkg_get(rdeps[i], PKG_NAME), pkg_get(rdeps[i], PKG_VERSION));
		}
		if (!force) {
			sbuf_finish(rdep_msg);
			ret = pkg_error_set(EPKG_REQUIRED, "%s", sbuf_get(rdep_msg));
			sbuf_free(rdep_msg);
			return ret;
		}
		sbuf_cat(rdep_msg, ", deleting anyway");
		sbuf_finish(rdep_msg);
		fprintf(stderr, "%s\n", sbuf_get(rdep_msg));
		sbuf_free(rdep_msg);
	}

	if ((ret = pkg_script_pre_deinstall(pkg)) != EPKG_OK)
		return (ret);

	if ((ret = pkg_delete_files(pkg, force)) != EPKG_OK)
		return (ret);

	if ((ret = pkg_script_post_deinstall(pkg)) != EPKG_OK)
		return (ret);

	return (pkgdb_unregister_pkg(db, pkg_get(pkg, PKG_ORIGIN)));
}
开发者ID:flz,项目名称:pkgng,代码行数:57,代码来源:pkg_delete.c

示例7: 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

示例8: pkg_conflicts_chain_cmp_cb

static int
pkg_conflicts_chain_cmp_cb(struct pkg_conflict_chain *a, struct pkg_conflict_chain *b)
{
	const char *vera, *verb;

	if (a->req->skip || b->req->skip) {
		return (a->req->skip - b->req->skip);
	}

	pkg_get(a->req->item->pkg, PKG_VERSION, &vera);
	pkg_get(b->req->item->pkg, PKG_VERSION, &verb);

	/* Inverse sort to get the maximum version as the first element */
	return (pkg_version_cmp(vera, verb));
}
开发者ID:gavinatkinson,项目名称:pkg,代码行数:15,代码来源:pkg_conflicts.c

示例9: pkg_emit_upgrade_finished

void
pkg_emit_upgrade_finished(struct pkg *p)
{
    struct pkg_event ev;
    bool syslog_enabled = false;
    char *name, *version, *newversion;

    ev.type = PKG_EVENT_UPGRADE_FINISHED;
    ev.e_upgrade_finished.pkg = p;

    pkg_config_bool(PKG_CONFIG_SYSLOG, &syslog_enabled);
    if (syslog_enabled) {
        const char *actions[] = {
            "upgraded", "reinstalled", "downgraded"
        };
        int num_actions = sizeof(actions) / sizeof(*actions);
        int action;

        pkg_get(p, PKG_NAME, &name, PKG_VERSION, &version,
                PKG_NEWVERSION, &newversion);
        action = pkg_version_cmp(version, newversion) + 1;
        if (action >= 0 && action < num_actions)
            syslog(LOG_NOTICE, "%s %s: %s -> %s ",
                   name, actions[action], version, newversion);
    }

    pkg_emit_event(&ev);
}
开发者ID:rg1,项目名称:pkgng,代码行数:28,代码来源:pkg_event.c

示例10: pkg_repo_binary_add_from_manifest

static int
pkg_repo_binary_add_from_manifest(char *buf, const char *origin, const char *digest,
		long offset, sqlite3 *sqlite,
		struct pkg_manifest_key **keys, struct pkg **p, bool is_legacy,
		struct pkg_repo *repo)
{
	int rc = EPKG_OK;
	struct pkg *pkg;
	const char *local_origin, *pkg_arch;

	if (*p == NULL) {
		rc = pkg_new(p, PKG_REMOTE);
		if (rc != EPKG_OK)
			return (EPKG_FATAL);
	} else {
		pkg_reset(*p, PKG_REMOTE);
	}

	pkg = *p;

	pkg_manifest_keys_new(keys);
	rc = pkg_parse_manifest(pkg, buf, offset, *keys);
	if (rc != EPKG_OK) {
		goto cleanup;
	}
	rc = pkg_is_valid(pkg);
	if (rc != EPKG_OK) {
		goto cleanup;
	}

	/* Ensure that we have a proper origin and arch*/
	pkg_get(pkg, PKG_ORIGIN, &local_origin, PKG_ARCH, &pkg_arch);
	if (local_origin == NULL || strcmp(local_origin, origin) != 0) {
		pkg_emit_error("manifest contains origin %s while we wanted to add origin %s",
				local_origin ? local_origin : "NULL", origin);
		rc = EPKG_FATAL;
		goto cleanup;
	}

	if (pkg_arch == NULL || !is_valid_abi(pkg_arch, true)) {
		rc = EPKG_FATAL;
		pkg_emit_error("repository %s contains packages with wrong ABI: %s",
			repo->name, pkg_arch);
		goto cleanup;
	}

	pkg_set(pkg, PKG_REPONAME, repo->name);
	if (is_legacy) {
		pkg_set(pkg, PKG_OLD_DIGEST, digest);
		pkg_checksum_calculate(pkg, NULL);
	}
	else {
		pkg_set(pkg, PKG_DIGEST, digest);
	}

	rc = pkg_repo_binary_add_pkg(pkg, NULL, sqlite, true);

cleanup:
	return (rc);
}
开发者ID:zxombie,项目名称:pkg,代码行数:60,代码来源:update.c

示例11: populate_sums

static kh_sum_t *
populate_sums(struct pkgdb *db)
{
	struct pkg *p = NULL;
	struct pkgdb_it *it = NULL;
	const char *sum;
	char *cksum;
	size_t slen;
	kh_sum_t *suml = NULL;
	khint_t k;
	int ret;

	suml = kh_init_sum();
	it = pkgdb_repo_search(db, "*", MATCH_GLOB, FIELD_NAME, FIELD_NONE, NULL);
	while (pkgdb_it_next(it, &p, PKG_LOAD_BASIC) == EPKG_OK) {
		pkg_get(p, PKG_CKSUM, &sum);
		slen = MIN(strlen(sum), PKG_FILE_CKSUM_CHARS);
		cksum = strndup(sum, slen);
		k = kh_put_sum(suml, cksum, &ret);
		if (ret != 0)
			kh_value(suml, k) = cksum;
	}

	return (suml);
}
开发者ID:grembo,项目名称:pkg,代码行数:25,代码来源:clean.c

示例12: add_shlibs_to_pkg

/* ARGSUSED */
static int
add_shlibs_to_pkg(__unused void *actdata, struct pkg *pkg, const char *fpath,
		  const char *name, bool is_shlib)
{
	const char *pkgname, *pkgversion;
	struct pkg_file *file = NULL;
	const char *filepath;

	switch(filter_system_shlibs(name, NULL, 0)) {
	case EPKG_OK:		/* A non-system library */
		pkg_addshlib_required(pkg, name);
		return (EPKG_OK);
	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);

		while (pkg_files(pkg, &file) == EPKG_OK) {
			filepath = pkg_file_path(file);
			if (strcmp(&filepath[strlen(filepath) - strlen(name)], name) == 0) {
				pkg_addshlib_required(pkg, name);
				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);
	}
}
开发者ID:dschossig,项目名称:pkg,代码行数:36,代码来源:pkg_elf.c

示例13: check_deps

static int
check_deps(struct pkgdb *db, struct pkg *p, struct deps_head *dh, bool noinstall)
{
	struct pkg_dep *dep = NULL;
	char *name, *version, *origin;
	int nbpkgs = 0;

	assert(db != NULL);
	assert(p != NULL);

	name = version = origin = NULL;
	pkg_get(p, PKG_NAME, &name, PKG_VERSION, &version, PKG_ORIGIN, &origin);

	while (pkg_deps(p, &dep) == EPKG_OK) {
		/* do we have a missing dependency? */
		if (pkg_is_installed(db, pkg_dep_origin(dep)) != EPKG_OK) {
			if (noinstall)
				printf("%s\n", pkg_dep_origin(dep));
			else
				printf("%s has a missing dependency: %s\n", origin,
			       pkg_dep_origin(dep));
			add_missing_dep(dep, dh, &nbpkgs);
		}
	}
	
	return (nbpkgs);
}
开发者ID:yaneurabeya,项目名称:pkgng,代码行数:27,代码来源:check.c

示例14: pkg_create_archive

static struct packing *
pkg_create_archive(const char *outdir, struct pkg *pkg, pkg_formats format,
    unsigned required_flags)
{
	char		*pkg_path = NULL;
	struct packing	*pkg_archive = NULL;
	const char	*pkgname, *pkgversion;

	/*
	 * Ensure that we have all the information we need
	 */
	if (pkg->type != PKG_OLD_FILE)
		assert((pkg->flags & required_flags) == required_flags);

	if (mkdirs(outdir) != EPKG_OK)
		return NULL;

	pkg_get(pkg, PKG_NAME, &pkgname, PKG_VERSION, &pkgversion);
	if (asprintf(&pkg_path, "%s/%s-%s", outdir, pkgname, pkgversion) == -1) {
		pkg_emit_errno("asprintf", "");
		return (NULL);
	}

	if (packing_init(&pkg_archive, pkg_path, format) != EPKG_OK)
		pkg_archive = NULL;

	free(pkg_path);

	return pkg_archive;
}
开发者ID:rakhij,项目名称:pkg,代码行数:30,代码来源:pkg_create.c

示例15: 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


注:本文中的pkg_get函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。