4 * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
5 * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include <alpm_list.h>
34 * @brief Modify the 'local' package database.
36 * @param targets a list of packages (as strings) to modify
38 * @return 0 on success, 1 on failure
40 int pacman_database(alpm_list_t
*targets
)
45 alpm_pkgreason_t reason
;
48 pm_printf(PM_LOG_ERROR
, _("no targets specified (use -h for help)\n"));
52 if(config
->flags
& PM_TRANS_FLAG_ALLDEPS
) { /* --asdeps */
53 reason
= PM_PKG_REASON_DEPEND
;
54 } else if(config
->flags
& PM_TRANS_FLAG_ALLEXPLICIT
) { /* --asexplicit */
55 reason
= PM_PKG_REASON_EXPLICIT
;
57 pm_printf(PM_LOG_ERROR
, _("no install reason specified (use -h for help)\n"));
62 if(trans_init(0) == -1) {
66 db_local
= alpm_option_get_localdb(config
->handle
);
67 for(i
= targets
; i
; i
= alpm_list_next(i
)) {
68 char *pkgname
= i
->data
;
69 if(alpm_db_set_pkgreason(db_local
, pkgname
, reason
) == -1) {
70 pm_printf(PM_LOG_ERROR
, _("could not set install reason for package %s (%s)\n"),
71 pkgname
, alpm_strerror(alpm_errno(config
->handle
)));
74 if(reason
== PM_PKG_REASON_DEPEND
) {
75 printf(_("%s: install reason has been set to 'installed as dependency'\n"), pkgname
);
77 printf(_("%s: install reason has been set to 'explicitly installed'\n"), pkgname
);
83 if(trans_release() == -1) {
89 /* vim: set ts=2 sw=2 noet: */