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.
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.
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]
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
37 #include <sys/types.h>
47 extern struct admin adm
;
49 extern char pkgloc
[], *pkginst
, *msgtext
;
51 static boolean_t preremoveCheck
= B_FALSE
;
52 static char *zoneName
= (char *)NULL
;
56 rcksetPreremoveCheck(boolean_t a_preremoveCheck
)
58 preremoveCheck
= a_preremoveCheck
;
62 rcksetZoneName(char *a_zoneName
)
64 zoneName
= a_zoneName
;
78 if (ADM(runlevel
, "nocheck")) {
82 pt
= getenv("RSTATES");
87 utmpx
.ut_type
= RUN_LVL
;
88 putmpx
= getutxid(&utmpx
);
90 progerr(ERR_RUNSTATE
);
93 uxstate
= strtok(&putmpx
->ut_line
[10], " \t\n");
95 rstates
= qstrdup(pt
);
96 if ((pt
= strtok(pt
, " \t\n, ")) == NULL
)
97 return (0); /* no list is no list */
99 if (strcmp(pt
, uxstate
) == NULL
) {
103 } while (pt
= strtok(NULL
, " \t\n, "));
105 if (preremoveCheck
== B_FALSE
) {
106 msgtext
= MSG_PKGREMOVE_RUNLEVEL
;
107 ptext(stderr
, msgtext
, uxstate
);
109 (void) fprintf(stdout
, "runlevel=%s", uxstate
);
112 pt
= strtok(rstates
, " \t\n, ");
114 if (preremoveCheck
== B_FALSE
) {
115 ptext(stderr
, "\\t%s", pt
);
117 (void) fprintf(stdout
, ":%s", pt
);
119 } while (pt
= strtok(NULL
, " \t\n, "));
121 if (preremoveCheck
== B_TRUE
) {
122 (void) fprintf(stdout
, "\n");
127 if (ADM(runlevel
, "quit")) {
131 if (echoGetFlag() == B_FALSE
) {
137 n
= ckyorn(ans
, NULL
, NULL
, HLP_PKGREMOVE_RUNLEVEL
,
138 ASK_PKGREMOVE_CONTINUE
);
144 if (strchr("yY", *ans
) == NULL
) {
158 if (ADM(rdepend
, "nocheck")) {
162 if (zoneName
== (char *)NULL
) {
163 echo(MSG_CHECKREMOVE_PKG_IN_GZ
, pkginst
);
165 echo(MSG_CHECKREMOVE_PKG_IN_ZONE
, pkginst
, zoneName
);
168 if (dockdeps(pkginst
, 1, preremoveCheck
)) {
169 msgtext
= MSG_PKGREMOVE_DEPEND
;
171 if (preremoveCheck
== B_FALSE
) {
175 if (ADM(rdepend
, "quit")) {
179 if (echoGetFlag() == B_FALSE
) {
185 n
= ckyorn(ans
, NULL
, NULL
, HLP_PKGREMOVE_DEPEND
,
186 ASK_PKGREMOVE_CONTINUE
);
192 if (strchr("yY", *ans
) == NULL
) {
210 if (ADM(action
, "nocheck")) {
214 (void) snprintf(path
, sizeof (path
), "%s/install", pkgloc
);
215 if ((dirfp
= opendir(path
)) == NULL
)
219 while ((dp
= readdir(dirfp
)) != NULL
) {
220 if ((strcmp(dp
->d_name
, "preremove") == NULL
) ||
221 (strcmp(dp
->d_name
, "postremove") == NULL
) ||
222 (strncmp(dp
->d_name
, "r.", 2) == NULL
)) {
227 (void) closedir(dirfp
);
230 if (preremoveCheck
== B_FALSE
) {
231 ptext(stderr
, MSG_PKGREMOVE_PRIV
);
233 msgtext
= MSG_PKGSCRIPTS_FOUND
;
235 if (ADM(action
, "quit")) {
239 if (echoGetFlag() == B_FALSE
) {
245 n
= ckyorn(ans
, NULL
, NULL
, HLP_PKGREMOVE_PRIV
,
246 ASK_PKGREMOVE_CONTINUE
);
252 if (strchr("yY", *ans
) == NULL
) {