API clean up (part 2), plus misc changes and improvements.

- Rename regpkgs_dictionary to regpkgdb_dictionary to better describe what is is.
- Change some funcs in plist.c to return a boolean rather than int.
- Hide more internal funcs off the API.
- Simplify xbps_repository_update_pkg() and remove its second arg.
- Hide implementation details in xbps_repository_pool, now to iterate over the
  pool you have to use xbps_repository_pool_foreach and its struct
  repository_pool_index.
- Introduce xbps_{init,end}, to initialize/destroy some stuff in the library.
- Introduce xbps_dbg_printf to printf stuff for debugging purposes.
- xbps-{bin,repo}:  added -d arg to enable debugging output.
- Before checking if a config file needs to be installed or such, check that
  package contains the "conf_files" array.
- Remove obsolete dirs as well while updating packages.
- If transaction dictionary is ready remove the "missing_deps" array.

Bump XBPS_RELVER to 20101118.

--HG--
rename : lib/regpkgs_dictionary.c => lib/regpkgdb_dictionary.c
This commit is contained in:
Juan RP
2010-11-19 13:40:13 +01:00
parent ffc255b715
commit fdec663855
33 changed files with 1426 additions and 943 deletions

View File

@@ -53,7 +53,7 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic)
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
return EINVAL;
return ENOMEM;
prop_dictionary_get_cstring_nocopy(pkgrd, "pkgname", &pkgname);
prop_dictionary_get_cstring_nocopy(pkgrd, "version", &version);
@@ -70,29 +70,24 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic)
"packages", pkgname);
if (pkgd == NULL) {
rv = errno;
DPRINTF(("%s: find_pkg_in_dict_by_name failed: %s\n",
__func__, strerror(rv)));
goto out;
}
if (!prop_dictionary_set_cstring_nocopy(pkgd,
"version", version)) {
prop_object_release(pkgd);
rv = errno;
DPRINTF(("%s: version obj not found!\n", __func__));
rv = EINVAL;
goto out;
}
if (!prop_dictionary_set_cstring_nocopy(pkgd,
"pkgver", pkgver)) {
prop_object_release(pkgd);
rv = errno;
DPRINTF(("%s: pkgver obj not found!\n", __func__));
rv = EINVAL;
goto out;
}
if (!prop_dictionary_set_cstring_nocopy(pkgd,
"short_desc", desc)) {
prop_object_release(pkgd);
rv = errno;
DPRINTF(("%s: short_desc obj not found!\n", __func__));
rv = EINVAL;
goto out;
}
if (!prop_dictionary_get_bool(pkgd,
@@ -100,9 +95,7 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic)
if (!prop_dictionary_set_bool(pkgd,
"automatic-install", automatic)) {
prop_object_release(pkgd);
rv = errno;
DPRINTF(("%s: autoinst obj not found!\n",
__func__));
rv = EINVAL;
goto out;
}
}
@@ -114,24 +107,19 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic)
array = prop_dictionary_get(dict, "packages");
if (array == NULL) {
prop_object_release(pkgd);
rv = ENOENT;
DPRINTF(("%s: packages array obj not found!\n",
__func__));
rv = EINVAL;
goto out;
}
rv = xbps_requiredby_pkg_add(array, pkgrd);
if (rv != 0) {
prop_object_release(pkgd);
DPRINTF(("%s: requiredby_pkg_add failed %d\n",
__func__, rv));
if ((rv = xbps_requiredby_pkg_add(array, pkgrd)) != 0)
goto out;
}
}
/*
* Write plist file to storage.
*/
if (!prop_dictionary_externalize_to_zfile(dict, plist))
if (!prop_dictionary_externalize_to_zfile(dict, plist)) {
rv = errno;
goto out;
}
} else {
free(plist);
return ENOENT;
@@ -154,9 +142,11 @@ xbps_unregister_pkg(const char *pkgname)
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
return EINVAL;
return ENOMEM;
if (!xbps_remove_pkg_dict_from_file(pkgname, plist))
rv = errno;
rv = xbps_remove_pkg_dict_from_file(pkgname, plist);
free(plist);
return rv;