mirror of
https://github.com/void-linux/void-packages.git
synced 2025-07-29 08:52:56 +02:00
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
|
prop_dictionary_t
|
||||||
xbps_find_pkg_in_dict(prop_dictionary_t dict, const char *key,
|
xbps_find_pkg_in_dict(prop_dictionary_t dict, const char *pkgname)
|
||||||
const char *pkgname)
|
|
||||||
{
|
{
|
||||||
prop_object_iterator_t iter;
|
prop_object_iterator_t iter;
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
|
@ -95,7 +94,7 @@ xbps_find_pkg_in_dict(prop_dictionary_t dict, const char *key,
|
||||||
if (pkgname == NULL)
|
if (pkgname == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
iter = xbps_get_array_iter_from_dict(dict, key);
|
iter = xbps_get_array_iter_from_dict(dict, "packages");
|
||||||
if (iter == NULL)
|
if (iter == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -69,13 +69,12 @@ xbps_callback_array_iter_in_dict(prop_dictionary_t, const char *,
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* - prop_dictionary_t: main dictionary to search the object.
|
* - prop_dictionary_t: main dictionary to search the object.
|
||||||
* - 1st const char *key: use a dictionary with that key.
|
* - const char *: string of package name.
|
||||||
* - 2nd const char *pkgname: string of package name.
|
|
||||||
*
|
*
|
||||||
* Returns the package's dictionary object, otherwise NULL.
|
* Returns the package's dictionary object, otherwise NULL.
|
||||||
*/
|
*/
|
||||||
prop_dictionary_t
|
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.
|
* Finds a string object in an array.
|
||||||
|
|
|
@ -110,7 +110,7 @@ write_repo_pkgindex_header()
|
||||||
<string>$XBPS_PKGINDEX_VERSION</string>
|
<string>$XBPS_PKGINDEX_VERSION</string>
|
||||||
<key>location-local</key>
|
<key>location-local</key>
|
||||||
<string>$repodir</string>
|
<string>$repodir</string>
|
||||||
<key>available-packages</key>
|
<key>packages</key>
|
||||||
<array>
|
<array>
|
||||||
_EOF
|
_EOF
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ register_pkg(prop_dictionary_t dict, pkg_data_t *pkg, const char *dbfile)
|
||||||
exit(1);
|
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) {
|
if (array == NULL || prop_object_type(array) != PROP_TYPE_ARRAY) {
|
||||||
printf("%s: NULL or incorrect array type\n", __func__);
|
printf("%s: NULL or incorrect array type\n", __func__);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -109,7 +109,7 @@ unregister_pkg(prop_dictionary_t dict, const char *pkgname, const char *dbfile)
|
||||||
exit(1);
|
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) {
|
if (array == NULL || prop_object_type(array) != PROP_TYPE_ARRAY) {
|
||||||
printf("%s: NULL or incorrect array type\n", __func__);
|
printf("%s: NULL or incorrect array type\n", __func__);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -137,7 +137,7 @@ unregister_pkg(prop_dictionary_t dict, const char *pkgname, const char *dbfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
prop_array_remove(array, i);
|
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",
|
printf("=> ERROR: couldn't unregister %s from database\n",
|
||||||
pkgname);
|
pkgname);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -257,8 +257,7 @@ main(int argc, char **argv)
|
||||||
prop_object_release(dbdict);
|
prop_object_release(dbdict);
|
||||||
} else {
|
} else {
|
||||||
/* Check if pkg is already registered. */
|
/* Check if pkg is already registered. */
|
||||||
pkgdict = xbps_find_pkg_in_dict(dbdict,
|
pkgdict = xbps_find_pkg_in_dict(dbdict, argv[2]);
|
||||||
"packages_installed", argv[2]);
|
|
||||||
if (pkgdict != NULL) {
|
if (pkgdict != NULL) {
|
||||||
printf("%s=> Package %s-%s already registered.\n",
|
printf("%s=> Package %s-%s already registered.\n",
|
||||||
in_chroot ? "[chroot] " : "",
|
in_chroot ? "[chroot] " : "",
|
||||||
|
@ -293,7 +292,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
dbdict = prop_dictionary_internalize_from_file(dbfile);
|
dbdict = prop_dictionary_internalize_from_file(dbfile);
|
||||||
xbps_callback_array_iter_in_dict(dbdict,
|
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) {
|
} else if (strcmp(argv[1], "version") == 0) {
|
||||||
/* Prints version of an installed package */
|
/* Prints version of an installed package */
|
||||||
|
@ -301,8 +300,7 @@ main(int argc, char **argv)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
pkgdict = xbps_find_pkg_in_dict(
|
pkgdict = xbps_find_pkg_in_dict(
|
||||||
prop_dictionary_internalize_from_file(dbfile),
|
prop_dictionary_internalize_from_file(dbfile), argv[2]);
|
||||||
"packages_installed", argv[2]);
|
|
||||||
if (pkgdict == NULL)
|
if (pkgdict == NULL)
|
||||||
exit(1);
|
exit(1);
|
||||||
if (!prop_dictionary_get_cstring_nocopy(pkgdict, "version",
|
if (!prop_dictionary_get_cstring_nocopy(pkgdict, "version",
|
||||||
|
|
Loading…
Add table
Reference in a new issue