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:
Juan RP
2012-01-17 16:17:03 +01:00
parent da5e9f841f
commit f2b05d6438
12 changed files with 332 additions and 282 deletions

View File

@ -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);
}