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