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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <alpm.h>
#include "util.h"
#include "list.h"
#include "package.h"
extern char *pmo_root;
void dump_pkg_full(PM_PKG *pkg, int level)
{
char *date;
if(pkg == NULL) {
return;
}
printf("Name : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_NAME));
printf("Version : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_VERSION));
PM_LIST_display("Groups :", alpm_pkg_getinfo(pkg, PM_PKG_GROUPS));
printf("Packager : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_PACKAGER));
printf("URL : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_URL));
printf("License : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_LICENSE));
printf("Architecture : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_ARCH));
printf("Size : %ld\n", (long int)alpm_pkg_getinfo(pkg, PM_PKG_SIZE));
date = alpm_pkg_getinfo(pkg, PM_PKG_BUILDDATE);
printf("Build Date : %s %s\n", date, strlen(date) ? "UTC" : "");
date = alpm_pkg_getinfo(pkg, PM_PKG_INSTALLDATE);
printf("Install Date : %s %s\n", date, strlen(date) ? "UTC" : "");
printf("Install Script : %s\n", (alpm_pkg_getinfo(pkg, PM_PKG_SCRIPLET) ? "Yes" : "No"));
printf("Reason: : ");
switch((int)alpm_pkg_getinfo(pkg, PM_PKG_REASON)) {
case PM_PKG_REASON_EXPLICIT:
printf("explicitly installed\n");
break;
case PM_PKG_REASON_DEPEND:
printf("installed as a dependency for another package\n");
break;
default:
printf("unknown\n");
break;
}
PM_LIST_display("Provides :", alpm_pkg_getinfo(pkg, PM_PKG_PROVIDES));
PM_LIST_display("Depends On :", alpm_pkg_getinfo(pkg, PM_PKG_DEPENDS));
PM_LIST_display("Required By :", alpm_pkg_getinfo(pkg, PM_PKG_REQUIREDBY));
PM_LIST_display("Conflicts With :", alpm_pkg_getinfo(pkg, PM_PKG_CONFLICTS));
printf("Description : ");
indentprint(alpm_pkg_getinfo(pkg, PM_PKG_DESC), 17);
printf("\n");
printf("\n");
}
void dump_pkg_sync(PM_PKG *pkg, char *treename)
{
if(pkg == NULL) {
return;
}
printf("Repository : %s\n", treename);
printf("Name : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_NAME));
printf("Version : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_VERSION));
PM_LIST_display("Groups :", alpm_pkg_getinfo(pkg, PM_PKG_GROUPS));
PM_LIST_display("Provides :", alpm_pkg_getinfo(pkg, PM_PKG_PROVIDES));
PM_LIST_display("Depends On :", alpm_pkg_getinfo(pkg, PM_PKG_DEPENDS));
PM_LIST_display("Conflicts With :", alpm_pkg_getinfo(pkg, PM_PKG_CONFLICTS));
PM_LIST_display("Replaces :", alpm_pkg_getinfo(pkg, PM_PKG_REPLACES));
printf("Size (compressed) : %ld\n", (long)alpm_pkg_getinfo(pkg, PM_PKG_SIZE));
printf("Description : ");
indentprint(alpm_pkg_getinfo(pkg, PM_PKG_DESC), 17);
printf("\nMD5 Sum : %s\n", (char *)alpm_pkg_getinfo(pkg, PM_PKG_MD5SUM));
}
void dump_pkg_files(PM_PKG *pkg)
{
char *pkgname;
PM_LIST *i, *pkgfiles;
pkgname = alpm_pkg_getinfo(pkg, PM_PKG_NAME);
pkgfiles = alpm_pkg_getinfo(pkg, PM_PKG_FILES);
for(i = pkgfiles; i; i = alpm_list_next(i)) {
fprintf(stdout, "%s %s\n", (char *)pkgname, (char *)alpm_list_getdata(i));
}
fflush(stdout);
}
int split_pkgname(char *target, char *name, char *version)
{
char tmp[512];
char *p, *q;
if(target == NULL) {
return(-1);
}
if((p = strrchr(target, '/')) == NULL) {
p = target;
} else {
p++;
}
strncpy(tmp, p, 512);
if((p = strstr(tmp, PM_EXT_PKG))) {
*p = 0;
}
p = tmp + strlen(tmp);
for(q = --p; *q && *q != '-'; q--);
if(*q != '-' || q == tmp) {
return(-1);
}
for(p = --q; *p && *p != '-'; p--);
if(*p != '-' || p == tmp) {
return(-1);
}
strncpy(version, p+1, 64);
*p = 0;
strncpy(name, tmp, 256);
return(0);
}
|