main.c revision 71373
1#ifndef lint 2static const char rcsid[] = 3 "$FreeBSD: head/usr.sbin/pkg_install/create/main.c 71373 2001-01-22 12:01:55Z sobomax $"; 4#endif 5 6/* 7 * FreeBSD install - a package for the installation and maintainance 8 * of non-core utilities. 9 * 10 * Jordan K. Hubbard 11 * 18 July 1993 12 * 13 * This is the create module. 14 * 15 */ 16 17#include <err.h> 18#include "lib.h" 19#include "create.h" 20 21static char Options[] = "YNOhvyf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:o:"; 22 23char *Prefix = NULL; 24char *Comment = NULL; 25char *Desc = NULL; 26char *SrcDir = NULL; 27char *Display = NULL; 28char *Install = NULL; 29char *PostInstall = NULL; 30char *DeInstall = NULL; 31char *PostDeInstall = NULL; 32char *Contents = NULL; 33char *Require = NULL; 34char *ExcludeFrom = NULL; 35char *Mtree = NULL; 36char *Pkgdeps = NULL; 37char *Origin = NULL; 38char PlayPen[FILENAME_MAX]; 39int Dereference = FALSE; 40int PlistOnly = FALSE; 41int UseBzip2 = FALSE; 42 43static void usage __P((void)); 44 45int 46main(int argc, char **argv) 47{ 48 int ch; 49 char **pkgs, **start; 50 51 pkgs = start = argv; 52 while ((ch = getopt(argc, argv, Options)) != -1) 53 switch(ch) { 54 case 'v': 55 Verbose = TRUE; 56 break; 57 58 case 'N': 59 AutoAnswer = NO; 60 break; 61 62 case 'Y': 63 AutoAnswer = YES; 64 break; 65 66 case 'O': 67 PlistOnly = TRUE; 68 break; 69 70 case 'p': 71 Prefix = optarg; 72 break; 73 74 case 's': 75 SrcDir = optarg; 76 break; 77 78 case 'f': 79 Contents = optarg; 80 break; 81 82 case 'c': 83 Comment = optarg; 84 break; 85 86 case 'd': 87 Desc = optarg; 88 break; 89 90 case 'i': 91 Install = optarg; 92 break; 93 94 case 'I': 95 PostInstall = optarg; 96 break; 97 98 case 'k': 99 DeInstall = optarg; 100 break; 101 102 case 'K': 103 PostDeInstall = optarg; 104 break; 105 106 case 'r': 107 Require = optarg; 108 break; 109 110 case 't': 111 strcpy(PlayPen, optarg); 112 break; 113 114 case 'X': 115 ExcludeFrom = optarg; 116 break; 117 118 case 'h': 119 Dereference = TRUE; 120 break; 121 122 case 'D': 123 Display = optarg; 124 break; 125 126 case 'm': 127 Mtree = optarg; 128 break; 129 130 case 'P': 131 Pkgdeps = optarg; 132 break; 133 134 case 'o': 135 Origin = optarg; 136 break; 137 138 case 'y': 139 UseBzip2 = FALSE; 140 break; 141 142 case '?': 143 default: 144 usage(); 145 break; 146 } 147 148 argc -= optind; 149 argv += optind; 150 151 /* Get all the remaining package names, if any */ 152 while (*argv) 153 *pkgs++ = *argv++; 154 155 /* If no packages, yelp */ 156 if (pkgs == start) 157 warnx("missing package name"), usage(); 158 *pkgs = NULL; 159 if (start[1]) 160 warnx("only one package name allowed ('%s' extraneous)", start[1]), 161 usage(); 162 if (!pkg_perform(start)) { 163 if (Verbose) 164 warnx("package creation failed"); 165 return 1; 166 } 167 else 168 return 0; 169} 170 171static void 172usage() 173{ 174 fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", 175"usage: pkg_create [-YNOhvy] [-P pkgs] [-p prefix] [-f contents] [-i iscript]", 176" [-I piscript] [-k dscript] [-K pdscript] [-r rscript] ", 177" [-t template] [-X excludefile] [-D displayfile] ", 178" [-m mtreefile] [-o origin] -c comment -d description ", 179" -f packlist pkg-name"); 180 exit(1); 181} 182