main.c revision 7713
1#ifndef lint 2static const char *rcsid = "$Id: main.c,v 1.8 1994/12/06 00:51:36 jkh Exp $"; 3#endif 4 5/* 6 * FreeBSD install - a package for the installation and maintainance 7 * of non-core utilities. 8 * 9 * Jordan K. Hubbard 10 * 18 July 1993 11 * 12 * This is the create module. 13 * 14 */ 15 16#include "lib.h" 17#include "create.h" 18 19static char Options[] = "YNhvf:p:P:c:d:i:k:r:t:X:D:m:"; 20 21char *Prefix = NULL; 22char *Comment = NULL; 23char *Desc = NULL; 24char *Display = NULL; 25char *Install = NULL; 26char *DeInstall = NULL; 27char *Contents = NULL; 28char *Require = NULL; 29char *PlayPen = NULL; 30char *ExcludeFrom = NULL; 31char *Mtree = NULL; 32char *Pkgdeps = NULL; 33int Dereference = 0; 34 35int 36main(int argc, char **argv) 37{ 38 int ch; 39 char **pkgs, **start; 40 char *prog_name = argv[0]; 41 42 pkgs = start = argv; 43 while ((ch = getopt(argc, argv, Options)) != EOF) 44 switch(ch) { 45 case 'v': 46 Verbose = TRUE; 47 break; 48 49 case 'N': 50 AutoAnswer = NO; 51 break; 52 53 case 'Y': 54 AutoAnswer = YES; 55 break; 56 57 case 'p': 58 Prefix = optarg; 59 break; 60 61 case 'f': 62 Contents = optarg; 63 break; 64 65 case 'c': 66 Comment = optarg; 67 break; 68 69 case 'd': 70 Desc = optarg; 71 break; 72 73 case 'i': 74 Install = optarg; 75 break; 76 77 case 'k': 78 DeInstall = optarg; 79 break; 80 81 case 'r': 82 Require = optarg; 83 break; 84 85 case 't': 86 PlayPen = optarg; 87 break; 88 89 case 'X': 90 ExcludeFrom = optarg; 91 break; 92 93 case 'h': 94 Dereference = 1; 95 break; 96 97 case 'D': 98 Display = optarg; 99 break; 100 101 case 'm': 102 Mtree = optarg; 103 break; 104 105 case 'P': 106 Pkgdeps = optarg; 107 break; 108 109 case '?': 110 default: 111 usage(prog_name, NULL); 112 break; 113 } 114 115 argc -= optind; 116 argv += optind; 117 118 /* Get all the remaining package names, if any */ 119 while (*argv) 120 *pkgs++ = *argv++; 121 122 /* If no packages, yelp */ 123 if (pkgs == start) 124 usage(prog_name, "Missing package name"); 125 *pkgs = NULL; 126 if (start[1]) 127 usage(prog_name, "Only one package name allowed\n\t('%s' extraneous)", 128 start[1]); 129 if (!pkg_perform(start)) { 130 if (Verbose) 131 fprintf(stderr, "Package creation failed.\n"); 132 return 1; 133 } 134 else 135 return 0; 136} 137 138void 139usage(const char *name, const char *fmt, ...) 140{ 141 va_list args; 142 143 va_start(args, fmt); 144 if (fmt) { 145 fprintf(stderr, "%s: ", name); 146 vfprintf(stderr, fmt, args); 147 fprintf(stderr, "\n\n"); 148 } 149 va_end(args); 150 fprintf(stderr, "Usage: %s [args] pkg\n\n", name); 151 fprintf(stderr, "Where args are one or more of:\n\n"); 152 153 fprintf(stderr, "-c [-]file Get one-line comment from file (-or arg)\n"); 154 fprintf(stderr, "-d [-]file Get description from file (-or arg)\n"); 155 fprintf(stderr, "-f file get list of files from file (- for stdin)\n"); 156 fprintf(stderr, "-h follow symbolic links\n"); 157 fprintf(stderr, "-i script install script\n"); 158 fprintf(stderr, "-k script de-install script\n"); 159 fprintf(stderr, "-D file install notice\n"); 160 fprintf(stderr, "-m file mtree spec for directories\n"); 161 fprintf(stderr, "-P pkgs set package dependency list to pkgs\n"); 162 fprintf(stderr, "-p prefix install prefix will be arg\n"); 163 fprintf(stderr, "-r script pre/post requirements script\n"); 164 fprintf(stderr, "-t temp use temp as template for mktemp()\n"); 165 fprintf(stderr, "-X file exclude files listed in file\n"); 166 fprintf(stderr, "-v verbose\n"); 167 fprintf(stderr, "-Y assume `yes' answer to all questions\n"); 168 fprintf(stderr, "-N assume `no' answer to all questions\n"); 169 exit(1); 170} 171