main.c revision 383
1#ifndef lint 2static const char *rcsid = "$Id: main.c,v 1.4 1993/09/04 05:06:33 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[] = "hvf:p:c:d:i:k:r:t:"; 20 21char *Prefix = NULL; 22char *Comment = NULL; 23char *Desc = NULL; 24char *Install = NULL; 25char *DeInstall = NULL; 26char *Contents = NULL; 27char *Require = NULL; 28char *PlayPen = NULL; 29 30int 31main(int argc, char **argv) 32{ 33 int ch; 34 char **pkgs, **start; 35 char *prog_name = argv[0]; 36 37 pkgs = start = argv; 38 while ((ch = getopt(argc, argv, Options)) != EOF) 39 switch(ch) { 40 case 'v': 41 Verbose = TRUE; 42 break; 43 44 case 'p': 45 Prefix = optarg; 46 break; 47 48 case 'f': 49 Contents = optarg; 50 break; 51 52 case 'c': 53 Comment = optarg; 54 break; 55 56 case 'd': 57 Desc = optarg; 58 break; 59 60 case 'i': 61 Install = optarg; 62 break; 63 64 case 'k': 65 DeInstall = optarg; 66 break; 67 68 case 'r': 69 Require = optarg; 70 break; 71 72 case 't': 73 PlayPen = optarg; 74 break; 75 76 case 'h': 77 case '?': 78 default: 79 usage(prog_name, NULL); 80 break; 81 } 82 83 argc -= optind; 84 argv += optind; 85 86 /* Get all the remaining package names, if any */ 87 while (*argv) 88 *pkgs++ = *argv++; 89 90 /* If no packages, yelp */ 91 if (pkgs == start) 92 usage(prog_name, "Missing package name"); 93 *pkgs = NULL; 94 if (start[1]) 95 usage(prog_name, "Only one package name allowed\n\t('%s' extraneous)", 96 start[1]); 97 if (!pkg_perform(start)) { 98 if (Verbose) 99 fprintf(stderr, "Package creation failed.\n"); 100 return 1; 101 } 102 else 103 return 0; 104} 105 106void 107usage(const char *name, const char *fmt, ...) 108{ 109 va_list args; 110 111 va_start(args, fmt); 112 if (fmt) { 113 fprintf(stderr, "%s: ", name); 114 vfprintf(stderr, fmt, args); 115 fprintf(stderr, "\n\n"); 116 } 117 va_end(args); 118 fprintf(stderr, "Usage: %s [args] pkg\n\n", name); 119 fprintf(stderr, "Where args are one or more of:\n\n"); 120 121 fprintf(stderr, "-c [-]file Get one-line comment from file (-or arg)\n"); 122 fprintf(stderr, "-d [-]file Get description from file (-or arg)\n"); 123 fprintf(stderr, "-f file get list of files from file (- for stdin)\n"); 124 fprintf(stderr, "-i script install script\n"); 125 fprintf(stderr, "-p arg install prefix will be arg\n"); 126 fprintf(stderr, "-k script de-install script\n"); 127 fprintf(stderr, "-r script pre/post requirements script\n"); 128 fprintf(stderr, "-t temp use temp as template for mktemp()\n"); 129 fprintf(stderr, "-v verbose\n"); 130 exit(1); 131} 132