perform.c (83663) | perform.c (84670) |
---|---|
1#ifndef lint 2static const char rcsid[] = | 1#ifndef lint 2static const char rcsid[] = |
3 "$FreeBSD: head/usr.sbin/pkg_install/create/perform.c 83663 2001-09-19 08:06:48Z sobomax $"; | 3 "$FreeBSD: head/usr.sbin/pkg_install/create/perform.c 84670 2001-10-08 17:01:35Z sobomax $"; |
4#endif 5 6/* 7 * FreeBSD install - a package for the installation and maintainance 8 * of non-core utilities. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions --- 18 unchanged lines hidden (view full) --- 30#include <libgen.h> 31#include <signal.h> 32#include <sys/syslimits.h> 33#include <sys/wait.h> 34#include <unistd.h> 35 36static void sanity_check(void); 37static void make_dist(char *, char *, char *, Package *); | 4#endif 5 6/* 7 * FreeBSD install - a package for the installation and maintainance 8 * of non-core utilities. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions --- 18 unchanged lines hidden (view full) --- 30#include <libgen.h> 31#include <signal.h> 32#include <sys/syslimits.h> 33#include <sys/wait.h> 34#include <unistd.h> 35 36static void sanity_check(void); 37static void make_dist(char *, char *, char *, Package *); |
38static int create_from_installed(char *, char *); |
|
38 39static char *home; 40 41int 42pkg_perform(char **pkgs) 43{ 44 char *pkg = *pkgs; /* Only one arg to create */ 45 char *cp; 46 FILE *pkg_in, *fp; 47 Package plist; 48 int len; 49 char *suf; 50 int compress = TRUE; /* default is to compress packages */ 51 52 /* Preliminary setup */ | 39 40static char *home; 41 42int 43pkg_perform(char **pkgs) 44{ 45 char *pkg = *pkgs; /* Only one arg to create */ 46 char *cp; 47 FILE *pkg_in, *fp; 48 Package plist; 49 int len; 50 char *suf; 51 int compress = TRUE; /* default is to compress packages */ 52 53 /* Preliminary setup */ |
53 sanity_check(); | 54 if (InstalledPkg == NULL) 55 sanity_check(); |
54 if (Verbose && !PlistOnly) 55 printf("Creating package %s\n", pkg); | 56 if (Verbose && !PlistOnly) 57 printf("Creating package %s\n", pkg); |
56 get_dash_string(&Comment); 57 get_dash_string(&Desc); 58 if (!strcmp(Contents, "-")) 59 pkg_in = stdin; 60 else { 61 pkg_in = fopen(Contents, "r"); 62 if (!pkg_in) { 63 cleanup(0); 64 errx(2, __FUNCTION__ ": unable to open contents file '%s' for input", Contents); 65 } 66 } 67 plist.head = plist.tail = NULL; | |
68 69 /* chop suffix off if already specified, remembering if we want to compress */ 70 len = strlen(pkg); 71 if (len > 4) { 72 if (!strcmp(&pkg[len - 4], ".tgz")) { 73 compress = TRUE; 74 UseBzip2 = FALSE; 75 pkg[len - 4] = '\0'; --- 11 unchanged lines hidden (view full) --- 87 } 88 if (UseBzip2) 89 suf = "tbz2"; 90 else if (compress) 91 suf = "tgz"; 92 else 93 suf = "tar"; 94 | 58 59 /* chop suffix off if already specified, remembering if we want to compress */ 60 len = strlen(pkg); 61 if (len > 4) { 62 if (!strcmp(&pkg[len - 4], ".tgz")) { 63 compress = TRUE; 64 UseBzip2 = FALSE; 65 pkg[len - 4] = '\0'; --- 11 unchanged lines hidden (view full) --- 77 } 78 if (UseBzip2) 79 suf = "tbz2"; 80 else if (compress) 81 suf = "tgz"; 82 else 83 suf = "tar"; 84 |
85 if (InstalledPkg != NULL) 86 return (create_from_installed(pkg, suf)); 87 88 get_dash_string(&Comment); 89 get_dash_string(&Desc); 90 if (!strcmp(Contents, "-")) 91 pkg_in = stdin; 92 else { 93 pkg_in = fopen(Contents, "r"); 94 if (!pkg_in) { 95 cleanup(0); 96 errx(2, __FUNCTION__ ": unable to open contents file '%s' for input", Contents); 97 } 98 } 99 plist.head = plist.tail = NULL; 100 |
|
95 /* Add the origin if asked, at the top */ 96 if (Origin) 97 add_plist(&plist, PLIST_COMMENT, strconcat("ORIGIN:", Origin)); 98 99 /* Stick the dependencies, if any, at the top */ 100 if (Pkgdeps) { 101 char **deps; 102 int i; --- 284 unchanged lines hidden (view full) --- 387 388 if (!in_cleanup) { 389 in_cleanup = 1; 390 leave_playpen(); 391 } 392 if (sig) 393 exit(1); 394} | 101 /* Add the origin if asked, at the top */ 102 if (Origin) 103 add_plist(&plist, PLIST_COMMENT, strconcat("ORIGIN:", Origin)); 104 105 /* Stick the dependencies, if any, at the top */ 106 if (Pkgdeps) { 107 char **deps; 108 int i; --- 284 unchanged lines hidden (view full) --- 393 394 if (!in_cleanup) { 395 in_cleanup = 1; 396 leave_playpen(); 397 } 398 if (sig) 399 exit(1); 400} |
401 402static int 403create_from_installed(char *pkg, char *suf) 404{ 405 FILE *fp; 406 Package plist; 407 char home[MAXPATHLEN], log_dir[FILENAME_MAX]; 408 409 snprintf(log_dir, sizeof(log_dir), "%s/%s", LOG_DIR, InstalledPkg); 410 if (!fexists(log_dir)) { 411 warnx("can't find package '%s' installed!", InstalledPkg); 412 return 1; 413 } 414 getcwd(home, sizeof(home)); 415 if (chdir(log_dir) == FAIL) { 416 warnx("can't change directory to '%s'!", log_dir); 417 return 1; 418 } 419 /* Suck in the contents list */ 420 plist.head = plist.tail = NULL; 421 fp = fopen(CONTENTS_FNAME, "r"); 422 if (!fp) { 423 warnx("unable to open %s file", CONTENTS_FNAME); 424 return 1; 425 } 426 /* If we have a prefix, add it now */ 427 read_plist(&plist, fp); 428 fclose(fp); 429 430 make_dist(home, pkg, suf, &plist); 431 432 free_plist(&plist); 433 return TRUE; 434} |
|