1 /* $NetBSD: main.c,v 1.3 2021/04/10 19:49:59 nia Exp $ */ 2 3 #if HAVE_CONFIG_H 4 #include "config.h" 5 #endif 6 #include <nbcompat.h> 7 #if HAVE_SYS_CDEFS_H 8 #include <sys/cdefs.h> 9 #endif 10 __RCSID("$NetBSD: main.c,v 1.3 2021/04/10 19:49:59 nia Exp $"); 11 12 /* 13 * FreeBSD install - a package for the installation and maintainance 14 * of non-core utilities. 15 * 16 * Jordan K. Hubbard 17 * 18 July 1993 18 * 19 * This is the create module. 20 * 21 */ 22 23 #if HAVE_ERR_H 24 #include <err.h> 25 #endif 26 #include "lib.h" 27 #include "create.h" 28 29 /* -U is silently ignored, it used to inhibit pkgdb changes. */ 30 static const char Options[] = "B:C:D:F:I:K:L:OP:S:T:UVb:c:d:f:g:i:k:ln:p:r:s:u:v"; 31 32 char *Prefix = NULL; 33 char *Comment = NULL; 34 char *Desc = NULL; 35 char *Display = NULL; 36 char *Install = NULL; 37 char *DeInstall = NULL; 38 char *Contents = NULL; 39 char *Pkgdeps = NULL; 40 char *BuildPkgdeps = NULL; 41 char *Pkgcfl = NULL; 42 char *BuildVersion = NULL; 43 char *BuildInfo = NULL; 44 char *SizePkg = NULL; 45 char *SizeAll = NULL; 46 char *Preserve = NULL; 47 char *DefaultOwner = NULL; 48 char *DefaultGroup = NULL; 49 char *realprefix = NULL; 50 const char *CompressionType = NULL; 51 int PlistOnly = 0; 52 int RelativeLinks = 0; 53 Boolean File2Pkg = FALSE; 54 55 static void usage(void)56usage(void) 57 { 58 fprintf(stderr, 59 "usage: pkg_create [-lOUVv] [-B build-info-file] [-b build-version-file]\n" 60 " [-C cpkgs] [-D displayfile] [-F compression] \n" 61 " [-I realprefix] [-i iscript]\n" 62 " [-K pkg_dbdir] [-k dscript]\n" 63 " [-n preserve-file] [-P dpkgs] [-p prefix] [-r rscript]\n" 64 " [-S size-all-file] [-s size-pkg-file]\n" 65 " [-T buildpkgs] [-u owner] [-g group]\n" 66 " -c comment -d description -f packlist\n" 67 " pkg-name\n"); 68 exit(1); 69 } 70 71 int main(int argc,char ** argv)72main(int argc, char **argv) 73 { 74 int ch; 75 76 setprogname(argv[0]); 77 while ((ch = getopt(argc, argv, Options)) != -1) 78 switch (ch) { 79 case 'v': 80 Verbose = TRUE; 81 break; 82 83 case 'F': 84 CompressionType = optarg; 85 break; 86 87 case 'I': 88 realprefix = optarg; 89 break; 90 91 case 'O': 92 PlistOnly = 1; 93 break; 94 95 case 'U': 96 break; 97 98 case 'p': 99 Prefix = optarg; 100 break; 101 102 case 's': 103 SizePkg = optarg; 104 break; 105 106 case 'S': 107 SizeAll = optarg; 108 break; 109 110 case 'f': 111 Contents = optarg; 112 break; 113 114 case 'c': 115 Comment = optarg; 116 break; 117 118 case 'd': 119 Desc = optarg; 120 break; 121 122 case 'g': 123 DefaultGroup = optarg; 124 break; 125 126 case 'i': 127 Install = optarg; 128 break; 129 130 case 'K': 131 pkgdb_set_dir(optarg, 3); 132 break; 133 134 case 'k': 135 DeInstall = optarg; 136 break; 137 138 case 'l': 139 RelativeLinks = 1; 140 break; 141 142 case 'L': 143 warnx("Obsolete -L option ignored"); 144 break; 145 146 case 'u': 147 DefaultOwner = optarg; 148 break; 149 150 case 'D': 151 Display = optarg; 152 break; 153 154 case 'n': 155 Preserve = optarg; 156 break; 157 158 case 'P': 159 Pkgdeps = optarg; 160 break; 161 162 case 'T': 163 BuildPkgdeps = optarg; 164 break; 165 166 case 'C': 167 Pkgcfl = optarg; 168 break; 169 170 case 'b': 171 BuildVersion = optarg; 172 break; 173 174 case 'B': 175 BuildInfo = optarg; 176 break; 177 178 case 'V': 179 show_version(); 180 /* NOTREACHED */ 181 182 case '?': 183 default: 184 usage(); 185 break; 186 } 187 188 argc -= optind; 189 argv += optind; 190 191 pkg_install_config(); 192 193 if (argc == 0) { 194 warnx("missing package name"); 195 usage(); 196 } 197 if (argc != 1) { 198 warnx("only one package name allowed"); 199 usage(); 200 } 201 202 if (pkg_perform(*argv)) 203 return 0; 204 if (Verbose) { 205 if (PlistOnly) 206 warnx("PLIST adjustment failed"); 207 else 208 warnx("package creation failed"); 209 } 210 return 1; 211 } 212