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