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