New function: xbps_get_pkg_dict_from_metadata_plist.
This function returns and internalized dictionary from a package's metadata plist file as specified by its arguments. Update all code to use it where appropiate.
This commit is contained in:
@@ -110,15 +110,7 @@ xbps_check_pkg_integrity(const char *pkgname)
|
||||
/*
|
||||
* Check for props.plist metadata file.
|
||||
*/
|
||||
path = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(),
|
||||
XBPS_META_PATH, pkgname, XBPS_PKGPROPS);
|
||||
if (path == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
|
||||
propsd = prop_dictionary_internalize_from_zfile(path);
|
||||
free(path);
|
||||
propsd = xbps_get_pkg_dict_from_metadata_plist(pkgname, XBPS_PKGPROPS);
|
||||
if (propsd == NULL) {
|
||||
fprintf(stderr,
|
||||
"E: %s: unexistent %s metadata file.\n", pkgname,
|
||||
@@ -142,15 +134,7 @@ xbps_check_pkg_integrity(const char *pkgname)
|
||||
/*
|
||||
* Check for files.plist metadata file.
|
||||
*/
|
||||
path = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(),
|
||||
XBPS_META_PATH, pkgname, XBPS_PKGFILES);
|
||||
if (path == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
|
||||
filesd = prop_dictionary_internalize_from_zfile(path);
|
||||
free(path);
|
||||
filesd = xbps_get_pkg_dict_from_metadata_plist(pkgname, XBPS_PKGFILES);
|
||||
if (filesd == NULL) {
|
||||
fprintf(stderr,
|
||||
"E: %s: unexistent %s metadata file.\n", pkgname,
|
||||
|
||||
@@ -75,7 +75,7 @@ find_files_in_packages(const char *pattern)
|
||||
prop_array_t files_keys;
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
char *path, *filesplist;
|
||||
char *path;
|
||||
int rv = 0;
|
||||
unsigned int i, count;
|
||||
|
||||
@@ -94,16 +94,9 @@ find_files_in_packages(const char *pattern)
|
||||
(strcmp(dp->d_name, "..") == 0))
|
||||
continue;
|
||||
|
||||
filesplist = xbps_xasprintf("%s/%s/%s", path, dp->d_name,
|
||||
pkg_filesd = xbps_get_pkg_dict_from_metadata_plist(dp->d_name,
|
||||
XBPS_PKGFILES);
|
||||
if (filesplist == NULL) {
|
||||
rv = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
pkg_filesd = prop_dictionary_internalize_from_zfile(filesplist);
|
||||
if (pkg_filesd == NULL) {
|
||||
free(filesplist);
|
||||
if (errno == ENOENT)
|
||||
continue;
|
||||
rv = -1;
|
||||
@@ -118,7 +111,6 @@ find_files_in_packages(const char *pattern)
|
||||
break;
|
||||
}
|
||||
prop_object_release(pkg_filesd);
|
||||
free(filesplist);
|
||||
if (rv == -1)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2009 Juan Romero Pardines.
|
||||
* Copyright (c) 2009-2010 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -37,7 +37,6 @@ int
|
||||
xbps_show_pkg_deps(const char *pkgname)
|
||||
{
|
||||
prop_dictionary_t pkgd, propsd;
|
||||
char *path;
|
||||
int rv = 0;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
@@ -47,17 +46,12 @@ xbps_show_pkg_deps(const char *pkgname)
|
||||
printf("Package %s is not installed.\n", pkgname);
|
||||
return 0;
|
||||
}
|
||||
prop_object_release(pkgd);
|
||||
|
||||
/*
|
||||
* Check for props.plist metadata file.
|
||||
*/
|
||||
path = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(),
|
||||
XBPS_META_PATH, pkgname, XBPS_PKGPROPS);
|
||||
if (path == NULL)
|
||||
return errno;
|
||||
|
||||
propsd = prop_dictionary_internalize_from_zfile(path);
|
||||
free(path);
|
||||
propsd = xbps_get_pkg_dict_from_metadata_plist(pkgname, XBPS_PKGPROPS);
|
||||
if (propsd == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: unexistent %s metadata file.\n", pkgname,
|
||||
@@ -68,7 +62,6 @@ xbps_show_pkg_deps(const char *pkgname)
|
||||
rv = xbps_callback_array_iter_in_dict(propsd, "run_depends",
|
||||
list_strings_sep_in_array, NULL);
|
||||
prop_object_release(propsd);
|
||||
prop_object_release(pkgd);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2008-2009 Juan Romero Pardines.
|
||||
* Copyright (c) 2008-2010 Juan Romero Pardines.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -37,23 +37,14 @@
|
||||
int
|
||||
show_pkg_info_from_metadir(const char *pkgname)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
char *plist;
|
||||
prop_dictionary_t d;
|
||||
|
||||
plist = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(),
|
||||
XBPS_META_PATH, pkgname, XBPS_PKGPROPS);
|
||||
if (plist == NULL)
|
||||
return EINVAL;
|
||||
|
||||
pkgd = prop_dictionary_internalize_from_zfile(plist);
|
||||
if (pkgd == NULL) {
|
||||
free(plist);
|
||||
d = xbps_get_pkg_dict_from_metadata_plist(pkgname, XBPS_PKGPROPS);
|
||||
if (d == NULL)
|
||||
return errno;
|
||||
}
|
||||
|
||||
show_pkg_info(pkgd);
|
||||
prop_object_release(pkgd);
|
||||
free(plist);
|
||||
show_pkg_info(d);
|
||||
prop_object_release(d);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -61,24 +52,15 @@ show_pkg_info_from_metadir(const char *pkgname)
|
||||
int
|
||||
show_pkg_files_from_metadir(const char *pkgname)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
char *plist;
|
||||
prop_dictionary_t d;
|
||||
int rv = 0;
|
||||
|
||||
plist = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(),
|
||||
XBPS_META_PATH, pkgname, XBPS_PKGFILES);
|
||||
if (plist == NULL)
|
||||
return EINVAL;
|
||||
|
||||
pkgd = prop_dictionary_internalize_from_zfile(plist);
|
||||
if (pkgd == NULL) {
|
||||
free(plist);
|
||||
d = xbps_get_pkg_dict_from_metadata_plist(pkgname, XBPS_PKGFILES);
|
||||
if (d == NULL)
|
||||
return errno;
|
||||
}
|
||||
free(plist);
|
||||
|
||||
rv = show_pkg_files(pkgd);
|
||||
prop_object_release(pkgd);
|
||||
rv = show_pkg_files(d);
|
||||
prop_object_release(d);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user