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