| @@ -1,23 +1,23 @@ | | | @@ -1,23 +1,23 @@ |
1 | /* $NetBSD: main.c,v 1.56 2009/10/07 12:53:26 joerg Exp $ */ | | 1 | /* $NetBSD: main.c,v 1.57 2009/10/08 16:16:12 joerg Exp $ */ |
2 | | | 2 | |
3 | #if HAVE_CONFIG_H | | 3 | #if HAVE_CONFIG_H |
4 | #include "config.h" | | 4 | #include "config.h" |
5 | #endif | | 5 | #endif |
6 | #include <nbcompat.h> | | 6 | #include <nbcompat.h> |
7 | #if HAVE_SYS_CDEFS_H | | 7 | #if HAVE_SYS_CDEFS_H |
8 | #include <sys/cdefs.h> | | 8 | #include <sys/cdefs.h> |
9 | #endif | | 9 | #endif |
10 | __RCSID("$NetBSD: main.c,v 1.56 2009/10/07 12:53:26 joerg Exp $"); | | 10 | __RCSID("$NetBSD: main.c,v 1.57 2009/10/08 16:16:12 joerg Exp $"); |
11 | | | 11 | |
12 | /*- | | 12 | /*- |
13 | * Copyright (c) 1999-2009 The NetBSD Foundation, Inc. | | 13 | * Copyright (c) 1999-2009 The NetBSD Foundation, Inc. |
14 | * All rights reserved. | | 14 | * All rights reserved. |
15 | * | | 15 | * |
16 | * This code is derived from software contributed to The NetBSD Foundation | | 16 | * This code is derived from software contributed to The NetBSD Foundation |
17 | * by Hubert Feyrer <hubert@feyrer.de> and | | 17 | * by Hubert Feyrer <hubert@feyrer.de> and |
18 | * by Joerg Sonnenberger <joerg@NetBSD.org>. | | 18 | * by Joerg Sonnenberger <joerg@NetBSD.org>. |
19 | * | | 19 | * |
20 | * Redistribution and use in source and binary forms, with or without | | 20 | * Redistribution and use in source and binary forms, with or without |
21 | * modification, are permitted provided that the following conditions | | 21 | * modification, are permitted provided that the following conditions |
22 | * are met: | | 22 | * are met: |
23 | * 1. Redistributions of source code must retain the above copyright | | 23 | * 1. Redistributions of source code must retain the above copyright |
| @@ -243,27 +243,27 @@ rebuild(void) | | | @@ -243,27 +243,27 @@ rebuild(void) |
243 | count.files = 0; | | 243 | count.files = 0; |
244 | count.directories = 0; | | 244 | count.directories = 0; |
245 | count.packages = 0; | | 245 | count.packages = 0; |
246 | | | 246 | |
247 | (void) _pkgdb_getPKGDB_FILE(cachename, sizeof(cachename)); | | 247 | (void) _pkgdb_getPKGDB_FILE(cachename, sizeof(cachename)); |
248 | if (unlink(cachename) != 0 && errno != ENOENT) | | 248 | if (unlink(cachename) != 0 && errno != ENOENT) |
249 | err(EXIT_FAILURE, "unlink %s", cachename); | | 249 | err(EXIT_FAILURE, "unlink %s", cachename); |
250 | | | 250 | |
251 | setbuf(stdout, NULL); | | 251 | setbuf(stdout, NULL); |
252 | | | 252 | |
253 | iterate_pkg_db(add_pkg, &count); | | 253 | iterate_pkg_db(add_pkg, &count); |
254 | | | 254 | |
255 | printf("\n"); | | 255 | printf("\n"); |
256 | printf("Stored %zu file%s and %zu explizit director%s" | | 256 | printf("Stored %zu file%s and %zu explicit director%s" |
257 | " from %zu package%s in %s.\n", | | 257 | " from %zu package%s in %s.\n", |
258 | count.files, count.files == 1 ? "" : "s", | | 258 | count.files, count.files == 1 ? "" : "s", |
259 | count.directories, count.directories == 1 ? "y" : "ies", | | 259 | count.directories, count.directories == 1 ? "y" : "ies", |
260 | count.packages, count.packages == 1 ? "" : "s", | | 260 | count.packages, count.packages == 1 ? "" : "s", |
261 | cachename); | | 261 | cachename); |
262 | } | | 262 | } |
263 | | | 263 | |
264 | static int | | 264 | static int |
265 | lspattern(const char *pkg, void *vp) | | 265 | lspattern(const char *pkg, void *vp) |
266 | { | | 266 | { |
267 | const char *dir = vp; | | 267 | const char *dir = vp; |
268 | printf("%s/%s\n", dir, pkg); | | 268 | printf("%s/%s\n", dir, pkg); |
269 | return 0; | | 269 | return 0; |
| @@ -507,28 +507,34 @@ main(int argc, char *argv[]) | | | @@ -507,28 +507,34 @@ main(int argc, char *argv[]) |
507 | else | | 507 | else |
508 | printf("%s/%s\n", dir, p); | | 508 | printf("%s/%s\n", dir, p); |
509 | free(p); | | 509 | free(p); |
510 | } | | 510 | } |
511 | | | 511 | |
512 | argv++; | | 512 | argv++; |
513 | } | | 513 | } |
514 | } else if (strcasecmp(argv[0], "list") == 0 || | | 514 | } else if (strcasecmp(argv[0], "list") == 0 || |
515 | strcasecmp(argv[0], "dump") == 0) { | | 515 | strcasecmp(argv[0], "dump") == 0) { |
516 | | | 516 | |
517 | pkgdb_dump(); | | 517 | pkgdb_dump(); |
518 | | | 518 | |
519 | } else if (strcasecmp(argv[0], "add") == 0) { | | 519 | } else if (strcasecmp(argv[0], "add") == 0) { |
| | | 520 | struct pkgdb_count count; |
| | | 521 | |
| | | 522 | count.files = 0; |
| | | 523 | count.directories = 0; |
| | | 524 | count.packages = 0; |
| | | 525 | |
520 | for (++argv; *argv != NULL; ++argv) | | 526 | for (++argv; *argv != NULL; ++argv) |
521 | add_pkg(*argv, NULL); | | 527 | add_pkg(*argv, &count); |
522 | } else if (strcasecmp(argv[0], "delete") == 0) { | | 528 | } else if (strcasecmp(argv[0], "delete") == 0) { |
523 | argv++; /* "delete" */ | | 529 | argv++; /* "delete" */ |
524 | while (*argv != NULL) { | | 530 | while (*argv != NULL) { |
525 | delete1pkg(*argv); | | 531 | delete1pkg(*argv); |
526 | argv++; | | 532 | argv++; |
527 | } | | 533 | } |
528 | } else if (strcasecmp(argv[0], "set") == 0) { | | 534 | } else if (strcasecmp(argv[0], "set") == 0) { |
529 | argv++; /* "set" */ | | 535 | argv++; /* "set" */ |
530 | set_unset_variable(argv, FALSE); | | 536 | set_unset_variable(argv, FALSE); |
531 | } else if (strcasecmp(argv[0], "unset") == 0) { | | 537 | } else if (strcasecmp(argv[0], "unset") == 0) { |
532 | argv++; /* "unset" */ | | 538 | argv++; /* "unset" */ |
533 | set_unset_variable(argv, TRUE); | | 539 | set_unset_variable(argv, TRUE); |
534 | } else if (strcasecmp(argv[0], "config-var") == 0) { | | 540 | } else if (strcasecmp(argv[0], "config-var") == 0) { |