Improved pkg best matching in rpool, and support for exact pkgver matches.
- xbps_repository_pool_find_pkg in best match case, now returns the newest package version available in rpool. - Added xbps_repository_pool_find_pkg_exact that returns a package by exact matching a pkgver. - Removed xbps_handle_alloc(), the user is free to use memory allocated from heap or stack. - Improved API documentation in preparation for 0.12. Bumped XBPS_API_VERSION again.
This commit is contained in:
parent
da5e9f841f
commit
f2b05d6438
@ -62,7 +62,7 @@ cleanup(int signum)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
struct xbps_handle xh;
|
||||
struct xferstat xfer;
|
||||
struct list_pkgver_cb lpc;
|
||||
struct sigaction sa;
|
||||
@ -147,27 +147,23 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Initialize libxbps.
|
||||
*/
|
||||
xhp = xbps_handle_alloc();
|
||||
if (xhp == NULL) {
|
||||
xbps_error_printf("xbps-bin: failed to allocate resources.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
xhp->debug = debug;
|
||||
xhp->state_cb = state_cb;
|
||||
xhp->fetch_cb = fetch_file_progress_cb;
|
||||
xhp->fetch_cb_data = &xfer;
|
||||
xhp->rootdir = rootdir;
|
||||
xhp->cachedir = cachedir;
|
||||
xhp->conffile = conffile;
|
||||
xhp->flags = flags;
|
||||
xhp->install_reason_manual = install_manual;
|
||||
xhp->install_reason_auto = install_auto;
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
xh.debug = debug;
|
||||
xh.state_cb = state_cb;
|
||||
xh.fetch_cb = fetch_file_progress_cb;
|
||||
xh.fetch_cb_data = &xfer;
|
||||
xh.rootdir = rootdir;
|
||||
xh.cachedir = cachedir;
|
||||
xh.conffile = conffile;
|
||||
xh.flags = flags;
|
||||
xh.install_reason_manual = install_manual;
|
||||
xh.install_reason_auto = install_auto;
|
||||
if (flags & XBPS_FLAG_VERBOSE)
|
||||
xhp->unpack_cb = unpack_progress_cb_verbose;
|
||||
xh.unpack_cb = unpack_progress_cb_verbose;
|
||||
else
|
||||
xhp->unpack_cb = unpack_progress_cb;
|
||||
xh.unpack_cb = unpack_progress_cb;
|
||||
|
||||
if ((rv = xbps_init(xhp)) != 0) {
|
||||
if ((rv = xbps_init(&xh)) != 0) {
|
||||
xbps_error_printf("xbps-bin: couldn't initialize library: %s\n",
|
||||
strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
@ -184,7 +180,7 @@ main(int argc, char **argv)
|
||||
if (strcasecmp(argv[0], "list") == 0) {
|
||||
/* Lists packages currently registered in database. */
|
||||
if (argc < 1 || argc > 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
lpc.check_state = true;
|
||||
lpc.state = 0;
|
||||
@ -220,7 +216,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "install") == 0) {
|
||||
/* Installs a binary package and required deps. */
|
||||
if (argc < 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
if ((rv = install_new_pkg(argv[i], reinstall)) != 0)
|
||||
@ -231,7 +227,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "update") == 0) {
|
||||
/* Update an installed package. */
|
||||
if (argc < 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
if ((rv = update_pkg(argv[i])) != 0)
|
||||
@ -242,7 +238,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "remove") == 0) {
|
||||
/* Removes a package. */
|
||||
if (argc < 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
rv = remove_pkg(argv[i], recursive_rm);
|
||||
@ -262,7 +258,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "show") == 0) {
|
||||
/* Shows info about an installed binary package. */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = show_pkg_info_from_metadir(argv[1], option);
|
||||
if (rv != 0) {
|
||||
@ -273,7 +269,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "show-files") == 0) {
|
||||
/* Shows files installed by a binary package. */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = show_pkg_files_from_metadir(argv[1]);
|
||||
if (rv != 0) {
|
||||
@ -284,7 +280,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "check") == 0) {
|
||||
/* Checks the integrity of an installed package. */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
if (strcasecmp(argv[1], "all") == 0)
|
||||
rv = check_pkg_integrity_all();
|
||||
@ -296,7 +292,7 @@ main(int argc, char **argv)
|
||||
* To update all packages currently installed.
|
||||
*/
|
||||
if (argc != 1)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = autoupdate_pkgs(yes, show_download_pkglist_url);
|
||||
|
||||
@ -306,7 +302,7 @@ main(int argc, char **argv)
|
||||
* orphans.
|
||||
*/
|
||||
if (argc != 1)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = show_orphans();
|
||||
|
||||
@ -317,7 +313,7 @@ main(int argc, char **argv)
|
||||
* on it currently.
|
||||
*/
|
||||
if (argc != 1)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = autoremove_pkgs(yes);
|
||||
|
||||
@ -326,7 +322,7 @@ main(int argc, char **argv)
|
||||
* Reconfigure a package.
|
||||
*/
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
if (strcasecmp(argv[1], "all") == 0)
|
||||
rv = xbps_configure_packages(true);
|
||||
@ -338,7 +334,7 @@ main(int argc, char **argv)
|
||||
* Show dependencies for a package.
|
||||
*/
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = show_pkg_deps(argv[1]);
|
||||
|
||||
@ -348,7 +344,7 @@ main(int argc, char **argv)
|
||||
* dependencies.
|
||||
*/
|
||||
if (argc != 1)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = xbps_regpkgdb_foreach_pkg_cb(list_manual_pkgs, NULL);
|
||||
|
||||
@ -357,7 +353,7 @@ main(int argc, char **argv)
|
||||
* Show reverse dependencies for a package.
|
||||
*/
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = show_pkg_reverse_deps(argv[1]);
|
||||
|
||||
@ -367,15 +363,15 @@ main(int argc, char **argv)
|
||||
* packages.
|
||||
*/
|
||||
if (argc < 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = find_files_in_packages(argc, argv);
|
||||
|
||||
} else {
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
}
|
||||
|
||||
out:
|
||||
xbps_end(xhp);
|
||||
xbps_end(&xh);
|
||||
exit(rv);
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
prop_dictionary_t plistd, confd = NULL;
|
||||
struct xbps_handle *xhp;
|
||||
struct xbps_handle xh;
|
||||
FILE *f = NULL;
|
||||
char *outfile = NULL;
|
||||
const char *conf_file = NULL, *rootdir = NULL;
|
||||
@ -485,11 +485,9 @@ main(int argc, char **argv)
|
||||
usage();
|
||||
|
||||
/* Initialize libxbps */
|
||||
xhp = xbps_handle_alloc();
|
||||
if (xhp == NULL)
|
||||
die("failed to allocate resources");
|
||||
xhp->rootdir = rootdir;
|
||||
if ((rv = xbps_init(xhp)) != 0)
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
xh.rootdir = rootdir;
|
||||
if ((rv = xbps_init(&xh)) != 0)
|
||||
die("failed to initialize libxbps: %s", strerror(rv));
|
||||
|
||||
/*
|
||||
|
@ -53,7 +53,7 @@ usage(struct xbps_handle *xhp)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct xbps_handle *xhp;
|
||||
struct xbps_handle xh;
|
||||
struct xferstat xfer;
|
||||
struct repo_search_data *rsd = NULL;
|
||||
prop_dictionary_t pkgd;
|
||||
@ -99,20 +99,16 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Initialize XBPS subsystems.
|
||||
*/
|
||||
xhp = xbps_handle_alloc();
|
||||
if (xhp == NULL) {
|
||||
xbps_error_printf("xbps-repo: failed to allocate resources.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
xhp->debug = debug;
|
||||
xhp->state_cb = state_cb;
|
||||
xhp->fetch_cb = fetch_file_progress_cb;
|
||||
xhp->fetch_cb_data = &xfer;
|
||||
xhp->rootdir = rootdir;
|
||||
xhp->cachedir = cachedir;
|
||||
xhp->conffile = conffile;
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
xh.debug = debug;
|
||||
xh.state_cb = state_cb;
|
||||
xh.fetch_cb = fetch_file_progress_cb;
|
||||
xh.fetch_cb_data = &xfer;
|
||||
xh.rootdir = rootdir;
|
||||
xh.cachedir = cachedir;
|
||||
xh.conffile = conffile;
|
||||
|
||||
if ((rv = xbps_init(xhp)) != 0) {
|
||||
if ((rv = xbps_init(&xh)) != 0) {
|
||||
xbps_error_printf("xbps-repo: couldn't initialize library: %s\n",
|
||||
strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
@ -121,7 +117,7 @@ main(int argc, char **argv)
|
||||
if (strcasecmp(argv[0], "list") == 0) {
|
||||
/* Lists all repositories registered in pool. */
|
||||
if (argc != 1)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = xbps_repository_pool_foreach(repo_list_uri_cb, NULL);
|
||||
if (rv == ENOTSUP)
|
||||
@ -135,7 +131,7 @@ main(int argc, char **argv)
|
||||
* Only list packages for the target repository.
|
||||
*/
|
||||
if (argc < 1 || argc > 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = xbps_repository_pool_foreach(repo_pkg_list_cb, argv[1]);
|
||||
if (rv == ENOTSUP)
|
||||
@ -150,7 +146,7 @@ main(int argc, char **argv)
|
||||
* by using shell style match patterns (fnmatch(3)).
|
||||
*/
|
||||
if (argc < 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rsd = malloc(sizeof(*rsd));
|
||||
if (rsd == NULL) {
|
||||
@ -170,7 +166,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "show") == 0) {
|
||||
/* Shows info about a binary package. */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = show_pkg_info_from_repolist(argv[1], option);
|
||||
if (rv == ENOENT) {
|
||||
@ -186,7 +182,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "show-deps") == 0) {
|
||||
/* Shows the required run dependencies for a package. */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = show_pkg_deps_from_repolist(argv[1]);
|
||||
if (rv == ENOENT) {
|
||||
@ -202,7 +198,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "show-files") == 0) {
|
||||
/* Shows the package files in a binary package */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
pkgd = xbps_repository_pool_dictionary_metadata_plist(argv[1],
|
||||
XBPS_PKGFILES);
|
||||
@ -226,7 +222,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "find-files") == 0) {
|
||||
/* Finds files by patterns, exact matches and components. */
|
||||
if (argc < 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = repo_find_files_in_packages(argc, argv);
|
||||
if (rv == ENOTSUP) {
|
||||
@ -236,7 +232,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "genindex") == 0) {
|
||||
/* Generates a package repository index plist file. */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = repo_genindex(argv[1]);
|
||||
if (rv == 0)
|
||||
@ -245,18 +241,18 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "sync") == 0) {
|
||||
/* Syncs the pkg index for all registered remote repos */
|
||||
if (argc != 1)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = xbps_repository_pool_sync(xhp);
|
||||
rv = xbps_repository_pool_sync(&xh);
|
||||
if (rv == ENOTSUP) {
|
||||
xbps_error_printf("xbps-repo: no repositories "
|
||||
"currently registered!\n");
|
||||
}
|
||||
} else {
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
}
|
||||
|
||||
out:
|
||||
xbps_end(xhp);
|
||||
xbps_end(&xh);
|
||||
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2008-2011 Juan Romero Pardines.
|
||||
* Copyright (c) 2008-2012 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -110,7 +110,7 @@ usage(struct xbps_handle *xhp)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct xbps_handle *xhp = NULL;
|
||||
struct xbps_handle xh;
|
||||
struct xferstat xfer;
|
||||
prop_dictionary_t dict, pkgd;
|
||||
const char *pkgn, *version, *rootdir = NULL, *confdir = NULL;
|
||||
@ -152,18 +152,13 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Initialize libxbps.
|
||||
*/
|
||||
xhp = xbps_handle_alloc();
|
||||
if (xhp == NULL) {
|
||||
xbps_error_printf("xbps-uhelper: failed to allocate resources\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
xhp->debug = debug;
|
||||
xhp->fetch_cb = fetch_file_progress_cb;
|
||||
xhp->fetch_cb_data = &xfer;
|
||||
xhp->rootdir = rootdir;
|
||||
xhp->conffile = confdir;
|
||||
|
||||
if ((rv = xbps_init(xhp)) != 0) {
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
xh.debug = debug;
|
||||
xh.fetch_cb = fetch_file_progress_cb;
|
||||
xh.fetch_cb_data = &xfer;
|
||||
xh.rootdir = rootdir;
|
||||
xh.conffile = confdir;
|
||||
if ((rv = xbps_init(&xh)) != 0) {
|
||||
xbps_error_printf("xbps-uhelper: failed to "
|
||||
"initialize libxbps: %s.\n", strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
@ -177,7 +172,7 @@ main(int argc, char **argv)
|
||||
if (strcasecmp(argv[0], "register") == 0) {
|
||||
/* Registers a package into the database */
|
||||
if (argc != 4)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
dict = prop_dictionary_create();
|
||||
if (dict == NULL) {
|
||||
@ -230,7 +225,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "unregister") == 0) {
|
||||
/* Unregisters a package from the database */
|
||||
if (argc != 3)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
rv = xbps_unregister_pkg(argv[1], argv[2], true);
|
||||
if (rv == ENOENT) {
|
||||
@ -249,7 +244,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "version") == 0) {
|
||||
/* Prints version of an installed package */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
dict = xbps_regpkgdb_get_pkgd(argv[1], false);
|
||||
if (dict == NULL) {
|
||||
@ -263,7 +258,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "sanitize-plist") == 0) {
|
||||
/* Sanitize a plist file (properly indent the file) */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(NULL);
|
||||
|
||||
dict = prop_dictionary_internalize_from_zfile(argv[1]);
|
||||
if (dict == NULL) {
|
||||
@ -277,7 +272,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "getpkgversion") == 0) {
|
||||
/* Returns the version of a pkg string */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(NULL);
|
||||
|
||||
version = xbps_pkg_version(argv[1]);
|
||||
if (version == NULL) {
|
||||
@ -290,7 +285,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "getpkgname") == 0) {
|
||||
/* Returns the name of a pkg string */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(NULL);
|
||||
|
||||
pkgname = xbps_pkg_name(argv[1]);
|
||||
if (pkgname == NULL) {
|
||||
@ -304,7 +299,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "getpkgrevision") == 0) {
|
||||
/* Returns the revision of a pkg string */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(NULL);
|
||||
|
||||
version = xbps_pkg_revision(argv[1]);
|
||||
if (version == NULL)
|
||||
@ -315,7 +310,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "getpkgdepname") == 0) {
|
||||
/* Returns the pkgname of a dependency */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(NULL);
|
||||
|
||||
pkgname = xbps_pkgpattern_name(argv[1]);
|
||||
if (pkgname == NULL)
|
||||
@ -326,7 +321,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "getpkgdepversion") == 0) {
|
||||
/* returns the version of a package pattern dependency */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(NULL);
|
||||
|
||||
version = xbps_pkgpattern_version(argv[1]);
|
||||
if (version == NULL)
|
||||
@ -337,21 +332,21 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "pkgmatch") == 0) {
|
||||
/* Matches a pkg with a pattern */
|
||||
if (argc != 3)
|
||||
usage(xhp);
|
||||
usage(NULL);
|
||||
|
||||
exit(xbps_pkgpattern_match(argv[1], argv[2]));
|
||||
|
||||
} else if (strcasecmp(argv[0], "cmpver") == 0) {
|
||||
/* Compare two version strings, installed vs required */
|
||||
if (argc != 3)
|
||||
usage(xhp);
|
||||
usage(NULL);
|
||||
|
||||
exit(xbps_cmpver(argv[1], argv[2]));
|
||||
|
||||
} else if (strcasecmp(argv[0], "digest") == 0) {
|
||||
/* Prints SHA256 hashes for specified files */
|
||||
if (argc < 2)
|
||||
usage(xhp);
|
||||
usage(NULL);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
hash = xbps_file_hash(argv[i]);
|
||||
@ -368,7 +363,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "fetch") == 0) {
|
||||
/* Fetch a file from specified URL */
|
||||
if (argc != 2)
|
||||
usage(xhp);
|
||||
usage(&xh);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
rv = xbps_fetch_file(argv[i], ".", false, "v");
|
||||
@ -383,10 +378,10 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
} else {
|
||||
usage(xhp);
|
||||
usage(NULL);
|
||||
}
|
||||
|
||||
out:
|
||||
xbps_end(xhp);
|
||||
xbps_end(&xh);
|
||||
exit(rv ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@
|
||||
*/
|
||||
#define XBPS_PKGINDEX_VERSION "1.3"
|
||||
|
||||
#define XBPS_API_VERSION "20120117"
|
||||
#define XBPS_API_VERSION "20120117-1"
|
||||
#define XBPS_VERSION "0.12"
|
||||
|
||||
/**
|
||||
@ -571,8 +571,7 @@ struct xbps_handle {
|
||||
* - Set default cache connections for libfetch.
|
||||
* - Parse configuration file.
|
||||
*
|
||||
* @param[in] xhp The xbps_handle structure previously allocated
|
||||
* by \a xbps_handle_alloc().
|
||||
* @param[in] xhp Pointer to an xbps_handle strcucture.
|
||||
* @note It's assumed that \a xhp is a valid pointer.
|
||||
*
|
||||
* @return 0 on success, an errno value otherwise.
|
||||
@ -582,20 +581,11 @@ int xbps_init(struct xbps_handle *xhp);
|
||||
/**
|
||||
* Releases all resources used by libxbps.
|
||||
*
|
||||
* @param[in] xhp Pointer to an xbps_handle structure, as returned
|
||||
* by \a xbps_handle_alloc().
|
||||
* @param[in] xhp Pointer to an xbps_handle structure.
|
||||
* @note It's assumed that \a xhp is a valid pointer.
|
||||
*/
|
||||
void xbps_end(struct xbps_handle *xhp);
|
||||
|
||||
/**
|
||||
* Allocated an xbps_handle structure.
|
||||
*
|
||||
* @return A pointer to the allocated xbps_handle structure, NULL
|
||||
* otherwise.
|
||||
*/
|
||||
struct xbps_handle *xbps_handle_alloc(void);
|
||||
|
||||
/**
|
||||
* Returns a pointer to the xbps_handle structure set by xbps_init().
|
||||
*/
|
||||
@ -642,8 +632,6 @@ int xbps_configure_packages(bool flush);
|
||||
* The package version is defined by:
|
||||
* ${VERSION}[_${REVISION}].
|
||||
*
|
||||
* ${VERSION} supersedes ${REVISION}.
|
||||
*
|
||||
* @param[in] pkg1 a package version string.
|
||||
* @param[in] pkg2 a package version string.
|
||||
*
|
||||
@ -701,18 +689,20 @@ prop_array_t xbps_find_pkg_orphans(prop_array_t orphans);
|
||||
*
|
||||
* Package pattern matching.
|
||||
*
|
||||
* @param[in] instpkg Package/version string of an installed package.
|
||||
* @param[in] pattern Pattern required for \a instpkg to match.
|
||||
* @param[in] pkgver Package name/version, i.e `foo-1.0'.
|
||||
* @param[in] pattern Package pattern to match against \a pkgver, i.e
|
||||
* `foo>=0' or `foo<1'.
|
||||
*
|
||||
* @return 1 if \a instpkg is matched against \a pattern, 0 if no match.
|
||||
* @return 1 if \a pkgver is matched against \a pattern, 0 if no match.
|
||||
*/
|
||||
int xbps_pkgpattern_match(const char *instpkg, const char *pattern);
|
||||
int xbps_pkgpattern_match(const char *pkgver, const char *pattern);
|
||||
|
||||
/** @addtogroup plist */
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* Adds a proplib object into a proplib dictionary with specified key.
|
||||
* The object is always released.
|
||||
*
|
||||
* @param[in] dict Proplib dictionary to insert the object to.
|
||||
* @param[in] obj Proplib object to be inserted.
|
||||
@ -726,6 +716,7 @@ bool xbps_add_obj_to_dict(prop_dictionary_t dict,
|
||||
|
||||
/**
|
||||
* Adds a proplib object into a proplib array.
|
||||
* The object is always released.
|
||||
*
|
||||
* @param[in] array Proplib array to insert the object to.
|
||||
* @param[in] obj Proplib object to be inserted.
|
||||
@ -735,7 +726,7 @@ bool xbps_add_obj_to_dict(prop_dictionary_t dict,
|
||||
bool xbps_add_obj_to_array(prop_array_t array, prop_object_t obj);
|
||||
|
||||
/**
|
||||
* Executes a function callback specified in \a fn with \a arg paassed
|
||||
* Executes a function callback specified in \a fn with \a arg passed
|
||||
* as its argument into they array \a array.
|
||||
*
|
||||
* @param[in] array Proplib array to iterate.
|
||||
@ -744,7 +735,8 @@ bool xbps_add_obj_to_array(prop_array_t array, prop_object_t obj);
|
||||
* a boolean) can be set to true to stop immediately the loop.
|
||||
* @param[in] arg Argument to be passed to the function callback.
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value is set appropiately.
|
||||
* @return 0 on success, otherwise the value returned by the function
|
||||
* callback.
|
||||
*/
|
||||
int xbps_callback_array_iter(prop_array_t array,
|
||||
int (*fn)(prop_object_t, void *, bool *),
|
||||
@ -762,8 +754,8 @@ int xbps_callback_array_iter(prop_array_t array,
|
||||
* immediately the loop.
|
||||
* @param[in] arg Argument to be passed to the function callback.
|
||||
*
|
||||
* @return 0 on success (all objects were processed), otherwise an
|
||||
* errno value is set appropiately.
|
||||
* @return 0 on success (all objects were processed), otherwise
|
||||
* the value returned by the function callback.
|
||||
*/
|
||||
int xbps_callback_array_iter_in_dict(prop_dictionary_t dict,
|
||||
const char *key,
|
||||
@ -782,8 +774,8 @@ int xbps_callback_array_iter_in_dict(prop_dictionary_t dict,
|
||||
* immediately the loop.
|
||||
* @param[in] arg Argument to be passed to the function callback.
|
||||
*
|
||||
* @return 0 on success (all objects were processed), otherwise an
|
||||
* errno value is set appropiately.
|
||||
* @return 0 on success (all objects were processed), otherwise
|
||||
* the value returned by the function callback.
|
||||
*/
|
||||
int xbps_callback_array_iter_reverse_in_dict(prop_dictionary_t dict,
|
||||
const char *key,
|
||||
@ -797,8 +789,8 @@ int xbps_callback_array_iter_reverse_in_dict(prop_dictionary_t dict,
|
||||
* @param[in] fn Function callback to run for any pkg dictionary.
|
||||
* @param[in] arg Argument to be passed to the function callback.
|
||||
*
|
||||
* @return 0 on success (all objects were processed), otherwise an
|
||||
* errno value.
|
||||
* @return 0 on success (all objects were processed), otherwise
|
||||
* the value returned by the function callback.
|
||||
*/
|
||||
int xbps_regpkgdb_foreach_pkg_cb(int (*fn)(prop_object_t, void *, bool *),
|
||||
void *arg);
|
||||
@ -810,8 +802,8 @@ int xbps_regpkgdb_foreach_pkg_cb(int (*fn)(prop_object_t, void *, bool *),
|
||||
* @param[in] fn Function callback to run for any pkg dictionary.
|
||||
* @param[in] arg Argument to be passed to the function callback.
|
||||
*
|
||||
* @return 0 on success (all objects were processed), otherwise an
|
||||
* errno value.
|
||||
* @return 0 on success (all objects were processed), otherwise
|
||||
* the value returned by the funcion callback.
|
||||
*/
|
||||
int xbps_regpkgdb_foreach_reverse_pkg_cb(
|
||||
int (*fn)(prop_object_t, void *, bool *),
|
||||
@ -821,12 +813,13 @@ int xbps_regpkgdb_foreach_reverse_pkg_cb(
|
||||
* Returns a package dictionary from regpkgdb plist, matching pkgname or
|
||||
* pkgver specified in \a pkg.
|
||||
*
|
||||
* @param[in] pkg Package name or name-version tuple to match.
|
||||
* @param[in] bypattern If false \a pkg must be a pkgname, otherwise a pkgver.
|
||||
* @param[in] pkg Package name or name-version to match.
|
||||
* @param[in] bypattern If false \a pkg must be a pkgname, otherwise a
|
||||
* package pattern, i.e `foo>=0' or `foo<1'.
|
||||
*
|
||||
* @return The matching proplib package dictionary from regpkgdb copied
|
||||
* with \a prop_dictionary_copy() so it must be released when not required
|
||||
* anymore with prop_object_release().
|
||||
* anymore with prop_object_release(). NULL otherwise.
|
||||
*/
|
||||
prop_dictionary_t xbps_regpkgdb_get_pkgd(const char *pkg, bool bypattern);
|
||||
|
||||
@ -845,7 +838,7 @@ bool xbps_regpkgdb_remove_pkgd(const char *pkgname);
|
||||
* in memory.
|
||||
*
|
||||
* @param[in] xhp Pointer to our xbps_handle struct, as returned by
|
||||
* \a xbps_handle_get() or xbps_handle_alloc().
|
||||
* \a xbps_handle_get().
|
||||
* @param[in] flush If true the regpkgdb plist contents in memory will
|
||||
* be flushed atomically to disk.
|
||||
*
|
||||
@ -883,6 +876,22 @@ prop_dictionary_t xbps_find_pkg_in_dict_by_pattern(prop_dictionary_t dict,
|
||||
const char *key,
|
||||
const char *pattern);
|
||||
|
||||
/**
|
||||
* Finds the proplib's dictionary associated with a package, by matching
|
||||
* its \a pkgver object in its dictionary.
|
||||
*
|
||||
* @param[in] dict Proplib dictionary to look for the package dictionary.
|
||||
* @param[in] key Key associated with the array storing the package's
|
||||
* dictionary.
|
||||
* @param[in] pkgver Package name/version to match, i.e `foo-1.0'.
|
||||
*
|
||||
* @return The package's proplib dictionary on success, NULL otherwise
|
||||
* and errno is set appropiately.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_in_dict_by_pkgver(prop_dictionary_t dict,
|
||||
const char *key,
|
||||
const char *pkgver);
|
||||
|
||||
/**
|
||||
* Finds the package's proplib dictionary in a plist file by specifying
|
||||
* a package name.
|
||||
@ -892,9 +901,9 @@ prop_dictionary_t xbps_find_pkg_in_dict_by_pattern(prop_dictionary_t dict,
|
||||
* @param[in] pkgname Package name to match in array.
|
||||
*
|
||||
* @return The package's proplib dictionary on success, NULL otherwise and
|
||||
* errno is set appropiately. Returned dictionary is copied via
|
||||
* prop_dictionary_copy(), which means that caller is responsible to
|
||||
* release the object with prop_object_release() when done.
|
||||
* errno is set appropiately.
|
||||
* @note When returned dictionary is no longer needed, it must be released
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_dict_from_plist_by_name(const char *plist,
|
||||
const char *key,
|
||||
@ -909,8 +918,9 @@ prop_dictionary_t xbps_find_pkg_dict_from_plist_by_name(const char *plist,
|
||||
* @param[in] pattern Package pattern to match in array.
|
||||
*
|
||||
* @return The package's proplib dictionary on success, NULL otherwise and
|
||||
* errno is set appropiately. Returned dictionary should be released with
|
||||
* prop_object_release() when it's not any longer needed.
|
||||
* errno is set appropiately.
|
||||
* @note When returned dictionary is no longer needed, it must be released
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_dict_from_plist_by_pattern(const char *plist,
|
||||
const char *key,
|
||||
@ -925,9 +935,9 @@ prop_dictionary_t xbps_find_pkg_dict_from_plist_by_pattern(const char *plist,
|
||||
* by using a package pattern. If false, \a str is assumed to be a package name.
|
||||
*
|
||||
* @return The package's dictionary on success, NULL otherwise and
|
||||
* errno is set appropiately. Returned dictionary is copied via
|
||||
* prop_dictionary_copy(), which means that caller is responsible to
|
||||
* release the object with prop_object_release() when done.
|
||||
* errno is set appropiately.
|
||||
* @note When returned dictionary is no longer needed, it must be released
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_dict_installed(const char *str,
|
||||
bool bypattern);
|
||||
@ -942,9 +952,9 @@ prop_dictionary_t xbps_find_pkg_dict_installed(const char *str,
|
||||
* by using a package pattern. If false, \a str is assumed to be a package name.
|
||||
*
|
||||
* @return The virtual package's dictionary on success, NULL otherwise and
|
||||
* errno is set appropiately. Returned dictionary is copied via
|
||||
* prop_dictionary_copy(), which means that caller is responsible to
|
||||
* release the object with prop_object_release() when done.
|
||||
* errno is set appropiately.
|
||||
* @note When returned dictionary is no longer needed, it must be released
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_find_virtualpkg_dict_installed(const char *str,
|
||||
bool bypattern);
|
||||
@ -956,7 +966,7 @@ prop_dictionary_t xbps_find_virtualpkg_dict_installed(const char *str,
|
||||
* @param[in] pkgd Package dictionary.
|
||||
* @param[in] str Virtual package name or package pattern to match.
|
||||
* @param[in] bypattern If true, \a str should be a package name,
|
||||
* otherwise it should be a package pattern.
|
||||
* otherwise it should be a package pattern, i.e `foo>=0' or `foo<1'.
|
||||
*
|
||||
* @return True if \a str matches a virtual package in \a pkgd, false
|
||||
* otherwise.
|
||||
@ -981,7 +991,7 @@ bool xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps,
|
||||
/**
|
||||
* Finds a package dictionary in a proplib array by matching a package name.
|
||||
*
|
||||
* @param[in] array The proplib array where to look for.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] name The package name to match.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned.
|
||||
@ -992,8 +1002,8 @@ prop_dictionary_t xbps_find_pkg_in_array_by_name(prop_array_t array,
|
||||
/**
|
||||
* Finds a package dictionary in a proplib array by matching a package pattern.
|
||||
*
|
||||
* @param[in] array The proplib array where to look for.
|
||||
* @param[in] pattern The package pattern to match.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] pattern The package pattern to match, i.e `foo>=0' or `foo<1'.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned.
|
||||
*/
|
||||
@ -1004,8 +1014,8 @@ prop_dictionary_t xbps_find_pkg_in_array_by_pattern(prop_array_t array,
|
||||
* Finds a package dictionary in a proplib array by matching a \a pkgver
|
||||
* object.
|
||||
*
|
||||
* @param[in] array The proplib array where to look for.
|
||||
* @param[in] pkgver The package name/version tuple to match, i.e `foo-1.0'.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] pkgver The package name/version to match, i.e `foo-1.0'.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned.
|
||||
*/
|
||||
@ -1016,7 +1026,7 @@ prop_dictionary_t xbps_find_pkg_in_array_by_pkgver(prop_array_t array,
|
||||
* Finds a virtual package dictionary in a proplib array by matching a
|
||||
* package name.
|
||||
*
|
||||
* @param[in] array The proplib array where to look for.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] name The virtual package name to match.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned.
|
||||
@ -1028,8 +1038,9 @@ prop_dictionary_t xbps_find_virtualpkg_in_array_by_name(prop_array_t array,
|
||||
* Finds a virtual package dictionary in a proplib array by matching a
|
||||
* package pattern.
|
||||
*
|
||||
* @param[in] array The proplib array where to look for.
|
||||
* @param[in] pattern The virtual package pattern to match.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] pattern The virtual package pattern to match, i.e
|
||||
* `foo>=0' or `foo<1'.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned.
|
||||
*/
|
||||
@ -1038,7 +1049,7 @@ prop_dictionary_t xbps_find_virtualpkg_in_array_by_pattern(prop_array_t array,
|
||||
/**
|
||||
* Match a package name in the specified array of strings.
|
||||
*
|
||||
* @param[in] array The proplib array where to look for.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] pkgname The package name to match.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
@ -1048,8 +1059,8 @@ bool xbps_match_pkgname_in_array(prop_array_t array, const char *pkgname);
|
||||
/**
|
||||
* Match a package pattern in the specified array of strings.
|
||||
*
|
||||
* @param[in] array The proplib array where to look for.
|
||||
* @param[in] pattern The package pattern to match.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] pattern The package pattern to match, i.e `foo>=0' or `foo<1'.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
@ -1059,8 +1070,8 @@ bool xbps_match_pkgpattern_in_array(prop_array_t array, const char *pattern);
|
||||
* Match a package dependency against any package pattern in the specified
|
||||
* array of strings.
|
||||
*
|
||||
* @param[in] array The proplib array where to look for.
|
||||
* @param[in] pkgver The package name-version tuple to match.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] pkgver The package name-version to match, i.e `foo-1.0'.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
@ -1069,16 +1080,16 @@ bool xbps_match_pkgdep_in_array(prop_array_t array, const char *pkgver);
|
||||
/**
|
||||
* Match a string (exact match) in the specified array of strings.
|
||||
*
|
||||
* @param[in] array The proplib array where to look for.
|
||||
* @param[in] val The value of string to match.
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] val The string to be matched.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
bool xbps_match_string_in_array(prop_array_t array, const char *val);
|
||||
|
||||
/**
|
||||
* Gets a proplib object iterator associated with an array, contained
|
||||
* in a proplib dictionary matching a key.
|
||||
* Returns a proplib object iterator associated with an array, contained
|
||||
* in a proplib dictionary matching the specified key.
|
||||
*
|
||||
* @param[in] dict Proplib dictionary where to look for the array.
|
||||
* @param[in] key Key associated with the array.
|
||||
@ -1090,8 +1101,8 @@ prop_object_iterator_t xbps_array_iter_from_dict(prop_dictionary_t dict,
|
||||
const char *key);
|
||||
|
||||
/**
|
||||
* Get a proplib object dictionary associated with the installed package
|
||||
* \a pkgname, by internalizing its plist file defined by \a plist.
|
||||
* Returns a proplib object dictionary associated with the installed package
|
||||
* \a pkgname, by internalizing its plist file defined in \a plist.
|
||||
*
|
||||
* @param[in] pkgname Package name of installed package.
|
||||
* @param[in] plist Package metadata property list file.
|
||||
@ -1106,12 +1117,12 @@ prop_dictionary_t xbps_dictionary_from_metadata_plist(const char *pkgname,
|
||||
* Removes the package's proplib dictionary matching \a pkgname
|
||||
* in a plist file.
|
||||
*
|
||||
* @param[in] name Package name to match in plist's dictionary.
|
||||
* @param[in] pkgname Package name to match in plist's dictionary.
|
||||
* @param[in] plist Path to a plist file.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
bool xbps_remove_pkg_dict_from_plist_by_name(const char *name,
|
||||
bool xbps_remove_pkg_dict_from_plist_by_name(const char *pkgname,
|
||||
const char *plist);
|
||||
|
||||
/**
|
||||
@ -1130,7 +1141,7 @@ bool xbps_remove_pkg_from_array_by_name(prop_array_t array, const char *name);
|
||||
* object in a proplib array of dictionaries.
|
||||
*
|
||||
* @param[in] array Proplib array where to look for.
|
||||
* @param[in] pkgver Package name/version tuple to match, i.e `foo-1.0'.
|
||||
* @param[in] pkgver Package name/version to match, i.e `foo-1.0'.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
@ -1142,7 +1153,7 @@ bool xbps_remove_pkg_from_array_by_pkgver(prop_array_t array, const char *pkgver
|
||||
*
|
||||
* @param[in] dict Proplib dictionary storing the proplib array.
|
||||
* @param[in] key Key associated with the proplib array.
|
||||
* @param[in] name Package name to look for.
|
||||
* @param[in] name Package name to match.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
@ -1151,7 +1162,7 @@ bool xbps_remove_pkg_from_dict_by_name(prop_dictionary_t dict,
|
||||
const char *name);
|
||||
|
||||
/**
|
||||
* Removes a string from a proplib's array.
|
||||
* Removes a string from a proplib's array of strings.
|
||||
*
|
||||
* @param[in] array Proplib array where to look for.
|
||||
* @param[in] str String to match in the array.
|
||||
@ -1241,7 +1252,8 @@ int xbps_remove_pkg(const char *pkgname, const char *version, bool update);
|
||||
* The image in Detailed description shows off its structure.
|
||||
* @param[in] key Key of the array object to match, valid values are:
|
||||
* <b>files</b>, <b>dirs</b>, <b>links</b> and <b>conf_files</b>.
|
||||
* @param[in] pkgver Package/version string matching package dictionary.
|
||||
* @param[in] pkgver Package/version string matching package dictionary,
|
||||
* i.e `foo-1.0'.
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
@ -1259,7 +1271,7 @@ int xbps_remove_pkg_files(prop_dictionary_t dict,
|
||||
* the transaction dictionary for future use. The first repository in
|
||||
* the pool that matched the pattern wins.
|
||||
*
|
||||
* @param pkgpattern Package name or pattern to find.
|
||||
* @param pkgpattern Package pattern, i.e `foo>=0' or 'foo<2.0'.
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
@ -1267,8 +1279,9 @@ int xbps_transaction_install_pkg(const char *pkgpattern);
|
||||
|
||||
/**
|
||||
* Marks a package as "going to be updated" in the transaction dictionary.
|
||||
* All repositories in the pool will be used, and if a newer version
|
||||
* is available the package dictionary will be enqueued.
|
||||
* All repositories in the pool will be used, and newest version
|
||||
* available will be enqueued if it's greater than current installed
|
||||
* version.
|
||||
*
|
||||
* @param pkgname The package name to update.
|
||||
*
|
||||
@ -1436,10 +1449,24 @@ int xbps_repository_pool_foreach(
|
||||
* fetch the first package found matching its pkgname.
|
||||
*
|
||||
* @return The package dictionary if found, NULL otherwise.
|
||||
* @note When returned dictionary is no longer needed, you must release it
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t
|
||||
xbps_repository_pool_find_pkg(const char *pkg, bool bypattern, bool best);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in repository pool by matching its \a pkgver
|
||||
* object.
|
||||
*
|
||||
* @param[in] pkgver Package name/version to match, i.e `foo-1.0'.
|
||||
*
|
||||
* @return The package dictionary if found, NULL otherwise.
|
||||
* @note When returned dictionary is no longer needed, you must release it
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t xbps_repository_pool_find_pkg_exact(const char *pkgver);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in repository pool by specifying a
|
||||
* package pattern or a package name. Only virtual packages set in
|
||||
@ -1451,6 +1478,8 @@ prop_dictionary_t
|
||||
* fetch the first package found matching its pkgname.
|
||||
*
|
||||
* @return The package dictionary if found, NULL otherwise.
|
||||
* @note When returned dictionary is no longer needed, you must release it
|
||||
* with prop_object_release(3).
|
||||
*/
|
||||
prop_dictionary_t
|
||||
xbps_repository_pool_find_virtualpkg(const char *pkg,
|
||||
@ -1562,7 +1591,7 @@ int xbps_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t *state);
|
||||
*
|
||||
* @param[in] pkgname Package name.
|
||||
* @param[in] version Package version (optional).
|
||||
* @param[in] pkgver Package name/version touple (optional).
|
||||
* @param[in] pkgver Package name/version (optional).
|
||||
* @param[in] state Package state to be set.
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
@ -1584,22 +1613,6 @@ int xbps_set_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t state);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/** @addtogroup unpack */
|
||||
/*@{*/
|
||||
|
||||
|
||||
/**
|
||||
* Unpacks a binary package into specified root directory.
|
||||
*
|
||||
* @param[in] trans_pkg_dict Package proplib dictionary as stored in the
|
||||
* \a packages array returned by the transaction dictionary.
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_unpack_binary_pkg(prop_dictionary_t trans_pkg_dict);
|
||||
|
||||
/*@}*/
|
||||
|
||||
/** @addtogroup util */
|
||||
/*@{*/
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2010-2011 Juan Romero Pardines.
|
||||
* Copyright (c) 2010-2012 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -184,12 +184,6 @@ prop_dictionary_t HIDDEN
|
||||
xbps_find_virtualpkg_conf_in_dict_by_pattern(prop_dictionary_t,
|
||||
const char *,
|
||||
const char *);
|
||||
/**
|
||||
* @private
|
||||
* From lib/init_virtual_pkgs.c
|
||||
*/
|
||||
void HIDDEN xbps_init_virtual_pkgs(struct xbps_handle *);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/cb_util.c
|
||||
@ -201,6 +195,12 @@ void HIDDEN xbps_set_cb_state(xbps_state_t, int, const char *,
|
||||
void HIDDEN xbps_set_cb_unpack(const char *, int64_t, ssize_t,
|
||||
ssize_t, bool, bool);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* From lib/package_unpack.c
|
||||
*/
|
||||
int HIDDEN xbps_unpack_binary_pkg(prop_dictionary_t);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_XBPS_API_IMPL_H_ */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2011 Juan Romero Pardines.
|
||||
* Copyright (c) 2011-2012 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -205,8 +205,6 @@ xbps_end(struct xbps_handle *xh)
|
||||
if (xh->cachedir_priv != NULL)
|
||||
free(xh->cachedir_priv);
|
||||
|
||||
free(xh);
|
||||
xh = NULL;
|
||||
xhp = NULL;
|
||||
}
|
||||
|
||||
@ -217,12 +215,6 @@ xbps_handle_get(void)
|
||||
return xhp;
|
||||
}
|
||||
|
||||
struct xbps_handle *
|
||||
xbps_handle_alloc(void)
|
||||
{
|
||||
return calloc(1, sizeof(struct xbps_handle));
|
||||
}
|
||||
|
||||
static void
|
||||
common_printf(FILE *f, const char *msg, const char *fmt, va_list ap)
|
||||
{
|
||||
|
@ -57,9 +57,6 @@ static int
|
||||
set_new_state(prop_dictionary_t dict, pkg_state_t state)
|
||||
{
|
||||
const struct state *stp;
|
||||
#ifdef DEBUG
|
||||
const char *pkgname;
|
||||
#endif
|
||||
|
||||
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
|
||||
|
||||
@ -73,13 +70,6 @@ set_new_state(prop_dictionary_t dict, pkg_state_t state)
|
||||
if (!prop_dictionary_set_cstring_nocopy(dict, "state", stp->string))
|
||||
return EINVAL;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (prop_dictionary_get_cstring_nocopy(dict, "pkgname", &pkgname)) {
|
||||
xbps_dbg_printf("%s: changed pkg state to '%s'\n",
|
||||
pkgname, stp->string);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2008-2011 Juan Romero Pardines.
|
||||
* Copyright (c) 2008-2012 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -574,7 +574,7 @@ out:
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
int HIDDEN
|
||||
xbps_unpack_binary_pkg(prop_dictionary_t pkg_repod)
|
||||
{
|
||||
struct archive *ar = NULL;
|
||||
|
@ -266,6 +266,24 @@ xbps_find_pkg_in_dict_by_pattern(prop_dictionary_t d,
|
||||
return find_pkg_in_dict(d, key, pattern, true, false);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_dict_by_pkgver(prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *pkgver)
|
||||
{
|
||||
prop_array_t array;
|
||||
|
||||
assert(d != NULL);
|
||||
assert(key != NULL);
|
||||
assert(pkgver != NULL);
|
||||
|
||||
array = prop_dictionary_get(d, key);
|
||||
if (array == NULL)
|
||||
return NULL;
|
||||
|
||||
return xbps_find_pkg_in_array_by_pkgver(array, pkgver);
|
||||
}
|
||||
|
||||
prop_dictionary_t HIDDEN
|
||||
xbps_find_virtualpkg_in_dict_by_name(prop_dictionary_t d,
|
||||
const char *key,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2009-2011 Juan Romero Pardines.
|
||||
* Copyright (c) 2009-2012 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -39,7 +39,10 @@
|
||||
struct repo_pool_fpkg {
|
||||
prop_dictionary_t pkgd;
|
||||
const char *pattern;
|
||||
const char *bestpkgver;
|
||||
const char *repo_bestmatch;
|
||||
bool bypattern;
|
||||
bool exact;
|
||||
};
|
||||
|
||||
static int
|
||||
@ -79,7 +82,16 @@ repo_find_pkg_cb(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
|
||||
assert(rpi != NULL);
|
||||
|
||||
if (rpf->bypattern) {
|
||||
if (rpf->exact) {
|
||||
if (rpf->repo_bestmatch != NULL) {
|
||||
if (strcmp(rpf->repo_bestmatch, rpi->rpi_uri))
|
||||
return 0;
|
||||
}
|
||||
/* exact match by pkgver */
|
||||
rpf->pkgd = xbps_find_pkg_in_dict_by_pkgver(rpi->rpi_repod,
|
||||
"packages", rpf->pattern);
|
||||
} else if (rpf->bypattern) {
|
||||
/* match by pkgpattern in pkgver*/
|
||||
rpf->pkgd = xbps_find_pkg_in_dict_by_pattern(rpi->rpi_repod,
|
||||
"packages", rpf->pattern);
|
||||
/* If no pkg exists matching pattern, look for virtual packages */
|
||||
@ -88,6 +100,7 @@ repo_find_pkg_cb(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
rpi->rpi_repod, "packages", rpf->pattern);
|
||||
}
|
||||
} else {
|
||||
/* match by pkgname */
|
||||
rpf->pkgd = xbps_find_pkg_in_dict_by_name(rpi->rpi_repod,
|
||||
"packages", rpf->pattern);
|
||||
/* If no pkg exists matching pattern, look for virtual packages */
|
||||
@ -101,10 +114,6 @@ repo_find_pkg_cb(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
* Package dictionary found, add the "repository"
|
||||
* object with the URI.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
xbps_dbg_printf("%s: found pkg in repository\n", __func__);
|
||||
xbps_dbg_printf_append("%s", prop_dictionary_externalize(rpf->pkgd));
|
||||
#endif
|
||||
prop_dictionary_set_cstring(rpf->pkgd, "repository",
|
||||
rpi->rpi_uri);
|
||||
*done = true;
|
||||
@ -120,61 +129,52 @@ repo_find_best_pkg_cb(struct repository_pool_index *rpi,
|
||||
bool *done)
|
||||
{
|
||||
struct repo_pool_fpkg *rpf = arg;
|
||||
prop_dictionary_t instpkgd;
|
||||
const char *instver, *repover;
|
||||
const char *repopkgver;
|
||||
|
||||
assert(rpi != NULL);
|
||||
|
||||
rpf->pkgd = xbps_find_pkg_in_dict_by_name(rpi->rpi_repod,
|
||||
"packages", rpf->pattern);
|
||||
(void)done;
|
||||
|
||||
if (rpf->bypattern) {
|
||||
rpf->pkgd = xbps_find_pkg_in_dict_by_pattern(rpi->rpi_repod,
|
||||
"packages", rpf->pattern);
|
||||
} else {
|
||||
rpf->pkgd = xbps_find_pkg_in_dict_by_name(rpi->rpi_repod,
|
||||
"packages", rpf->pattern);
|
||||
}
|
||||
if (rpf->pkgd == NULL) {
|
||||
if (errno && errno != ENOENT)
|
||||
return errno;
|
||||
|
||||
xbps_dbg_printf("[rpool] Package '%s' not found in repository "
|
||||
"'%s'.\n", rpf->pattern, rpi->rpi_uri);
|
||||
} else {
|
||||
/*
|
||||
* Check if version in repository is greater than
|
||||
* the version currently installed.
|
||||
*/
|
||||
instpkgd = xbps_find_pkg_dict_installed(rpf->pattern, false);
|
||||
if (instpkgd == NULL) {
|
||||
xbps_dbg_printf("[rpool] `%s' not installed, "
|
||||
"ignoring...\n", rpf->pattern);
|
||||
rpf->pkgd = NULL;
|
||||
return ENODEV;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(instpkgd,
|
||||
"version", &instver);
|
||||
prop_dictionary_get_cstring_nocopy(rpf->pkgd,
|
||||
"version", &repover);
|
||||
prop_object_release(instpkgd);
|
||||
|
||||
if (xbps_cmpver(repover, instver) <= 0) {
|
||||
xbps_dbg_printf("[rpool] Skipping '%s-%s' "
|
||||
"(installed: %s) from repository `%s'\n",
|
||||
rpf->pattern, repover, instver,
|
||||
rpi->rpi_uri);
|
||||
rpf->pkgd = NULL;
|
||||
errno = EEXIST;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* New package version found, exit from the loop.
|
||||
*/
|
||||
xbps_dbg_printf("[rpool] Found '%s-%s' (installed: %s) "
|
||||
"in repository '%s'.\n", rpf->pattern, repover,
|
||||
instver, rpi->rpi_uri);
|
||||
prop_dictionary_set_cstring(rpf->pkgd, "repository",
|
||||
rpi->rpi_uri);
|
||||
*done = true;
|
||||
return 0;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(rpf->pkgd,
|
||||
"pkgver", &repopkgver);
|
||||
if (rpf->bestpkgver == NULL) {
|
||||
xbps_dbg_printf("[rpool] Found best match '%s' (%s).\n",
|
||||
repopkgver, rpi->rpi_uri);
|
||||
rpf->bestpkgver = repopkgver;
|
||||
rpf->repo_bestmatch = rpi->rpi_uri;
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Compare current stored version against new
|
||||
* version from current package in repository.
|
||||
*/
|
||||
if (xbps_cmpver(repopkgver, rpf->bestpkgver)) {
|
||||
xbps_dbg_printf("[rpool] Found best match '%s' (%s).\n",
|
||||
repopkgver, rpi->rpi_uri);
|
||||
rpf->bestpkgver = repopkgver;
|
||||
rpf->repo_bestmatch = rpi->rpi_uri;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct repo_pool_fpkg *
|
||||
repo_find_pkg(const char *pkg, bool bypattern, bool best, bool virtual)
|
||||
repo_find_pkg(const char *pkg, bool bypattern, bool best, bool exact,
|
||||
bool virtual)
|
||||
{
|
||||
struct repo_pool_fpkg *rpf;
|
||||
int rv = 0;
|
||||
@ -187,9 +187,19 @@ repo_find_pkg(const char *pkg, bool bypattern, bool best, bool virtual)
|
||||
|
||||
rpf->pattern = pkg;
|
||||
rpf->bypattern = bypattern;
|
||||
rpf->exact = exact;
|
||||
rpf->pkgd = NULL;
|
||||
rpf->bestpkgver = NULL;
|
||||
rpf->repo_bestmatch = NULL;
|
||||
|
||||
if (best) {
|
||||
if (exact) {
|
||||
/*
|
||||
* Look for exact package match with pkgver in all repos.
|
||||
*/
|
||||
rv = xbps_repository_pool_foreach(repo_find_pkg_cb, rpf);
|
||||
if (rv != 0)
|
||||
errno = rv;
|
||||
} else if (best) {
|
||||
/*
|
||||
* Look for the best package version of a package name or
|
||||
* pattern in all repositories.
|
||||
@ -197,6 +207,10 @@ repo_find_pkg(const char *pkg, bool bypattern, bool best, bool virtual)
|
||||
rv = xbps_repository_pool_foreach(repo_find_best_pkg_cb, rpf);
|
||||
if (rv != 0)
|
||||
errno = rv;
|
||||
|
||||
if (rpf->bestpkgver != NULL)
|
||||
rpf->pkgd =
|
||||
xbps_repository_pool_find_pkg_exact(rpf->bestpkgver);
|
||||
} else {
|
||||
if (virtual) {
|
||||
/*
|
||||
@ -227,7 +241,7 @@ xbps_repository_pool_find_virtualpkg(const char *pkg, bool bypattern, bool best)
|
||||
|
||||
assert(pkg != NULL);
|
||||
|
||||
rpf = repo_find_pkg(pkg, bypattern, best, true);
|
||||
rpf = repo_find_pkg(pkg, bypattern, best, false, true);
|
||||
if (prop_object_type(rpf->pkgd) == PROP_TYPE_DICTIONARY)
|
||||
pkgd = prop_dictionary_copy(rpf->pkgd);
|
||||
free(rpf);
|
||||
@ -243,7 +257,23 @@ xbps_repository_pool_find_pkg(const char *pkg, bool bypattern, bool best)
|
||||
|
||||
assert(pkg != NULL);
|
||||
|
||||
rpf = repo_find_pkg(pkg, bypattern, best, false);
|
||||
rpf = repo_find_pkg(pkg, bypattern, best, false, false);
|
||||
if (prop_object_type(rpf->pkgd) == PROP_TYPE_DICTIONARY)
|
||||
pkgd = prop_dictionary_copy(rpf->pkgd);
|
||||
free(rpf);
|
||||
|
||||
return pkgd;
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_repository_pool_find_pkg_exact(const char *pkgver)
|
||||
{
|
||||
struct repo_pool_fpkg *rpf;
|
||||
prop_dictionary_t pkgd = NULL;
|
||||
|
||||
assert(pkgver != NULL);
|
||||
|
||||
rpf = repo_find_pkg(pkgver, false, false, true, false);
|
||||
if (prop_object_type(rpf->pkgd) == PROP_TYPE_DICTIONARY)
|
||||
pkgd = prop_dictionary_copy(rpf->pkgd);
|
||||
free(rpf);
|
||||
|
@ -51,44 +51,48 @@
|
||||
* Text inside of white boxes are the key associated with the object, its
|
||||
* data type is specified on its edge, i.e string, array, integer, dictionary.
|
||||
*/
|
||||
enum {
|
||||
TRANS_INSTALL = 1,
|
||||
TRANS_UPDATE
|
||||
};
|
||||
|
||||
static int
|
||||
transaction_find_pkg(const char *pattern, const char *reason)
|
||||
transaction_find_pkg(const char *pattern, int action)
|
||||
{
|
||||
prop_dictionary_t pkg_repod = NULL;
|
||||
prop_dictionary_t pkg_regpkgdb, pkg_repod = NULL;
|
||||
prop_dictionary_t transd;
|
||||
prop_array_t mdeps, unsorted;
|
||||
const char *pkgname, *pkgver, *repoloc;
|
||||
const char *pkgname, *pkgver, *repoloc, *repover, *instver, *reason;
|
||||
int rv = 0;
|
||||
bool bypattern = false, bestpkg;
|
||||
bool bypattern, bestpkg;
|
||||
pkg_state_t state = 0;
|
||||
|
||||
assert(pattern != NULL);
|
||||
assert(reason != NULL);
|
||||
|
||||
if (strcmp(reason, "install") == 0) {
|
||||
if (action == TRANS_INSTALL) {
|
||||
/* install */
|
||||
bypattern = true;
|
||||
bestpkg = false;
|
||||
reason = "install";
|
||||
} else {
|
||||
/* update */
|
||||
pkg_repod = xbps_find_pkg_dict_installed(pattern, false);
|
||||
if (pkg_repod == NULL) {
|
||||
pkg_regpkgdb = xbps_find_pkg_dict_installed(pattern, false);
|
||||
if (pkg_regpkgdb == NULL) {
|
||||
rv = ENODEV;
|
||||
goto out;
|
||||
}
|
||||
prop_object_release(pkg_repod);
|
||||
pkg_repod = NULL;
|
||||
bypattern = false;
|
||||
bestpkg = true;
|
||||
reason = "update";
|
||||
}
|
||||
|
||||
xbps_dbg_printf("%s: pattern %s reason %s\n", __func__, pattern, reason);
|
||||
/*
|
||||
* Find out if the pkg has been found in repository pool.
|
||||
*/
|
||||
pkg_repod = xbps_repository_pool_find_pkg(pattern,
|
||||
bypattern, bestpkg);
|
||||
if (pkg_repod == NULL) {
|
||||
if (bestpkg == false) {
|
||||
if (!bestpkg) {
|
||||
pkg_repod = xbps_repository_pool_find_virtualpkg(
|
||||
pattern, bypattern, bestpkg);
|
||||
}
|
||||
@ -99,6 +103,27 @@ transaction_find_pkg(const char *pattern, const char *reason)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc);
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgname", &pkgname);
|
||||
|
||||
if (bestpkg) {
|
||||
/*
|
||||
* Compare installed version vs best pkg available in repos.
|
||||
*/
|
||||
prop_dictionary_get_cstring_nocopy(pkg_regpkgdb,
|
||||
"version", &instver);
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod,
|
||||
"version", &repover);
|
||||
prop_object_release(pkg_regpkgdb);
|
||||
if (xbps_cmpver(repover, instver) <= 0) {
|
||||
xbps_dbg_printf("[rpool] Skipping `%s' "
|
||||
"(installed: %s) from repository `%s'\n",
|
||||
pkgver, instver, repoloc);
|
||||
rv = EEXIST;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Prepare transaction dictionary and missing deps array.
|
||||
*/
|
||||
@ -111,9 +136,6 @@ transaction_find_pkg(const char *pattern, const char *reason)
|
||||
goto out;
|
||||
}
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc);
|
||||
/*
|
||||
* Prepare required package dependencies and add them into the
|
||||
* "unsorted" array in transaction dictionary.
|
||||
@ -217,13 +239,13 @@ xbps_transaction_update_packages(void)
|
||||
int
|
||||
xbps_transaction_update_pkg(const char *pkgname)
|
||||
{
|
||||
return transaction_find_pkg(pkgname, "update");
|
||||
return transaction_find_pkg(pkgname, TRANS_UPDATE);
|
||||
}
|
||||
|
||||
int
|
||||
xbps_transaction_install_pkg(const char *pkgpattern)
|
||||
{
|
||||
return transaction_find_pkg(pkgpattern, "install");
|
||||
return transaction_find_pkg(pkgpattern, TRANS_INSTALL);
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user