main.c revision 50479
1#ifndef lint 2static const char rcsid[] = 3 "$FreeBSD: head/usr.sbin/pkg_install/create/main.c 50479 1999-08-28 01:35:59Z peter $"; 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[] = "YNOhvf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:"; 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 PlayPen[FILENAME_MAX]; 38int Dereference = 0; 39int PlistOnly = 0; 40 41static void usage __P((void)); 42 43int 44main(int argc, char **argv) 45{ 46 int ch; 47 char **pkgs, **start; 48 49 pkgs = start = argv; 50 while ((ch = getopt(argc, argv, Options)) != -1) 51 switch(ch) { 52 case 'v': 53 Verbose = TRUE; 54 break; 55 56 case 'N': 57 AutoAnswer = NO; 58 break; 59 60 case 'Y': 61 AutoAnswer = YES; 62 break; 63 64 case 'O': 65 PlistOnly = YES; 66 break; 67 68 case 'p': 69 Prefix = optarg; 70 break; 71 72 case 's': 73 SrcDir = optarg; 74 break; 75 76 case 'f': 77 Contents = optarg; 78 break; 79 80 case 'c': 81 Comment = optarg; 82 break; 83 84 case 'd': 85 Desc = optarg; 86 break; 87 88 case 'i': 89 Install = optarg; 90 break; 91 92 case 'I': 93 PostInstall = optarg; 94 break; 95 96 case 'k': 97 DeInstall = optarg; 98 break; 99 100 case 'K': 101 PostDeInstall = optarg; 102 break; 103 104 case 'r': 105 Require = optarg; 106 break; 107 108 case 't': 109 strcpy(PlayPen, optarg); 110 break; 111 112 case 'X': 113 ExcludeFrom = optarg; 114 break; 115 116 case 'h': 117 Dereference = 1; 118 break; 119 120 case 'D': 121 Display = optarg; 122 break; 123 124 case 'm': 125 Mtree = optarg; 126 break; 127 128 case 'P': 129 Pkgdeps = optarg; 130 break; 131 132 case '?': 133 default: 134 usage(); 135 break; 136 } 137 138 argc -= optind; 139 argv += optind; 140 141 /* Get all the remaining package names, if any */ 142 while (*argv) 143 *pkgs++ = *argv++; 144 145 /* If no packages, yelp */ 146 if (pkgs == start) 147 warnx("missing package name"), usage(); 148 *pkgs = NULL; 149 if (start[1]) 150 warnx("only one package name allowed ('%s' extraneous)", start[1]), 151 usage(); 152 if (!pkg_perform(start)) { 153 if (Verbose) 154 warnx("package creation failed"); 155 return 1; 156 } 157 else 158 return 0; 159} 160 161static void 162usage() 163{ 164 fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", 165"usage: pkg_create [-YNOhv] [-P pkgs] [-p prefix] [-f contents] [-i iscript]", 166" [-I piscript] [-k dscript] [-K pdscript] [-r rscript] ", 167" [-t template] [-X excludefile] [-D displayfile] ", 168" [-m mtreefile] -c comment -d description -f packlist ", 169" pkg-name"); 170 exit(1); 171} 172