lib/util.c: add function which tests if a given pkgver is reverted by a given pkg.
This commit is contained in:
22
lib/util.c
22
lib/util.c
@ -425,3 +425,25 @@ xbps_humanize_number(char *buf, int64_t bytes)
|
||||
return humanize_number(buf, 7, bytes, "B",
|
||||
HN_AUTOSCALE, HN_DECIMAL|HN_NOSPACE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if pkg is explicitly marked to replace a specific installed version.
|
||||
*/
|
||||
int
|
||||
xbps_pkgver_is_reverted(const char *pkgver, xbps_dictionary_t pkg) {
|
||||
unsigned int i;
|
||||
xbps_array_t reverts;
|
||||
const char *revertver;
|
||||
|
||||
if ((reverts = xbps_dictionary_get(pkg, "reverts")) == NULL)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < xbps_array_count(reverts); i++) {
|
||||
xbps_array_get_cstring_nocopy(reverts, i, &revertver);
|
||||
if (strcmp(pkgver, revertver) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user