usr/src/cmd/svr4pkg/pkgremove/main.c
author Gary Pennington <gary.pennington@oracle.com>
Wed, 30 Jun 2010 03:42:01 -0700
changeset 12734 76969fc28795
parent 9869 9bff8d14ecc3
permissions -rw-r--r--
6939693 zones no longer needs the inherit-pkg-dir property
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9781
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
     1
/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
     2
 * CDDL HEADER START
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
     3
 *
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
     7
 *
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    11
 * and limitations under the License.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    12
 *
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    18
 *
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    19
 * CDDL HEADER END
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    20
 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    21
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    22
/*
12734
76969fc28795 6939693 zones no longer needs the inherit-pkg-dir property
Gary Pennington <gary.pennington@oracle.com>
parents: 9869
diff changeset
    23
 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
9781
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    24
 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    25
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    26
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    27
/* All Rights Reserved */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    28
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    29
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    30
#include <stdio.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    31
#include <limits.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    32
#include <stdlib.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    33
#include <unistd.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    34
#include <string.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    35
#include <signal.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    36
#include <errno.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    37
#include <fcntl.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    38
#include <sys/stat.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    39
#include <sys/types.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    40
#include <pkgstrct.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    41
#include <pkginfo.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    42
#include <pkglocs.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    43
#include <locale.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    44
#include <libintl.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    45
#include <assert.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    46
#include <cfext.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    47
#include <instzones_api.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    48
#include <pkglib.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    49
#include <install.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    50
#include <libinst.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    51
#include <libadm.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    52
#include <messages.h>
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    53
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    54
struct cfent **eptlist;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    55
extern int	eptnum;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    56
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    57
extern char	*pkgdir;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    58
extern char	**environ;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    59
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    60
/* quit.c */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    61
extern sighdlrFunc_t	*quitGetTrapHandler(void);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    62
extern void		quitSetSilentExit(boolean_t a_silentExit);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    63
extern void		quitSetZoneName(char *a_zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    64
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    65
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    66
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    67
/* check.c */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    68
extern void	rcksetPreremoveCheck(boolean_t);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    69
extern void	rcksetZoneName(char *);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    70
extern int	rckpriv(void);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    71
extern int	rckdepend(void);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    72
extern int	rckrunlevel(void);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    73
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    74
/* predepend.c */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    75
extern void	predepend(char *oldpkg);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    76
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    77
/* delmap.c */
9869
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
    78
extern int delmap(int flag, char *pkginst, PKGserver *server, VFP_T **tfp);
9781
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    79
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    80
#define	DEFPATH		"/sbin:/usr/sbin:/usr/bin"
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    81
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    82
#ifdef	ALLOW_EXCEPTION_PKG_LIST
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    83
#define	SCRIPT	0	/* Tells exception_pkg() which pkg list to use */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    84
#define	LINK	1
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    85
#endif
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    86
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    87
#if !defined(TEXT_DOMAIN)	/* Should be defined by cc -D */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    88
#define	TEXT_DOMAIN "SYS_TEST"
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    89
#endif
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    90
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    91
/* This is the text for the "-O parent-zone-name=" option */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    92
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    93
#define	PARENTZONENAME	"parent-zone-name="
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    94
#define	PARENTZONENAME_LEN	((sizeof (PARENTZONENAME))-1)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    95
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    96
/* This is the text for the "-O parent-zone-type=" option */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    97
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    98
#define	PARENTZONETYPE	"parent-zone-type="
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
    99
#define	PARENTZONETYPE_LEN	((sizeof (PARENTZONETYPE))-1)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   100
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   101
struct	admin adm; 	/* holds info about installation admin */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   102
int	dreboot; 	/* non-zero if reboot required after installation */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   103
int	ireboot;	/* non-zero if immediate reboot required */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   104
int	failflag;	/* non-zero if fatal error has occurred */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   105
int	warnflag;	/* non-zero if non-fatal error has occurred */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   106
int	pkgverbose;	/* non-zero if verbose mode is selected */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   107
int	started;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   108
int	nocnflct = 0; 	/* pkgdbmerg needs this defined */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   109
int	nosetuid = 0; 	/* pkgdbmerg needs this defined */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   110
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   111
char	*pkginst; 	/* current package (source) instance to process */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   112
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   113
int	dbchg;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   114
char	*msgtext;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   115
char	pkgloc[PATH_MAX];
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   116
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   117
/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   118
 * The following variable is the name of the device to which stdin
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   119
 * is connected during execution of a procedure script. /dev/null is
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   120
 * correct for all ABI compliant packages. For non-ABI-compliant
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   121
 * packages, the '-o' command line switch changes this to /dev/tty
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   122
 * to allow user interaction during these scripts. -- JST
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   123
 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   124
static char 	*script_in = PROC_STDIN;	/* assume ABI compliance */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   125
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   126
static char	*client_mntdir; 	/* mount point for client's basedir */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   127
static char	pkgbin[PATH_MAX],
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   128
		rlockfile[PATH_MAX],
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   129
		*admnfile, 		/* file to use for installation admin */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   130
		*tmpdir; 		/* location to place temporary files */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   131
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   132
static boolean_t	path_valid(char *path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   133
static void		ckreturn(int retcode, char *msg);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   134
static void		rmclass(char *aclass, int rm_remote, char *a_zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   135
static void		usage(void);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   136
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   137
/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   138
 * Set by -O debug: debug output is enabled?
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   139
 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   140
static boolean_t	debugFlag = B_FALSE;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   141
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   142
/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   143
 * Set by -O preremovecheck: do remove dependency checking only
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   144
 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   145
static boolean_t	preremoveCheck = B_FALSE;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   146
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   147
/* Set by -O parent-zone-name= */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   148
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   149
static char		*parentZoneName = (char *)NULL;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   150
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   151
/* Set by -O parent-zone-type= */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   152
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   153
static char		*parentZoneType = (char *)NULL;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   154
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   155
static int	nointeract;	/* != 0 no interaction with user should occur */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   156
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   157
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   158
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   159
int
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   160
main(int argc, char *argv[])
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   161
{
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   162
	FILE		*fp;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   163
	char		*abi_comp_ptr;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   164
	char		*abi_sym_ptr;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   165
	char		*p;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   166
	char		*prog_full_name = NULL;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   167
	char		*pt;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   168
	char		*value;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   169
	char		*vfstab_file = NULL;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   170
	char		*zoneName = (char *)NULL;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   171
	char		cmdbin[PATH_MAX];
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   172
	char		param[MAX_PKG_PARAM_LENGTH];
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   173
	char		path[PATH_MAX];
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   174
	char		script[PATH_MAX];
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   175
	int		c;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   176
	int		err;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   177
	int		fd;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   178
	int		i;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   179
	int		map_client = 1;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   180
	int		n;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   181
	int		nodelete = 0; 	/* do not delete file or run scripts */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   182
	int		pkgrmremote = 0;	/* dont remove remote objects */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   183
	struct sigaction	nact;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   184
	struct sigaction	oact;
9869
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
   185
	PKGserver	pkgserver = NULL;
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
   186
	VFP_T		*tmpfp;
9781
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   187
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   188
	/* reset contents of all default paths */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   189
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   190
	(void) memset(cmdbin, '\0', sizeof (cmdbin));
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   191
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   192
	/* initialize locale environment */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   193
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   194
	(void) setlocale(LC_ALL, "");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   195
	(void) textdomain(TEXT_DOMAIN);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   196
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   197
	/* initialize program name */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   198
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   199
	prog_full_name = argv[0];
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   200
	(void) set_prog_name(argv[0]);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   201
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   202
	/* tell spmi zones interface how to access package output functions */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   203
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   204
	z_set_output_functions(echo, echoDebug, progerr);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   205
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   206
	/* exit if not root */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   207
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   208
	if (getuid()) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   209
		progerr(ERR_NOT_ROOT, get_prog_name());
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   210
		exit(1);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   211
		/* NOTREACHED */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   212
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   213
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   214
	/* Read PKG_INSTALL_ROOT from the environment, if it's there. */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   215
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   216
	if (!set_inst_root(getenv("PKG_INSTALL_ROOT"))) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   217
		progerr(ERR_ROOT_SET);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   218
		exit(1);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   219
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   220
9869
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
   221
	pkgserversetmode(DEFAULTMODE);
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
   222
9781
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   223
	/* parse command line options */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   224
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   225
	while ((c = getopt(argc, argv, "?Aa:b:FMN:nO:oR:V:vy")) != EOF) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   226
		switch (c) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   227
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   228
		 * Same as pkgrm: Allow admin to remove package objects from
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   229
		 * a shared area from a reference client.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   230
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   231
		case 'A':
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   232
		    pkgrmremote++;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   233
		    break;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   234
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   235
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   236
		 * Same as pkgrm: Use the installation
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   237
		 * administration file, admin, in place of the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   238
		 * default admin file. pkgrm first looks in the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   239
		 * current working directory for the administration
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   240
		 * file.  If the specified administration file is not
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   241
		 * in the current working directory, pkgrm looks in
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   242
		 * the /var/sadm/install/admin directory for the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   243
		 * administration file.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   244
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   245
		case 'a':
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   246
		    admnfile = flex_device(optarg, 0);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   247
		    break;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   248
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   249
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   250
		 * Same as pkgrm: location where package executables
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   251
		 * can be found - default is /usr/sadm/install/bin.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   252
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   253
		case 'b':
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   254
			if (!path_valid(optarg)) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   255
				progerr(ERR_PATH, optarg);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   256
				exit(1);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   257
			}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   258
			if (isdir(optarg) != 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   259
				char *p = strerror(errno);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   260
				progerr(ERR_CANNOT_USE_DIR, optarg, p);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   261
				exit(1);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   262
			}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   263
			(void) strlcpy(cmdbin, optarg, sizeof (cmdbin));
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   264
			break;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   265
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   266
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   267
		 * Same as pkgrm: suppresses the removal of any
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   268
		 * files and any class action scripts, and suppresses
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   269
		 * the running of any class action scripts.  The
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   270
		 * package files remain but the package looks like it
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   271
		 * is not installed. This is mainly for use by the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   272
		 * upgrade process.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   273
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   274
		case 'F':
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   275
		    nodelete++;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   276
		    break;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   277
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   278
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   279
		 * Same as pkgrm: Instruct pkgrm not to use the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   280
		 * $root_path/etc/vfstab file for determining the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   281
		 * client's mount points. This option assumes the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   282
		 * mount points are correct on the server and it
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   283
		 * behaves consistently with Solaris 2.5 and earlier
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   284
		 * releases.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   285
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   286
		case 'M':
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   287
		    map_client = 0;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   288
		    break;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   289
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   290
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   291
		 * Different from pkgrm: specify program name to use
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   292
		 * for messages.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   293
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   294
		case 'N':
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   295
		    (void) set_prog_name(optarg);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   296
		    break;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   297
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   298
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   299
		 * Same as pkgrm: package removal occurs in
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   300
		 * non-interactive mode.  Suppress output of the list of
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   301
		 * removed files. The default mode is interactive.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   302
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   303
		case 'n':
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   304
		    nointeract++;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   305
		    (void) echoSetFlag(B_FALSE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   306
		    break;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   307
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   308
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   309
		 * Almost same as pkgrm: the -O option allows the behavior
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   310
		 * of the package tools to be modified. Recognized options:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   311
		 * -> debug
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   312
		 * ---> enable debugging output
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   313
		 * -> preremovecheck
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   314
		 * ---> perform a "pre removal" check of the specified
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   315
		 * ---> package - suppress all regular output and cause a
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   316
		 * ---> series of one or more "name=value" pair format lines
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   317
		 * ---> to be output that describes the "removability" of
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   318
		 * ---> the specified package
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   319
		 * -> enable-hollow-package-support
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   320
		 * --> Enable hollow package support. When specified, for any
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   321
		 * --> package that has SUNW_PKG_HOLLOW=true:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   322
		 * --> Do not calculate and verify package size against target
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   323
		 * --> Do not run any package procedure or class action scripts
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   324
		 * --> Do not create or remove any target directories
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   325
		 * --> Do not perform any script locking
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   326
		 * --> Do not install or uninstall any components of any package
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   327
		 * --> Do not output any status or database update messages
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   328
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   329
		case 'O':
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   330
			for (p = strtok(optarg, ","); p != (char *)NULL;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   331
				p = strtok(NULL, ",")) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   332
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   333
				/* process debug option */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   334
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   335
				if (strcmp(p, "debug") == 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   336
					/* set debug flag/enable debug output */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   337
					debugFlag = B_TRUE;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   338
					(void) echoDebugSetFlag(debugFlag);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   339
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   340
					/* debug info on arguments to pkgadd */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   341
					for (n = 0; n < argc && argv[n]; n++) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   342
						echoDebug(DBG_ARG, n, argv[n]);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   343
					}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   344
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   345
					continue;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   346
				}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   347
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   348
				/* process enable-hollow-package-support opt */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   349
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   350
				if (strcmp(p,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   351
					"enable-hollow-package-support") == 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   352
					set_depend_pkginfo_DB(B_TRUE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   353
					continue;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   354
				}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   355
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   356
				/* process preremovecheck option */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   357
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   358
				if (strcmp(p, "preremovecheck") == 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   359
					preremoveCheck = B_TRUE;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   360
					nointeract++;	/* -n */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   361
					nodelete++;	/* -F */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   362
					quitSetSilentExit(B_TRUE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   363
					continue;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   364
				}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   365
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   366
				/* process addzonename option */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   367
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   368
				if (strcmp(p, "addzonename") == 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   369
					zoneName = z_get_zonename();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   370
					quitSetZoneName(zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   371
					continue;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   372
				}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   373
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   374
				/* process parent-zone-name option */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   375
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   376
				if (strncmp(p, PARENTZONENAME,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   377
						PARENTZONENAME_LEN) == 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   378
					parentZoneName = p+PARENTZONENAME_LEN;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   379
					continue;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   380
				}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   381
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   382
				/* process parent-zone-type option */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   383
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   384
				if (strncmp(p, PARENTZONETYPE,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   385
						PARENTZONETYPE_LEN) == 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   386
					parentZoneType = p+PARENTZONETYPE_LEN;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   387
					continue;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   388
				}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   389
9869
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
   390
				if (strncmp(p, PKGSERV_MODE,
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
   391
				    PKGSERV_MODE_LEN) == 0) {
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
   392
					pkgserversetmode(pkgparsemode(p +
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
   393
					    PKGSERV_MODE_LEN));
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
   394
					continue;
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
   395
				}
9781
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   396
				/* option not recognized - issue warning */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   397
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   398
				progerr(ERR_INVALID_O_OPTION, p);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   399
				continue;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   400
			}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   401
			break;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   402
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   403
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   404
		 * Different from pkgrm: This is an old non-ABI package
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   405
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   406
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   407
		case 'o':
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   408
		    script_in = PROC_XSTDIN;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   409
		    break;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   410
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   411
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   412
		 * Same as pkgrm: defines the full path name of a
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   413
		 * directory to use as the root_path.  All files,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   414
		 * including package system information files, are
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   415
		 * relocated to a directory tree starting in the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   416
		 * specified root_path.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   417
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   418
		case 'R':
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   419
		    if (!set_inst_root(optarg)) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   420
			    progerr(ERR_ROOT_CMD);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   421
			    exit(1);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   422
		    }
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   423
		    break;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   424
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   425
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   426
		 * Same as pkgrm: allow admin to establish the client
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   427
		 * filesystem using a vfstab-like file of stable format.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   428
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   429
		case 'V':
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   430
		    vfstab_file = flex_device(optarg, 2);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   431
		    map_client = 1;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   432
		    break;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   433
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   434
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   435
		 * Same as pkgrm: trace all of the scripts that
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   436
		 * get executed by pkgrm, located in the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   437
		 * pkginst/install directory. This option is used for
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   438
		 * debugging the procedural and non-procedural
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   439
		 * scripts.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   440
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   441
		case 'v':
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   442
		    pkgverbose++;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   443
		    break;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   444
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   445
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   446
		 * Different from pkgrm: process this package using
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   447
		 * old non-ABI symlinks
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   448
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   449
		case 'y':
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   450
		    set_nonABI_symlinks();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   451
		    break;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   452
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   453
		default:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   454
		    usage();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   455
		    /*NOTREACHED*/
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   456
		    /*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   457
		     * Although usage() calls a noreturn function,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   458
		     * needed to add return (1);  so that main() would
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   459
		     * pass compilation checks. The statement below
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   460
   		     * should never be executed.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   461
		     */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   462
		    return (1);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   463
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   464
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   465
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   466
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   467
	 * ********************************************************************
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   468
	 * validate command line options
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   469
	 * ********************************************************************
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   470
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   471
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   472
	(void) echoDebugSetFlag(debugFlag);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   473
	(void) log_set_verbose(debugFlag);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   474
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   475
	if (z_running_in_global_zone()) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   476
		echoDebug(DBG_ENTRY_IN_GZ, prog_full_name);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   477
	} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   478
		echoDebug(DBG_ENTRY_IN_LZ, prog_full_name, getzoneid(),
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   479
			z_get_zonename());
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   480
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   481
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   482
	/* establish cmdbin path */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   483
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   484
	if (cmdbin[0] == '\0') {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   485
		(void) strlcpy(cmdbin, PKGBIN, sizeof (cmdbin));
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   486
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   487
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   488
	/* Read the mount table */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   489
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   490
	if (get_mntinfo(map_client, vfstab_file)) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   491
		quit(99);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   492
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   493
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   494
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   495
	 * This function defines the standard /var/... directories used later
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   496
	 * to construct the paths to the various databases.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   497
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   498
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   499
	set_PKGpaths(get_inst_root());
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   500
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   501
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   502
	 * If this is being removed from a client whose /var filesystem is
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   503
	 * mounted in some odd way, remap the administrative paths to the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   504
	 * real filesystem. This could be avoided by simply mounting up the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   505
	 * client now; but we aren't yet to the point in the process where
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   506
	 * modification of the filesystem is permitted.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   507
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   508
	if (is_an_inst_root()) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   509
		int fsys_value;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   510
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   511
		fsys_value = fsys(get_PKGLOC());
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   512
		if (use_srvr_map_n(fsys_value))
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   513
			set_PKGLOC(server_map(get_PKGLOC(), fsys_value));
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   514
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   515
		fsys_value = fsys(get_PKGADM());
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   516
		if (use_srvr_map_n(fsys_value))
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   517
			set_PKGADM(server_map(get_PKGADM(), fsys_value));
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   518
	} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   519
		pkgrmremote = 0;	/* Makes no sense on local host. */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   520
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   521
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   522
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   523
	 * hook SIGINT and SIGHUP interrupts into quit.c's trap handler
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   524
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   525
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   526
	/* hold SIGINT/SIGHUP interrupts */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   527
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   528
	(void) sighold(SIGHUP);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   529
	(void) sighold(SIGINT);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   530
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   531
	/* connect quit.c:trap() to SIGINT */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   532
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   533
	nact.sa_handler = quitGetTrapHandler();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   534
	nact.sa_flags = SA_RESTART;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   535
	(void) sigemptyset(&nact.sa_mask);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   536
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   537
	(void) sigaction(SIGINT, &nact, &oact);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   538
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   539
	/* connect quit.c:trap() to SIGHUP */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   540
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   541
	nact.sa_handler = quitGetTrapHandler();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   542
	nact.sa_flags = SA_RESTART;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   543
	(void) sigemptyset(&nact.sa_mask);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   544
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   545
	(void) sigaction(SIGHUP, &nact, &oact);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   546
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   547
	/* release hold on signals */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   548
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   549
	(void) sigrelse(SIGHUP);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   550
	(void) sigrelse(SIGINT);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   551
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   552
	pkginst = argv[optind++];
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   553
	if (optind != argc) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   554
		usage();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   555
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   556
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   557
	/* validate package software database (contents) file */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   558
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   559
	if (vcfile() == 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   560
		quit(99);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   561
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   562
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   563
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   564
	 * Acquire the package lock - currently at "remove initialization"
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   565
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   566
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   567
	if (!lockinst(get_prog_name(), pkginst, "remove-initial")) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   568
		quit(99);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   569
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   570
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   571
	/* establish temporary directory to use */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   572
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   573
	tmpdir = getenv("TMPDIR");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   574
	if (tmpdir == NULL) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   575
		tmpdir = P_tmpdir;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   576
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   577
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   578
	echoDebug(DBG_PKGREMOVE_TMPDIR, tmpdir);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   579
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   580
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   581
	 * Initialize installation admin parameters by reading
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   582
	 * the adminfile.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   583
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   584
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   585
	echoDebug(DBG_PKGREMOVE_ADMINFILE, admnfile ? admnfile : "");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   586
	setadminFile(admnfile);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   587
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   588
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   589
	 * about to perform first operation that could be modified by the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   590
	 * preremove check option - if preremove check is selected (that is,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   591
	 * only gathering dependencies), then output a debug message to
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   592
	 * indicate that the check is beginning. Also turn echo() output
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   593
	 * off and set various other flags.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   594
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   595
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   596
	if (preremoveCheck == B_TRUE) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   597
		(void) echoSetFlag(B_FALSE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   598
		echoDebug(DBG_PKGREMOVE_PRERMCHK, pkginst ? pkginst : "",
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   599
			zoneName ? zoneName : "global");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   600
		rcksetPreremoveCheck(B_TRUE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   601
		rcksetZoneName(zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   602
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   603
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   604
	(void) snprintf(pkgloc, sizeof (pkgloc), "%s/%s", get_PKGLOC(),
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   605
			pkginst);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   606
	(void) snprintf(pkgbin, sizeof (pkgbin), "%s/install", pkgloc);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   607
	(void) snprintf(rlockfile, sizeof (rlockfile), "%s/!R-Lock!", pkgloc);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   608
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   609
	if (chdir(pkgbin)) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   610
		progerr(ERR_CHDIR, pkgbin);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   611
		quit(99);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   612
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   613
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   614
	echo(MSG_PREREMOVE_REMINST, pkginst);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   615
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   616
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   617
	 * if a lock file is present, then a previous attempt to remove this
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   618
	 * package may have been unsuccessful.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   619
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   620
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   621
	if (access(rlockfile, F_OK) == 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   622
		echo(ERR_UNSUCC);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   623
		echoDebug(DBG_PKGINSTALL_HAS_LOCKFILE, pkginst, rlockfile,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   624
			zoneName ? zoneName : "global");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   625
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   626
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   627
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   628
	 * Process all parameters from the pkginfo file
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   629
	 * and place them in the execution environment
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   630
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   631
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   632
	/* Add DB retreival of the pkginfo parameters here */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   633
	(void) snprintf(path, sizeof (path), "%s/pkginfo", pkgloc);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   634
	if ((fp = fopen(path, "r")) == NULL) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   635
		progerr(ERR_PKGINFO, path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   636
		quit(99);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   637
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   638
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   639
	/* Mount up the client if necessary. */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   640
	if (map_client && !mount_client()) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   641
		logerr(MSG_MANMOUNT);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   642
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   643
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   644
	/* Get mount point of client */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   645
	client_mntdir = getenv("CLIENT_MNTDIR");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   646
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   647
	getuserlocale();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   648
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   649
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   650
	 * current environment has been read; clear environment out
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   651
	 * so putparam() can be used to populate the new environment
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   652
	 * to be passed to any executables/scripts.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   653
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   654
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   655
	environ = NULL;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   656
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   657
	if (nonABI_symlinks()) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   658
		putparam("PKG_NONABI_SYMLINKS", "TRUE");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   659
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   660
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   661
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   662
	 * read the pkginfo file and fix any PKGSAV path - the correct
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   663
	 * install_root will be prepended to the existing path.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   664
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   665
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   666
	param[0] = '\0';
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   667
	while (value = fpkgparam(fp, param)) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   668
		int validx = 0;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   669
		char *newvalue;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   670
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   671
		/* strip out any setting of PATH */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   672
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   673
		if (strcmp(param, "PATH") == 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   674
			free(value);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   675
			param[0] = '\0';
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   676
			continue;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   677
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   678
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   679
		/* if not PKGSAV then write out unchanged */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   680
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   681
		if (strcmp(param, "PKGSAV") != 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   682
			putparam(param, value);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   683
			free(value);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   684
			param[0] = '\0';
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   685
			continue;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   686
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   687
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   688
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   689
		 * PKGSAV parameter found - interpret the directory:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   690
		 * If in host:path format or marked with the leading "//",
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   691
		 * then there is no client-relative translation - take it
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   692
		 * literally later rather than use fixpath().
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   693
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   694
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   695
		if (strstr(value, ":/")) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   696
			/* no modification needed */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   697
			validx = 0;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   698
		} else if (strstr(value, "//") == value) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   699
			validx = 1;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   700
		} else if (is_an_inst_root()) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   701
			/* This PKGSAV needs to be made client-relative. */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   702
			newvalue = fixpath(value);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   703
			free(value);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   704
			value = newvalue;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   705
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   706
		putparam(param, value+validx);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   707
		free(value);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   708
		param[0] = '\0';
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   709
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   710
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   711
	(void) fclose(fp);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   712
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   713
	/* write parent condition information to environment */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   714
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   715
	putConditionInfo(parentZoneName, parentZoneType);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   716
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   717
	putuserlocale();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   718
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   719
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   720
	 * Now do all the various setups based on ABI compliance
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   721
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   722
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   723
	/* Read the environment provided by the pkginfo file */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   724
	abi_comp_ptr = getenv("NONABI_SCRIPTS");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   725
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   726
	/* if not ABI compliant set global flag */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   727
	abi_sym_ptr = getenv("PKG_NONABI_SYMLINKS");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   728
	if (abi_sym_ptr && strncasecmp(abi_sym_ptr, "TRUE", 4) == 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   729
		set_nonABI_symlinks();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   730
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   731
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   732
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   733
	 * If pkginfo says it's not compliant then set non_abi_scripts.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   734
	 * Oh, for two releases, set it from exception package names as
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   735
	 * well.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   736
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   737
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   738
	 * *********************************************************************
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   739
	 * this feature is removed starting with Solaris 10 - there is no built
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   740
	 * in list of packages that should be run "the old way"
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   741
	 * *********************************************************************
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   742
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   743
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   744
#ifdef	ALLOW_EXCEPTION_PKG_LIST
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   745
	if (exception_pkg(pkginst, SCRIPT) ||
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   746
	    (abi_comp_ptr && strncmp(abi_comp_ptr, "TRUE", 4) == 0))
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   747
		script_in = PROC_XSTDIN;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   748
#else
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   749
	if (abi_comp_ptr && strncmp(abi_comp_ptr, "TRUE", 4) == 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   750
		script_in = PROC_XSTDIN;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   751
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   752
#endif
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   753
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   754
	 * *********************************************************************
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   755
	 * this feature is removed starting with Solaris 10 - there is no built
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   756
	 * in list of packages that should be run "the old way"
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   757
	 * *********************************************************************
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   758
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   759
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   760
#ifdef	ALLOW_EXCEPTION_PKG_LIST
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   761
	/* Until 2.9, set it from the execption list */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   762
	if (exception_pkg(pkginst, LINK)) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   763
		set_nonABI_symlinks();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   764
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   765
#endif
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   766
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   767
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   768
	 * Since this is a removal, we can tell whether it's absolute or
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   769
	 * not from the resident pkginfo file read above.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   770
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   771
	if ((err = set_basedirs((getenv("BASEDIR") != NULL), adm.basedir,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   772
	    pkginst, nointeract)) != 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   773
		quit(err);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   774
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   775
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   776
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   777
	 * See if were are removing a package that only wants to update
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   778
	 * the database or only remove files associated with CAS's. We
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   779
	 * only check the PKG_HOLLOW_VARIABLE variable if told to do so by
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   780
	 * the caller.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   781
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   782
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   783
	if (is_depend_pkginfo_DB()) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   784
		pt = getenv(PKG_HOLLOW_VARIABLE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   785
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   786
		if ((pt != NULL) && (strncasecmp(pt, "true", 4) == 0)) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   787
			echoDebug(DBG_PKGREMOVE_HOLLOW_ENABLED);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   788
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   789
			/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   790
			 * this is a hollow package and hollow package support
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   791
			 * is enabled -- override admin settings to suppress
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   792
			 * checks that do not make sense since no scripts will
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   793
			 * be executed and no files will be removed.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   794
			 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   795
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   796
			setadminSetting("conflict", "nocheck");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   797
			setadminSetting("setuid", "nocheck");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   798
			setadminSetting("action", "nocheck");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   799
			setadminSetting("partial", "nocheck");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   800
			setadminSetting("space", "nocheck");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   801
			setadminSetting("authentication", "nocheck");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   802
		} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   803
			echoDebug(DBG_PKGREMOVE_HOLLOW_DISABLED);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   804
			set_depend_pkginfo_DB(B_FALSE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   805
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   806
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   807
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   808
	put_path_params();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   809
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   810
	/* If client mount point, add it to pkgremove environment */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   811
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   812
	if (client_mntdir != NULL) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   813
		putparam("CLIENT_MNTDIR", client_mntdir);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   814
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   815
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   816
	/* Establish the class list and the class attributes. */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   817
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   818
	if ((value = getenv("CLASSES")) != NULL) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   819
		cl_sets(qstrdup(value));
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   820
	} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   821
		progerr(ERR_CLASSES, path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   822
		quit(99);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   823
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   824
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   825
	/* establish path and tmpdir */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   826
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   827
	if (cmdbin[0] == '\0') {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   828
		(void) strlcpy(cmdbin, PKGBIN, sizeof (cmdbin));
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   829
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   830
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   831
	(void) snprintf(path, sizeof (path), "%s:%s", DEFPATH, cmdbin);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   832
	putparam("PATH", path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   833
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   834
	putparam("TMPDIR", tmpdir);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   835
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   836
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   837
	 * Check ulimit requirement (provided in pkginfo). The purpose of
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   838
	 * this limit is to terminate pathological file growth resulting from
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   839
	 * file edits in scripts. It does not apply to files in the pkgmap
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   840
	 * and it does not apply to any database files manipulated by the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   841
	 * installation service.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   842
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   843
	if (value = getenv("ULIMIT")) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   844
		if (assign_ulimit(value) == -1) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   845
			progerr(ERR_BADULIMIT, value);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   846
			warnflag++;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   847
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   848
		putparam("PKG_ULIMIT", "TRUE");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   849
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   850
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   851
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   852
	 * If only gathering dependencies, check and output status of all
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   853
	 * remaining dependencies and exit.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   854
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   855
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   856
	if (preremoveCheck == B_TRUE) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   857
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   858
		 * make sure current runlevel is appropriate
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   859
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   860
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   861
		(void) fprintf(stdout, "rckrunlevel=%d\n", rckrunlevel());
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   862
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   863
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   864
		 * determine if any packaging scripts provided with
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   865
		 * this package will execute as a priviledged user
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   866
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   867
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   868
		(void) fprintf(stdout, "rckpriv=%d\n", rckpriv());
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   869
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   870
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   871
		 * verify package dependencies
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   872
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   873
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   874
		(void) fprintf(stdout, "rckdepend=%d\n", rckdepend());
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   875
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   876
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   877
		 * ****** preremove check done - exit ******
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   878
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   879
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   880
		echoDebug(DBG_PKGREMOVE_PRERMCHK_OK);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   881
		quit(0);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   882
		/*NOTREACHED*/
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   883
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   884
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   885
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   886
	 * Not gathering dependencies only, proceed to check dependencies
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   887
	 * and continue with the package removal operation.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   888
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   889
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   890
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   891
	 * make sure current runlevel is appropriate
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   892
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   893
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   894
	n = rckrunlevel();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   895
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   896
	if (n != 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   897
		quit(n);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   898
		/* NOTREACHED */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   899
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   900
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   901
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   902
	 * determine if any packaging scripts provided with
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   903
	 * this package will execute as a priviledged user
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   904
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   905
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   906
	n = rckpriv();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   907
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   908
	if (n != 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   909
		quit(n);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   910
		/* NOTREACHED */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   911
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   912
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   913
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   914
	 * verify package dependencies
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   915
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   916
	n = rckdepend();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   917
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   918
	if (n != 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   919
		quit(n);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   920
		/* NOTREACHED */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   921
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   922
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   923
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   924
	 * *********************************************************************
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   925
	 * the actual removal of the package begins here
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   926
	 * *********************************************************************
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   927
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   928
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   929
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   930
	 * create lockfile to indicate start of removal
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   931
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   932
	started++;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   933
	if ((fd = open(rlockfile, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   934
		progerr(ERR_LOCKFILE, rlockfile);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   935
		quit(99);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   936
	} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   937
		(void) close(fd);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   938
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   939
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   940
	if (zoneName == (char *)NULL) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   941
		echo(MSG_PKGREMOVE_PROCPKG_GZ);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   942
		echoDebug(DBG_PKGREMOVE_PROCPKG_GZ, pkginst, rlockfile);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   943
	} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   944
		echo(MSG_PKGREMOVE_PROCPKG_LZ, zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   945
		echoDebug(DBG_PKGREMOVE_PROCPKG_LZ, pkginst, rlockfile,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   946
			zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   947
	}
9869
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
   948
	if (delmap(0, pkginst, &pkgserver, &tmpfp) != 0) {
9781
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   949
		progerr(ERR_DB_QUERY, pkginst);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   950
		quit(99);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   951
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   952
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   953
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   954
	 * Run a preremove script if one is provided by the package.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   955
	 * Don't execute preremove script if only updating the DB.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   956
	 * Don't execute preremove script if files are not being deleted.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   957
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   958
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   959
	/* update the lock - at the preremove script */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   960
	lockupd("preremove");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   961
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   962
	/* execute preremove script if one is provided */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   963
	(void) snprintf(script, sizeof (script), "%s/preremove", pkgbin);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   964
	if (access(script, F_OK) != 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   965
		/* no script present */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   966
		echoDebug(DBG_PKGREMOVE_POC_NONE, pkginst,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   967
			zoneName ? zoneName : "global");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   968
	} else if (nodelete) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   969
		/* not deleting files: skip preremove script */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   970
		echoDebug(DBG_PKGREMOVE_POC_NODEL, pkginst, script,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   971
			zoneName ? zoneName : "global");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   972
	} else if (is_depend_pkginfo_DB()) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   973
		/* updating db only: skip preremove script */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   974
		echoDebug(DBG_PKGREMOVE_POC_DBUPD, pkginst, script,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   975
			zoneName ? zoneName : "global");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   976
	} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   977
		/* script present and ok to run: run the script */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   978
		set_ulimit("preremove", ERR_PREREMOVE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   979
		if (zoneName == (char *)NULL) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   980
			echo(MSG_PKGREMOVE_EXEPOC_GZ);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   981
			echoDebug(DBG_PKGREMOVE_EXEPOC_GZ, pkginst, script);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   982
		} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   983
			echo(MSG_PKGREMOVE_EXEPOC_LZ, zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   984
			echoDebug(DBG_PKGREMOVE_EXEPOC_LZ, pkginst, script,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   985
				zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   986
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   987
		putparam("PKG_PROC_SCRIPT", "preremove");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   988
		if (pkgverbose) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   989
			ckreturn(pkgexecl(script_in, PROC_STDOUT,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   990
				PROC_USER, PROC_GRP, SHELL, "-x",
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   991
				script, NULL), ERR_PREREMOVE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   992
		} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   993
			ckreturn(pkgexecl(script_in, PROC_STDOUT,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   994
				PROC_USER, PROC_GRP, SHELL, script,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   995
				NULL), ERR_PREREMOVE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   996
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   997
		clr_ulimit();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   998
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
   999
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1000
	/* update the lock - doing removal */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1001
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1002
	lockupd("remove");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1003
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1004
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1005
	 * Ensure that the contents file is updated even if the db has
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1006
	 * been upgraded, in the case that there are relevant entries
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1007
	 * in a special_contents file.  The return value is ignored
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1008
	 * since we do not want special_contents operation to prevent
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1009
	 * pkgremove from succeeding.  We do report errors to stderr.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1010
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1011
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1012
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1013
	 * Remove all components belonging to this package.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1014
	 * Don't remove components if only updating the DB.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1015
	 * Don't remove components if files are not being deleted.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1016
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1017
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1018
	if (nodelete) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1019
		echoDebug(DBG_PKGREMOVE_REM_NODEL, pkginst,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1020
			zoneName ? zoneName : "global");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1021
	} else if (is_depend_pkginfo_DB()) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1022
		echoDebug(DBG_PKGREMOVE_REM_DBUPD, pkginst,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1023
			zoneName ? zoneName : "global");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1024
	} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1025
		echoDebug(DBG_PKGREMOVE_REM, pkginst,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1026
			zoneName ? zoneName : "global");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1027
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1028
		 * remove package one class at a time
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1029
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1030
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1031
		/* reverse order of classes */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1032
		for (i = cl_getn() - 1; i >= 0; i--) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1033
			rmclass(cl_nam(i), pkgrmremote, zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1034
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1035
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1036
		rmclass(NULL, pkgrmremote, zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1037
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1038
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1039
	z_destroyMountTable();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1040
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1041
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1042
	 * Execute postremove script, if any
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1043
	 * Don't execute postremove script if only updating the DB.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1044
	 * Don't execute postremove script if files are not being deleted.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1045
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1046
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1047
	/* update the lock - at the postremove script */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1048
	lockupd("postremove");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1049
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1050
	/* execute postremove script if one is provided */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1051
	(void) snprintf(script, sizeof (script), "%s/postremove", pkgbin);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1052
	if (access(script, F_OK) != 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1053
		/* no script present */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1054
		echoDebug(DBG_PKGREMOVE_PIC_NONE, pkginst,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1055
			zoneName ? zoneName : "global");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1056
	} else if (nodelete) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1057
		/* not deleting files: skip postremove script */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1058
		echoDebug(DBG_PKGREMOVE_PIC_NODEL, pkginst, script,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1059
			zoneName ? zoneName : "global");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1060
	} else if (is_depend_pkginfo_DB()) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1061
		/* updating db only: skip postremove script */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1062
		echoDebug(DBG_PKGREMOVE_PIC_DBUPD, pkginst, script,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1063
			zoneName ? zoneName : "global");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1064
	} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1065
		/* script present and ok to run: run the script */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1066
		set_ulimit("postremove", ERR_POSTREMOVE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1067
		if (zoneName == (char *)NULL) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1068
			echo(MSG_PKGREMOVE_EXEPIC_GZ);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1069
			echoDebug(DBG_PKGREMOVE_EXEPIC_GZ, pkginst, script);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1070
		} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1071
			echo(MSG_PKGREMOVE_EXEPIC_LZ, zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1072
			echoDebug(DBG_PKGREMOVE_EXEPIC_LZ, pkginst, script,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1073
				zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1074
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1075
		putparam("PKG_PROC_SCRIPT", "postremove");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1076
		putparam("TMPDIR", tmpdir);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1077
		if (pkgverbose) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1078
			ckreturn(pkgexecl(script_in, PROC_STDOUT, PROC_USER,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1079
			    PROC_GRP, SHELL, "-x", script, NULL),
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1080
			    ERR_POSTREMOVE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1081
		} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1082
			ckreturn(pkgexecl(script_in, PROC_STDOUT, PROC_USER,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1083
			    PROC_GRP, SHELL, script, NULL),
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1084
			    ERR_POSTREMOVE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1085
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1086
		clr_ulimit();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1087
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1088
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1089
	if (zoneName == (char *)NULL) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1090
		echo(MSG_PKGREMOVE_UPDINF_GZ);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1091
	} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1092
		echo(MSG_PKGREMOVE_UPDINF_LZ, zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1093
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1094
9869
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
  1095
	if (delmap(1, pkginst, &pkgserver, &tmpfp) != 0) {
9781
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1096
		progerr(ERR_DB_QUERY, pkginst);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1097
		quit(99);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1098
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1099
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1100
	if (!warnflag && !failflag) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1101
		if (pt = getenv("PREDEPEND"))
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1102
			predepend(pt);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1103
		(void) chdir("/");
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1104
		if (rrmdir(pkgloc))
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1105
			warnflag++;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1106
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1107
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1108
	if ((z_running_in_global_zone() == B_TRUE) &&
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1109
		(pkgIsPkgInGzOnly(get_inst_root(), pkginst) == B_TRUE)) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1110
		boolean_t	b;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1111
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1112
		b = pkgRemovePackageFromGzonlyList(get_inst_root(), pkginst);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1113
		if (b == B_FALSE) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1114
			progerr(ERR_PKGREMOVE_GZONLY_REMOVE, pkginst);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1115
			ckreturn(1, NULL);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1116
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1117
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1118
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1119
	/* release the generic package lock */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1120
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1121
	(void) unlockinst();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1122
9869
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
  1123
	pkgcloseserver(pkgserver);
9bff8d14ecc3 PSARC 2009/173 Fasttrack for turbo-charging SVr4 packaging
Casper H.S. Dik <Casper.Dik@Sun.COM>
parents: 9781
diff changeset
  1124
9781
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1125
	quit(0);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1126
	/* LINTED: no return */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1127
}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1128
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1129
int
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1130
issymlink(char *path)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1131
{
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1132
	struct stat statbuf;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1133
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1134
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1135
	 * Obtain status of path; if symbolic link get link's status
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1136
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1137
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1138
	if (lstat(path, &statbuf) != 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1139
		return (1);	/* not symlink */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1140
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1141
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1142
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1143
	 * Status obtained - if symbolic link, return 0
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1144
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1145
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1146
	if ((statbuf.st_mode & S_IFMT) == S_IFLNK) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1147
		return (0);	/* is a symlink */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1148
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1149
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1150
	/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1151
	 * Not a symbolic link - return 1
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1152
	 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1153
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1154
	return (1);		/* not symlink */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1155
}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1156
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1157
static void
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1158
rmclass(char *aclass, int rm_remote, char *a_zoneName)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1159
{
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1160
	struct cfent	*ept;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1161
	FILE	*fp;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1162
	char	tmpfile[PATH_MAX];
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1163
	char	script[PATH_MAX];
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1164
	int	i;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1165
	char	*tmp_path;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1166
	char	*save_path = NULL;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1167
	struct stat st;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1168
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1169
	if (aclass == NULL) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1170
		for (i = 0; i < eptnum; i++) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1171
			if (eptlist[i] != NULL) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1172
				rmclass(eptlist[i]->pkg_class,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1173
					rm_remote, a_zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1174
			}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1175
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1176
		return;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1177
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1178
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1179
	/* locate class action script to execute */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1180
	(void) snprintf(script, sizeof (script), "%s/r.%s", pkgbin, aclass);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1181
	if (access(script, F_OK) != 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1182
		(void) snprintf(script, sizeof (script), "%s/r.%s",
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1183
		    PKGSCR, aclass);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1184
		if (access(script, F_OK) != 0)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1185
			script[0] = '\0';
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1186
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1187
	if (script[0] != '\0') {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1188
		int td;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1189
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1190
		(void) snprintf(tmpfile, sizeof (tmpfile), "%s/RMLISTXXXXXX",
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1191
		    tmpdir);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1192
		td = mkstemp(tmpfile);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1193
		if (td == -1) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1194
			progerr(ERR_TMPFILE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1195
			quit(99);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1196
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1197
		if ((fp = fdopen(td, "w")) == NULL) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1198
			progerr(ERR_WTMPFILE, tmpfile);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1199
			quit(99);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1200
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1201
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1202
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1203
	if (a_zoneName == (char *)NULL) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1204
		echo(MSG_PKGREMOVE_REMPATHCLASS_GZ, aclass);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1205
	} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1206
		echo(MSG_PKGREMOVE_REMPATHCLASS_LZ, aclass, a_zoneName);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1207
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1208
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1209
	/* process paths in reverse order */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1210
	i = eptnum;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1211
	while (--i >= 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1212
		ept = eptlist[i];
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1213
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1214
		if ((ept == NULL) || strcmp(aclass, ept->pkg_class)) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1215
			continue;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1216
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1217
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1218
		/* save the path, and prepend the ir */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1219
		if (is_an_inst_root()) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1220
			save_path = ept->path;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1221
			tmp_path = fixpath(ept->path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1222
			ept->path = tmp_path;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1223
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1224
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1225
		if (!ept->ftype || (ept->ftype == '^' && !script[0])) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1226
			/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1227
			 * A path owned by more than one package is marked with
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1228
			 * a NULL ftype (seems odd, but that's how it's
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1229
			 * done). Such files are sacro sanct. Shared editable
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1230
			 * files are a special case, and are marked with an
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1231
			 * ftype of '^'. These files should only be ignored if
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1232
			 * no class action script is present. It is the CAS's
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1233
			 * responsibility to not remove the editable object.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1234
			 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1235
			echo(MSG_SHARED, ept->path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1236
		} else if (ept->pinfo->status == SERVED_FILE && !rm_remote) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1237
			/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1238
			 * If the path is provided to the client from a
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1239
			 * server, don't remove anything unless explicitly
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1240
			 * requested through the "-f" option.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1241
			 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1242
			echo(MSG_SERVER, ept->path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1243
		} else if (script[0]) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1244
			/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1245
			 * If there's a class action script, just put the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1246
			 * path name into the list.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1247
			 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1248
			(void) fprintf(fp, "%s\n", ept->path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1249
		} else if (strchr("dx", ept->ftype) != NULL ||
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1250
		    (lstat(ept->path, &st) == 0 && S_ISDIR(st.st_mode))) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1251
			/* Directories are rmdir()'d. */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1252
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1253
			if (rmdir(ept->path)) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1254
				if (errno == EBUSY) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1255
					echo(MSG_DIRBUSY, ept->path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1256
				} else if (errno == EEXIST) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1257
					echo(MSG_NOTEMPTY, ept->path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1258
				} else if (errno != ENOENT) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1259
					progerr(ERR_RMDIR, ept->path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1260
					warnflag++;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1261
				}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1262
			} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1263
				if (ept->pinfo->status == SERVED_FILE) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1264
					echo(MSG_RMSRVR, ept->path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1265
				} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1266
					echo("%s", ept->path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1267
				}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1268
			}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1269
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1270
		} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1271
			/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1272
			 * Before removing this object one more
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1273
			 * check should be done to assure that a
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1274
			 * shared object is not removed.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1275
			 * This can happen if the original object
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1276
			 * was incorrectly updated with the
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1277
			 * incorrect class identifier.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1278
			 * This handles pathologcal cases that
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1279
			 * weren't handled above.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1280
			 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1281
			if (ept->npkgs > 1) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1282
				echo(MSG_SHARED, ept->path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1283
				continue;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1284
			}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1285
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1286
			/* Regular files are unlink()'d. */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1287
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1288
			if (unlink(ept->path)) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1289
				if (errno != ENOENT) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1290
					progerr(ERR_RMPATH, ept->path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1291
					warnflag++;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1292
				}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1293
			} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1294
				if (ept->pinfo->status == SERVED_FILE) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1295
					echo(MSG_RMSRVR, ept->path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1296
				} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1297
					echo("%s", ept->path);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1298
				}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1299
			}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1300
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1301
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1302
		/* restore the original path */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1303
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1304
		if (is_an_inst_root()) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1305
			ept->path = save_path;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1306
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1307
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1308
		/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1309
		 * free memory allocated for this entry memory used for
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1310
		 * pathnames will be freed later by a call to pathdup()
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1311
		 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1312
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1313
		if (eptlist[i]) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1314
			free(eptlist[i]);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1315
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1316
		eptlist[i] = NULL;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1317
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1318
	if (script[0]) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1319
		(void) fclose(fp);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1320
		set_ulimit(script, ERR_CASFAIL);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1321
		if (pkgverbose)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1322
			ckreturn(pkgexecl(tmpfile, CAS_STDOUT, CAS_USER,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1323
			    CAS_GRP, SHELL, "-x", script, NULL),
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1324
			    ERR_CASFAIL);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1325
		else
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1326
			ckreturn(pkgexecl(tmpfile, CAS_STDOUT, CAS_USER,
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1327
			    CAS_GRP, SHELL, script, NULL),
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1328
			    ERR_CASFAIL);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1329
		clr_ulimit();
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1330
		if (isfile(NULL, tmpfile) == 0) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1331
			if (unlink(tmpfile) == -1)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1332
				progerr(ERR_RMPATH, tmpfile);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1333
		}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1334
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1335
}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1336
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1337
static void
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1338
ckreturn(int retcode, char *msg)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1339
{
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1340
	switch (retcode) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1341
	    case 2:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1342
	    case 12:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1343
	    case 22:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1344
		warnflag++;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1345
		/*FALLTHRU*/
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1346
		if (msg)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1347
			progerr(msg);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1348
	    case 10:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1349
	    case 20:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1350
		if (retcode >= 10)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1351
			dreboot++;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1352
		if (retcode >= 20)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1353
			ireboot++;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1354
		/*FALLTHRU*/
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1355
	    case 0:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1356
		break; /* okay */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1357
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1358
	    case -1:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1359
		retcode = 99;
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1360
		/*FALLTHRU*/
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1361
	    case 99:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1362
	    case 1:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1363
	    case 11:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1364
	    case 21:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1365
	    case 4:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1366
	    case 14:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1367
	    case 24:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1368
	    case 5:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1369
	    case 15:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1370
	    case 25:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1371
		if (msg)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1372
			progerr(msg);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1373
		/*FALLTHRU*/
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1374
	    case 3:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1375
	    case 13:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1376
	    case 23:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1377
		quit(retcode);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1378
		/* NOT REACHED */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1379
	    default:
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1380
		if (msg)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1381
			progerr(msg);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1382
		quit(1);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1383
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1384
}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1385
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1386
static void
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1387
usage(void)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1388
{
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1389
	(void) fprintf(stderr, ERR_USAGE_PKGREMOVE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1390
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1391
	exit(1);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1392
}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1393
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1394
/*
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1395
 * Name:		path_valid
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1396
 * Description:	Checks a string for being a valid path
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1397
 *
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1398
 * Arguments:	path - path to validate
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1399
 *
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1400
 * Returns :	B_TRUE - success, B_FALSE otherwise.
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1401
 *		B_FALSE means path was null, too long (>PATH_MAX),
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1402
 *		or too short (<1)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1403
 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1404
static boolean_t
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1405
path_valid(char *path)
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1406
{
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1407
	if (path == NULL) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1408
		return (B_FALSE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1409
	} else if (strlen(path) > PATH_MAX) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1410
		return (B_FALSE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1411
	} else if (strlen(path) >= 1) {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1412
		return (B_TRUE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1413
	} else {
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1414
		/* path < 1 */
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1415
		return (B_FALSE);
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1416
	}
ccf49524d5dc 6739234 move SVR4 packaging to ONNV gate
Moriah Waterland <Moriah.Waterland@Sun.COM>
parents:
diff changeset
  1417
}