From 91aeac4dadd8fcb9be944a93ed85cae44dea9930 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 30 Nov 2009 12:08:46 +0100 Subject: [PATCH] Rename some function from lib/repository* with more meaningful names. xbps_unregister_repository() -> xbps_repository_register() xbps_register_repository() -> xbps_repository_unregister() xbps_find_deps_in_pkg() -> xbps_repository_find_pkg_deps() xbps_prepare_pkg() -> xbps_repository_install_pkg() xbps_find_new_pkg() -> xbps_repository_update_pkg() xbps_find_new_packages() -> xbps_repository_update_allpkgs() xbps_get_pkg_props() -> xbps_repository_get_transaction_dict() --HG-- extra : convert_revision : xtraeme%40gmail.com-20091130110846-5uaqxdhfo0kl0cqd --- bin/xbps-bin/install.c | 8 +++--- bin/xbps-repo/repository.c | 4 +-- include/xbps_api.h | 15 +++++----- lib/repository.c | 4 +-- lib/repository_finddeps.c | 2 +- lib/repository_findpkg.c | 57 +++++++++++++++++++------------------- 6 files changed, 46 insertions(+), 44 deletions(-) diff --git a/bin/xbps-bin/install.c b/bin/xbps-bin/install.c index 2be56e9f..b45d0f74 100644 --- a/bin/xbps-bin/install.c +++ b/bin/xbps-bin/install.c @@ -312,7 +312,7 @@ xbps_exec_transaction(const char *pkgname, bool force, bool update) * "xbps-bin autoupdate". */ printf("Finding new packages...\n"); - if ((rv = xbps_find_new_packages()) != 0) { + if ((rv = xbps_repository_update_allpkgs()) != 0) { if (rv == ENOENT) { printf("No packages currently registered.\n"); return 0; @@ -331,7 +331,7 @@ xbps_exec_transaction(const char *pkgname, bool force, bool update) */ printf("Finding new '%s' package...\n", pkgname); if (pkgd) { - rv = xbps_find_new_pkg(pkgname, pkgd); + rv = xbps_repository_update_pkg(pkgname, pkgd); if (rv == EEXIST) { printf("Package '%s' is up to date.\n", pkgname); @@ -363,7 +363,7 @@ xbps_exec_transaction(const char *pkgname, bool force, bool update) prop_object_release(pkgd); return rv; } - rv = xbps_prepare_pkg(pkgname); + rv = xbps_repository_install_pkg(pkgname); if (rv != 0 && rv == EAGAIN) { printf("Unable to locate '%s' in " "repository pool.\n", pkgname); @@ -379,7 +379,7 @@ xbps_exec_transaction(const char *pkgname, bool force, bool update) if (trans == NULL) goto out; - trans->dict = xbps_get_pkg_props(); + trans->dict = xbps_repository_get_transaction_dict(); if (trans->dict == NULL) { printf("error: unexistent props dictionary!\n"); goto out1; diff --git a/bin/xbps-repo/repository.c b/bin/xbps-repo/repository.c index d6ecf88d..7e6c09b3 100644 --- a/bin/xbps-repo/repository.c +++ b/bin/xbps-repo/repository.c @@ -134,7 +134,7 @@ unregister_repository(const char *uri) if (!sanitize_url(idxstr, uri)) return errno; - if ((rv = xbps_unregister_repository(idxstr)) != 0) { + if ((rv = xbps_repository_unregister(idxstr)) != 0) { if (rv == ENOENT) printf("Repository '%s' not actually " "registered.\n", idxstr); @@ -182,7 +182,7 @@ register_repository(const char *uri) if ((rv = pkgindex_verify(plist, idxstr, false)) != 0) goto out; - if ((rv = xbps_register_repository(idxstr)) != 0) { + if ((rv = xbps_repository_register(idxstr)) != 0) { printf("ERROR: couldn't register repository (%s)\n", strerror(rv)); goto out; diff --git a/include/xbps_api.h b/include/xbps_api.h index 9d708981..17984f16 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -191,17 +191,18 @@ int SYMEXPORT xbps_remove_pkg(const char *, const char *, bool); int xbps_remove_obsoletes(prop_dictionary_t, prop_dictionary_t); /* From lib/repository.c */ -int SYMEXPORT xbps_register_repository(const char *); -int SYMEXPORT xbps_unregister_repository(const char *); +int SYMEXPORT xbps_repository_register(const char *); +int SYMEXPORT xbps_repository_unregister(const char *); /* From lib/repository_finddeps.c */ -int SYMEXPORT xbps_find_deps_in_pkg(prop_dictionary_t, prop_dictionary_t); +int SYMEXPORT xbps_repository_find_pkg_deps(prop_dictionary_t, + prop_dictionary_t); /* From lib/repository_findpkg.c */ -int SYMEXPORT xbps_prepare_pkg(const char *); -int SYMEXPORT xbps_find_new_pkg(const char *, prop_dictionary_t); -int SYMEXPORT xbps_find_new_packages(void); -prop_dictionary_t SYMEXPORT xbps_get_pkg_props(void); +int SYMEXPORT xbps_repository_install_pkg(const char *); +int SYMEXPORT xbps_repository_update_pkg(const char *, prop_dictionary_t); +int SYMEXPORT xbps_repository_update_allpkgs(void); +prop_dictionary_t SYMEXPORT xbps_repository_get_transaction_dict(void); /* From lib/repository_plist.c */ char SYMEXPORT diff --git a/lib/repository.c b/lib/repository.c index 267b61c6..a7c47b46 100644 --- a/lib/repository.c +++ b/lib/repository.c @@ -31,7 +31,7 @@ #include int SYMEXPORT -xbps_register_repository(const char *uri) +xbps_repository_register(const char *uri) { prop_dictionary_t dict; prop_array_t array; @@ -107,7 +107,7 @@ out: } int SYMEXPORT -xbps_unregister_repository(const char *uri) +xbps_repository_unregister(const char *uri) { prop_dictionary_t dict; prop_array_t array; diff --git a/lib/repository_finddeps.c b/lib/repository_finddeps.c index aa7c7682..2b373003 100644 --- a/lib/repository_finddeps.c +++ b/lib/repository_finddeps.c @@ -237,7 +237,7 @@ out: } int SYMEXPORT -xbps_find_deps_in_pkg(prop_dictionary_t master, prop_dictionary_t pkg) +xbps_repository_find_pkg_deps(prop_dictionary_t master, prop_dictionary_t pkg) { prop_array_t pkg_rdeps, missing_rdeps; struct repository_data *rdata; diff --git a/lib/repository_findpkg.c b/lib/repository_findpkg.c index cb018da2..7f47bb73 100644 --- a/lib/repository_findpkg.c +++ b/lib/repository_findpkg.c @@ -31,22 +31,22 @@ #include -static prop_dictionary_t pkg_props; -static bool pkg_props_initialized; +static prop_dictionary_t trans_dict; +static bool trans_dict_initialized; static int set_pkg_state(prop_dictionary_t, const char *); static int -create_pkg_props_dictionary(void) +create_transaction_dictionary(void) { prop_array_t unsorted, missing; int rv = 0; - if (pkg_props_initialized) + if (trans_dict_initialized) return 0; - pkg_props = prop_dictionary_create(); - if (pkg_props == NULL) + trans_dict = prop_dictionary_create(); + if (trans_dict == NULL) return ENOMEM; missing = prop_array_create(); @@ -61,16 +61,16 @@ create_pkg_props_dictionary(void) goto fail2; } - if (!xbps_add_obj_to_dict(pkg_props, missing, "missing_deps")) { + if (!xbps_add_obj_to_dict(trans_dict, missing, "missing_deps")) { rv = EINVAL; goto fail3; } - if (!xbps_add_obj_to_dict(pkg_props, unsorted, "unsorted_deps")) { + if (!xbps_add_obj_to_dict(trans_dict, unsorted, "unsorted_deps")) { rv = EINVAL; goto fail3; } - pkg_props_initialized = true; + trans_dict_initialized = true; return rv; @@ -79,22 +79,22 @@ fail3: fail2: prop_object_release(missing); fail: - prop_object_release(pkg_props); + prop_object_release(trans_dict); return rv; } prop_dictionary_t SYMEXPORT -xbps_get_pkg_props(void) +xbps_repository_get_transaction_dict(void) { - if (pkg_props_initialized == false) + if (trans_dict_initialized == false) return NULL; - return pkg_props; + return trans_dict; } int SYMEXPORT -xbps_find_new_packages(void) +xbps_repository_update_allpkgs(void) { prop_dictionary_t dict; prop_object_t obj; @@ -132,7 +132,7 @@ xbps_find_new_packages(void) rv = errno; break; } - rv = xbps_find_new_pkg(pkgname, obj); + rv = xbps_repository_update_pkg(pkgname, obj); if (rv == ENOENT) continue; else if (rv == EEXIST) { @@ -155,7 +155,7 @@ out: } int SYMEXPORT -xbps_find_new_pkg(const char *pkgname, prop_dictionary_t instpkg) +xbps_repository_update_pkg(const char *pkgname, prop_dictionary_t instpkg) { prop_dictionary_t pkgrd = NULL; prop_array_t unsorted; @@ -223,9 +223,9 @@ xbps_find_new_pkg(const char *pkgname, prop_dictionary_t instpkg) goto out; } /* - * Create master pkg dictionary. + * Create the transaction dictionary. */ - if ((rv = create_pkg_props_dictionary()) != 0) + if ((rv = create_transaction_dictionary()) != 0) goto out; /* @@ -239,14 +239,14 @@ xbps_find_new_pkg(const char *pkgname, prop_dictionary_t instpkg) /* * Construct the dependency chain for this package. */ - if ((rv = xbps_find_deps_in_pkg(pkg_props, pkgrd)) != 0) + if ((rv = xbps_repository_find_pkg_deps(trans_dict, pkgrd)) != 0) goto out; /* * Add required package dictionary into the packages * dictionary. */ - unsorted = prop_dictionary_get(pkg_props, "unsorted_deps"); + unsorted = prop_dictionary_get(trans_dict, "unsorted_deps"); if (unsorted == NULL) { rv = EINVAL; goto out; @@ -298,7 +298,7 @@ set_pkg_state(prop_dictionary_t pkgd, const char *pkgname) } int SYMEXPORT -xbps_prepare_pkg(const char *pkgname) +xbps_repository_install_pkg(const char *pkgname) { prop_dictionary_t origin_pkgrd = NULL, pkgrd = NULL; prop_array_t pkgs_array; @@ -331,9 +331,9 @@ xbps_prepare_pkg(const char *pkgname) } /* - * Create master pkg dictionary. + * Create the transaction dictionary. */ - if ((rv = create_pkg_props_dictionary()) != 0) + if ((rv = create_transaction_dictionary()) != 0) goto out; /* @@ -345,7 +345,7 @@ xbps_prepare_pkg(const char *pkgname) } origin_pkgrd = prop_dictionary_copy(pkgrd); - if (!prop_dictionary_set_cstring(pkg_props, "origin", pkgname)) { + if (!prop_dictionary_set_cstring(trans_dict, "origin", pkgname)) { rv = errno; goto out; } @@ -356,12 +356,13 @@ xbps_prepare_pkg(const char *pkgname) /* * Construct the dependency chain for this package. */ - if ((rv = xbps_find_deps_in_pkg(pkg_props, pkgrd)) != 0) + if ((rv = xbps_repository_find_pkg_deps(trans_dict, + pkgrd)) != 0) goto out; /* * Sort the dependency chain for this package. */ - if ((rv = xbps_sort_pkg_deps(pkg_props)) != 0) + if ((rv = xbps_sort_pkg_deps(trans_dict)) != 0) goto out; } else { /* @@ -373,7 +374,7 @@ xbps_prepare_pkg(const char *pkgname) rv = errno; goto out; } - if (!prop_dictionary_set(pkg_props, "packages", + if (!prop_dictionary_set(trans_dict, "packages", pkgs_array)) { rv = errno; goto out; @@ -384,7 +385,7 @@ xbps_prepare_pkg(const char *pkgname) * Add required package dictionary into the packages * dictionary. */ - pkgs_array = prop_dictionary_get(pkg_props, "packages"); + pkgs_array = prop_dictionary_get(trans_dict, "packages"); if (pkgs_array == NULL || prop_object_type(pkgs_array) != PROP_TYPE_ARRAY) { rv = EINVAL;