Add ALPM_PKG_REASON_UNKNOWN type

Return ALPM_PKG_REASON_UNKNOWN when parsing of %REASON% in the local
database fails.

Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Allan McRae 2024-02-04 10:10:28 +10:00
parent 6e6d3f18e3
commit 0649a66ee5
3 changed files with 5 additions and 3 deletions

View file

@ -2293,7 +2293,9 @@ typedef enum _alpm_pkgreason_t {
/** Explicitly requested by the user. */ /** Explicitly requested by the user. */
ALPM_PKG_REASON_EXPLICIT = 0, ALPM_PKG_REASON_EXPLICIT = 0,
/** Installed as a dependency for another package. */ /** Installed as a dependency for another package. */
ALPM_PKG_REASON_DEPEND = 1 ALPM_PKG_REASON_DEPEND = 1,
/** Failed parsing of local database */
ALPM_PKG_REASON_UNKNOWN = 2
} alpm_pkgreason_t; } alpm_pkgreason_t;
/** Location a package object was loaded from. */ /** Location a package object was loaded from. */

View file

@ -661,7 +661,7 @@ static alpm_pkgreason_t _read_pkgreason(alpm_handle_t *handle, const char *pkgna
return ALPM_PKG_REASON_DEPEND; return ALPM_PKG_REASON_DEPEND;
} else { } else {
_alpm_log(handle, ALPM_LOG_ERROR, _("unknown install reason for package %s: %s\n"), pkgname, line); _alpm_log(handle, ALPM_LOG_ERROR, _("unknown install reason for package %s: %s\n"), pkgname, line);
return ALPM_PKG_REASON_EXPLICIT; return ALPM_PKG_REASON_UNKNOWN;
} }
} }

View file

@ -556,7 +556,7 @@ static void _alpm_select_depends(alpm_list_t **from, alpm_list_t **to,
for(i = *from; i; i = next) { for(i = *from; i; i = next) {
alpm_pkg_t *deppkg = i->data; alpm_pkg_t *deppkg = i->data;
next = i->next; next = i->next;
if((explicit || alpm_pkg_get_reason(deppkg) != ALPM_PKG_REASON_EXPLICIT) if((explicit || alpm_pkg_get_reason(deppkg) == ALPM_PKG_REASON_DEPEND)
&& _alpm_pkg_depends_on(pkg, deppkg)) { && _alpm_pkg_depends_on(pkg, deppkg)) {
*to = alpm_list_add(*to, deppkg); *to = alpm_list_add(*to, deppkg);
*from = alpm_list_remove_item(*from, i); *from = alpm_list_remove_item(*from, i);