1*9781SMoriah.Waterland@Sun.COM /* 2*9781SMoriah.Waterland@Sun.COM * CDDL HEADER START 3*9781SMoriah.Waterland@Sun.COM * 4*9781SMoriah.Waterland@Sun.COM * The contents of this file are subject to the terms of the 5*9781SMoriah.Waterland@Sun.COM * Common Development and Distribution License (the "License"). 6*9781SMoriah.Waterland@Sun.COM * You may not use this file except in compliance with the License. 7*9781SMoriah.Waterland@Sun.COM * 8*9781SMoriah.Waterland@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*9781SMoriah.Waterland@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*9781SMoriah.Waterland@Sun.COM * See the License for the specific language governing permissions 11*9781SMoriah.Waterland@Sun.COM * and limitations under the License. 12*9781SMoriah.Waterland@Sun.COM * 13*9781SMoriah.Waterland@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*9781SMoriah.Waterland@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*9781SMoriah.Waterland@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*9781SMoriah.Waterland@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*9781SMoriah.Waterland@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*9781SMoriah.Waterland@Sun.COM * 19*9781SMoriah.Waterland@Sun.COM * CDDL HEADER END 20*9781SMoriah.Waterland@Sun.COM */ 21*9781SMoriah.Waterland@Sun.COM 22*9781SMoriah.Waterland@Sun.COM /* 23*9781SMoriah.Waterland@Sun.COM * Copyright 1993 Sun Microsystems, Inc. All rights reserved. 24*9781SMoriah.Waterland@Sun.COM * Use is subject to license terms. 25*9781SMoriah.Waterland@Sun.COM */ 26*9781SMoriah.Waterland@Sun.COM 27*9781SMoriah.Waterland@Sun.COM /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*9781SMoriah.Waterland@Sun.COM /* All Rights Reserved */ 29*9781SMoriah.Waterland@Sun.COM 30*9781SMoriah.Waterland@Sun.COM 31*9781SMoriah.Waterland@Sun.COM #include <stdio.h> 32*9781SMoriah.Waterland@Sun.COM #include <sys/types.h> 33*9781SMoriah.Waterland@Sun.COM #include <sys/stat.h> 34*9781SMoriah.Waterland@Sun.COM #include <string.h> 35*9781SMoriah.Waterland@Sun.COM #include <limits.h> 36*9781SMoriah.Waterland@Sun.COM #include <stdlib.h> 37*9781SMoriah.Waterland@Sun.COM #include <unistd.h> 38*9781SMoriah.Waterland@Sun.COM #include <pkglocs.h> 39*9781SMoriah.Waterland@Sun.COM #include <locale.h> 40*9781SMoriah.Waterland@Sun.COM #include <libintl.h> 41*9781SMoriah.Waterland@Sun.COM #include <pkglib.h> 42*9781SMoriah.Waterland@Sun.COM #include "libadm.h" 43*9781SMoriah.Waterland@Sun.COM 44*9781SMoriah.Waterland@Sun.COM extern char *pkgname, pkgloc[]; 45*9781SMoriah.Waterland@Sun.COM extern int warnflag; 46*9781SMoriah.Waterland@Sun.COM 47*9781SMoriah.Waterland@Sun.COM #define ERR_RMLINK "unable to remove options file <%s>" 48*9781SMoriah.Waterland@Sun.COM #define ERR_SYMLINK "unable to create symbloic link from <%s> to <%s>" 49*9781SMoriah.Waterland@Sun.COM #define ERR_PREDEPEND "unable to create predepend file <%s>" 50*9781SMoriah.Waterland@Sun.COM 51*9781SMoriah.Waterland@Sun.COM void 52*9781SMoriah.Waterland@Sun.COM predepend(char *oldpkg) 53*9781SMoriah.Waterland@Sun.COM { 54*9781SMoriah.Waterland@Sun.COM FILE *fp; 55*9781SMoriah.Waterland@Sun.COM char path[PATH_MAX]; 56*9781SMoriah.Waterland@Sun.COM char spath[PATH_MAX]; 57*9781SMoriah.Waterland@Sun.COM struct stat statbuf; 58*9781SMoriah.Waterland@Sun.COM 59*9781SMoriah.Waterland@Sun.COM oldpkg = strtok(oldpkg, " \t\n"); 60*9781SMoriah.Waterland@Sun.COM if (oldpkg == NULL) 61*9781SMoriah.Waterland@Sun.COM return; 62*9781SMoriah.Waterland@Sun.COM 63*9781SMoriah.Waterland@Sun.COM (void) sprintf(path, "%s/predepend", pkgloc); 64*9781SMoriah.Waterland@Sun.COM if ((fp = fopen(path, "w")) == NULL) { 65*9781SMoriah.Waterland@Sun.COM progerr(gettext(ERR_PREDEPEND), path); 66*9781SMoriah.Waterland@Sun.COM warnflag++; 67*9781SMoriah.Waterland@Sun.COM return; 68*9781SMoriah.Waterland@Sun.COM } 69*9781SMoriah.Waterland@Sun.COM (void) fprintf(fp, "%s\n", pkgname); 70*9781SMoriah.Waterland@Sun.COM (void) fclose(fp); 71*9781SMoriah.Waterland@Sun.COM 72*9781SMoriah.Waterland@Sun.COM do { 73*9781SMoriah.Waterland@Sun.COM (void) sprintf(spath, "%s/%s.name", get_PKGOLD(), oldpkg); 74*9781SMoriah.Waterland@Sun.COM if (lstat(spath, &statbuf) == 0) { 75*9781SMoriah.Waterland@Sun.COM /* options file already exists */ 76*9781SMoriah.Waterland@Sun.COM if (statbuf.st_mode & S_IFLNK) { 77*9781SMoriah.Waterland@Sun.COM /* remove current link */ 78*9781SMoriah.Waterland@Sun.COM if (unlink(spath)) { 79*9781SMoriah.Waterland@Sun.COM progerr(gettext(ERR_RMLINK), spath); 80*9781SMoriah.Waterland@Sun.COM warnflag++; 81*9781SMoriah.Waterland@Sun.COM } 82*9781SMoriah.Waterland@Sun.COM } 83*9781SMoriah.Waterland@Sun.COM } 84*9781SMoriah.Waterland@Sun.COM if (symlink(path, spath)) { 85*9781SMoriah.Waterland@Sun.COM progerr(gettext(ERR_SYMLINK), path, spath); 86*9781SMoriah.Waterland@Sun.COM warnflag++; 87*9781SMoriah.Waterland@Sun.COM } 88*9781SMoriah.Waterland@Sun.COM } while (oldpkg = strtok(NULL, " \t\n")); 89*9781SMoriah.Waterland@Sun.COM } 90