Introduce xbps_plist_{array,dictionary}_from_file().
Those are a wrapper around xbps_{array,dictionary}_internalize_from_zfile()
that prints a debugging msg when the plist file cannot be internalized.
Update xbps to use these wrappers.
This commit is contained in:
@@ -293,7 +293,7 @@ xbps_remove_pkg(struct xbps_handle *xhp, const char *pkgver, bool update)
|
||||
|
||||
/* internalize pkg files dictionary from metadir */
|
||||
snprintf(metafile, sizeof(metafile), "%s/.%s-files.plist", xhp->metadir, pkgname);
|
||||
pkgfilesd = xbps_dictionary_internalize_from_zfile(metafile);
|
||||
pkgfilesd = xbps_plist_dictionary_from_file(xhp, metafile);
|
||||
if (pkgfilesd == NULL)
|
||||
xbps_dbg_printf(xhp, "WARNING: metaplist for %s "
|
||||
"doesn't exist!\n", pkgver);
|
||||
|
||||
@@ -423,7 +423,7 @@ xbps_pkgdb_get_pkg_files(struct xbps_handle *xhp, const char *pkg)
|
||||
|
||||
plist = xbps_xasprintf("%s/.%s-files.plist", xhp->metadir, pkgname);
|
||||
free(pkgname);
|
||||
pkgfilesd = xbps_dictionary_internalize_from_zfile(plist);
|
||||
pkgfilesd = xbps_plist_dictionary_from_file(xhp, plist);
|
||||
free(plist);
|
||||
|
||||
if (pkgfilesd == NULL) {
|
||||
|
||||
@@ -50,7 +50,7 @@ pkgdb038(struct xbps_handle *xhp, const char *opkgdb_plist)
|
||||
* - <metadir>/pkgdb-0.38.plist
|
||||
* - <metadir>/.<pkgname>-files.plist
|
||||
*/
|
||||
opkgdb = xbps_dictionary_internalize_from_zfile(opkgdb_plist);
|
||||
opkgdb = xbps_plist_dictionary_from_file(xhp, opkgdb_plist);
|
||||
if (opkgdb == NULL)
|
||||
return EINVAL;
|
||||
|
||||
@@ -93,7 +93,7 @@ pkgdb038(struct xbps_handle *xhp, const char *opkgdb_plist)
|
||||
* Copy pkg metadata objs to the new pkgdb.
|
||||
*/
|
||||
pkgmeta = xbps_xasprintf("%s/.%s.plist", xhp->metadir, pkgname);
|
||||
pkgmetad = xbps_dictionary_internalize_from_zfile(pkgmeta);
|
||||
pkgmetad = xbps_plist_dictionary_from_file(xhp, pkgmeta);
|
||||
if (pkgmetad == NULL) {
|
||||
rv = EINVAL;
|
||||
xbps_dbg_printf(xhp, "%s: cannot open %s: %s\n",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2013 Juan Romero Pardines.
|
||||
* Copyright (c) 2013-2015 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -931,3 +931,30 @@ xbps_string_equals_cstring(xbps_string_t s, const char *ss)
|
||||
{
|
||||
return prop_string_equals_cstring(s, ss);
|
||||
}
|
||||
|
||||
/* xbps specific helpers */
|
||||
xbps_array_t
|
||||
xbps_plist_array_from_file(struct xbps_handle *xhp, const char *f)
|
||||
{
|
||||
xbps_array_t a;
|
||||
|
||||
a = xbps_array_internalize_from_zfile(f);
|
||||
if (xbps_object_type(a) != XBPS_TYPE_ARRAY) {
|
||||
xbps_dbg_printf(xhp,
|
||||
"xbps: failed to internalize array from %s\n", f);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
xbps_dictionary_t
|
||||
xbps_plist_dictionary_from_file(struct xbps_handle *xhp, const char *f)
|
||||
{
|
||||
xbps_dictionary_t d;
|
||||
|
||||
d = xbps_dictionary_internalize_from_zfile(f);
|
||||
if (xbps_object_type(d) != XBPS_TYPE_DICTIONARY) {
|
||||
xbps_dbg_printf(xhp,
|
||||
"xbps: failed to internalize dict from %s\n", f);
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
@@ -540,7 +540,7 @@ xbps_repo_key_import(struct xbps_repo *repo)
|
||||
* Check if the public key is alredy stored.
|
||||
*/
|
||||
rkeyfile = xbps_xasprintf("%s/keys/%s.plist", repo->xhp->metadir, hexfp);
|
||||
repokeyd = xbps_dictionary_internalize_from_zfile(rkeyfile);
|
||||
repokeyd = xbps_plist_dictionary_from_file(repo->xhp, rkeyfile);
|
||||
if (xbps_object_type(repokeyd) == XBPS_TYPE_DICTIONARY) {
|
||||
xbps_dbg_printf(repo->xhp,
|
||||
"[repo] `%s' public key already stored.\n", repo->uri);
|
||||
|
||||
@@ -102,7 +102,7 @@ xbps_verify_file_signature(struct xbps_repo *repo, const char *fname)
|
||||
* Prepare repository RSA public key to verify fname signature.
|
||||
*/
|
||||
rkeyfile = xbps_xasprintf("%s/keys/%s.plist", repo->xhp->metadir, hexfp);
|
||||
repokeyd = xbps_dictionary_internalize_from_zfile(rkeyfile);
|
||||
repokeyd = xbps_plist_dictionary_from_file(repo->xhp, rkeyfile);
|
||||
if (xbps_object_type(repokeyd) != XBPS_TYPE_DICTIONARY) {
|
||||
xbps_dbg_printf(repo->xhp, "cannot read rkey data at %s: %s\n",
|
||||
rkeyfile, strerror(errno));
|
||||
|
||||
Reference in New Issue
Block a user