aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2001-04-16 10:26:46 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2001-04-16 10:26:46 +0000
commitae1c704c44573c710ff196fa9c8bcaebbfe34966 (patch)
tree8298c3ed99cd23cf450833c09dd1b5264fc588a8
parent33431ebb9ace3fba76138198596f8155c2e14354 (diff)
downloadbusybox-w32-ae1c704c44573c710ff196fa9c8bcaebbfe34966.tar.gz
busybox-w32-ae1c704c44573c710ff196fa9c8bcaebbfe34966.tar.bz2
busybox-w32-ae1c704c44573c710ff196fa9c8bcaebbfe34966.zip
Write full status file
-rw-r--r--archival/dpkg.c95
-rw-r--r--dpkg.c95
2 files changed, 152 insertions, 38 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 0d2b2dc3c..e5ed95cb8 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -17,10 +17,10 @@
17#define DEPENDSMAX 64 /* maximum number of depends we can handle */ 17#define DEPENDSMAX 64 /* maximum number of depends we can handle */
18 18
19/* Should we do full dependency checking? */ 19/* Should we do full dependency checking? */
20#define DODEPENDS 1 20//#define DODEPENDS 0
21 21
22/* Should we do debugging? */ 22/* Should we do debugging? */
23#define DODEBUG 0 23//#define DODEBUG 0
24 24
25#ifdef DODEBUG 25#ifdef DODEBUG
26#define SYSTEM(x) do_system(x) 26#define SYSTEM(x) do_system(x)
@@ -341,6 +341,7 @@ static int fill_package_struct(package_t *package, const char *package_buffer)
341 char *field = NULL; 341 char *field = NULL;
342 int field_start = 0; 342 int field_start = 0;
343 int field_length = 0; 343 int field_length = 0;
344
344 while ((field = read_package_field(&package_buffer[field_start])) != NULL) { 345 while ((field = read_package_field(&package_buffer[field_start])) != NULL) {
345 field_length = strlen(field); 346 field_length = strlen(field);
346 field_start += (field_length + 1); 347 field_start += (field_length + 1);
@@ -430,6 +431,78 @@ static int fill_package_struct(package_t *package, const char *package_buffer)
430 return EXIT_SUCCESS; 431 return EXIT_SUCCESS;
431} 432}
432 433
434extern void write_package(FILE *out_file, package_t *pkg)
435{
436 if (pkg->package) {
437 fprintf(out_file, "Package: %s\n", pkg->package);
438 }
439 if ((pkg->state_want != 0) || (pkg->state_flag != 0)|| (pkg->state_status != 0)) {
440 fprintf(out_file, "Status: %s %s %s\n",
441 state_words_want[pkg->state_want - 1],
442 state_words_flag[pkg->state_flag - 1],
443 state_words_status[pkg->state_status - 1]);
444 }
445 if (pkg->depends) {
446 fprintf(out_file, "Depends: %s\n", pkg->depends);
447 }
448 if (pkg->provides) {
449 fprintf(out_file, "Provides: %s\n", pkg->provides);
450 }
451 if (pkg->priority) {
452 fprintf(out_file, "Priority: %s\n", pkg->priority);
453 }
454 if (pkg->section) {
455 fprintf(out_file, "Section: %s\n", pkg->section);
456 }
457 if (pkg->section) {
458 fprintf(out_file, "Installed-Size: %s\n", pkg->installed_size);
459 }
460 if (pkg->maintainer) {
461 fprintf(out_file, "Maintainer: %s\n", pkg->maintainer);
462 }
463 if (pkg->source) {
464 fprintf(out_file, "Source: %s\n", pkg->source);
465 }
466 if (pkg->version) {
467 fprintf(out_file, "Version: %s\n", pkg->version);
468 }
469 if (pkg->pre_depends) {
470 fprintf(out_file, "Pre-depends: %s\n", pkg->pre_depends);
471 }
472 if (pkg->replaces) {
473 fprintf(out_file, "Replaces: %s\n", pkg->replaces);
474 }
475 if (pkg->recommends) {
476 fprintf(out_file, "Recommends: %s\n", pkg->recommends);
477 }
478 if (pkg->suggests) {
479 fprintf(out_file, "Suggests: %s\n", pkg->suggests);
480 }
481 if (pkg->conflicts) {
482 fprintf(out_file, "Conflicts: %s\n", pkg->conflicts);
483 }
484 if (pkg->conffiles) {
485 fprintf(out_file, "Conf-files: %s\n", pkg->conffiles);
486 }
487 if (pkg->architecture) {
488 fprintf(out_file, "Architecture: %s\n", pkg->architecture);
489 }
490 if (pkg->filename) {
491 fprintf(out_file, "Filename: %s\n", pkg->filename);
492 }
493 if (pkg->md5sum) {
494 fprintf(out_file, "MD5sum: %s\n", pkg->md5sum);
495 }
496 if (pkg->installer_menu_item) {
497 fprintf(out_file, "installer-main-menu %d\n", pkg->installer_menu_item);
498 }
499 if (pkg->description) {
500 fprintf(out_file, "Description: %s\n", pkg->description);
501 }
502 fputc('\n', out_file);
503 pkg = pkg->next;
504}
505
433static void *status_read(void) 506static void *status_read(void)
434{ 507{
435 FILE *f; 508 FILE *f;
@@ -447,9 +520,7 @@ static void *status_read(void)
447 520
448 while ( (package_control_buffer = read_text_file_to_buffer(f)) != NULL) { 521 while ( (package_control_buffer = read_text_file_to_buffer(f)) != NULL) {
449 m = (package_t *)xcalloc(1, sizeof(package_t)); 522 m = (package_t *)xcalloc(1, sizeof(package_t));
450 printf("read buffer [%s]\n", package_control_buffer);
451 fill_package_struct(m, package_control_buffer); 523 fill_package_struct(m, package_control_buffer);
452 printf("package is [%s]\n", m->package);
453 if (m->package) { 524 if (m->package) {
454 /* 525 /*
455 * If there is an item in the tree by this name, 526 * If there is an item in the tree by this name,
@@ -489,7 +560,6 @@ static void *status_read(void)
489 free(m); 560 free(m);
490 } 561 }
491 } 562 }
492 printf("done\n");
493 fclose(f); 563 fclose(f);
494 return status; 564 return status;
495} 565}
@@ -553,20 +623,7 @@ static int status_merge(void *status, package_t *pkgs)
553 623
554 // Print out packages we processed. 624 // Print out packages we processed.
555 for (pkg = pkgs; pkg != 0; pkg = pkg->next) { 625 for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
556 fprintf(fout, "Package: %s\nStatus: %s %s %s\n", 626 write_package(fout, pkg);
557 pkg->package, state_words_want[pkg->state_want - 1],
558 state_words_flag[pkg->state_flag - 1],
559 state_words_status[pkg->state_status - 1]);
560
561 if (pkg->depends)
562 fprintf(fout, "Depends: %s\n", pkg->depends);
563 if (pkg->provides)
564 fprintf(fout, "Provides: %s\n", pkg->provides);
565 if (pkg->installer_menu_item)
566 fprintf(fout, "installer-menu-item: %i\n", pkg->installer_menu_item);
567 if (pkg->description)
568 fprintf(fout, "Description: %s\n", pkg->description);
569 fputc('\n', fout);
570 } 627 }
571 fclose(fout); 628 fclose(fout);
572 629
diff --git a/dpkg.c b/dpkg.c
index 0d2b2dc3c..e5ed95cb8 100644
--- a/dpkg.c
+++ b/dpkg.c
@@ -17,10 +17,10 @@
17#define DEPENDSMAX 64 /* maximum number of depends we can handle */ 17#define DEPENDSMAX 64 /* maximum number of depends we can handle */
18 18
19/* Should we do full dependency checking? */ 19/* Should we do full dependency checking? */
20#define DODEPENDS 1 20//#define DODEPENDS 0
21 21
22/* Should we do debugging? */ 22/* Should we do debugging? */
23#define DODEBUG 0 23//#define DODEBUG 0
24 24
25#ifdef DODEBUG 25#ifdef DODEBUG
26#define SYSTEM(x) do_system(x) 26#define SYSTEM(x) do_system(x)
@@ -341,6 +341,7 @@ static int fill_package_struct(package_t *package, const char *package_buffer)
341 char *field = NULL; 341 char *field = NULL;
342 int field_start = 0; 342 int field_start = 0;
343 int field_length = 0; 343 int field_length = 0;
344
344 while ((field = read_package_field(&package_buffer[field_start])) != NULL) { 345 while ((field = read_package_field(&package_buffer[field_start])) != NULL) {
345 field_length = strlen(field); 346 field_length = strlen(field);
346 field_start += (field_length + 1); 347 field_start += (field_length + 1);
@@ -430,6 +431,78 @@ static int fill_package_struct(package_t *package, const char *package_buffer)
430 return EXIT_SUCCESS; 431 return EXIT_SUCCESS;
431} 432}
432 433
434extern void write_package(FILE *out_file, package_t *pkg)
435{
436 if (pkg->package) {
437 fprintf(out_file, "Package: %s\n", pkg->package);
438 }
439 if ((pkg->state_want != 0) || (pkg->state_flag != 0)|| (pkg->state_status != 0)) {
440 fprintf(out_file, "Status: %s %s %s\n",
441 state_words_want[pkg->state_want - 1],
442 state_words_flag[pkg->state_flag - 1],
443 state_words_status[pkg->state_status - 1]);
444 }
445 if (pkg->depends) {
446 fprintf(out_file, "Depends: %s\n", pkg->depends);
447 }
448 if (pkg->provides) {
449 fprintf(out_file, "Provides: %s\n", pkg->provides);
450 }
451 if (pkg->priority) {
452 fprintf(out_file, "Priority: %s\n", pkg->priority);
453 }
454 if (pkg->section) {
455 fprintf(out_file, "Section: %s\n", pkg->section);
456 }
457 if (pkg->section) {
458 fprintf(out_file, "Installed-Size: %s\n", pkg->installed_size);
459 }
460 if (pkg->maintainer) {
461 fprintf(out_file, "Maintainer: %s\n", pkg->maintainer);
462 }
463 if (pkg->source) {
464 fprintf(out_file, "Source: %s\n", pkg->source);
465 }
466 if (pkg->version) {
467 fprintf(out_file, "Version: %s\n", pkg->version);
468 }
469 if (pkg->pre_depends) {
470 fprintf(out_file, "Pre-depends: %s\n", pkg->pre_depends);
471 }
472 if (pkg->replaces) {
473 fprintf(out_file, "Replaces: %s\n", pkg->replaces);
474 }
475 if (pkg->recommends) {
476 fprintf(out_file, "Recommends: %s\n", pkg->recommends);
477 }
478 if (pkg->suggests) {
479 fprintf(out_file, "Suggests: %s\n", pkg->suggests);
480 }
481 if (pkg->conflicts) {
482 fprintf(out_file, "Conflicts: %s\n", pkg->conflicts);
483 }
484 if (pkg->conffiles) {
485 fprintf(out_file, "Conf-files: %s\n", pkg->conffiles);
486 }
487 if (pkg->architecture) {
488 fprintf(out_file, "Architecture: %s\n", pkg->architecture);
489 }
490 if (pkg->filename) {
491 fprintf(out_file, "Filename: %s\n", pkg->filename);
492 }
493 if (pkg->md5sum) {
494 fprintf(out_file, "MD5sum: %s\n", pkg->md5sum);
495 }
496 if (pkg->installer_menu_item) {
497 fprintf(out_file, "installer-main-menu %d\n", pkg->installer_menu_item);
498 }
499 if (pkg->description) {
500 fprintf(out_file, "Description: %s\n", pkg->description);
501 }
502 fputc('\n', out_file);
503 pkg = pkg->next;
504}
505
433static void *status_read(void) 506static void *status_read(void)
434{ 507{
435 FILE *f; 508 FILE *f;
@@ -447,9 +520,7 @@ static void *status_read(void)
447 520
448 while ( (package_control_buffer = read_text_file_to_buffer(f)) != NULL) { 521 while ( (package_control_buffer = read_text_file_to_buffer(f)) != NULL) {
449 m = (package_t *)xcalloc(1, sizeof(package_t)); 522 m = (package_t *)xcalloc(1, sizeof(package_t));
450 printf("read buffer [%s]\n", package_control_buffer);
451 fill_package_struct(m, package_control_buffer); 523 fill_package_struct(m, package_control_buffer);
452 printf("package is [%s]\n", m->package);
453 if (m->package) { 524 if (m->package) {
454 /* 525 /*
455 * If there is an item in the tree by this name, 526 * If there is an item in the tree by this name,
@@ -489,7 +560,6 @@ static void *status_read(void)
489 free(m); 560 free(m);
490 } 561 }
491 } 562 }
492 printf("done\n");
493 fclose(f); 563 fclose(f);
494 return status; 564 return status;
495} 565}
@@ -553,20 +623,7 @@ static int status_merge(void *status, package_t *pkgs)
553 623
554 // Print out packages we processed. 624 // Print out packages we processed.
555 for (pkg = pkgs; pkg != 0; pkg = pkg->next) { 625 for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
556 fprintf(fout, "Package: %s\nStatus: %s %s %s\n", 626 write_package(fout, pkg);
557 pkg->package, state_words_want[pkg->state_want - 1],
558 state_words_flag[pkg->state_flag - 1],
559 state_words_status[pkg->state_status - 1]);
560
561 if (pkg->depends)
562 fprintf(fout, "Depends: %s\n", pkg->depends);
563 if (pkg->provides)
564 fprintf(fout, "Provides: %s\n", pkg->provides);
565 if (pkg->installer_menu_item)
566 fprintf(fout, "installer-menu-item: %i\n", pkg->installer_menu_item);
567 if (pkg->description)
568 fprintf(fout, "Description: %s\n", pkg->description);
569 fputc('\n', fout);
570 } 627 }
571 fclose(fout); 628 fclose(fout);
572 629