summaryrefslogtreecommitdiffstats
path: root/src/pacman/database.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman/database.c')
-rw-r--r--src/pacman/database.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/pacman/database.c b/src/pacman/database.c
index 36433f33..3e4a672f 100644
--- a/src/pacman/database.c
+++ b/src/pacman/database.c
@@ -20,7 +20,6 @@
#include "config.h"
-#include <stdlib.h>
#include <stdio.h>
#include <alpm.h>
@@ -41,38 +40,39 @@
int pacman_database(alpm_list_t *targets)
{
alpm_list_t *i;
- pmdb_t *db_local;
+ alpm_db_t *db_local;
int retval = 0;
- pmpkgreason_t reason;
+ alpm_pkgreason_t reason;
if(targets == NULL) {
- pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n"));
- return(1);
+ pm_printf(ALPM_LOG_ERROR, _("no targets specified (use -h for help)\n"));
+ return 1;
}
- if(config->flags & PM_TRANS_FLAG_ALLDEPS) { /* --asdeps */
- reason = PM_PKG_REASON_DEPEND;
- } else if(config->flags & PM_TRANS_FLAG_ALLEXPLICIT) { /* --asexplicit */
- reason = PM_PKG_REASON_EXPLICIT;
+ if(config->flags & ALPM_TRANS_FLAG_ALLDEPS) { /* --asdeps */
+ reason = ALPM_PKG_REASON_DEPEND;
+ } else if(config->flags & ALPM_TRANS_FLAG_ALLEXPLICIT) { /* --asexplicit */
+ reason = ALPM_PKG_REASON_EXPLICIT;
} else {
- pm_printf(PM_LOG_ERROR, _("no install reason specified (use -h for help)\n"));
- return(1);
+ pm_printf(ALPM_LOG_ERROR, _("no install reason specified (use -h for help)\n"));
+ return 1;
}
/* Lock database */
- if(trans_init(0) == -1) {
- return(1);
+ if(trans_init(0, 0) == -1) {
+ return 1;
}
- db_local = alpm_option_get_localdb();
+ db_local = alpm_option_get_localdb(config->handle);
for(i = targets; i; i = alpm_list_next(i)) {
char *pkgname = i->data;
- if(alpm_db_set_pkgreason(db_local, pkgname, reason) == -1) {
- pm_printf(PM_LOG_ERROR, _("could not set install reason for package %s (%s)\n"),
- pkgname, alpm_strerrorlast());
+ alpm_pkg_t *pkg = alpm_db_get_pkg(db_local, pkgname);
+ if(!pkg || alpm_db_set_pkgreason(config->handle, 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;
} else {
- if(reason == PM_PKG_REASON_DEPEND) {
+ if(reason == ALPM_PKG_REASON_DEPEND) {
printf(_("%s: install reason has been set to 'installed as dependency'\n"), pkgname);
} else {
printf(_("%s: install reason has been set to 'explicitly installed'\n"), pkgname);
@@ -82,9 +82,9 @@ int pacman_database(alpm_list_t *targets)
/* Unlock database */
if(trans_release() == -1) {
- return(1);
+ return 1;
}
- return(retval);
+ return retval;
}
/* vim: set ts=2 sw=2 noet: */