Use a common key for all arrays of pkgdicts.
--HG-- extra : convert_revision : cab30e527b438afb266f4e6084af7c51357efd17
This commit is contained in:
parent
289709fe1b
commit
00e90663af
4 changed files with 11 additions and 15 deletions
|
@ -85,8 +85,7 @@ xbps_callback_array_iter_in_dict(prop_dictionary_t dict, const char *key,
|
|||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_dict(prop_dictionary_t dict, const char *key,
|
||||
const char *pkgname)
|
||||
xbps_find_pkg_in_dict(prop_dictionary_t dict, const char *pkgname)
|
||||
{
|
||||
prop_object_iterator_t iter;
|
||||
prop_object_t obj;
|
||||
|
@ -95,7 +94,7 @@ xbps_find_pkg_in_dict(prop_dictionary_t dict, const char *key,
|
|||
if (pkgname == NULL)
|
||||
return NULL;
|
||||
|
||||
iter = xbps_get_array_iter_from_dict(dict, key);
|
||||
iter = xbps_get_array_iter_from_dict(dict, "packages");
|
||||
if (iter == NULL)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -69,13 +69,12 @@ xbps_callback_array_iter_in_dict(prop_dictionary_t, const char *,
|
|||
*
|
||||
* Arguments:
|
||||
* - prop_dictionary_t: main dictionary to search the object.
|
||||
* - 1st const char *key: use a dictionary with that key.
|
||||
* - 2nd const char *pkgname: string of package name.
|
||||
* - const char *: string of package name.
|
||||
*
|
||||
* Returns the package's dictionary object, otherwise NULL.
|
||||
*/
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_dict(prop_dictionary_t, const char *, const char *);
|
||||
xbps_find_pkg_in_dict(prop_dictionary_t, const char *);
|
||||
|
||||
/*
|
||||
* Finds a string object in an array.
|
||||
|
|
|
@ -110,7 +110,7 @@ write_repo_pkgindex_header()
|
|||
<string>$XBPS_PKGINDEX_VERSION</string>
|
||||
<key>location-local</key>
|
||||
<string>$repodir</string>
|
||||
<key>available-packages</key>
|
||||
<key>packages</key>
|
||||
<array>
|
||||
_EOF
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ register_pkg(prop_dictionary_t dict, pkg_data_t *pkg, const char *dbfile)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
array = prop_dictionary_get(dict, "packages_installed");
|
||||
array = prop_dictionary_get(dict, "packages");
|
||||
if (array == NULL || prop_object_type(array) != PROP_TYPE_ARRAY) {
|
||||
printf("%s: NULL or incorrect array type\n", __func__);
|
||||
exit(1);
|
||||
|
@ -109,7 +109,7 @@ unregister_pkg(prop_dictionary_t dict, const char *pkgname, const char *dbfile)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
array = prop_dictionary_get(dict, "packages_installed");
|
||||
array = prop_dictionary_get(dict, "packages");
|
||||
if (array == NULL || prop_object_type(array) != PROP_TYPE_ARRAY) {
|
||||
printf("%s: NULL or incorrect array type\n", __func__);
|
||||
exit(1);
|
||||
|
@ -137,7 +137,7 @@ unregister_pkg(prop_dictionary_t dict, const char *pkgname, const char *dbfile)
|
|||
}
|
||||
|
||||
prop_array_remove(array, i);
|
||||
if (!xbps_add_array_to_dict(dict, array, "packages_installed")) {
|
||||
if (!xbps_add_array_to_dict(dict, array, "packages")) {
|
||||
printf("=> ERROR: couldn't unregister %s from database\n",
|
||||
pkgname);
|
||||
exit(1);
|
||||
|
@ -257,8 +257,7 @@ main(int argc, char **argv)
|
|||
prop_object_release(dbdict);
|
||||
} else {
|
||||
/* Check if pkg is already registered. */
|
||||
pkgdict = xbps_find_pkg_in_dict(dbdict,
|
||||
"packages_installed", argv[2]);
|
||||
pkgdict = xbps_find_pkg_in_dict(dbdict, argv[2]);
|
||||
if (pkgdict != NULL) {
|
||||
printf("%s=> Package %s-%s already registered.\n",
|
||||
in_chroot ? "[chroot] " : "",
|
||||
|
@ -293,7 +292,7 @@ main(int argc, char **argv)
|
|||
|
||||
dbdict = prop_dictionary_internalize_from_file(dbfile);
|
||||
xbps_callback_array_iter_in_dict(dbdict,
|
||||
"packages_installed", xbps_list_pkgs_in_dict);
|
||||
"packages", xbps_list_pkgs_in_dict);
|
||||
|
||||
} else if (strcmp(argv[1], "version") == 0) {
|
||||
/* Prints version of an installed package */
|
||||
|
@ -301,8 +300,7 @@ main(int argc, char **argv)
|
|||
usage();
|
||||
|
||||
pkgdict = xbps_find_pkg_in_dict(
|
||||
prop_dictionary_internalize_from_file(dbfile),
|
||||
"packages_installed", argv[2]);
|
||||
prop_dictionary_internalize_from_file(dbfile), argv[2]);
|
||||
if (pkgdict == NULL)
|
||||
exit(1);
|
||||
if (!prop_dictionary_get_cstring_nocopy(pkgdict, "version",
|
||||
|
|
Loading…
Reference in a new issue