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