From 194dea2de10c3507608e4f826c66802671a719a8 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sun, 28 Dec 2014 19:08:59 +1000 Subject: Split install reason changing into its own function Prepare for other functions to be added to the --database option. Signed-off-by: Allan McRae --- src/pacman/database.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/pacman/database.c b/src/pacman/database.c index e858e0c8..dac0ab1d 100644 --- a/src/pacman/database.c +++ b/src/pacman/database.c @@ -35,11 +35,12 @@ * * @return 0 on success, 1 on failure */ -int pacman_database(alpm_list_t *targets) +static int change_install_reason(alpm_list_t *targets) { alpm_list_t *i; alpm_db_t *db_local; - int retval = 0; + int ret = 0; + alpm_pkgreason_t reason; if(targets == NULL) { @@ -68,7 +69,7 @@ int pacman_database(alpm_list_t *targets) if(!pkg || alpm_pkg_set_reason(pkg, reason)) { pm_printf(ALPM_LOG_ERROR, _("could not set install reason for package %s (%s)\n"), pkgname, alpm_strerror(alpm_errno(config->handle))); - retval = 1; + ret = 1; } else { if(reason == ALPM_PKG_REASON_DEPEND) { printf(_("%s: install reason has been set to 'installed as dependency'\n"), pkgname); @@ -82,7 +83,20 @@ int pacman_database(alpm_list_t *targets) if(trans_release() == -1) { return 1; } - return retval; + return ret; +} + + +int pacman_database(alpm_list_t *targets) +{ + int ret = 0; + + if(config->flags & (ALPM_TRANS_FLAG_ALLDEPS | ALPM_TRANS_FLAG_ALLEXPLICIT)) { + ret = change_install_reason(targets); + return ret; + } + + return ret; } /* vim: set noet: */ -- cgit v1.2.3-70-g09d2