blob: 3e4a672fbf08ff5abcc3c61301ac9afd1f38a5b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#include "config.h"
#include <stdio.h>
#include <alpm.h>
#include <alpm_list.h>
#include "pacman.h"
#include "conf.h"
#include "util.h"
int pacman_database(alpm_list_t *targets)
{
alpm_list_t *i;
alpm_db_t *db_local;
int retval = 0;
alpm_pkgreason_t reason;
if(targets == NULL) {
pm_printf(ALPM_LOG_ERROR, _("no targets specified (use -h for help)\n"));
return 1;
}
if(config->flags & ALPM_TRANS_FLAG_ALLDEPS) {
reason = ALPM_PKG_REASON_DEPEND;
} else if(config->flags & ALPM_TRANS_FLAG_ALLEXPLICIT) {
reason = ALPM_PKG_REASON_EXPLICIT;
} else {
pm_printf(ALPM_LOG_ERROR, _("no install reason specified (use -h for help)\n"));
return 1;
}
if(trans_init(0, 0) == -1) {
return 1;
}
db_local = alpm_option_get_localdb(config->handle);
for(i = targets; i; i = alpm_list_next(i)) {
char *pkgname = i->data;
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 == 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);
}
}
}
if(trans_release() == -1) {
return 1;
}
return retval;
}
|