Home | History | Annotate | Line # | Download | only in create
main.c revision 1.1
      1 /*	$NetBSD: main.c,v 1.1 2008/09/30 19:00:26 joerg 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 #ifndef lint
     11 #if 0
     12 static const char *rcsid = "from FreeBSD Id: main.c,v 1.17 1997/10/08 07:46:23 charnier Exp";
     13 #else
     14 __RCSID("$NetBSD: main.c,v 1.1 2008/09/30 19:00:26 joerg Exp $");
     15 #endif
     16 #endif
     17 
     18 /*
     19  * FreeBSD install - a package for the installation and maintainance
     20  * of non-core utilities.
     21  *
     22  * Jordan K. Hubbard
     23  * 18 July 1993
     24  *
     25  * This is the create module.
     26  *
     27  */
     28 
     29 #if HAVE_ERR_H
     30 #include <err.h>
     31 #endif
     32 #include "lib.h"
     33 #include "create.h"
     34 
     35 static const char Options[] = "B:C:D:EFI:K:L:OP:RS:T:UVb:c:d:f:g:i:k:ln:p:r:s:u:v";
     36 
     37 char   *Prefix = NULL;
     38 char   *Comment = NULL;
     39 char   *Desc = NULL;
     40 char   *Display = NULL;
     41 char   *Install = NULL;
     42 char   *DeInstall = NULL;
     43 char   *Contents = NULL;
     44 char   *Pkgdeps = NULL;
     45 char   *BuildPkgdeps = NULL;
     46 char   *Pkgcfl = NULL;
     47 char   *BuildVersion = NULL;
     48 char   *BuildInfo = NULL;
     49 char   *SizePkg = NULL;
     50 char   *SizeAll = NULL;
     51 char   *Preserve = NULL;
     52 char   *SrcDir = NULL;
     53 char   *DefaultOwner = NULL;
     54 char   *DefaultGroup = NULL;
     55 char   *realprefix = NULL;
     56 char    PlayPen[MaxPathSize];
     57 size_t  PlayPenSize = sizeof(PlayPen);
     58 int	update_pkgdb = 1;
     59 int	create_views = 0;
     60 int     PlistOnly = 0;
     61 int     RelativeLinks = 0;
     62 int     ReorderDirs = 0;
     63 Boolean File2Pkg = FALSE;
     64 
     65 static void
     66 usage(void)
     67 {
     68 	fprintf(stderr,
     69 	    "usage: pkg_create [-ElORUVv] [-B build-info-file] [-b build-version-file]\n"
     70             "                  [-C cpkgs] [-D displayfile] [-I realprefix] [-i iscript]\n"
     71             "                  [-K pkg_dbdir] [-k dscript] [-L SrcDir]\n"
     72             "                  [-n preserve-file] [-P dpkgs] [-p prefix] [-r rscript]\n"
     73             "                  [-S size-all-file] [-s size-pkg-file]\n"
     74 	    "                  [-T buildpkgs] [-u owner] [-g group]\n"
     75             "                  -c comment -d description -f packlist\n"
     76             "                  pkg-name\n");
     77 	exit(1);
     78 }
     79 
     80 void
     81 cleanup(int in_signal)
     82 {
     83 }
     84 
     85 int
     86 main(int argc, char **argv)
     87 {
     88 	int     ch;
     89 
     90 	setprogname(argv[0]);
     91 	while ((ch = getopt(argc, argv, Options)) != -1)
     92 		switch (ch) {
     93 		case 'v':
     94 			Verbose = TRUE;
     95 			break;
     96 
     97 		case 'E':
     98 			create_views = 1;
     99 			break;
    100 
    101 		case 'I':
    102 			realprefix = optarg;
    103 			break;
    104 
    105 		case 'O':
    106 			PlistOnly = 1;
    107 			break;
    108 
    109 		case 'R':
    110 			ReorderDirs = 1;
    111 			break;
    112 
    113 		case 'U':
    114 			update_pkgdb = 0;
    115 			break;
    116 
    117 		case 'p':
    118 			Prefix = optarg;
    119 			break;
    120 
    121 		case 's':
    122 			SizePkg = optarg;
    123 			break;
    124 
    125 		case 'S':
    126 			SizeAll = optarg;
    127 			break;
    128 
    129 		case 'f':
    130 			Contents = optarg;
    131 			break;
    132 
    133 		case 'c':
    134 			Comment = optarg;
    135 			break;
    136 
    137 		case 'd':
    138 			Desc = optarg;
    139 			break;
    140 
    141 		case 'g':
    142 			DefaultGroup = optarg;
    143 			break;
    144 
    145 		case 'i':
    146 			Install = optarg;
    147 			break;
    148 
    149 		case 'K':
    150 			_pkgdb_setPKGDB_DIR(optarg);
    151 			break;
    152 
    153 		case 'k':
    154 			DeInstall = optarg;
    155 			break;
    156 
    157 		case 'l':
    158 			RelativeLinks = 1;
    159 			break;
    160 
    161 		case 'L':
    162 			SrcDir = optarg;
    163 			break;
    164 
    165 		case 'u':
    166 			DefaultOwner = optarg;
    167 			break;
    168 
    169 		case 'D':
    170 			Display = optarg;
    171 			break;
    172 
    173 		case 'n':
    174 			Preserve = optarg;
    175 			break;
    176 
    177 		case 'P':
    178 			Pkgdeps = optarg;
    179 			break;
    180 
    181 		case 'T':
    182 			BuildPkgdeps = optarg;
    183 			break;
    184 
    185 		case 'C':
    186 			Pkgcfl = optarg;
    187 			break;
    188 
    189 		case 'b':
    190 			BuildVersion = optarg;
    191 			break;
    192 
    193 		case 'B':
    194 			BuildInfo = optarg;
    195 			break;
    196 
    197 		case 'V':
    198 			show_version();
    199 			/* NOTREACHED */
    200 
    201 		case '?':
    202 		default:
    203 			usage();
    204 			break;
    205 		}
    206 
    207 	argc -= optind;
    208 	argv += optind;
    209 
    210 	if (argc == 0) {
    211 		warnx("missing package name");
    212 		usage();
    213 	}
    214 	if (argc != 1) {
    215 		warnx("only one package name allowed");
    216 		usage();
    217 	}
    218 
    219 	if (pkg_perform(*argv))
    220 		return 0;
    221 	if (Verbose) {
    222 		if (PlistOnly)
    223 			warnx("package registration failed");
    224 		else
    225 			warnx("package creation failed");
    226 	}
    227 	return 1;
    228 }
    229