Lines 21-31
Link Here
|
21 |
# include <sys/time.h> |
21 |
# include <sys/time.h> |
22 |
#endif |
22 |
#endif |
23 |
|
23 |
|
24 |
#define QLOP_DEFAULT_LOGFILE "/var/log/emerge.log" |
24 |
#define QLOP_DEFAULT_LOGFILE "/var/log/paludis.log" |
25 |
|
25 |
|
26 |
|
26 |
|
27 |
|
27 |
|
28 |
#define QLOP_FLAGS "gtluscf:F:H" COMMON_FLAGS |
28 |
#define QLOP_FLAGS "gtluso:cf:F:H" COMMON_FLAGS |
29 |
static struct option const qlop_long_opts[] = { |
29 |
static struct option const qlop_long_opts[] = { |
30 |
{"gauge", no_argument, NULL, 'g'}, |
30 |
{"gauge", no_argument, NULL, 'g'}, |
31 |
{"time", no_argument, NULL, 't'}, |
31 |
{"time", no_argument, NULL, 't'}, |
Lines 33-38
static struct option const qlop_long_opt
Link Here
|
33 |
{"list", no_argument, NULL, 'l'}, |
33 |
{"list", no_argument, NULL, 'l'}, |
34 |
{"unlist", no_argument, NULL, 'u'}, |
34 |
{"unlist", no_argument, NULL, 'u'}, |
35 |
{"sync", no_argument, NULL, 's'}, |
35 |
{"sync", no_argument, NULL, 's'}, |
|
|
36 |
{"overlay", a_argument, NULL, 'o'}, |
36 |
{"current", no_argument, NULL, 'c'}, |
37 |
{"current", no_argument, NULL, 'c'}, |
37 |
{"logfile", a_argument, NULL, 'f'}, |
38 |
{"logfile", a_argument, NULL, 'f'}, |
38 |
COMMON_LONG_OPTS |
39 |
COMMON_LONG_OPTS |
Lines 44-49
static const char *qlop_opts_help[] = {
Link Here
|
44 |
"Show merge history", |
45 |
"Show merge history", |
45 |
"Show unmerge history", |
46 |
"Show unmerge history", |
46 |
"Show sync history", |
47 |
"Show sync history", |
|
|
48 |
"Do only consider the <arg> repository", |
47 |
"Show current emerging packages", |
49 |
"Show current emerging packages", |
48 |
"Read emerge logfile instead of " QLOP_DEFAULT_LOGFILE, |
50 |
"Read emerge logfile instead of " QLOP_DEFAULT_LOGFILE, |
49 |
COMMON_OPTS_HELP |
51 |
COMMON_OPTS_HELP |
Lines 79-108
static const char *chop_ctime(time_t t)
Link Here
|
79 |
return ctime_out; |
81 |
return ctime_out; |
80 |
} |
82 |
} |
81 |
|
83 |
|
82 |
unsigned long show_merge_times(char *package, const char *logfile, int average, char human_readable); |
84 |
unsigned long show_merge_times(char *package, const short repo, const char repo_search[], const char *logfile, int average, char human_readable); |
83 |
unsigned long show_merge_times(char *package, const char *logfile, int average, char human_readable) |
85 |
unsigned long show_merge_times(char *package, const short repo, const char repo_search[], const char *logfile, int average, char human_readable) |
84 |
{ |
86 |
{ |
85 |
FILE *fp; |
87 |
FILE *fp; |
86 |
char cat[126], buf[2][BUFSIZ]; |
88 |
char catPN[BUFSIZ], buf[2][BUFSIZ], matched; |
87 |
char *pkg, *p; |
89 |
char *p, *q; |
88 |
unsigned long count, merge_time; |
90 |
unsigned long count, merge_time; |
89 |
time_t t[2]; |
91 |
time_t t[2]; |
90 |
depend_atom *atom; |
92 |
depend_atom *atom,*search; |
|
|
93 |
int l; |
94 |
long pos; |
91 |
|
95 |
|
92 |
t[0] = t[1] = 0UL; |
96 |
t[0] = t[1] = 0UL; |
93 |
count = merge_time = 0; |
97 |
count = merge_time = 0; |
94 |
cat[0] = 0; |
98 |
matched = 0; |
|
|
99 |
pos = 0; |
95 |
|
100 |
|
96 |
if ((p = strchr(package, '/')) != NULL) { |
101 |
if ((search = atom_explode(package)) == NULL ) |
97 |
pkg = p + 1; |
102 |
err("%s is not a valid atom", package); |
98 |
strncpy(cat, package, sizeof(cat)); |
103 |
if (!search->CATEGORY && !search->PN && !search->OVERLAY) |
99 |
if ((p = strchr(cat, '/')) != NULL) |
104 |
err("You need to specify at least an overlay, a category, or a package name"); |
100 |
*p = 0; |
|
|
101 |
} else { |
102 |
pkg = package; |
103 |
} |
104 |
|
105 |
|
105 |
DBG("Searching for %s in %s\n", pkg, logfile); |
106 |
DBG("Searching for %s in %s\n", package, logfile); |
106 |
|
107 |
|
107 |
if ((fp = fopen(logfile, "r")) == NULL) { |
108 |
if ((fp = fopen(logfile, "r")) == NULL) { |
108 |
warnp("Could not open logfile '%s'", logfile); |
109 |
warnp("Could not open logfile '%s'", logfile); |
Lines 110-116
unsigned long show_merge_times(char *pac
Link Here
|
110 |
} |
111 |
} |
111 |
|
112 |
|
112 |
while ((fgets(buf[0], sizeof(buf[0]), fp)) != NULL) { |
113 |
while ((fgets(buf[0], sizeof(buf[0]), fp)) != NULL) { |
113 |
if (strstr(buf[0], pkg) == NULL) |
114 |
if (matched) { |
|
|
115 |
matched = 0; |
116 |
continue; |
117 |
} |
118 |
/* len( time:{starting,finished} install of package ) = 41 */ |
119 |
if (search->CATEGORY && !strstr(&buf[0][40], search->CATEGORY)) |
120 |
continue; |
121 |
|
122 |
if (search->PN && !strstr(&buf[0][40], search->PN)) |
123 |
continue; |
124 |
|
125 |
if (search->OVERLAY && !strstr(&buf[0][40], search->OVERLAY)) |
114 |
continue; |
126 |
continue; |
115 |
|
127 |
|
116 |
if ((p = strchr(buf[0], '\n')) != NULL) |
128 |
if ((p = strchr(buf[0], '\n')) != NULL) |
Lines 121-200
unsigned long show_merge_times(char *pac
Link Here
|
121 |
t[0] = atol(buf[0]); |
133 |
t[0] = atol(buf[0]); |
122 |
strcpy(buf[1], p + 1); |
134 |
strcpy(buf[1], p + 1); |
123 |
rmspace(buf[1]); |
135 |
rmspace(buf[1]); |
124 |
if ((strncmp(buf[1], ">>> emerge (", 12)) == 0) { |
136 |
if ((strncmp(buf[1], "starting install of package", 26)) == 0) { |
125 |
char matched = 0; |
137 |
p = &buf[1][28]; |
126 |
if ((p = strchr(buf[1], ')')) == NULL) |
138 |
if (repo && !strstr(p, repo_search)) |
127 |
continue; |
139 |
continue; |
128 |
*p = 0; |
140 |
|
129 |
strcpy(buf[0], p + 1); |
141 |
if ((q = strchr(p, ' ')) == NULL) |
130 |
rmspace(buf[0]); |
|
|
131 |
if ((p = strchr(buf[0], ' ')) == NULL) |
132 |
continue; |
142 |
continue; |
133 |
*p = 0; |
143 |
*q = 0; |
|
|
144 |
|
145 |
strcpy(buf[0], p); |
146 |
rmspace(buf[0]); |
134 |
if ((atom = atom_explode(buf[0])) == NULL) |
147 |
if ((atom = atom_explode(buf[0])) == NULL) |
135 |
continue; |
148 |
continue; |
136 |
|
149 |
|
137 |
if (*cat) { |
150 |
if (search->CATEGORY && strcmp(atom->CATEGORY, search->CATEGORY)) { |
138 |
if ((strcmp(cat, atom->CATEGORY) == 0) && (strcmp(pkg, atom->PN) == 0)) |
151 |
atom_implode(atom); |
139 |
matched = 1; |
152 |
continue; |
140 |
} else if (strcmp(pkg, atom->PN) == 0) |
153 |
} |
141 |
matched = 1; |
154 |
|
|
|
155 |
if (search->PN && *search->PN && strcmp(atom->PN, search->PN)) { |
156 |
atom_implode(atom); |
157 |
continue; |
158 |
} |
159 |
|
160 |
if (search->PV && strcmp(atom->PV, search->PV)) { |
161 |
atom_implode(atom); |
162 |
continue; |
163 |
} |
164 |
|
165 |
if (search->PR_int && atom->PR_int!=search->PR_int) { |
166 |
atom_implode(atom); |
167 |
continue; |
168 |
} |
169 |
|
170 |
if (search->OVERLAY && strcmp(atom->OVERLAY, search->OVERLAY)) { |
171 |
atom_implode(atom); |
172 |
continue; |
173 |
} |
174 |
pos = ftell(fp); |
175 |
matched = 1; |
142 |
|
176 |
|
143 |
if (matched) { |
177 |
if (matched) { |
144 |
while ((fgets(buf[0], sizeof(buf[0]), fp)) != NULL) { |
178 |
/* In case of simultaneous install, we search the corresponding */ |
|
|
179 |
/* "finished install of package" pkg up to 20 lines after the 'starting line' */ |
180 |
l=0; |
181 |
snprintf(catPN, sizeof(catPN), "%s/%s-%s::%s", atom->CATEGORY, atom->PN, (atom->PR_int ? atom->PVR : atom->PV), atom->OVERLAY); |
182 |
while ((fgets(buf[0], sizeof(buf[0]), fp)) != NULL && l++ < 20) { |
183 |
if ((p = strchr(buf[0],':')) == NULL) |
184 |
continue; |
185 |
p = p+2; |
186 |
|
187 |
/* Stop the search in case the package is already being reinstalled even in a different version/revision */ |
188 |
if (!strncmp(p, "starting", 8) && strcmp(p+28, catPN)) |
189 |
break; |
190 |
|
191 |
if (strncmp(p, "finished install of package", 26) != 0) |
192 |
continue; |
193 |
if (!strcmp(p+28, catPN)) |
194 |
continue; |
195 |
|
145 |
if ((p = strchr(buf[0], '\n')) != NULL) |
196 |
if ((p = strchr(buf[0], '\n')) != NULL) |
146 |
*p = 0; |
197 |
*p = 0; |
147 |
if ((p = strchr(buf[0], ':')) == NULL) |
198 |
if ((p = strchr(buf[0], ':')) == NULL) |
148 |
continue; |
199 |
*p = 0; |
149 |
*p = 0; |
|
|
150 |
t[1] = atol(buf[0]); |
200 |
t[1] = atol(buf[0]); |
151 |
strcpy(buf[1], p + 1); |
201 |
strcpy(buf[1], p + 1); |
152 |
rmspace(buf[1]); |
202 |
rmspace(buf[1]); |
153 |
if (*buf[1] == '*') |
203 |
|
154 |
break; |
204 |
if (!average) { |
155 |
if ((strncmp(buf[1], "::: completed emerge (", 22)) == 0) { |
205 |
strcpy(buf[1], ""); |
156 |
if (!average) { |
206 |
if (verbose) |
157 |
strcpy(buf[1], ""); |
207 |
snprintf(buf[1], sizeof(buf[1]), "-%s%s::%s ", (atom->PR_int ? atom->PVR : atom->PV), YELLOW, atom->OVERLAY); |
158 |
if (verbose) { |
208 |
|
159 |
if (atom->PR_int) |
209 |
printf("%s%s/%s%s%s%s: %s: ", GREEN, atom->CATEGORY, BLUE, atom->PN, buf[1], NORM, chop_ctime(t[0])); |
160 |
snprintf(buf[1], sizeof(buf[1]), "-%s-r%i", atom->PV, atom->PR_int); |
210 |
if (human_readable) |
161 |
else |
211 |
print_seconds_for_earthlings(t[1] - t[0]); |
162 |
snprintf(buf[1], sizeof(buf[1]), "-%s", atom->PV); |
212 |
else |
163 |
} |
213 |
printf("%s%lu%s seconds", GREEN, (t[1] - t[0]), NORM); |
164 |
printf("%s%s%s%s: %s: ", BLUE, atom->PN, buf[1], NORM, chop_ctime(t[0])); |
214 |
puts(""); |
165 |
if (human_readable) |
|
|
166 |
print_seconds_for_earthlings(t[1] - t[0]); |
167 |
else |
168 |
printf("%s%lu%s seconds", GREEN, (t[1] - t[0]), NORM); |
169 |
puts(""); |
170 |
} |
171 |
merge_time += (t[1] - t[0]); |
172 |
count++; |
173 |
break; |
174 |
} |
215 |
} |
|
|
216 |
merge_time += (t[1] - t[0]); |
217 |
count++; |
218 |
break; |
219 |
|
175 |
} |
220 |
} |
176 |
} |
221 |
} |
177 |
atom_implode(atom); |
222 |
atom_implode(atom); |
|
|
223 |
/* time to go back where we were */ |
224 |
fseek(fp, pos, SEEK_SET); |
178 |
} |
225 |
} |
179 |
} |
226 |
} |
180 |
fclose(fp); |
227 |
fclose(fp); |
181 |
if (count == 0) |
228 |
if (count == 0) |
182 |
return 0; |
229 |
return 0; |
183 |
if (average == 1) { |
230 |
if (average == 1) { |
184 |
printf("%s%s%s: ", BLUE, pkg, NORM); |
231 |
printf("%s%s%s%s%s%s%s%s%s%s%s : ", GREEN, (search->CATEGORY? search->CATEGORY : ""), (search->CATEGORY ? "/": ""), |
|
|
232 |
BLUE, search->PN, (search->PV ? "-" : ""), (search->PV ? (search->PR_int ? search->PVR : search->PV) : ""), |
233 |
YELLOW, (search->OVERLAY ? "::" : ""), (search->OVERLAY ? search->OVERLAY : ""), NORM); |
185 |
if (human_readable) |
234 |
if (human_readable) |
186 |
print_seconds_for_earthlings(merge_time / count); |
235 |
print_seconds_for_earthlings(merge_time / count); |
187 |
else |
236 |
else |
188 |
printf("%s%lu%s seconds average", GREEN, merge_time / count, NORM); |
237 |
printf("%s%lu%s seconds", GREEN, merge_time / count, NORM); |
189 |
printf(" for %s%lu%s merges\n", GREEN, count, NORM); |
238 |
printf(" average for %s%lu%s merges%s", GREEN, count, NORM, (verbose ? ", for a total time of " : "")); |
|
|
239 |
|
240 |
if (verbose) { |
241 |
if (human_readable) |
242 |
print_seconds_for_earthlings(merge_time); |
243 |
else |
244 |
printf("%s%lu%s seconds", GREEN, merge_time, NORM); |
245 |
} |
246 |
fputc('\n', stdout); |
190 |
} else { |
247 |
} else { |
191 |
printf("%s%s%s: %s%lu%s times\n", BLUE, pkg, NORM, GREEN, count, NORM); |
248 |
printf("%s%s%s%s%s%s%s%s%s%s%s : %s%lu%s times%s", GREEN, (search->CATEGORY ? search->CATEGORY : ""), (search->CATEGORY ? "/": ""), |
|
|
249 |
BLUE, (search->PN ? search->PN : ""), (search->PV ? "-" : ""), (search->PV ? (search->PR_int ? search->PVR : search->PV) : ""), |
250 |
YELLOW, (search->OVERLAY ? "::" : ""), (search->OVERLAY ? search->OVERLAY : ""), |
251 |
NORM, GREEN, count, NORM, |
252 |
(verbose ? ", for a total time of " : "")); |
253 |
if (verbose) { |
254 |
if (human_readable) |
255 |
print_seconds_for_earthlings(merge_time); |
256 |
else |
257 |
printf("%s%lu%s seconds", GREEN, merge_time, NORM); |
258 |
} |
259 |
fputc('\n', stdout); |
192 |
} |
260 |
} |
|
|
261 |
atom_implode(search); |
193 |
return 0; |
262 |
return 0; |
194 |
} |
263 |
} |
195 |
|
264 |
|
196 |
void show_emerge_history(char listflag, int argc, char **argv, const char *logfile); |
265 |
void show_emerge_history(char listflag, const short repo, const char repo_search[], int argc, char **argv, const char *logfile); |
197 |
void show_emerge_history(char listflag, int argc, char **argv, const char *logfile) |
266 |
void show_emerge_history(char listflag, const short repo, const char repo_search[], int argc, char **argv, const char *logfile) |
198 |
{ |
267 |
{ |
199 |
FILE *fp; |
268 |
FILE *fp; |
200 |
char buf[BUFSIZ], merged; |
269 |
char buf[BUFSIZ], merged; |
Lines 222-244
void show_emerge_history(char listflag,
Link Here
|
222 |
if ((p = strchr(buf, ':')) == NULL) |
291 |
if ((p = strchr(buf, ':')) == NULL) |
223 |
continue; |
292 |
continue; |
224 |
*p = 0; |
293 |
*p = 0; |
225 |
q = p + 3; |
294 |
q = p + 2; |
226 |
|
295 |
|
227 |
t = (time_t) atol(buf); |
296 |
t = (time_t) atol(buf); |
228 |
|
297 |
|
229 |
if ((listflag & QLOP_LIST) && !strncmp(q, "::: completed emerge (", 22)) { |
298 |
if ((listflag & QLOP_LIST) && !strncmp(q, "finished install of package", 25)) { |
230 |
merged = 1; |
299 |
merged = 1; |
231 |
if ((p = strchr(q, ')')) == NULL) |
300 |
p = strstr(q, "package"); |
232 |
continue; |
301 |
q = p + 1; |
233 |
q = p + 2; |
|
|
234 |
if ((p = strchr(q, ' ')) == NULL) |
302 |
if ((p = strchr(q, ' ')) == NULL) |
235 |
continue; |
303 |
continue; |
236 |
*p = 0; |
304 |
q = p + 1; |
237 |
} else if ((listflag & QLOP_UNLIST) && !strncmp(q, ">>> unmerge success: ", 21)) { |
305 |
if (repo) { |
|
|
306 |
if ((p = strstr(q, "::")) && strncmp(p+2, repo_search, sizeof(repo_search))) |
307 |
continue; |
308 |
} |
309 |
} else if ((listflag & QLOP_UNLIST) && !strncmp(q, "finished uninstall of package", 29)) { |
238 |
merged = 0; |
310 |
merged = 0; |
239 |
if ((p = strchr(q, ':')) == NULL) |
311 |
p = strstr(q, "package"); |
|
|
312 |
q = p + 1; |
313 |
if ((p = strchr(q, ' ')) == NULL) |
240 |
continue; |
314 |
continue; |
241 |
q = p + 2; |
315 |
q = p + 1; |
|
|
316 |
if ((p = strchr(p, ':')) != NULL) |
317 |
*p = 0; |
242 |
} |
318 |
} |
243 |
else |
319 |
else |
244 |
continue; |
320 |
continue; |
Lines 258-265
void show_emerge_history(char listflag,
Link Here
|
258 |
fclose(fp); |
334 |
fclose(fp); |
259 |
} |
335 |
} |
260 |
|
336 |
|
261 |
void show_sync_history(const char *logfile); |
337 |
void show_sync_history(const char *logfile, const short repo, char repo_search[]); |
262 |
void show_sync_history(const char *logfile) |
338 |
void show_sync_history(const char *logfile, const short repo, char repo_search[]) |
263 |
{ |
339 |
{ |
264 |
FILE *fp; |
340 |
FILE *fp; |
265 |
char buf[BUFSIZ]; |
341 |
char buf[BUFSIZ]; |
Lines 274-280
void show_sync_history(const char *logfi
Link Here
|
274 |
while ((fgets(buf, sizeof(buf), fp)) != NULL) { |
350 |
while ((fgets(buf, sizeof(buf), fp)) != NULL) { |
275 |
if (strlen(buf) < 35) |
351 |
if (strlen(buf) < 35) |
276 |
continue; |
352 |
continue; |
277 |
if (strncmp(buf+12, "=== Sync completed with", 23) != 0) |
353 |
if (strncmp(buf+12, "finished sync", 13) != 0) |
|
|
354 |
continue; |
355 |
|
356 |
if (repo && strstr(buf, repo_search) == NULL) |
278 |
continue; |
357 |
continue; |
279 |
|
358 |
|
280 |
if ((p = strchr(buf, '\n')) != NULL) |
359 |
if ((p = strchr(buf, '\n')) != NULL) |
Lines 282-294
void show_sync_history(const char *logfi
Link Here
|
282 |
if ((p = strchr(buf, ':')) == NULL) |
361 |
if ((p = strchr(buf, ':')) == NULL) |
283 |
continue; |
362 |
continue; |
284 |
*p = 0; |
363 |
*p = 0; |
285 |
q = p+2; |
364 |
q = p+1; |
286 |
|
365 |
|
287 |
t = (time_t)atol(buf); |
366 |
t = (time_t)atol(buf); |
288 |
|
367 |
|
289 |
if ((p = strstr(q, "with")) == NULL) |
368 |
if ((p = strstr(q, "repository")) == NULL) |
290 |
continue; |
369 |
continue; |
291 |
q = p + 5; |
370 |
q = p + 11; |
292 |
|
371 |
|
293 |
printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, q, NORM); |
372 |
printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, q, NORM); |
294 |
} |
373 |
} |
Lines 304-313
void show_current_emerge(void)
Link Here
|
304 |
pid_t pid; |
383 |
pid_t pid; |
305 |
char buf[BUFSIZE], bufstat[300]; |
384 |
char buf[BUFSIZE], bufstat[300]; |
306 |
char path[50]; |
385 |
char path[50]; |
307 |
char *p, *q; |
386 |
char *p, *q, *cat, *pnv; |
308 |
unsigned long long start_time = 0; |
387 |
unsigned long long start_time = 0; |
309 |
double uptime_secs; |
388 |
double uptime_secs; |
310 |
time_t start_date; |
389 |
time_t start_date; |
|
|
390 |
overlay_t *overlay_tmp; |
311 |
|
391 |
|
312 |
if ((proc = opendir("/proc")) == NULL) { |
392 |
if ((proc = opendir("/proc")) == NULL) { |
313 |
warnp("Could not open /proc"); |
393 |
warnp("Could not open /proc"); |
Lines 319-333
void show_current_emerge(void)
Link Here
|
319 |
if ((pid = (pid_t)atol(de->d_name)) == 0) |
399 |
if ((pid = (pid_t)atol(de->d_name)) == 0) |
320 |
continue; |
400 |
continue; |
321 |
|
401 |
|
322 |
/* portage renames the cmdline so the package name is first */ |
|
|
323 |
snprintf(path, sizeof(path), "/proc/%i/cmdline", pid); |
402 |
snprintf(path, sizeof(path), "/proc/%i/cmdline", pid); |
324 |
if (!eat_file(path, buf, sizeof(buf))) |
403 |
if (!eat_file(path, buf, sizeof(buf))) |
325 |
continue; |
404 |
continue; |
326 |
|
405 |
|
327 |
if (buf[0] == '[' && (p = strchr(buf, ']')) != NULL && strstr(buf, "sandbox") != NULL) { |
406 |
if (! strncmp(buf, "sandbox", 7)) { |
328 |
*p = '\0'; |
407 |
/* 0123456789012345678 */ |
329 |
p = buf+1; |
408 |
if (!(p = strstr(&buf[8],"paludis/ebuild.bash"))) |
330 |
q = p + strlen(p) + 1; |
409 |
continue; |
|
|
410 |
|
411 |
q = p + 20; |
412 |
if (*q != '/') |
413 |
continue; |
414 |
|
415 |
/* |
416 |
* ex: /var/paludis/repositories/local/category/package_name/package_name_version.ebuild |
417 |
* expected: |
418 |
* q cat 0 pnv |
419 |
*/ |
420 |
if (q == (pnv=strrchr(q, '/'))) |
421 |
continue; |
422 |
*pnv = 0; |
423 |
pnv++; |
424 |
if (q == (cat=strrchr(q, '/'))) |
425 |
continue; |
426 |
*cat = 0; |
427 |
if (q == (cat=strrchr(q, '/'))) |
428 |
continue; |
429 |
*cat = 0; |
430 |
cat++; |
431 |
overlay_tmp=first_overlay; |
432 |
do { |
433 |
if (!strcmp(q, overlay_tmp->path)) |
434 |
break; |
435 |
} while ((overlay_tmp=overlay_tmp->next)); |
436 |
|
437 |
if (NULL == overlay_tmp) |
438 |
continue; |
331 |
|
439 |
|
332 |
/* open the stat file to figure out how long we have been running */ |
440 |
/* open the stat file to figure out how long we have been running */ |
333 |
snprintf(path, sizeof(path), "/proc/%i/stat", pid); |
441 |
snprintf(path, sizeof(path), "/proc/%i/stat", pid); |
Lines 356-365
void show_current_emerge(void)
Link Here
|
356 |
/* figure out when this thing started and then show it */ |
464 |
/* figure out when this thing started and then show it */ |
357 |
start_date = time(0) - (uptime_secs - (start_time / HZ)); |
465 |
start_date = time(0) - (uptime_secs - (start_time / HZ)); |
358 |
printf( |
466 |
printf( |
359 |
" %s*%s %s%s%s\n" |
467 |
" %s*%s %s::%s%s%s/%s%s\n" |
360 |
" started: %s%s%s\n" |
468 |
" started: %s%s%s\n" |
361 |
" elapsed: ", /*%s%llu%s seconds\n",*/ |
469 |
" elapsed: ", /*%s%llu%s seconds\n",*/ |
362 |
BOLD, NORM, BLUE, p, NORM, |
470 |
BOLD, YELLOW, overlay_tmp->name, NORM, BLUE, cat, pnv, NORM, |
363 |
GREEN, chop_ctime(start_date), NORM); |
471 |
GREEN, chop_ctime(start_date), NORM); |
364 |
print_seconds_for_earthlings(uptime_secs - (start_time / HZ)); |
472 |
print_seconds_for_earthlings(uptime_secs - (start_time / HZ)); |
365 |
puts(NORM); |
473 |
puts(NORM); |
Lines 380-385
void show_current_emerge(void)
Link Here
|
380 |
char *p, *q; |
488 |
char *p, *q; |
381 |
time_t start_date = 0; |
489 |
time_t start_date = 0; |
382 |
|
490 |
|
|
|
491 |
/* this would need to be written for paludis, but I don't really know *BSD */ |
492 |
warn("You need to adapt the show_current_emerge(void) function for __FreeBSD__\n" |
493 |
"this may be trivial, just do as in the __linux__ one, but as I can't test it, I didn't make it"); |
494 |
|
383 |
if (! (kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY, "kvm_open"))) { |
495 |
if (! (kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY, "kvm_open"))) { |
384 |
warnp("Could not open kvm: %s", kvm_geterr(kd)); |
496 |
warnp("Could not open kvm: %s", kvm_geterr(kd)); |
385 |
return; |
497 |
return; |
Lines 433-444
int qlop_main(int argc, char **argv)
Link Here
|
433 |
int i, average = 1; |
545 |
int i, average = 1; |
434 |
char do_time, do_list, do_unlist, do_sync, do_current, do_human_readable = 0; |
546 |
char do_time, do_list, do_unlist, do_sync, do_current, do_human_readable = 0; |
435 |
char *opt_logfile; |
547 |
char *opt_logfile; |
|
|
548 |
short repo; |
549 |
char repo_search[64]; |
436 |
const char *logfile = QLOP_DEFAULT_LOGFILE; |
550 |
const char *logfile = QLOP_DEFAULT_LOGFILE; |
|
|
551 |
overlay_t *overlay_tmp; |
437 |
|
552 |
|
438 |
DBG("argc=%d argv[0]=%s argv[1]=%s", |
553 |
DBG("argc=%d argv[0]=%s argv[1]=%s", |
439 |
argc, argv[0], argc > 1 ? argv[1] : "NULL?"); |
554 |
argc, argv[0], argc > 1 ? argv[1] : "NULL?"); |
440 |
|
555 |
|
441 |
opt_logfile = NULL; |
556 |
opt_logfile = NULL; |
|
|
557 |
repo = 0; |
558 |
repo_search[0] = 0; |
442 |
do_time = do_list = do_unlist = do_sync = do_current = 0; |
559 |
do_time = do_list = do_unlist = do_sync = do_current = 0; |
443 |
|
560 |
|
444 |
while ((i = GETOPT_LONG(QLOP, qlop, "")) != -1) { |
561 |
while ((i = GETOPT_LONG(QLOP, qlop, "")) != -1) { |
Lines 448-454
int qlop_main(int argc, char **argv)
Link Here
|
448 |
case 't': do_time = 1; break; |
565 |
case 't': do_time = 1; break; |
449 |
case 'l': do_list = 1; break; |
566 |
case 'l': do_list = 1; break; |
450 |
case 'u': do_unlist = 1; break; |
567 |
case 'u': do_unlist = 1; break; |
451 |
case 's': do_sync = 1; break; |
568 |
case 's': |
|
|
569 |
if (do_sync) err("Only use -s or -S once"); |
570 |
do_sync = 1; |
571 |
break; |
572 |
case 'o': |
573 |
repo = 1; |
574 |
strncpy(repo_search, optarg, sizeof(repo_search)); |
575 |
break; |
452 |
case 'c': do_current = 1; break; |
576 |
case 'c': do_current = 1; break; |
453 |
case 'g': do_time = 1; average = 0; break; |
577 |
case 'g': do_time = 1; average = 0; break; |
454 |
case 'H': do_human_readable = 1; break; |
578 |
case 'H': do_human_readable = 1; break; |
Lines 458-463
int qlop_main(int argc, char **argv)
Link Here
|
458 |
break; |
582 |
break; |
459 |
} |
583 |
} |
460 |
} |
584 |
} |
|
|
585 |
if (repo) { |
586 |
overlay_tmp = first_overlay; |
587 |
do { |
588 |
if (!strncmp(overlay_tmp->name, repo_search, sizeof(overlay_tmp->name))) |
589 |
break; |
590 |
} while ((overlay_tmp=overlay_tmp->next)); |
591 |
if (NULL == overlay_tmp) |
592 |
err("%s : Unknown overlay, try 'q --ls-overlays'", repo_search); |
593 |
} |
594 |
|
461 |
if (!do_list && !do_unlist && !do_time && !do_sync && !do_current) |
595 |
if (!do_list && !do_unlist && !do_time && !do_sync && !do_current) |
462 |
qlop_usage(EXIT_FAILURE); |
596 |
qlop_usage(EXIT_FAILURE); |
463 |
if (opt_logfile != NULL) |
597 |
if (opt_logfile != NULL) |
Lines 467-485
int qlop_main(int argc, char **argv)
Link Here
|
467 |
argv += optind; |
601 |
argv += optind; |
468 |
|
602 |
|
469 |
if (do_list && do_unlist) |
603 |
if (do_list && do_unlist) |
470 |
show_emerge_history(QLOP_LIST | QLOP_UNLIST, argc, argv, logfile); |
604 |
show_emerge_history(QLOP_LIST | QLOP_UNLIST, repo, repo_search,argc, argv, logfile); |
471 |
else if (do_list) |
605 |
else if (do_list) |
472 |
show_emerge_history(QLOP_LIST, argc, argv, logfile); |
606 |
show_emerge_history(QLOP_LIST, repo, repo_search, argc, argv, logfile); |
473 |
else if (do_unlist) |
607 |
else if (do_unlist) |
474 |
show_emerge_history(QLOP_UNLIST, argc, argv, logfile); |
608 |
show_emerge_history(QLOP_UNLIST, repo, repo_search, argc, argv, logfile); |
475 |
if (do_current) |
609 |
if (do_current) |
476 |
show_current_emerge(); |
610 |
show_current_emerge(); |
477 |
if (do_sync) |
611 |
if (do_sync) |
478 |
show_sync_history(logfile); |
612 |
show_sync_history(logfile, repo, repo_search); |
479 |
|
613 |
|
480 |
if (do_time) { |
614 |
if (do_time) { |
481 |
for (i = 0; i < argc; ++i) |
615 |
for (i = 0; i < argc; ++i) |
482 |
show_merge_times(argv[i], logfile, average, do_human_readable); |
616 |
show_merge_times(argv[i], repo, repo_search, logfile, average, do_human_readable); |
483 |
} |
617 |
} |
484 |
|
618 |
|
485 |
if (opt_logfile) free(opt_logfile); |
619 |
if (opt_logfile) free(opt_logfile); |
Lines 490-492
int qlop_main(int argc, char **argv)
Link Here
|
490 |
#else |
624 |
#else |
491 |
DEFINE_APPLET_STUB(qlop) |
625 |
DEFINE_APPLET_STUB(qlop) |
492 |
#endif |
626 |
#endif |
|
|
627 |
/* vim: set noet sts=8 sw=8 : */ |
628 |
|