main.c revision 379
117695Swosch#ifndef lint 217695Swoschstatic char *rcsid = "$Id: main.c,v 1.6 1993/09/04 05:06:28 jkh Exp $"; 317695Swosch#endif 417695Swosch 517695Swosch/* 617695Swosch * 717695Swosch * FreeBSD install - a package for the installation and maintainance 817695Swosch * of non-core utilities. 917695Swosch * 1017695Swosch * Redistribution and use in source and binary forms, with or without 1117695Swosch * modification, are permitted provided that the following conditions 1217695Swosch * are met: 1317695Swosch * 1. Redistributions of source code must retain the above copyright 1417695Swosch * notice, this list of conditions and the following disclaimer. 1517695Swosch * 2. Redistributions in binary form must reproduce the above copyright 1617695Swosch * notice, this list of conditions and the following disclaimer in the 1717695Swosch * documentation and/or other materials provided with the distribution. 1817695Swosch * 1917695Swosch * Jordan K. Hubbard 2017695Swosch * 18 July 1993 2117695Swosch * 2217695Swosch * This is the add module. 2317695Swosch * 2417695Swosch */ 2517695Swosch 2617695Swosch#include "lib.h" 2717695Swosch#include "add.h" 2817695Swosch 2917695Swoschstatic char Options[] = "hvIRnp:"; 3017695Swosch 3117695Swoschchar *Prefix = NULL; 3217695SwoschBoolean NoInstall = FALSE; 3317695SwoschBoolean NoRecord = FALSE; 3417695Swosch 3517695Swoschchar *Mode = NULL; 3617695Swoschchar *Owner = NULL; 3717695Swoschchar *Group = NULL; 3817695Swoschchar *PkgName = NULL; 3917695Swoschchar *Directory = NULL; 4017695Swosch 4117695Swoschint 4217695Swoschmain(int argc, char **argv) 4317695Swosch{ 4417695Swosch int ch, err; 4517695Swosch char **pkgs, **start; 4617695Swosch char *prog_name = argv[0]; 4717695Swosch 4817695Swosch pkgs = start = argv; 4917695Swosch while ((ch = getopt(argc, argv, Options)) != EOF) 5017695Swosch switch(ch) { 5117695Swosch case 'v': 5217695Swosch Verbose = TRUE; 5317695Swosch break; 5417695Swosch 5517695Swosch case 'p': 5617695Swosch Prefix = optarg; 5717695Swosch break; 5817695Swosch 5917695Swosch case 'I': 6017695Swosch NoInstall = TRUE; 6117695Swosch break; 6217695Swosch 6317695Swosch case 'R': 6417695Swosch NoRecord = TRUE; 6517695Swosch break; 6617695Swosch 6717695Swosch case 'n': 6817695Swosch Fake = TRUE; 6917695Swosch Verbose = TRUE; 7017695Swosch break; 7117695Swosch 7217695Swosch case 'h': 7317695Swosch case '?': 7417695Swosch default: 7517695Swosch usage(prog_name, NULL); 7617695Swosch break; 7717695Swosch } 7817695Swosch 7917695Swosch argc -= optind; 8017695Swosch argv += optind; 8117695Swosch 8217695Swosch /* Get all the remaining package names, if any */ 8317695Swosch while (*argv) 8417695Swosch *pkgs++ = *argv++; 8517695Swosch 8617695Swosch /* If no packages, yelp */ 8717695Swosch if (pkgs == start) 8817695Swosch usage(prog_name, "Missing package name(s)"); 8917695Swosch *pkgs = NULL; 9017695Swosch if ((err = pkg_perform(start)) != NULL) { 9117695Swosch if (Verbose) 9217695Swosch fprintf(stderr, "%d package addition(s) failed.\n", err); 9317695Swosch return err; 9418194Ssos } 9517695Swosch else 9617695Swosch return 0; 9717695Swosch} 9817695Swosch 9917695Swoschvoid 10017695Swoschusage(const char *name, const char *fmt, ...) 10117695Swosch{ 10217695Swosch va_list args; 10317695Swosch 10417695Swosch va_start(args, fmt); 10517695Swosch if (fmt) { 10617695Swosch fprintf(stderr, "%s: ", name); 10717695Swosch vfprintf(stderr, fmt, args); 10817695Swosch fprintf(stderr, "\n\n"); 10917695Swosch } 11017695Swosch va_end(args); 11117695Swosch fprintf(stderr, "Usage: %s [args] pkg [ .. pkg ]\n", name); 11217695Swosch fprintf(stderr, "Where args are one or more of:\n\n"); 113 fprintf(stderr, "-v verbose\n"); 114 fprintf(stderr, "-p arg override prefix with arg\n"); 115 fprintf(stderr, "-I don't execute pkg install script, if any\n"); 116 fprintf(stderr, "-R don't record installation (can't delete!)\n"); 117 fprintf(stderr, "-n don't actually install, just show steps\n"); 118 exit(1); 119} 120