Deleted Added
full compact
perform.c (132789) perform.c (147043)
1/*
2 * FreeBSD install - a package for the installation and maintainance
3 * of non-core utilities.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 5 unchanged lines hidden (view full) ---

14 * Jordan K. Hubbard
15 * 18 July 1993
16 *
17 * This is the main body of the create module.
18 *
19 */
20
21#include <sys/cdefs.h>
1/*
2 * FreeBSD install - a package for the installation and maintainance
3 * of non-core utilities.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 5 unchanged lines hidden (view full) ---

14 * Jordan K. Hubbard
15 * 18 July 1993
16 *
17 * This is the main body of the create module.
18 *
19 */
20
21#include <sys/cdefs.h>
22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/create/perform.c 132789 2004-07-28 07:19:15Z kan $");
22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/create/perform.c 147043 2005-06-06 03:24:14Z sobomax $");
23
24#include "lib.h"
25#include "create.h"
26
27#include <err.h>
28#include <libgen.h>
29#include <signal.h>
30#include <stdlib.h>
31#include <sys/syslimits.h>
32#include <sys/wait.h>
33#include <unistd.h>
34
35static void sanity_check(void);
36static void make_dist(const char *, const char *, const char *, Package *);
23
24#include "lib.h"
25#include "create.h"
26
27#include <err.h>
28#include <libgen.h>
29#include <signal.h>
30#include <stdlib.h>
31#include <sys/syslimits.h>
32#include <sys/wait.h>
33#include <unistd.h>
34
35static void sanity_check(void);
36static void make_dist(const char *, const char *, const char *, Package *);
37static int create_from_installed(const char *, const char *);
37static int create_from_installed_recursive(const char *, const char *);
38static int create_from_installed(const char *, const char *, const char *);
38
39static char *home;
40
41int
42pkg_perform(char **pkgs)
43{
44 char *pkg = *pkgs; /* Only one arg to create */
45 char *cp;

--- 28 unchanged lines hidden (view full) ---

74 suf = "tbz";
75 setenv("BZIP2", "--best", 0);
76 } else if (Zipper == GZIP) {
77 suf = "tgz";
78 setenv("GZIP", "-9", 0);
79 } else
80 suf = "tar";
81
39
40static char *home;
41
42int
43pkg_perform(char **pkgs)
44{
45 char *pkg = *pkgs; /* Only one arg to create */
46 char *cp;

--- 28 unchanged lines hidden (view full) ---

75 suf = "tbz";
76 setenv("BZIP2", "--best", 0);
77 } else if (Zipper == GZIP) {
78 suf = "tgz";
79 setenv("GZIP", "-9", 0);
80 } else
81 suf = "tar";
82
82 if (InstalledPkg != NULL)
83 return (create_from_installed(pkg, suf));
83 if (InstalledPkg != NULL) {
84 if (!Recursive)
85 return (create_from_installed(InstalledPkg, pkg, suf));
86 return (create_from_installed_recursive(pkg, suf));
87 }
84
85 get_dash_string(&Comment);
86 get_dash_string(&Desc);
87 if (!strcmp(Contents, "-"))
88 pkg_in = stdin;
89 else {
90 pkg_in = fopen(Contents, "r");
91 if (!pkg_in) {

--- 349 unchanged lines hidden (view full) ---

441 in_cleanup = 1;
442 leave_playpen();
443 }
444 if (sig)
445 exit(1);
446}
447
448static int
88
89 get_dash_string(&Comment);
90 get_dash_string(&Desc);
91 if (!strcmp(Contents, "-"))
92 pkg_in = stdin;
93 else {
94 pkg_in = fopen(Contents, "r");
95 if (!pkg_in) {

--- 349 unchanged lines hidden (view full) ---

445 in_cleanup = 1;
446 leave_playpen();
447 }
448 if (sig)
449 exit(1);
450}
451
452static int
449create_from_installed(const char *pkg, const char *suf)
453create_from_installed_recursive(const char *pkg, const char *suf)
450{
451 FILE *fp;
452 Package plist;
454{
455 FILE *fp;
456 Package plist;
457 PackingList p;
458 char tmp[PATH_MAX];
459 int rval;
460
461 if (!create_from_installed(InstalledPkg, pkg, suf))
462 return FALSE;
463 snprintf(tmp, sizeof(tmp), "%s/%s/%s", LOG_DIR, InstalledPkg, CONTENTS_FNAME);
464 if (!fexists(tmp)) {
465 warnx("can't find package '%s' installed!", InstalledPkg);
466 return FALSE;
467 }
468 /* Suck in the contents list */
469 plist.head = plist.tail = NULL;
470 fp = fopen(tmp, "r");
471 if (!fp) {
472 warnx("unable to open %s file", tmp);
473 return FALSE;
474 }
475 read_plist(&plist, fp);
476 fclose(fp);
477 rval = TRUE;
478 for (p = plist.head; p ; p = p->next) {
479 if (p->type != PLIST_PKGDEP)
480 continue;
481 if (Verbose)
482 printf("Creating package %s\n", p->name);
483 if (!create_from_installed(p->name, p->name, suf)) {
484 rval = FALSE;
485 break;
486 }
487 }
488 free_plist(&plist);
489 return rval;
490}
491
492static int
493create_from_installed(const char *ipkg, const char *pkg, const char *suf)
494{
495 FILE *fp;
496 Package plist;
453 char homedir[MAXPATHLEN], log_dir[FILENAME_MAX];
454
497 char homedir[MAXPATHLEN], log_dir[FILENAME_MAX];
498
455 snprintf(log_dir, sizeof(log_dir), "%s/%s", LOG_DIR, InstalledPkg);
499 snprintf(log_dir, sizeof(log_dir), "%s/%s", LOG_DIR, ipkg);
456 if (!fexists(log_dir)) {
500 if (!fexists(log_dir)) {
457 warnx("can't find package '%s' installed!", InstalledPkg);
501 warnx("can't find package '%s' installed!", ipkg);
458 return FALSE;
459 }
460 getcwd(homedir, sizeof(homedir));
461 if (chdir(log_dir) == FAIL) {
462 warnx("can't change directory to '%s'!", log_dir);
463 return FALSE;
464 }
465 /* Suck in the contents list */

--- 14 unchanged lines hidden (view full) ---

480 (char *)POST_DEINSTALL_FNAME : NULL;
481 Require = isfile(REQUIRE_FNAME) ? (char *)REQUIRE_FNAME : NULL;
482 Display = isfile(DISPLAY_FNAME) ? (char *)DISPLAY_FNAME : NULL;
483 Mtree = isfile(MTREE_FNAME) ? (char *)MTREE_FNAME : NULL;
484
485 make_dist(homedir, pkg, suf, &plist);
486
487 free_plist(&plist);
502 return FALSE;
503 }
504 getcwd(homedir, sizeof(homedir));
505 if (chdir(log_dir) == FAIL) {
506 warnx("can't change directory to '%s'!", log_dir);
507 return FALSE;
508 }
509 /* Suck in the contents list */

--- 14 unchanged lines hidden (view full) ---

524 (char *)POST_DEINSTALL_FNAME : NULL;
525 Require = isfile(REQUIRE_FNAME) ? (char *)REQUIRE_FNAME : NULL;
526 Display = isfile(DISPLAY_FNAME) ? (char *)DISPLAY_FNAME : NULL;
527 Mtree = isfile(MTREE_FNAME) ? (char *)MTREE_FNAME : NULL;
528
529 make_dist(homedir, pkg, suf, &plist);
530
531 free_plist(&plist);
532 if (chdir(homedir) == FAIL) {
533 warnx("can't change directory to '%s'!", homedir);
534 return FALSE;
535 }
488 return TRUE;
489}
536 return TRUE;
537}