diff --git a/bin/xbps-bin/install.c b/bin/xbps-bin/install.c index e9e458b0..c65015e3 100644 --- a/bin/xbps-bin/install.c +++ b/bin/xbps-bin/install.c @@ -112,7 +112,7 @@ static int download_package_list(prop_object_iterator_t iter) { prop_object_t obj; - const char *pkgname, *version, *repoloc, *filename, *arch; + const char *pkgver, *repoloc, *filename, *arch; char *savedir, *binfile, *lbinfile, *repoloc_trans; int rv = 0; @@ -126,8 +126,7 @@ download_package_list(prop_object_iterator_t iter) (strncmp(repoloc, "ftp://", 6))) continue; - prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); - prop_dictionary_get_cstring_nocopy(obj, "version", &version); + prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); prop_dictionary_get_cstring_nocopy(obj, "filename", &filename); prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch); @@ -162,8 +161,7 @@ download_package_list(prop_object_iterator_t iter) free(savedir); return errno; } - printf("Downloading %s-%s binary package ...\n", - pkgname, version); + printf("Downloading %s binary package ...\n", pkgver); rv = xbps_fetch_file(binfile, savedir, false, NULL); free(savedir); free(binfile); @@ -198,17 +196,16 @@ show_package_list(prop_object_iterator_t iter, const char *match) { prop_object_t obj; size_t cols = 0; - const char *pkgname, *version, *tract; + const char *pkgver, *tract; bool first = false; while ((obj = prop_object_iterator_next(iter)) != NULL) { - prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); - prop_dictionary_get_cstring_nocopy(obj, "version", &version); + prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); prop_dictionary_get_cstring_nocopy(obj, "trans-action", &tract); if (strcmp(match, tract)) continue; - cols += strlen(pkgname) + strlen(version) + 4; + cols += strlen(pkgver) + 4; if (cols <= 80) { if (first == false) { printf(" "); @@ -216,9 +213,9 @@ show_package_list(prop_object_iterator_t iter, const char *match) } } else { printf("\n "); - cols = strlen(pkgname) + strlen(version) + 4; + cols = strlen(pkgver) + 4; } - printf("%s-%s ", pkgname, version); + printf("%s ", pkgver); } prop_object_iterator_reset(iter); } @@ -425,8 +422,7 @@ out: } static int -replace_packages(prop_object_iterator_t iter, const char *pkgname, - const char *version) +replace_packages(prop_object_iterator_t iter, const char *pkgver) { prop_dictionary_t instd; prop_object_t obj; @@ -443,8 +439,8 @@ replace_packages(prop_object_iterator_t iter, const char *pkgname, if (instd == NULL) continue; - printf("Replacing package '%s' with '%s-%s' ...\n", - reppkgn, pkgname, version); + printf("Replacing package '%s' with '%s' ...\n", + reppkgn, pkgver); if ((rv = xbps_remove_pkg(reppkgn, NULL, false)) != 0) { printf("Couldn't remove %s (%s)\n", reppkgn, strerror(rv)); @@ -467,7 +463,7 @@ exec_transaction(struct transaction *trans) prop_dictionary_t instpkgd; prop_object_t obj; prop_object_iterator_t replaces_iter; - const char *pkgname, *version, *instver, *filename, *tract; + const char *pkgname, *version, *pkgver, *instver, *filename, *tract; int rv = 0; bool essential, autoinst; pkg_state_t state = 0; @@ -512,6 +508,7 @@ exec_transaction(struct transaction *trans) while ((obj = prop_object_iterator_next(trans->iter)) != NULL) { prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); prop_dictionary_get_cstring_nocopy(obj, "version", &version); + prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); prop_dictionary_get_bool(obj, "essential", &essential); prop_dictionary_get_cstring_nocopy(obj, "filename", &filename); prop_dictionary_get_cstring_nocopy(obj, "trans-action", &tract); @@ -543,7 +540,7 @@ exec_transaction(struct transaction *trans) * Replace package(s) if necessary. */ if (replaces_iter != NULL) { - rv = replace_packages(replaces_iter, pkgname, version); + rv = replace_packages(replaces_iter, pkgver); if (rv != 0) { printf("Couldn't replace some packages! " "(%s)\n", strerror(rv)); @@ -594,19 +591,18 @@ exec_transaction(struct transaction *trans) /* * Unpack binary package. */ - printf("Unpacking %s-%s (from .../%s) ...\n", pkgname, version, - filename); + printf("Unpacking %s (from .../%s) ...\n", pkgver, filename); if ((rv = xbps_unpack_binary_pkg(obj, essential)) != 0) { - printf("error: unpacking %s-%s (%s)\n", pkgname, - version, strerror(rv)); + printf("error: unpacking %s (%s)\n", pkgver, + strerror(rv)); return rv; } /* * Register binary package. */ if ((rv = xbps_register_pkg(obj, autoinst)) != 0) { - printf("error: registering %s-%s! (%s)\n", - pkgname, version, strerror(rv)); + printf("error: registering %s! (%s)\n", + pkgver, strerror(rv)); return rv; } autoinst = false; diff --git a/bin/xbps-bin/main.c b/bin/xbps-bin/main.c index 95140827..d4a4d97d 100644 --- a/bin/xbps-bin/main.c +++ b/bin/xbps-bin/main.c @@ -71,18 +71,17 @@ usage(void) static int list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done) { - const char *pkgname, *version, *short_desc; + const char *pkgver, *short_desc; (void)arg; (void)loop_done; assert(prop_object_type(obj) == PROP_TYPE_DICTIONARY); - prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); - prop_dictionary_get_cstring_nocopy(obj, "version", &version); + prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); prop_dictionary_get_cstring_nocopy(obj, "short_desc", &short_desc); - if (pkgname && version && short_desc) { - printf("%s-%s\t%s\n", pkgname, version, short_desc); + if (pkgver && short_desc) { + printf("%s\t%s\n", pkgver, short_desc); return 0; } @@ -92,7 +91,7 @@ list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done) static int list_manual_packages(prop_object_t obj, void *arg, bool *loop_done) { - const char *pkgname, *version; + const char *pkgver; bool automatic = false; (void)arg; @@ -100,9 +99,8 @@ list_manual_packages(prop_object_t obj, void *arg, bool *loop_done) prop_dictionary_get_bool(obj, "automatic-install", &automatic); if (automatic == false) { - prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); - prop_dictionary_get_cstring_nocopy(obj, "version", &version); - printf("%s-%s\n", pkgname, version); + prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + printf("%s\n", pkgver); } return 0; diff --git a/bin/xbps-bin/remove.c b/bin/xbps-bin/remove.c index f9efcde3..ad6388da 100644 --- a/bin/xbps-bin/remove.c +++ b/bin/xbps-bin/remove.c @@ -39,7 +39,7 @@ xbps_autoremove_pkgs(void) prop_array_t orphans; prop_object_t obj; prop_object_iterator_t iter; - const char *pkgname, *version; + const char *pkgver, *pkgname, *version; size_t cols = 0; int rv = 0; bool first = false; @@ -68,9 +68,8 @@ xbps_autoremove_pkgs(void) printf("The following packages were installed automatically\n" "(as dependencies) and aren't needed anymore:\n\n"); while ((obj = prop_object_iterator_next(iter)) != NULL) { - prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); - prop_dictionary_get_cstring_nocopy(obj, "version", &version); - cols += strlen(pkgname) + strlen(version) + 4; + prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); + cols += strlen(pkgver) + 4; if (cols <= 80) { if (first == false) { printf(" "); @@ -78,9 +77,9 @@ xbps_autoremove_pkgs(void) } } else { printf("\n "); - cols = strlen(pkgname) + strlen(version) + 4; + cols = strlen(pkgver) + 4; } - printf("%s-%s ", pkgname, version); + printf("%s ", pkgver); } prop_object_iterator_reset(iter); printf("\n\n"); @@ -93,7 +92,6 @@ xbps_autoremove_pkgs(void) while ((obj = prop_object_iterator_next(iter)) != NULL) { prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); prop_dictionary_get_cstring_nocopy(obj, "version", &version); - printf("Removing package %s-%s ...\n", pkgname, version); if ((rv = xbps_remove_pkg(pkgname, version, false)) != 0) goto out2; diff --git a/include/xbps_api.h b/include/xbps_api.h index 8f049f65..f99cda91 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -38,7 +38,7 @@ #include /* Current release version */ -#define XBPS_RELVER "20091118" +#define XBPS_RELVER "20091121" /* Default root PATH for xbps to store metadata info. */ #define XBPS_META_PATH "/var/db/xbps" @@ -227,6 +227,7 @@ char SYMEXPORT *xbps_get_pkgdep_name(const char *); const char SYMEXPORT *xbps_get_pkg_version(const char *); const char SYMEXPORT *xbps_get_pkgdep_version(const char *); const char SYMEXPORT *xbps_get_pkg_revision(const char *); +const char SYMEXPORT *xbps_get_pkgver_from_dict(prop_dictionary_t); bool SYMEXPORT xbps_pkg_has_rundeps(prop_dictionary_t); void SYMEXPORT xbps_set_rootdir(const char *); const char SYMEXPORT *xbps_get_rootdir(void); diff --git a/lib/depends.c b/lib/depends.c index 3cfb325f..b26e8783 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -195,7 +195,7 @@ find_repo_deps(prop_dictionary_t master, prop_dictionary_t repo, prop_array_t curpkg_rdeps; prop_object_t obj; prop_object_iterator_t iter; - const char *reqpkg, *reqvers; + const char *reqpkg, *reqvers, *pkg_queued; char *pkgname; int rv = 0; @@ -217,12 +217,12 @@ find_repo_deps(prop_dictionary_t master, prop_dictionary_t repo, /* There was an error checking it... */ break; } else if (rv == 1) { - /* pkgdep is satisfied */ + /* Required pkg dependency is satisfied */ DPRINTF(("Dependency %s satisfied.\n", reqpkg)); rv = 0; continue; } - DPRINTF(("Dependency %s not mached.\n", reqpkg)); + DPRINTF(("Dependency %s not installed.\n", reqpkg)); pkgname = xbps_get_pkgdep_name(reqpkg); if (pkgname == NULL) { rv = EINVAL; @@ -236,12 +236,24 @@ find_repo_deps(prop_dictionary_t master, prop_dictionary_t repo, } /* * Check if package is already added in the - * array of unsorted deps. + * array of unsorted deps, and check if current required + * dependency pattern is matched. */ - if (xbps_find_pkg_in_dict(master, "unsorted_deps", pkgname)) { - DPRINTF(("Dependency %s already queued.\n", pkgname)); - free(pkgname); - continue; + curpkgd = xbps_find_pkg_in_dict(master, "unsorted_deps", pkgname); + if (curpkgd) { + prop_dictionary_get_cstring_nocopy(curpkgd, + "pkgver", &pkg_queued); + if (pkg_queued == NULL) { + free(pkgname); + return errno; + } + if (xbps_pkgdep_match(pkg_queued, __UNCONST(reqpkg))) { + DPRINTF(("Dependency %s already queued.\n", + pkgname)); + free(pkgname); + continue; + } + curpkgd = NULL; } /* diff --git a/lib/register.c b/lib/register.c index 996dd25e..282a2439 100644 --- a/lib/register.c +++ b/lib/register.c @@ -35,7 +35,7 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic) { prop_dictionary_t dict, pkgd; prop_array_t array; - const char *pkgname, *version, *desc; + const char *pkgname, *version, *desc, *pkgver; char *plist; int rv = 0; @@ -47,6 +47,7 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic) prop_dictionary_get_cstring_nocopy(pkgrd, "pkgname", &pkgname); prop_dictionary_get_cstring_nocopy(pkgrd, "version", &version); prop_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc); + prop_dictionary_get_cstring_nocopy(pkgrd, "pkgver", &pkgver); dict = prop_dictionary_internalize_from_file(plist); if (dict != NULL) { @@ -56,6 +57,7 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic) goto out; } prop_dictionary_set_cstring_nocopy(pkgd, "version", version); + prop_dictionary_set_cstring_nocopy(pkgd, "pkgver", pkgver); prop_dictionary_set_cstring_nocopy(pkgd, "short_desc", desc); prop_dictionary_set_bool(pkgd, "automatic-install", automatic); diff --git a/lib/requiredby.c b/lib/requiredby.c index cca552f8..09a1ac9a 100644 --- a/lib/requiredby.c +++ b/lib/requiredby.c @@ -153,27 +153,19 @@ xbps_requiredby_pkg_add(prop_array_t regar, prop_dictionary_t pkg) prop_array_t rdeps; prop_object_t obj, obj2; prop_object_iterator_t iter, iter2; - const char *reqname, *pkgname, *version, *str; - char *rdepname, *fpkgn; + const char *reqname, *pkgver, *str; + char *rdepname; int rv = 0; - prop_dictionary_get_cstring_nocopy(pkg, "pkgname", &pkgname); - prop_dictionary_get_cstring_nocopy(pkg, "version", &version); - fpkgn = xbps_xasprintf("%s-%s", pkgname, version); - if (fpkgn == NULL) - return ENOMEM; + prop_dictionary_get_cstring_nocopy(pkg, "pkgver", &pkgver); rdeps = prop_dictionary_get(pkg, "run_depends"); - if (rdeps == NULL || prop_array_count(rdeps) == 0) { - free(fpkgn); + if (rdeps == NULL || prop_array_count(rdeps) == 0) return EINVAL; - } iter = prop_array_iterator(rdeps); - if (iter == NULL) { - free(fpkgn); + if (iter == NULL) return ENOMEM; - } while ((obj = prop_object_iterator_next(iter)) != NULL) { str = prop_string_cstring_nocopy(obj); @@ -193,7 +185,7 @@ xbps_requiredby_pkg_add(prop_array_t regar, prop_dictionary_t pkg) prop_dictionary_get_cstring_nocopy(obj2, "pkgname", &reqname); if (strcmp(rdepname, reqname) == 0) { - rv = add_pkg_into_reqby(obj2, fpkgn); + rv = add_pkg_into_reqby(obj2, pkgver); if (rv == EEXIST) continue; else if (rv != 0) { @@ -209,7 +201,6 @@ xbps_requiredby_pkg_add(prop_array_t regar, prop_dictionary_t pkg) } out: - free(fpkgn); prop_object_iterator_release(iter); return rv; diff --git a/lib/util.c b/lib/util.c index b0b521ea..69feecad 100644 --- a/lib/util.c +++ b/lib/util.c @@ -115,8 +115,8 @@ int SYMEXPORT xbps_check_is_installed_pkg(const char *pkg) { prop_dictionary_t dict; - const char *instver; - char *pkgname, *instpkg; + const char *instpkgver; + char *pkgname; int rv = 0; pkg_state_t state = 0; @@ -146,18 +146,15 @@ xbps_check_is_installed_pkg(const char *pkg) free(pkgname); return 0; /* not fully installed */ } - - /* Get version from installed package */ - prop_dictionary_get_cstring_nocopy(dict, "version", &instver); - instpkg = xbps_xasprintf("%s-%s", pkgname, instver); free(pkgname); - if (instpkg == NULL) { + + instpkgver = xbps_get_pkgver_from_dict(dict); + if (instpkgver == NULL) { prop_object_release(dict); return -1; } /* Check if installed pkg is matched against pkgdep pattern */ - rv = xbps_pkgdep_match(instpkg, __UNCONST(pkg)); - free(instpkg); + rv = xbps_pkgdep_match(instpkgver, __UNCONST(pkg)); prop_object_release(dict); return rv; @@ -269,6 +266,17 @@ xbps_get_pkgdep_version(const char *pkg) return res; } +const char SYMEXPORT * +xbps_get_pkgver_from_dict(prop_dictionary_t d) +{ + const char *pkgver; + + assert(d != NULL); + + prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver); + return pkgver; +} + static char * get_pkg_index_remote_plist(const char *uri, const char *machine) {