main.c revision 30221
1327Sjkh#ifndef lint 230221Scharnierstatic const char rcsid[] = 330221Scharnier "$Id: main.c,v 1.10 1997/09/18 14:08:40 phk Exp $"; 4327Sjkh#endif 5327Sjkh 6327Sjkh/* 7327Sjkh * 8327Sjkh * FreeBSD install - a package for the installation and maintainance 9327Sjkh * of non-core utilities. 10327Sjkh * 11327Sjkh * Redistribution and use in source and binary forms, with or without 12327Sjkh * modification, are permitted provided that the following conditions 13327Sjkh * are met: 14327Sjkh * 1. Redistributions of source code must retain the above copyright 15327Sjkh * notice, this list of conditions and the following disclaimer. 16327Sjkh * 2. Redistributions in binary form must reproduce the above copyright 17327Sjkh * notice, this list of conditions and the following disclaimer in the 18327Sjkh * documentation and/or other materials provided with the distribution. 19327Sjkh * 20327Sjkh * Jordan K. Hubbard 21327Sjkh * 18 July 1993 22327Sjkh * 23327Sjkh * This is the delete module. 24327Sjkh * 25327Sjkh */ 26327Sjkh 2730221Scharnier#include <err.h> 28327Sjkh#include "lib.h" 29327Sjkh#include "delete.h" 30327Sjkh 314996Sjkhstatic char Options[] = "hvDdnfp:"; 32327Sjkh 33327Sjkhchar *Prefix = NULL; 34327SjkhBoolean NoDeInstall = FALSE; 354996SjkhBoolean CleanDirs = FALSE; 36327Sjkh 3730221Scharnierstatic void usage __P((void)); 3830221Scharnier 39327Sjkhint 40327Sjkhmain(int argc, char **argv) 41327Sjkh{ 424996Sjkh int ch, error; 43327Sjkh char **pkgs, **start; 44327Sjkh 45327Sjkh pkgs = start = argv; 4624428Simp while ((ch = getopt(argc, argv, Options)) != -1) 47327Sjkh switch(ch) { 48327Sjkh case 'v': 49327Sjkh Verbose = TRUE; 50327Sjkh break; 51327Sjkh 524996Sjkh case 'f': 534996Sjkh Force = TRUE; 544996Sjkh break; 554996Sjkh 56327Sjkh case 'p': 57327Sjkh Prefix = optarg; 58327Sjkh break; 59327Sjkh 60327Sjkh case 'D': 61327Sjkh NoDeInstall = TRUE; 62327Sjkh break; 63327Sjkh 644996Sjkh case 'd': 654996Sjkh CleanDirs = TRUE; 664996Sjkh break; 674996Sjkh 68327Sjkh case 'n': 69327Sjkh Fake = TRUE; 70327Sjkh Verbose = TRUE; 71327Sjkh break; 72327Sjkh 73327Sjkh case 'h': 74327Sjkh case '?': 75327Sjkh default: 7630221Scharnier usage(); 77327Sjkh break; 78327Sjkh } 79327Sjkh 808857Srgrimes argc -= optind; 81327Sjkh argv += optind; 82327Sjkh 83327Sjkh /* Get all the remaining package names, if any */ 84327Sjkh /* Get all the remaining package names, if any */ 85327Sjkh while (*argv) 86327Sjkh *pkgs++ = *argv++; 87327Sjkh 88327Sjkh /* If no packages, yelp */ 89327Sjkh if (pkgs == start) 9030221Scharnier warnx("missing package name(s)"), usage(); 91327Sjkh *pkgs = NULL; 924996Sjkh if (!Fake && getuid() != 0) 9330221Scharnier errx(1, "you must be root to delete packages"); 9429574Sphk if ((error = pkg_perform(start)) != 0) { 95327Sjkh if (Verbose) 9630221Scharnier warnx("%d package deletion(s) failed", error); 974996Sjkh return error; 98327Sjkh } 99327Sjkh else 100327Sjkh return 0; 101327Sjkh} 102327Sjkh 10330221Scharnierstatic void 10430221Scharnierusage() 105327Sjkh{ 10630221Scharnier fprintf(stderr, "usage: pkg_delete [-vDdnf] [-p prefix] pkg-name ...\n"); 107327Sjkh exit(1); 108327Sjkh} 109