Welcome pkgdb-0.38.

This commit is contained in:
Juan RP
2014-09-11 00:12:12 +02:00
parent fb9c94fab9
commit 01dbb968dd
30 changed files with 480 additions and 477 deletions

View File

@@ -34,12 +34,10 @@
int HIDDEN
xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
{
xbps_dictionary_t pkgd;
xbps_array_t provides, rundeps;
char outstr[64];
time_t t;
struct tm *tmp;
const char *desc, *pkgver, *repo;
const char *pkgver;
char *pkgname = NULL, *buf, *sha256;
int rv = 0;
bool autoinst = false;
@@ -47,41 +45,17 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
assert(xbps_object_type(pkgrd) == XBPS_TYPE_DICTIONARY);
xbps_dictionary_get_cstring_nocopy(pkgrd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc);
xbps_dictionary_get_cstring_nocopy(pkgrd, "repository", &repo);
xbps_dictionary_get_bool(pkgrd, "automatic-install", &autoinst);
provides = xbps_dictionary_get(pkgrd, "provides");
rundeps = xbps_dictionary_get(pkgrd, "run_depends");
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
assert(pkgver != NULL);
assert(desc != NULL);
pkgd = xbps_pkgdb_get_pkg(xhp, pkgver);
if (pkgd == NULL) {
rv = ENOENT;
goto out;
}
if (!xbps_dictionary_set_cstring_nocopy(pkgd,
"pkgver", pkgver)) {
xbps_dbg_printf(xhp, "%s: invalid pkgver for %s\n",
__func__, pkgver);
rv = EINVAL;
goto out;
}
if (!xbps_dictionary_set_cstring_nocopy(pkgd,
"short_desc", desc)) {
xbps_dbg_printf(xhp, "%s: invalid short_desc for %s\n",
__func__, pkgver);
rv = EINVAL;
goto out;
}
if (xhp->flags & XBPS_FLAG_INSTALL_AUTO)
autoinst = true;
if (!xbps_dictionary_set_bool(pkgd,
"automatic-install", autoinst)) {
xbps_dbg_printf(xhp, "%s: invalid autoinst for %s\n",
__func__, pkgver);
/*
* Set automatic-install to true, iff it was explicitly set; otherwise
* preserve its value.
*/
if (autoinst && !xbps_dictionary_set_bool(pkgrd, "automatic-install", true)) {
xbps_dbg_printf(xhp, "%s: invalid autoinst for %s\n", __func__, pkgver);
rv = EINVAL;
goto out;
}
@@ -101,50 +75,31 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
rv = EINVAL;
goto out;
}
if (!xbps_dictionary_set_cstring(pkgd, "install-date", outstr)) {
if (!xbps_dictionary_set_cstring(pkgrd, "install-date", outstr)) {
xbps_dbg_printf(xhp, "%s: install-date set failed!\n", pkgver);
rv = EINVAL;
goto out;
}
if (provides && !xbps_dictionary_set(pkgd, "provides", provides)) {
xbps_dbg_printf(xhp, "%s: failed to set provides for %s\n",
__func__, pkgver);
rv = EINVAL;
goto out;
}
if (rundeps && !xbps_dictionary_set(pkgd, "run_depends", rundeps)) {
xbps_dbg_printf(xhp, "%s: failed to set rundeps for %s\n",
__func__, pkgver);
rv = EINVAL;
goto out;
}
/* Save the repository origin which was used to install the pkg from */
if (!xbps_dictionary_set_cstring(pkgd, "repository-origin", repo)) {
xbps_dbg_printf(xhp, "%s: repository-origin set failed!\n", pkgver);
rv = EINVAL;
goto out;
}
/*
* Create a hash for the pkg's metafile.
*/
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
buf = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
buf = xbps_xasprintf("%s/.%s-files.plist", xhp->metadir, pkgname);
sha256 = xbps_file_hash(buf);
assert(sha256);
xbps_dictionary_set_cstring(pkgd, "metafile-sha256", sha256);
xbps_dictionary_set_cstring(pkgrd, "metafile-sha256", sha256);
free(sha256);
free(buf);
/*
* Remove unneeded objs from pkg dictionary.
*/
xbps_dictionary_remove(pkgd, "remove-and-update");
xbps_dictionary_remove(pkgd, "transaction");
xbps_dictionary_remove(pkgd, "skip-obsoletes");
xbps_dictionary_remove(pkgrd, "download");
xbps_dictionary_remove(pkgrd, "remove-and-update");
xbps_dictionary_remove(pkgrd, "transaction");
xbps_dictionary_remove(pkgrd, "skip-obsoletes");
xbps_dictionary_remove(pkgrd, "pkgname");
xbps_dictionary_remove(pkgrd, "version");
if (!xbps_dictionary_set(xhp->pkgdb, pkgname, pkgd)) {
if (!xbps_dictionary_set(xhp->pkgdb, pkgname, pkgrd)) {
xbps_dbg_printf(xhp,
"%s: failed to set pkgd for %s\n", __func__, pkgver);
}