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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <sys/stat.h>
#include <libintl.h>
#include <alpm.h>
#include "log.h"
#include "util.h"
#include "list.h"
#include "package.h"
void dump_pkg_full(pmpkg_t *pkg, int level)
{
const char *bdate, *type, *idate, *reason;
if(pkg == NULL) {
return;
}
bdate = alpm_pkg_get_builddate(pkg);
type = alpm_pkg_get_buildtype(pkg);
idate = alpm_pkg_get_installdate(pkg);
switch((long)alpm_pkg_get_reason(pkg)) {
case PM_PKG_REASON_EXPLICIT:
reason = _("Explicitly installed\n");
break;
case PM_PKG_REASON_DEPEND:
reason = _("Installed as a dependency for another package\n");
break;
default:
reason = _("Unknown\n");
break;
}
printf(_("Name : %s\n"), (char *)alpm_pkg_get_name(pkg));
printf(_("Version : %s\n"), (char *)alpm_pkg_get_version(pkg));
pmlist_display(_("Groups :"), alpm_pkg_get_groups(pkg));
printf(_("Packager : %s\n"), (char *)alpm_pkg_get_packager(pkg));
printf(_("URL : %s\n"), (char *)alpm_pkg_get_url(pkg));
pmlist_display(_("License :"), alpm_pkg_get_licenses(pkg));
printf(_("Architecture : %s\n"), (char *)alpm_pkg_get_arch(pkg));
printf(_("Installed Size : %ld\n"), (long int)alpm_pkg_get_size(pkg));
printf(_("Build Date : %s %s\n"), bdate, strlen(bdate) ? "UTC" : "");
printf(_("Build Type : %s\n"), strlen(type) ? type : _("Unknown"));
TODO
printf(_("Install Date : %s %s\n"), idate, strlen(idate) ? "UTC" : "");
printf(_("Install Script : %s\n"), alpm_pkg_has_scriptlet(pkg) ? _("Yes") : _("No"));
printf(_("Reason : %s\n"), reason);
pmlist_display(_("Provides :"), alpm_pkg_get_provides(pkg));
pmlist_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
pmlist_display(_("Removes :"), alpm_pkg_get_removes(pkg));
TODO
pmlist_display(_("Required By :"), alpm_pkg_get_requiredby(pkg));
pmlist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
printf(_("Description : "));
indentprint(alpm_pkg_get_desc(pkg), 17);
printf("\n");
TODO
if(level > 1) {
dump_pkg_backups(pkg);
}
printf("\n");
}
void dump_pkg_sync(pmpkg_t *pkg, char *treename)
{
char *md5sum, *sha1sum;
if(pkg == NULL) {
return;
}
md5sum = (char *)alpm_pkg_get_md5sum(pkg);
sha1sum = (char *)alpm_pkg_get_sha1sum(pkg);
printf(_("Repository : %s\n"), treename);
printf(_("Name : %s\n"), (char *)alpm_pkg_get_name(pkg));
printf(_("Version : %s\n"), (char *)alpm_pkg_get_version(pkg));
pmlist_display(_("Groups :"), alpm_pkg_get_groups(pkg));
pmlist_display(_("Provides :"), alpm_pkg_get_provides(pkg));
pmlist_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
pmlist_display(_("Removes :"), alpm_pkg_get_removes(pkg));
pmlist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
pmlist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
printf(_("Download Size : %ld\n"), (long)alpm_pkg_get_size(pkg));
printf(_("Installed Size : %ld\n"), (long)alpm_pkg_get_isize(pkg));
printf(_("Description : "));
indentprint(alpm_pkg_get_desc(pkg), 17);
printf("\n");
if (md5sum != NULL && md5sum[0] != '\0') {
printf(_("MD5 Sum : %s"), md5sum);
}
if (sha1sum != NULL && sha1sum[0] != '\0') {
printf(_("SHA1 Sum : %s"), sha1sum);
}
printf("\n");
}
void dump_pkg_backups(pmpkg_t *pkg)
{
pmlist_t *i;
const char *root = alpm_option_get_root();
printf("\nBackup Files :\n");
for(i = alpm_list_first(alpm_pkg_get_backup(pkg)); i; i = alpm_list_next(i)) {
struct stat buf;
char path[PATH_MAX];
char *str = strdup(alpm_list_getdata(i));
char *ptr = index(str, '\t');
if(ptr == NULL) {
FREE(str);
continue;
}
*ptr = '\0';
ptr++;
snprintf(path, PATH_MAX-1, "%s%s", root, str);
if(!stat(path, &buf)) {
char *sum;
char *md5sum = alpm_get_md5sum(path);
char *sha1sum = alpm_get_sha1sum(path);
if(md5sum == NULL || sha1sum == NULL) {
ERR(NL, _("error calculating checksums for %s\n"), path);
FREE(str);
continue;
}
TODO
if (strlen(ptr) == 32) {
sum = md5sum;
} else {
sum = sha1sum;
}
if (strcmp(sum, ptr)) {
printf(_("MODIFIED\t%s\n"), path);
} else {
printf(_("Not Modified\t%s\n"), path);
}
FREE(md5sum);
FREE(sha1sum);
} else {
printf(_("MISSING\t\t%s\n"), path);
}
FREE(str);
}
}
void dump_pkg_files(pmpkg_t *pkg)
{
const char *pkgname;
pmlist_t *i, *pkgfiles;
pkgname = alpm_pkg_get_name(pkg);
pkgfiles = alpm_pkg_get_files(pkg);
for(i = pkgfiles; i; i = alpm_list_next(i)) {
fprintf(stdout, "%s %s\n", (char *)pkgname, (char *)alpm_list_getdata(i));
}
fflush(stdout);
}
void dump_pkg_changelog(char *clfile, const char *pkgname)
{
FILE* fp = NULL;
char line[PATH_MAX+1];
if((fp = fopen(clfile, "r")) == NULL)
{
ERR(NL, _("No changelog available for '%s'.\n"), pkgname);
return;
}
else
{
while(!feof(fp))
{
fgets(line, PATH_MAX, fp);
printf("%s", line);
line[0] = '\0';
}
fclose(fp);
return;
}
}
|