1*5c51f124SMoriah Waterland /* 2*5c51f124SMoriah Waterland * CDDL HEADER START 3*5c51f124SMoriah Waterland * 4*5c51f124SMoriah Waterland * The contents of this file are subject to the terms of the 5*5c51f124SMoriah Waterland * Common Development and Distribution License (the "License"). 6*5c51f124SMoriah Waterland * You may not use this file except in compliance with the License. 7*5c51f124SMoriah Waterland * 8*5c51f124SMoriah Waterland * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*5c51f124SMoriah Waterland * or http://www.opensolaris.org/os/licensing. 10*5c51f124SMoriah Waterland * See the License for the specific language governing permissions 11*5c51f124SMoriah Waterland * and limitations under the License. 12*5c51f124SMoriah Waterland * 13*5c51f124SMoriah Waterland * When distributing Covered Code, include this CDDL HEADER in each 14*5c51f124SMoriah Waterland * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*5c51f124SMoriah Waterland * If applicable, add the following below this CDDL HEADER, with the 16*5c51f124SMoriah Waterland * fields enclosed by brackets "[]" replaced with your own identifying 17*5c51f124SMoriah Waterland * information: Portions Copyright [yyyy] [name of copyright owner] 18*5c51f124SMoriah Waterland * 19*5c51f124SMoriah Waterland * CDDL HEADER END 20*5c51f124SMoriah Waterland */ 21*5c51f124SMoriah Waterland 22*5c51f124SMoriah Waterland /* 23*5c51f124SMoriah Waterland * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24*5c51f124SMoriah Waterland * Use is subject to license terms. 25*5c51f124SMoriah Waterland */ 26*5c51f124SMoriah Waterland 27*5c51f124SMoriah Waterland /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*5c51f124SMoriah Waterland /* All Rights Reserved */ 29*5c51f124SMoriah Waterland 30*5c51f124SMoriah Waterland 31*5c51f124SMoriah Waterland #include <stdio.h> 32*5c51f124SMoriah Waterland #include <time.h> 33*5c51f124SMoriah Waterland #include <wait.h> 34*5c51f124SMoriah Waterland #include <stdlib.h> 35*5c51f124SMoriah Waterland #include <unistd.h> 36*5c51f124SMoriah Waterland #include <ulimit.h> 37*5c51f124SMoriah Waterland #include <sys/stat.h> 38*5c51f124SMoriah Waterland #include <sys/statvfs.h> 39*5c51f124SMoriah Waterland #include <fcntl.h> 40*5c51f124SMoriah Waterland #include <errno.h> 41*5c51f124SMoriah Waterland #include <ctype.h> 42*5c51f124SMoriah Waterland #include <dirent.h> 43*5c51f124SMoriah Waterland #include <string.h> 44*5c51f124SMoriah Waterland #include <signal.h> 45*5c51f124SMoriah Waterland #include <locale.h> 46*5c51f124SMoriah Waterland #include <libintl.h> 47*5c51f124SMoriah Waterland #include <pkgstrct.h> 48*5c51f124SMoriah Waterland #include <pkginfo.h> 49*5c51f124SMoriah Waterland #include <pkgdev.h> 50*5c51f124SMoriah Waterland #include <pkglocs.h> 51*5c51f124SMoriah Waterland #include <pwd.h> 52*5c51f124SMoriah Waterland #include <assert.h> 53*5c51f124SMoriah Waterland #include <instzones_api.h> 54*5c51f124SMoriah Waterland #include <pkglib.h> 55*5c51f124SMoriah Waterland #include <pkgweb.h> 56*5c51f124SMoriah Waterland #include <install.h> 57*5c51f124SMoriah Waterland #include <libinst.h> 58*5c51f124SMoriah Waterland #include <libadm.h> 59*5c51f124SMoriah Waterland #include <dryrun.h> 60*5c51f124SMoriah Waterland #include <messages.h> 61*5c51f124SMoriah Waterland #include "pkginstall.h" 62*5c51f124SMoriah Waterland 63*5c51f124SMoriah Waterland /* imported globals */ 64*5c51f124SMoriah Waterland 65*5c51f124SMoriah Waterland extern char **environ; 66*5c51f124SMoriah Waterland extern char *pkgabrv; 67*5c51f124SMoriah Waterland extern char *pkgname; 68*5c51f124SMoriah Waterland extern char *pkgarch; 69*5c51f124SMoriah Waterland extern char *pkgvers; 70*5c51f124SMoriah Waterland extern char pkgwild[]; 71*5c51f124SMoriah Waterland 72*5c51f124SMoriah Waterland /* libadm(3LIB) */ 73*5c51f124SMoriah Waterland 74*5c51f124SMoriah Waterland extern char *get_install_root(void); 75*5c51f124SMoriah Waterland 76*5c51f124SMoriah Waterland /* quit.c */ 77*5c51f124SMoriah Waterland 78*5c51f124SMoriah Waterland extern sighdlrFunc_t *quitGetTrapHandler(void); 79*5c51f124SMoriah Waterland extern void quitSetDstreamTmpdir(char *a_dstreamTempDir); 80*5c51f124SMoriah Waterland extern void quitSetInstallStarted(boolean_t a_installStarted); 81*5c51f124SMoriah Waterland extern void quitSetPkgask(boolean_t a_pkgaskFlag); 82*5c51f124SMoriah Waterland extern void quitSetSilentExit(boolean_t a_silentExit); 83*5c51f124SMoriah Waterland extern void quitSetUpdatingExisting(boolean_t a_updatingExisting); 84*5c51f124SMoriah Waterland extern void quitSetZoneName(char *a_zoneName); 85*5c51f124SMoriah Waterland 86*5c51f124SMoriah Waterland 87*5c51f124SMoriah Waterland /* static globals */ 88*5c51f124SMoriah Waterland 89*5c51f124SMoriah Waterland static char path[PATH_MAX]; 90*5c51f124SMoriah Waterland static int ck_instbase(void); 91*5c51f124SMoriah Waterland static int cp_pkgdirs(void); 92*5c51f124SMoriah Waterland static int merg_pkginfos(struct cl_attr **pclass, 93*5c51f124SMoriah Waterland struct cl_attr ***mpclass); 94*5c51f124SMoriah Waterland static int merg_respfile(void); 95*5c51f124SMoriah Waterland static int mv_pkgdirs(void); 96*5c51f124SMoriah Waterland static int rdonly(char *p); 97*5c51f124SMoriah Waterland static void ck_w_dryrun(int (*func)(), int type); 98*5c51f124SMoriah Waterland static void copyright(void), usage(void); 99*5c51f124SMoriah Waterland static void do_pkgask(boolean_t a_run_request_as_root); 100*5c51f124SMoriah Waterland static void rm_icas(char *casdir); 101*5c51f124SMoriah Waterland static void set_dryrun_dir_loc(void); 102*5c51f124SMoriah Waterland static void unpack(void); 103*5c51f124SMoriah Waterland 104*5c51f124SMoriah Waterland void ckreturn(int retcode, char *msg); 105*5c51f124SMoriah Waterland 106*5c51f124SMoriah Waterland static char *ro_params[] = { 107*5c51f124SMoriah Waterland "PATH", "NAME", "PKG", "PKGINST", 108*5c51f124SMoriah Waterland "VERSION", "ARCH", 109*5c51f124SMoriah Waterland "INSTDATE", "CATEGORY", 110*5c51f124SMoriah Waterland NULL 111*5c51f124SMoriah Waterland }; 112*5c51f124SMoriah Waterland 113*5c51f124SMoriah Waterland /* 114*5c51f124SMoriah Waterland * The following variable is the name of the device to which stdin 115*5c51f124SMoriah Waterland * is connected during execution of a procedure script. PROC_STDIN is 116*5c51f124SMoriah Waterland * correct for all ABI compliant packages. For non-ABI-compliant 117*5c51f124SMoriah Waterland * packages, the '-o' command line switch changes this to PROC_XSTDIN 118*5c51f124SMoriah Waterland * to allow user interaction during these scripts. -- JST 119*5c51f124SMoriah Waterland */ 120*5c51f124SMoriah Waterland static char *script_in = PROC_STDIN; /* assume ABI compliance */ 121*5c51f124SMoriah Waterland 122*5c51f124SMoriah Waterland static char *pkgdrtarg = NULL; 123*5c51f124SMoriah Waterland static char *pkgcontsrc = NULL; 124*5c51f124SMoriah Waterland static int non_abi_scripts = 0; 125*5c51f124SMoriah Waterland static char *respfile = NULL; 126*5c51f124SMoriah Waterland static char *srcinst = NULL; 127*5c51f124SMoriah Waterland static int suppressCopyright = 0; 128*5c51f124SMoriah Waterland static int nointeract = 0; 129*5c51f124SMoriah Waterland 130*5c51f124SMoriah Waterland /* exported globals */ 131*5c51f124SMoriah Waterland 132*5c51f124SMoriah Waterland char *msgtext; 133*5c51f124SMoriah Waterland char *pkginst = (char *)NULL; 134*5c51f124SMoriah Waterland char *rw_block_size = NULL; 135*5c51f124SMoriah Waterland char ilockfile[PATH_MAX]; 136*5c51f124SMoriah Waterland char instdir[PATH_MAX]; 137*5c51f124SMoriah Waterland char saveSpoolInstallDir[PATH_MAX]; 138*5c51f124SMoriah Waterland char pkgbin[PATH_MAX]; 139*5c51f124SMoriah Waterland char pkgloc[PATH_MAX]; 140*5c51f124SMoriah Waterland char pkgloc_sav[PATH_MAX]; 141*5c51f124SMoriah Waterland char pkgsav[PATH_MAX]; 142*5c51f124SMoriah Waterland char rlockfile[PATH_MAX]; 143*5c51f124SMoriah Waterland char savlog[PATH_MAX]; 144*5c51f124SMoriah Waterland char tmpdir[PATH_MAX]; 145*5c51f124SMoriah Waterland int dbchg; 146*5c51f124SMoriah Waterland int dparts = 0; 147*5c51f124SMoriah Waterland int dreboot = 0; 148*5c51f124SMoriah Waterland int failflag = 0; 149*5c51f124SMoriah Waterland static int askflag = 0; /* non-zero if invoked as "pkgask" */ 150*5c51f124SMoriah Waterland int ireboot = 0; 151*5c51f124SMoriah Waterland int maxinst = 1; 152*5c51f124SMoriah Waterland int nocnflct; 153*5c51f124SMoriah Waterland int nosetuid; 154*5c51f124SMoriah Waterland int opresvr4 = 0; 155*5c51f124SMoriah Waterland int pkgverbose = 0; 156*5c51f124SMoriah Waterland int rprcflag; 157*5c51f124SMoriah Waterland int warnflag = 0; 158*5c51f124SMoriah Waterland struct admin adm; 159*5c51f124SMoriah Waterland struct cfextra **extlist; /* pkgmap structure and other path info */ 160*5c51f124SMoriah Waterland struct pkgdev pkgdev; 161*5c51f124SMoriah Waterland fsblkcnt_t pkgmap_blks = 0LL; 162*5c51f124SMoriah Waterland 163*5c51f124SMoriah Waterland /* 164*5c51f124SMoriah Waterland * this global is referenced by: 165*5c51f124SMoriah Waterland * getinst - [RW] - incremented if: 166*5c51f124SMoriah Waterland * - installing same instance again 167*5c51f124SMoriah Waterland * - overwriting an existing instance 168*5c51f124SMoriah Waterland * - not installing a new instance 169*5c51f124SMoriah Waterland * quit - [RO] - if non-zero and started non-zero: 170*5c51f124SMoriah Waterland * - the new <PKGINST>/install directory and rename <PKGINST>/install.save 171*5c51f124SMoriah Waterland * - back to <PKGINST>/install 172*5c51f124SMoriah Waterland * main.c - [RO] - if non-zero: 173*5c51f124SMoriah Waterland * - alter manner in which parameters are setup for scripts 174*5c51f124SMoriah Waterland * - set UPDATE=yes in environment 175*5c51f124SMoriah Waterland */ 176*5c51f124SMoriah Waterland static int update = 0; 177*5c51f124SMoriah Waterland 178*5c51f124SMoriah Waterland /* Set by -O debug: debug output is enabled? */ 179*5c51f124SMoriah Waterland 180*5c51f124SMoriah Waterland static boolean_t debugFlag = B_FALSE; 181*5c51f124SMoriah Waterland 182*5c51f124SMoriah Waterland /* Set by the -G option: install packages in global zone only */ 183*5c51f124SMoriah Waterland 184*5c51f124SMoriah Waterland static boolean_t globalZoneOnly = B_FALSE; 185*5c51f124SMoriah Waterland 186*5c51f124SMoriah Waterland /* Set by -O patchPkgInstall */ 187*5c51f124SMoriah Waterland 188*5c51f124SMoriah Waterland static boolean_t patchPkgInstall = B_FALSE; 189*5c51f124SMoriah Waterland 190*5c51f124SMoriah Waterland /* Set by -O patchPkgRemoval */ 191*5c51f124SMoriah Waterland 192*5c51f124SMoriah Waterland static boolean_t patchPkgRemoval = B_FALSE; 193*5c51f124SMoriah Waterland 194*5c51f124SMoriah Waterland /* Set by -O preinstallcheck */ 195*5c51f124SMoriah Waterland 196*5c51f124SMoriah Waterland static boolean_t preinstallCheck = B_FALSE; 197*5c51f124SMoriah Waterland 198*5c51f124SMoriah Waterland /* Set by -O parent-zone-name= */ 199*5c51f124SMoriah Waterland 200*5c51f124SMoriah Waterland static char *parentZoneName = (char *)NULL; 201*5c51f124SMoriah Waterland 202*5c51f124SMoriah Waterland /* Set by -O parent-zone-type= */ 203*5c51f124SMoriah Waterland 204*5c51f124SMoriah Waterland static char *parentZoneType = (char *)NULL; 205*5c51f124SMoriah Waterland 206*5c51f124SMoriah Waterland #define DEFPATH "/sbin:/usr/sbin:/usr/bin" 207*5c51f124SMoriah Waterland #define MALSIZ 4 /* best guess at likely maximum value of MAXINST */ 208*5c51f124SMoriah Waterland #define LSIZE 256 /* maximum line size supported in copyright file */ 209*5c51f124SMoriah Waterland 210*5c51f124SMoriah Waterland #ifdef ALLOW_EXCEPTION_PKG_LIST 211*5c51f124SMoriah Waterland #define SCRIPT 0 /* which exception_pkg() pkg list to use (SCRIPTS) */ 212*5c51f124SMoriah Waterland #define LINK 1 /* which exception_pkg() pkg list to use (SYMLINKS) */ 213*5c51f124SMoriah Waterland #endif 214*5c51f124SMoriah Waterland 215*5c51f124SMoriah Waterland #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ 216*5c51f124SMoriah Waterland #define TEXT_DOMAIN "SYS_TEST" 217*5c51f124SMoriah Waterland #endif 218*5c51f124SMoriah Waterland 219*5c51f124SMoriah Waterland /* This is the text for the "-O inherited-filesystem=" option */ 220*5c51f124SMoriah Waterland 221*5c51f124SMoriah Waterland #define INHERITFS "inherited-filesystem=" 222*5c51f124SMoriah Waterland #define INHERITFS_LEN ((sizeof (INHERITFS))-1) 223*5c51f124SMoriah Waterland 224*5c51f124SMoriah Waterland /* This is the text for the "-O parent-zone-name=" option */ 225*5c51f124SMoriah Waterland 226*5c51f124SMoriah Waterland #define PARENTZONENAME "parent-zone-name=" 227*5c51f124SMoriah Waterland #define PARENTZONENAME_LEN ((sizeof (PARENTZONENAME))-1) 228*5c51f124SMoriah Waterland 229*5c51f124SMoriah Waterland /* This is the text for the "-O parent-zone-type=" option */ 230*5c51f124SMoriah Waterland 231*5c51f124SMoriah Waterland #define PARENTZONETYPE "parent-zone-type=" 232*5c51f124SMoriah Waterland #define PARENTZONETYPE_LEN ((sizeof (PARENTZONETYPE))-1) 233*5c51f124SMoriah Waterland 234*5c51f124SMoriah Waterland static char *cpio_names[] = { 235*5c51f124SMoriah Waterland "root", 236*5c51f124SMoriah Waterland "root.cpio", 237*5c51f124SMoriah Waterland "reloc", 238*5c51f124SMoriah Waterland "reloc.cpio", 239*5c51f124SMoriah Waterland "root.Z", 240*5c51f124SMoriah Waterland "root.cpio.Z", 241*5c51f124SMoriah Waterland "reloc.Z", 242*5c51f124SMoriah Waterland "reloc.cpio.Z", 243*5c51f124SMoriah Waterland 0 244*5c51f124SMoriah Waterland }; 245*5c51f124SMoriah Waterland 246*5c51f124SMoriah Waterland int 247*5c51f124SMoriah Waterland main(int argc, char *argv[]) 248*5c51f124SMoriah Waterland { 249*5c51f124SMoriah Waterland VFP_T *cfTmpVfp = (VFP_T *)NULL; /* t.contents */ 250*5c51f124SMoriah Waterland VFP_T *cfVfp = (VFP_T *)NULL; /* contents */ 251*5c51f124SMoriah Waterland VFP_T *pkgmapVfp; /* "../pkgmap" file */ 252*5c51f124SMoriah Waterland boolean_t run_request_as_root = B_FALSE; 253*5c51f124SMoriah Waterland char **np; 254*5c51f124SMoriah Waterland char *abi_comp_ptr; 255*5c51f124SMoriah Waterland char *abi_nm_ptr; 256*5c51f124SMoriah Waterland char *abi_sym_ptr; 257*5c51f124SMoriah Waterland char *admnfile = NULL; 258*5c51f124SMoriah Waterland char *device; 259*5c51f124SMoriah Waterland char *p; 260*5c51f124SMoriah Waterland char *prog_full_name = NULL; 261*5c51f124SMoriah Waterland char *pt; 262*5c51f124SMoriah Waterland char *skipped = (char *)NULL; 263*5c51f124SMoriah Waterland char *updated = (char *)NULL; 264*5c51f124SMoriah Waterland char *vfstab_file = NULL; 265*5c51f124SMoriah Waterland char *zoneName = (char *)NULL; 266*5c51f124SMoriah Waterland char cbuf[MAX_PKG_PARAM_LENGTH]; 267*5c51f124SMoriah Waterland char cmdbin[PATH_MAX]; 268*5c51f124SMoriah Waterland char p_pkginfo[PATH_MAX]; 269*5c51f124SMoriah Waterland char p_pkgmap[PATH_MAX]; 270*5c51f124SMoriah Waterland char param[MAX_PKG_PARAM_LENGTH]; 271*5c51f124SMoriah Waterland char script[PATH_MAX]; 272*5c51f124SMoriah Waterland char altscript[PATH_MAX]; 273*5c51f124SMoriah Waterland int c; 274*5c51f124SMoriah Waterland int disableAttributes = 0; 275*5c51f124SMoriah Waterland int err; 276*5c51f124SMoriah Waterland int init_install = 0; 277*5c51f124SMoriah Waterland int is_comp_arch; 278*5c51f124SMoriah Waterland int live_continue = 0; 279*5c51f124SMoriah Waterland int map_client = 1; 280*5c51f124SMoriah Waterland int n; 281*5c51f124SMoriah Waterland int nparts; 282*5c51f124SMoriah Waterland int npkgs; 283*5c51f124SMoriah Waterland int part; 284*5c51f124SMoriah Waterland int saveSpoolInstall = 0; 285*5c51f124SMoriah Waterland boolean_t cont_file_read; 286*5c51f124SMoriah Waterland struct cl_attr **pclass = NULL; 287*5c51f124SMoriah Waterland struct cl_attr **mergd_pclass = NULL; 288*5c51f124SMoriah Waterland struct pkginfo *prvinfo; 289*5c51f124SMoriah Waterland struct sigaction nact; 290*5c51f124SMoriah Waterland struct sigaction oact; 291*5c51f124SMoriah Waterland struct stat statb; 292*5c51f124SMoriah Waterland struct statvfs64 svfsb; 293*5c51f124SMoriah Waterland time_t clock; 294*5c51f124SMoriah Waterland 295*5c51f124SMoriah Waterland /* reset contents of all default paths */ 296*5c51f124SMoriah Waterland 297*5c51f124SMoriah Waterland (void) memset(path, '\0', sizeof (path)); 298*5c51f124SMoriah Waterland (void) memset(cmdbin, '\0', sizeof (cmdbin)); 299*5c51f124SMoriah Waterland (void) memset(script, '\0', sizeof (script)); 300*5c51f124SMoriah Waterland (void) memset(cbuf, '\0', sizeof (cbuf)); 301*5c51f124SMoriah Waterland (void) memset(param, '\0', sizeof (param)); 302*5c51f124SMoriah Waterland 303*5c51f124SMoriah Waterland /* initialize locale environment */ 304*5c51f124SMoriah Waterland 305*5c51f124SMoriah Waterland (void) setlocale(LC_ALL, ""); 306*5c51f124SMoriah Waterland (void) textdomain(TEXT_DOMAIN); 307*5c51f124SMoriah Waterland 308*5c51f124SMoriah Waterland /* initialize program name */ 309*5c51f124SMoriah Waterland 310*5c51f124SMoriah Waterland prog_full_name = argv[0]; 311*5c51f124SMoriah Waterland (void) set_prog_name(argv[0]); 312*5c51f124SMoriah Waterland 313*5c51f124SMoriah Waterland /* tell spmi zones interface how to access package output functions */ 314*5c51f124SMoriah Waterland 315*5c51f124SMoriah Waterland z_set_output_functions(echo, echoDebug, progerr); 316*5c51f124SMoriah Waterland 317*5c51f124SMoriah Waterland /* exit if not root */ 318*5c51f124SMoriah Waterland 319*5c51f124SMoriah Waterland if (getuid()) { 320*5c51f124SMoriah Waterland progerr(ERR_NOT_ROOT, get_prog_name()); 321*5c51f124SMoriah Waterland exit(1); 322*5c51f124SMoriah Waterland /* NOTREACHED */ 323*5c51f124SMoriah Waterland } 324*5c51f124SMoriah Waterland 325*5c51f124SMoriah Waterland /* 326*5c51f124SMoriah Waterland * determine how pkgmap() deals with environment variables: 327*5c51f124SMoriah Waterland * - MAPALL - resolve all variables 328*5c51f124SMoriah Waterland * - MAPBUILD - map only build variables 329*5c51f124SMoriah Waterland * - MAPINSTALL - map only install variables 330*5c51f124SMoriah Waterland * - MAPNONE - map no variables 331*5c51f124SMoriah Waterland */ 332*5c51f124SMoriah Waterland 333*5c51f124SMoriah Waterland setmapmode(MAPINSTALL); 334*5c51f124SMoriah Waterland 335*5c51f124SMoriah Waterland /* set sane umask */ 336*5c51f124SMoriah Waterland 337*5c51f124SMoriah Waterland (void) umask(0022); 338*5c51f124SMoriah Waterland 339*5c51f124SMoriah Waterland /* initially no source "device" */ 340*5c51f124SMoriah Waterland 341*5c51f124SMoriah Waterland device = NULL; 342*5c51f124SMoriah Waterland 343*5c51f124SMoriah Waterland /* reset npkgs (used as pkg remaining count in quit.c) */ 344*5c51f124SMoriah Waterland 345*5c51f124SMoriah Waterland npkgs = 0; 346*5c51f124SMoriah Waterland 347*5c51f124SMoriah Waterland /* Read PKG_INSTALL_ROOT from the environment, if it's there. */ 348*5c51f124SMoriah Waterland 349*5c51f124SMoriah Waterland if (!set_inst_root(getenv("PKG_INSTALL_ROOT"))) { 350*5c51f124SMoriah Waterland progerr(ERR_ROOT_SET); 351*5c51f124SMoriah Waterland exit(1); 352*5c51f124SMoriah Waterland } 353*5c51f124SMoriah Waterland 354*5c51f124SMoriah Waterland /* parse command line options */ 355*5c51f124SMoriah Waterland 356*5c51f124SMoriah Waterland while ((c = getopt(argc, argv, 357*5c51f124SMoriah Waterland "?Aa:B:b:Cc:D:d:eFf:GhIiMm:N:noO:p:R:r:StV:vyz")) != EOF) { 358*5c51f124SMoriah Waterland 359*5c51f124SMoriah Waterland switch (c) { 360*5c51f124SMoriah Waterland 361*5c51f124SMoriah Waterland /* 362*5c51f124SMoriah Waterland * Same as pkgadd: This disables attribute checking. 363*5c51f124SMoriah Waterland * It speeds up installation a little bit. 364*5c51f124SMoriah Waterland */ 365*5c51f124SMoriah Waterland case 'A': 366*5c51f124SMoriah Waterland disableAttributes++; 367*5c51f124SMoriah Waterland break; 368*5c51f124SMoriah Waterland 369*5c51f124SMoriah Waterland /* 370*5c51f124SMoriah Waterland * Same as pkgadd: Define an installation administration 371*5c51f124SMoriah Waterland * file, admin, to be used in place of the default 372*5c51f124SMoriah Waterland * administration file. The token none overrides the use 373*5c51f124SMoriah Waterland * of any admin file, and thus forces interaction with the 374*5c51f124SMoriah Waterland * user. Unless a full path name is given, pkgadd first 375*5c51f124SMoriah Waterland * looks in the current working directory for the 376*5c51f124SMoriah Waterland * administration file. If the specified administration 377*5c51f124SMoriah Waterland * file is not in the current working directory, pkgadd 378*5c51f124SMoriah Waterland * looks in the /var/sadm/install/admin directory for the 379*5c51f124SMoriah Waterland * administration file. 380*5c51f124SMoriah Waterland */ 381*5c51f124SMoriah Waterland case 'a': 382*5c51f124SMoriah Waterland admnfile = flex_device(optarg, 0); 383*5c51f124SMoriah Waterland break; 384*5c51f124SMoriah Waterland 385*5c51f124SMoriah Waterland /* 386*5c51f124SMoriah Waterland * Same as pkgadd: control block size given to 387*5c51f124SMoriah Waterland * pkginstall - block size used in read()/write() loop; 388*5c51f124SMoriah Waterland * default is st_blksize from stat() of source file. 389*5c51f124SMoriah Waterland */ 390*5c51f124SMoriah Waterland case 'B': 391*5c51f124SMoriah Waterland rw_block_size = optarg; 392*5c51f124SMoriah Waterland break; 393*5c51f124SMoriah Waterland 394*5c51f124SMoriah Waterland /* 395*5c51f124SMoriah Waterland * Same as pkgadd: location where executables needed 396*5c51f124SMoriah Waterland * by procedure scripts can be found 397*5c51f124SMoriah Waterland * default is /usr/sadm/install/bin. 398*5c51f124SMoriah Waterland */ 399*5c51f124SMoriah Waterland case 'b': 400*5c51f124SMoriah Waterland if (!path_valid(optarg)) { 401*5c51f124SMoriah Waterland progerr(ERR_PATH, optarg); 402*5c51f124SMoriah Waterland exit(1); 403*5c51f124SMoriah Waterland } 404*5c51f124SMoriah Waterland if (isdir(optarg) != 0) { 405*5c51f124SMoriah Waterland char *p = strerror(errno); 406*5c51f124SMoriah Waterland progerr(ERR_CANNOT_USE_DIR, optarg, p); 407*5c51f124SMoriah Waterland exit(1); 408*5c51f124SMoriah Waterland } 409*5c51f124SMoriah Waterland (void) strlcpy(cmdbin, optarg, sizeof (cmdbin)); 410*5c51f124SMoriah Waterland break; 411*5c51f124SMoriah Waterland 412*5c51f124SMoriah Waterland /* 413*5c51f124SMoriah Waterland * Same as pkgadd: This disables checksum tests on 414*5c51f124SMoriah Waterland * the source files. It speeds up installation a little bit. 415*5c51f124SMoriah Waterland */ 416*5c51f124SMoriah Waterland case 'C': 417*5c51f124SMoriah Waterland (void) checksum_off(); 418*5c51f124SMoriah Waterland break; 419*5c51f124SMoriah Waterland 420*5c51f124SMoriah Waterland /* 421*5c51f124SMoriah Waterland * Same as pkgadd: This allows designation of a 422*5c51f124SMoriah Waterland * continuation file. It is the same format as a dryrun file 423*5c51f124SMoriah Waterland * but it is used to take up where the dryrun left off. 424*5c51f124SMoriah Waterland */ 425*5c51f124SMoriah Waterland case 'c': 426*5c51f124SMoriah Waterland pkgcontsrc = optarg; 427*5c51f124SMoriah Waterland set_continue_mode(); 428*5c51f124SMoriah Waterland set_dr_info(DR_TYPE, INSTALL_TYPE); 429*5c51f124SMoriah Waterland init_contfile(pkgcontsrc); 430*5c51f124SMoriah Waterland break; 431*5c51f124SMoriah Waterland 432*5c51f124SMoriah Waterland /* 433*5c51f124SMoriah Waterland * Same as pkgadd: This allows designation of a 434*5c51f124SMoriah Waterland * dryrun file. This pkgadd will create dryrun files 435*5c51f124SMoriah Waterland * in the directory provided. 436*5c51f124SMoriah Waterland */ 437*5c51f124SMoriah Waterland case 'D': 438*5c51f124SMoriah Waterland pkgdrtarg = optarg; 439*5c51f124SMoriah Waterland set_dryrun_mode(); 440*5c51f124SMoriah Waterland set_dr_info(DR_TYPE, INSTALL_TYPE); 441*5c51f124SMoriah Waterland break; 442*5c51f124SMoriah Waterland 443*5c51f124SMoriah Waterland /* 444*5c51f124SMoriah Waterland * Same as pkgadd: Install or copy a package from 445*5c51f124SMoriah Waterland * device. device can be a full path name to a directory 446*5c51f124SMoriah Waterland * or the identifiers for tape, floppy disk, or removable 447*5c51f124SMoriah Waterland * disk - for example, /var/tmp or /floppy/floppy_name. 448*5c51f124SMoriah Waterland * It can also be a device alias - for example, 449*5c51f124SMoriah Waterland * /floppy/floppy0, or a datastream created by pkgtrans. 450*5c51f124SMoriah Waterland */ 451*5c51f124SMoriah Waterland case 'd': 452*5c51f124SMoriah Waterland device = flex_device(optarg, 1); 453*5c51f124SMoriah Waterland break; 454*5c51f124SMoriah Waterland 455*5c51f124SMoriah Waterland /* 456*5c51f124SMoriah Waterland * Different from pkgadd: disable the 32 char name 457*5c51f124SMoriah Waterland * limit extension 458*5c51f124SMoriah Waterland */ 459*5c51f124SMoriah Waterland case 'e': 460*5c51f124SMoriah Waterland (void) set_ABI_namelngth(); 461*5c51f124SMoriah Waterland break; 462*5c51f124SMoriah Waterland 463*5c51f124SMoriah Waterland /* 464*5c51f124SMoriah Waterland * Different from pkgadd: specify file system type for 465*5c51f124SMoriah Waterland * the package device. Must be used with -m. 466*5c51f124SMoriah Waterland */ 467*5c51f124SMoriah Waterland case 'f': 468*5c51f124SMoriah Waterland pkgdev.fstyp = optarg; 469*5c51f124SMoriah Waterland break; 470*5c51f124SMoriah Waterland 471*5c51f124SMoriah Waterland /* 472*5c51f124SMoriah Waterland * Same as pkgadd: install package in global zone only. 473*5c51f124SMoriah Waterland */ 474*5c51f124SMoriah Waterland case 'G': 475*5c51f124SMoriah Waterland globalZoneOnly = B_TRUE; 476*5c51f124SMoriah Waterland break; 477*5c51f124SMoriah Waterland 478*5c51f124SMoriah Waterland /* 479*5c51f124SMoriah Waterland * Same as pkgadd: Enable hollow package support. When 480*5c51f124SMoriah Waterland * specified, for any package that has SUNW_PKG_HOLLOW=true: 481*5c51f124SMoriah Waterland * Do not calculate and verify package size against target. 482*5c51f124SMoriah Waterland * Do not run any package procedure or class action scripts. 483*5c51f124SMoriah Waterland * Do not create any target directories. 484*5c51f124SMoriah Waterland * Do not perform any script locking. 485*5c51f124SMoriah Waterland * Do not install any components of any package. 486*5c51f124SMoriah Waterland * Do not output any status or database update messages. 487*5c51f124SMoriah Waterland */ 488*5c51f124SMoriah Waterland case 'h': 489*5c51f124SMoriah Waterland set_depend_pkginfo_DB(B_TRUE); 490*5c51f124SMoriah Waterland break; 491*5c51f124SMoriah Waterland 492*5c51f124SMoriah Waterland /* 493*5c51f124SMoriah Waterland * Same as pkgadd: Informs scripts that this is 494*5c51f124SMoriah Waterland * an initial install by setting the environment parameter 495*5c51f124SMoriah Waterland * PKG_INIT_INSTALL=TRUE for all scripts. They may use it as 496*5c51f124SMoriah Waterland * they see fit, safe in the knowledge that the target 497*5c51f124SMoriah Waterland * filesystem is tabula rasa. 498*5c51f124SMoriah Waterland */ 499*5c51f124SMoriah Waterland case 'I': 500*5c51f124SMoriah Waterland init_install++; 501*5c51f124SMoriah Waterland break; 502*5c51f124SMoriah Waterland 503*5c51f124SMoriah Waterland /* 504*5c51f124SMoriah Waterland * Different from pkgadd: use by pkgask. 505*5c51f124SMoriah Waterland */ 506*5c51f124SMoriah Waterland case 'i': 507*5c51f124SMoriah Waterland askflag++; 508*5c51f124SMoriah Waterland quitSetPkgask(B_TRUE); 509*5c51f124SMoriah Waterland break; 510*5c51f124SMoriah Waterland 511*5c51f124SMoriah Waterland /* 512*5c51f124SMoriah Waterland * Same as pkgadd: Instruct pkgadd not to use the 513*5c51f124SMoriah Waterland * $root_path/etc/vfstab file for determining the client's 514*5c51f124SMoriah Waterland * mount points. This option assumes the mount points are 515*5c51f124SMoriah Waterland * correct on the server and it behaves consistently with 516*5c51f124SMoriah Waterland * Solaris 2.5 and earlier releases. 517*5c51f124SMoriah Waterland */ 518*5c51f124SMoriah Waterland case 'M': 519*5c51f124SMoriah Waterland map_client = 0; 520*5c51f124SMoriah Waterland break; 521*5c51f124SMoriah Waterland 522*5c51f124SMoriah Waterland /* 523*5c51f124SMoriah Waterland * Different from pkgadd: specify device to use for package 524*5c51f124SMoriah Waterland * source. 525*5c51f124SMoriah Waterland */ 526*5c51f124SMoriah Waterland case 'm': 527*5c51f124SMoriah Waterland pkgdev.mount = optarg; 528*5c51f124SMoriah Waterland pkgdev.rdonly++; 529*5c51f124SMoriah Waterland pkgdev.mntflg++; 530*5c51f124SMoriah Waterland break; 531*5c51f124SMoriah Waterland 532*5c51f124SMoriah Waterland /* 533*5c51f124SMoriah Waterland * Different from pkgadd: specify program name to use 534*5c51f124SMoriah Waterland * for messages. 535*5c51f124SMoriah Waterland */ 536*5c51f124SMoriah Waterland case 'N': 537*5c51f124SMoriah Waterland (void) set_prog_name(optarg); 538*5c51f124SMoriah Waterland break; 539*5c51f124SMoriah Waterland 540*5c51f124SMoriah Waterland /* 541*5c51f124SMoriah Waterland * Same as pkgadd: installation occurs in 542*5c51f124SMoriah Waterland * non-interactive mode. Suppress output of the list of 543*5c51f124SMoriah Waterland * installed files. The default mode is interactive. 544*5c51f124SMoriah Waterland */ 545*5c51f124SMoriah Waterland case 'n': 546*5c51f124SMoriah Waterland nointeract++; 547*5c51f124SMoriah Waterland (void) echoSetFlag(B_FALSE); 548*5c51f124SMoriah Waterland break; 549*5c51f124SMoriah Waterland 550*5c51f124SMoriah Waterland /* 551*5c51f124SMoriah Waterland * Almost same as pkgadd: the -O option allows the behavior 552*5c51f124SMoriah Waterland * of the package tools to be modified. Recognized options: 553*5c51f124SMoriah Waterland * -> debug 554*5c51f124SMoriah Waterland * ---> enable debugging output 555*5c51f124SMoriah Waterland * -> preinstallcheck 556*5c51f124SMoriah Waterland * ---> perform a "pre installation" check of the specified 557*5c51f124SMoriah Waterland * ---> package - suppress all regular output and cause a 558*5c51f124SMoriah Waterland * ---> series of one or more "name=value" pair format lines 559*5c51f124SMoriah Waterland * ---> to be output that describes the "installability" of 560*5c51f124SMoriah Waterland * ---> the specified package 561*5c51f124SMoriah Waterland * -> enable-hollow-package-support 562*5c51f124SMoriah Waterland * --> Enable hollow package support. When specified, for any 563*5c51f124SMoriah Waterland * --> package that has SUNW_PKG_HOLLOW=true: 564*5c51f124SMoriah Waterland * --> Do not calculate and verify package size against target 565*5c51f124SMoriah Waterland * --> Do not run any package procedure or class action scripts 566*5c51f124SMoriah Waterland * --> Do not create or remove any target directories 567*5c51f124SMoriah Waterland * --> Do not perform any script locking 568*5c51f124SMoriah Waterland * --> Do not install or uninstall any components of any package 569*5c51f124SMoriah Waterland * --> Do not output any status or database update messages 570*5c51f124SMoriah Waterland */ 571*5c51f124SMoriah Waterland case 'O': 572*5c51f124SMoriah Waterland for (p = strtok(optarg, ","); p != (char *)NULL; 573*5c51f124SMoriah Waterland p = strtok(NULL, ",")) { 574*5c51f124SMoriah Waterland 575*5c51f124SMoriah Waterland /* process debug option */ 576*5c51f124SMoriah Waterland 577*5c51f124SMoriah Waterland if (strcmp(p, "debug") == 0) { 578*5c51f124SMoriah Waterland /* set debug flag/enable debug output */ 579*5c51f124SMoriah Waterland if (debugFlag == B_TRUE) { 580*5c51f124SMoriah Waterland smlSetVerbose(B_TRUE); 581*5c51f124SMoriah Waterland } 582*5c51f124SMoriah Waterland debugFlag = B_TRUE; 583*5c51f124SMoriah Waterland (void) echoDebugSetFlag(debugFlag); 584*5c51f124SMoriah Waterland 585*5c51f124SMoriah Waterland /* debug info on arguments to pkgadd */ 586*5c51f124SMoriah Waterland for (n = 0; n < argc && argv[n]; n++) { 587*5c51f124SMoriah Waterland echoDebug(DBG_ARG, n, argv[n]); 588*5c51f124SMoriah Waterland } 589*5c51f124SMoriah Waterland 590*5c51f124SMoriah Waterland continue; 591*5c51f124SMoriah Waterland } 592*5c51f124SMoriah Waterland 593*5c51f124SMoriah Waterland /* process enable-hollow-package-support opt */ 594*5c51f124SMoriah Waterland 595*5c51f124SMoriah Waterland if (strcmp(p, 596*5c51f124SMoriah Waterland "enable-hollow-package-support") == 0) { 597*5c51f124SMoriah Waterland set_depend_pkginfo_DB(B_TRUE); 598*5c51f124SMoriah Waterland continue; 599*5c51f124SMoriah Waterland } 600*5c51f124SMoriah Waterland 601*5c51f124SMoriah Waterland /* process inherited-filesystem= option */ 602*5c51f124SMoriah Waterland 603*5c51f124SMoriah Waterland if (strncmp(p, INHERITFS, INHERITFS_LEN) == 0) { 604*5c51f124SMoriah Waterland if (z_add_inherited_file_system( 605*5c51f124SMoriah Waterland p+INHERITFS_LEN) == B_FALSE) { 606*5c51f124SMoriah Waterland progerr(ERR_NOSUCH_INHERITED, 607*5c51f124SMoriah Waterland p+INHERITFS_LEN); 608*5c51f124SMoriah Waterland quit(1); 609*5c51f124SMoriah Waterland /* NOTREACHED */ 610*5c51f124SMoriah Waterland } 611*5c51f124SMoriah Waterland continue; 612*5c51f124SMoriah Waterland } 613*5c51f124SMoriah Waterland 614*5c51f124SMoriah Waterland /* process preinstallcheck option */ 615*5c51f124SMoriah Waterland 616*5c51f124SMoriah Waterland if (strcmp(p, "preinstallcheck") == 0) { 617*5c51f124SMoriah Waterland preinstallCheck = B_TRUE; 618*5c51f124SMoriah Waterland nointeract++; /* -n */ 619*5c51f124SMoriah Waterland suppressCopyright++; /* -S */ 620*5c51f124SMoriah Waterland quitSetSilentExit(B_TRUE); 621*5c51f124SMoriah Waterland continue; 622*5c51f124SMoriah Waterland } 623*5c51f124SMoriah Waterland 624*5c51f124SMoriah Waterland /* process addzonename option */ 625*5c51f124SMoriah Waterland 626*5c51f124SMoriah Waterland if (strcmp(p, "addzonename") == 0) { 627*5c51f124SMoriah Waterland /* 628*5c51f124SMoriah Waterland * set zone name to add to messages; 629*5c51f124SMoriah Waterland * first look in the current environment 630*5c51f124SMoriah Waterland * and use the default package zone name 631*5c51f124SMoriah Waterland * if it is set; otherwise, use the name 632*5c51f124SMoriah Waterland * of the current zone 633*5c51f124SMoriah Waterland */ 634*5c51f124SMoriah Waterland zoneName = 635*5c51f124SMoriah Waterland getenv(PKG_ZONENAME_VARIABLE); 636*5c51f124SMoriah Waterland 637*5c51f124SMoriah Waterland if ((zoneName == (char *)NULL) || 638*5c51f124SMoriah Waterland (*zoneName == '\0')) { 639*5c51f124SMoriah Waterland zoneName = z_get_zonename(); 640*5c51f124SMoriah Waterland } 641*5c51f124SMoriah Waterland 642*5c51f124SMoriah Waterland if (zoneName != (char *)NULL) { 643*5c51f124SMoriah Waterland if (*zoneName != '\0') { 644*5c51f124SMoriah Waterland quitSetZoneName( 645*5c51f124SMoriah Waterland zoneName); 646*5c51f124SMoriah Waterland } else { 647*5c51f124SMoriah Waterland zoneName = (char *)NULL; 648*5c51f124SMoriah Waterland } 649*5c51f124SMoriah Waterland } 650*5c51f124SMoriah Waterland continue; 651*5c51f124SMoriah Waterland } 652*5c51f124SMoriah Waterland 653*5c51f124SMoriah Waterland /* 654*5c51f124SMoriah Waterland * If this is a patch installation 655*5c51f124SMoriah Waterland * then call setPatchUpdate(). 656*5c51f124SMoriah Waterland */ 657*5c51f124SMoriah Waterland 658*5c51f124SMoriah Waterland if (strcmp(p, "patchPkgInstall") == 0) { 659*5c51f124SMoriah Waterland setPatchUpdate(); 660*5c51f124SMoriah Waterland patchPkgInstall = B_TRUE; 661*5c51f124SMoriah Waterland continue; 662*5c51f124SMoriah Waterland } 663*5c51f124SMoriah Waterland 664*5c51f124SMoriah Waterland /* 665*5c51f124SMoriah Waterland * If this is a patch removal 666*5c51f124SMoriah Waterland * then call setPatchUpdate() and set 667*5c51f124SMoriah Waterland * patchPkgRemoval flag. 668*5c51f124SMoriah Waterland */ 669*5c51f124SMoriah Waterland 670*5c51f124SMoriah Waterland if (strcmp(p, "patchPkgRemoval") == 0) { 671*5c51f124SMoriah Waterland setPatchUpdate(); 672*5c51f124SMoriah Waterland patchPkgRemoval = B_TRUE; 673*5c51f124SMoriah Waterland continue; 674*5c51f124SMoriah Waterland } 675*5c51f124SMoriah Waterland 676*5c51f124SMoriah Waterland /* process parent-zone-name option */ 677*5c51f124SMoriah Waterland 678*5c51f124SMoriah Waterland if (strncmp(p, PARENTZONENAME, 679*5c51f124SMoriah Waterland PARENTZONENAME_LEN) == 0) { 680*5c51f124SMoriah Waterland parentZoneName = p+PARENTZONENAME_LEN; 681*5c51f124SMoriah Waterland continue; 682*5c51f124SMoriah Waterland } 683*5c51f124SMoriah Waterland 684*5c51f124SMoriah Waterland /* process parent-zone-type option */ 685*5c51f124SMoriah Waterland 686*5c51f124SMoriah Waterland if (strncmp(p, PARENTZONETYPE, 687*5c51f124SMoriah Waterland PARENTZONETYPE_LEN) == 0) { 688*5c51f124SMoriah Waterland parentZoneType = p+PARENTZONETYPE_LEN; 689*5c51f124SMoriah Waterland continue; 690*5c51f124SMoriah Waterland } 691*5c51f124SMoriah Waterland 692*5c51f124SMoriah Waterland /* option not recognized - issue warning */ 693*5c51f124SMoriah Waterland 694*5c51f124SMoriah Waterland progerr(ERR_INVALID_O_OPTION, p); 695*5c51f124SMoriah Waterland continue; 696*5c51f124SMoriah Waterland 697*5c51f124SMoriah Waterland } 698*5c51f124SMoriah Waterland break; 699*5c51f124SMoriah Waterland 700*5c51f124SMoriah Waterland /* 701*5c51f124SMoriah Waterland * Different from pkgadd: This is an old non-ABI package 702*5c51f124SMoriah Waterland */ 703*5c51f124SMoriah Waterland case 'o': 704*5c51f124SMoriah Waterland non_abi_scripts++; 705*5c51f124SMoriah Waterland break; 706*5c51f124SMoriah Waterland 707*5c51f124SMoriah Waterland /* 708*5c51f124SMoriah Waterland * Different from pkgadd: specify number of parts to package. 709*5c51f124SMoriah Waterland */ 710*5c51f124SMoriah Waterland case 'p': 711*5c51f124SMoriah Waterland dparts = ds_getinfo(optarg); 712*5c51f124SMoriah Waterland break; 713*5c51f124SMoriah Waterland 714*5c51f124SMoriah Waterland /* 715*5c51f124SMoriah Waterland * Same as pkgadd: Define the full path name of a 716*5c51f124SMoriah Waterland * directory to use as the root_path. All files, 717*5c51f124SMoriah Waterland * including package system information files, are 718*5c51f124SMoriah Waterland * relocated to a directory tree starting in the specified 719*5c51f124SMoriah Waterland * root_path. The root_path may be specified when 720*5c51f124SMoriah Waterland * installing to a client from a server (for example, 721*5c51f124SMoriah Waterland * /export/root/client1). 722*5c51f124SMoriah Waterland */ 723*5c51f124SMoriah Waterland case 'R': 724*5c51f124SMoriah Waterland if (!set_inst_root(optarg)) { 725*5c51f124SMoriah Waterland progerr(ERR_ROOT_CMD); 726*5c51f124SMoriah Waterland exit(1); 727*5c51f124SMoriah Waterland } 728*5c51f124SMoriah Waterland break; 729*5c51f124SMoriah Waterland 730*5c51f124SMoriah Waterland /* 731*5c51f124SMoriah Waterland * Same as pkgadd: Identify a file or directory which 732*5c51f124SMoriah Waterland * contains output from a previous pkgask(1M) 733*5c51f124SMoriah Waterland * session. This file supplies the interaction responses 734*5c51f124SMoriah Waterland * that would be requested by the package in interactive 735*5c51f124SMoriah Waterland * mode. response must be a full pathname. 736*5c51f124SMoriah Waterland */ 737*5c51f124SMoriah Waterland case 'r': 738*5c51f124SMoriah Waterland respfile = flex_device(optarg, 2); 739*5c51f124SMoriah Waterland break; 740*5c51f124SMoriah Waterland 741*5c51f124SMoriah Waterland /* 742*5c51f124SMoriah Waterland * Same as pkgadd: suppress copyright notice being 743*5c51f124SMoriah Waterland * output during installation. 744*5c51f124SMoriah Waterland */ 745*5c51f124SMoriah Waterland case 'S': 746*5c51f124SMoriah Waterland suppressCopyright++; 747*5c51f124SMoriah Waterland break; 748*5c51f124SMoriah Waterland 749*5c51f124SMoriah Waterland /* 750*5c51f124SMoriah Waterland * Same as pkgadd: disable save spool area creation; 751*5c51f124SMoriah Waterland * do not spool any partial package contents, that is, 752*5c51f124SMoriah Waterland * suppress the creation and population of the package save 753*5c51f124SMoriah Waterland * spool area (var/sadm/pkg/PKG/save/pspool/PKG). 754*5c51f124SMoriah Waterland */ 755*5c51f124SMoriah Waterland case 't': 756*5c51f124SMoriah Waterland disable_spool_create(); 757*5c51f124SMoriah Waterland break; 758*5c51f124SMoriah Waterland 759*5c51f124SMoriah Waterland /* 760*5c51f124SMoriah Waterland * Same as pkgadd: Specify an alternative fs_file to map 761*5c51f124SMoriah Waterland * the client's file systems. For example, used in 762*5c51f124SMoriah Waterland * situations where the $root_path/etc/vfstab file is 763*5c51f124SMoriah Waterland * non-existent or unreliable. Informs the pkginstall 764*5c51f124SMoriah Waterland * portion to mount up a client filesystem based upon the 765*5c51f124SMoriah Waterland * supplied vfstab-like file of stable format. 766*5c51f124SMoriah Waterland */ 767*5c51f124SMoriah Waterland case 'V': 768*5c51f124SMoriah Waterland vfstab_file = flex_device(optarg, 2); 769*5c51f124SMoriah Waterland map_client = 1; 770*5c51f124SMoriah Waterland break; 771*5c51f124SMoriah Waterland 772*5c51f124SMoriah Waterland /* 773*5c51f124SMoriah Waterland * Same as pkgadd: Trace all of the scripts that get 774*5c51f124SMoriah Waterland * executed by pkgadd, located in the pkginst/install 775*5c51f124SMoriah Waterland * directory. This option is used for debugging the 776*5c51f124SMoriah Waterland * procedural and non-procedural scripts 777*5c51f124SMoriah Waterland */ 778*5c51f124SMoriah Waterland case 'v': 779*5c51f124SMoriah Waterland pkgverbose++; 780*5c51f124SMoriah Waterland break; 781*5c51f124SMoriah Waterland 782*5c51f124SMoriah Waterland /* 783*5c51f124SMoriah Waterland * Different from pkgadd: process this package using 784*5c51f124SMoriah Waterland * old non-ABI symlinks 785*5c51f124SMoriah Waterland */ 786*5c51f124SMoriah Waterland case 'y': 787*5c51f124SMoriah Waterland set_nonABI_symlinks(); 788*5c51f124SMoriah Waterland break; 789*5c51f124SMoriah Waterland 790*5c51f124SMoriah Waterland /* 791*5c51f124SMoriah Waterland * Same as pkgadd: perform fresh install from 792*5c51f124SMoriah Waterland * package save spool area. When set, the package contents 793*5c51f124SMoriah Waterland * are installed from the package spool save area instead 794*5c51f124SMoriah Waterland * of from the package root area, so that the original 795*5c51f124SMoriah Waterland * source packages are not required to install the 796*5c51f124SMoriah Waterland * package. If the -h option is also specified and the 797*5c51f124SMoriah Waterland * package is hollow, then this option is ignored. When -z 798*5c51f124SMoriah Waterland * is specified: 799*5c51f124SMoriah Waterland * - Editable files are installed from the package instance 800*5c51f124SMoriah Waterland * save area. 801*5c51f124SMoriah Waterland * - Volatile files are installed from the package instance 802*5c51f124SMoriah Waterland * save area. 803*5c51f124SMoriah Waterland * - Executable and data files are installed from the final 804*5c51f124SMoriah Waterland * installed location as specified in the pkgmap file. 805*5c51f124SMoriah Waterland * - Installation scripts are run from the package spool 806*5c51f124SMoriah Waterland * save area. 807*5c51f124SMoriah Waterland */ 808*5c51f124SMoriah Waterland case 'z': 809*5c51f124SMoriah Waterland saveSpoolInstall++; 810*5c51f124SMoriah Waterland break; 811*5c51f124SMoriah Waterland 812*5c51f124SMoriah Waterland /* 813*5c51f124SMoriah Waterland * unrecognized option 814*5c51f124SMoriah Waterland */ 815*5c51f124SMoriah Waterland default: 816*5c51f124SMoriah Waterland usage(); 817*5c51f124SMoriah Waterland /*NOTREACHED*/ 818*5c51f124SMoriah Waterland /* 819*5c51f124SMoriah Waterland * Although usage() calls a noreturn function, 820*5c51f124SMoriah Waterland * needed to add return (1); so that main() would 821*5c51f124SMoriah Waterland * pass compilation checks. The statement below 822*5c51f124SMoriah Waterland * should never be executed. 823*5c51f124SMoriah Waterland */ 824*5c51f124SMoriah Waterland return (1); 825*5c51f124SMoriah Waterland } 826*5c51f124SMoriah Waterland } 827*5c51f124SMoriah Waterland 828*5c51f124SMoriah Waterland /* 829*5c51f124SMoriah Waterland * ******************************************************************** 830*5c51f124SMoriah Waterland * validate command line options 831*5c51f124SMoriah Waterland * ******************************************************************** 832*5c51f124SMoriah Waterland */ 833*5c51f124SMoriah Waterland 834*5c51f124SMoriah Waterland /* set "debug echo" flag according to setting of "-O debug" option */ 835*5c51f124SMoriah Waterland 836*5c51f124SMoriah Waterland (void) echoDebugSetFlag(debugFlag); 837*5c51f124SMoriah Waterland (void) log_set_verbose(debugFlag); 838*5c51f124SMoriah Waterland 839*5c51f124SMoriah Waterland /* output entry debugging information */ 840*5c51f124SMoriah Waterland 841*5c51f124SMoriah Waterland if (z_running_in_global_zone()) { 842*5c51f124SMoriah Waterland echoDebug(DBG_ENTRY_IN_GZ, prog_full_name); 843*5c51f124SMoriah Waterland } else { 844*5c51f124SMoriah Waterland echoDebug(DBG_ENTRY_IN_LZ, prog_full_name, getzoneid(), 845*5c51f124SMoriah Waterland z_get_zonename()); 846*5c51f124SMoriah Waterland } 847*5c51f124SMoriah Waterland 848*5c51f124SMoriah Waterland if (in_continue_mode() && !in_dryrun_mode()) { 849*5c51f124SMoriah Waterland progerr(ERR_LIVE_CONTINUE_NOT_SUPPORTED); 850*5c51f124SMoriah Waterland usage(); 851*5c51f124SMoriah Waterland /*NOTREACHED*/ 852*5c51f124SMoriah Waterland } 853*5c51f124SMoriah Waterland 854*5c51f124SMoriah Waterland /* pkgask requires a response file */ 855*5c51f124SMoriah Waterland 856*5c51f124SMoriah Waterland if (askflag && (respfile == NULL)) { 857*5c51f124SMoriah Waterland usage(); 858*5c51f124SMoriah Waterland /*NOTREACHED*/ 859*5c51f124SMoriah Waterland } 860*5c51f124SMoriah Waterland 861*5c51f124SMoriah Waterland /* if device specified, set appropriate device in pkgdev */ 862*5c51f124SMoriah Waterland 863*5c51f124SMoriah Waterland if (device) { 864*5c51f124SMoriah Waterland if (pkgdev.mount) { 865*5c51f124SMoriah Waterland pkgdev.bdevice = device; 866*5c51f124SMoriah Waterland } else { 867*5c51f124SMoriah Waterland pkgdev.cdevice = device; 868*5c51f124SMoriah Waterland } 869*5c51f124SMoriah Waterland } 870*5c51f124SMoriah Waterland 871*5c51f124SMoriah Waterland /* if file system type specified, must have a device to mount */ 872*5c51f124SMoriah Waterland 873*5c51f124SMoriah Waterland if (pkgdev.fstyp && !pkgdev.mount) { 874*5c51f124SMoriah Waterland progerr(ERR_F_REQUIRES_M); 875*5c51f124SMoriah Waterland usage(); 876*5c51f124SMoriah Waterland /*NOTREACHED*/ 877*5c51f124SMoriah Waterland } 878*5c51f124SMoriah Waterland 879*5c51f124SMoriah Waterland /* BEGIN DATA GATHERING PHASE */ 880*5c51f124SMoriah Waterland 881*5c51f124SMoriah Waterland /* 882*5c51f124SMoriah Waterland * Get the mount table info and store internally. 883*5c51f124SMoriah Waterland */ 884*5c51f124SMoriah Waterland cont_file_read = B_FALSE; 885*5c51f124SMoriah Waterland if (in_continue_mode()) { 886*5c51f124SMoriah Waterland int error; 887*5c51f124SMoriah Waterland cont_file_read = read_continuation(&error); 888*5c51f124SMoriah Waterland if (error == -1) { 889*5c51f124SMoriah Waterland quit(99); 890*5c51f124SMoriah Waterland /*NOTREACHED*/ 891*5c51f124SMoriah Waterland } 892*5c51f124SMoriah Waterland if (!in_dryrun_mode()) { 893*5c51f124SMoriah Waterland live_continue = 1; 894*5c51f124SMoriah Waterland } 895*5c51f124SMoriah Waterland } 896*5c51f124SMoriah Waterland /* Read the mount table if not done in continuation mode */ 897*5c51f124SMoriah Waterland if (!cont_file_read) { 898*5c51f124SMoriah Waterland if (get_mntinfo(map_client, vfstab_file)) { 899*5c51f124SMoriah Waterland quit(99); 900*5c51f124SMoriah Waterland /*NOTREACHED*/ 901*5c51f124SMoriah Waterland } 902*5c51f124SMoriah Waterland } 903*5c51f124SMoriah Waterland 904*5c51f124SMoriah Waterland /* 905*5c51f124SMoriah Waterland * This function defines the standard /var/... directories used later 906*5c51f124SMoriah Waterland * to construct the paths to the various databases. 907*5c51f124SMoriah Waterland */ 908*5c51f124SMoriah Waterland 909*5c51f124SMoriah Waterland set_PKGpaths(get_inst_root()); 910*5c51f124SMoriah Waterland 911*5c51f124SMoriah Waterland /* 912*5c51f124SMoriah Waterland * If this is being installed on a client whose /var filesystem is 913*5c51f124SMoriah Waterland * mounted in some odd way, remap the administrative paths to the 914*5c51f124SMoriah Waterland * real filesystem. This could be avoided by simply mounting up the 915*5c51f124SMoriah Waterland * client now; but we aren't yet to the point in the process where 916*5c51f124SMoriah Waterland * modification of the filesystem is permitted. 917*5c51f124SMoriah Waterland */ 918*5c51f124SMoriah Waterland if (is_an_inst_root()) { 919*5c51f124SMoriah Waterland int fsys_value; 920*5c51f124SMoriah Waterland 921*5c51f124SMoriah Waterland fsys_value = fsys(get_PKGLOC()); 922*5c51f124SMoriah Waterland if (use_srvr_map_n(fsys_value)) 923*5c51f124SMoriah Waterland set_PKGLOC(server_map(get_PKGLOC(), fsys_value)); 924*5c51f124SMoriah Waterland 925*5c51f124SMoriah Waterland fsys_value = fsys(get_PKGADM()); 926*5c51f124SMoriah Waterland if (use_srvr_map_n(fsys_value)) 927*5c51f124SMoriah Waterland set_PKGADM(server_map(get_PKGADM(), fsys_value)); 928*5c51f124SMoriah Waterland } 929*5c51f124SMoriah Waterland 930*5c51f124SMoriah Waterland /* 931*5c51f124SMoriah Waterland * Initialize pkginfo PKGSAV entry, just in case we dryrun to 932*5c51f124SMoriah Waterland * somewhere else. 933*5c51f124SMoriah Waterland */ 934*5c51f124SMoriah Waterland set_infoloc(get_PKGLOC()); 935*5c51f124SMoriah Waterland 936*5c51f124SMoriah Waterland /* pull off directory and package name from end of command line */ 937*5c51f124SMoriah Waterland 938*5c51f124SMoriah Waterland switch (argc-optind) { 939*5c51f124SMoriah Waterland case 0: /* missing directory and package instance */ 940*5c51f124SMoriah Waterland progerr(ERR_MISSING_DIR_AND_PKG); 941*5c51f124SMoriah Waterland usage(); 942*5c51f124SMoriah Waterland /*NOTREACHED*/ 943*5c51f124SMoriah Waterland case 1: /* missing package instance */ 944*5c51f124SMoriah Waterland progerr(ERR_MISSING_PKG_INSTANCE); 945*5c51f124SMoriah Waterland usage(); 946*5c51f124SMoriah Waterland /*NOTREACHED*/ 947*5c51f124SMoriah Waterland case 2: /* just right! */ 948*5c51f124SMoriah Waterland pkgdev.dirname = argv[optind++]; 949*5c51f124SMoriah Waterland srcinst = argv[optind++]; 950*5c51f124SMoriah Waterland break; 951*5c51f124SMoriah Waterland default: /* too many args! */ 952*5c51f124SMoriah Waterland progerr(ERR_TOO_MANY_CMD_ARGS); 953*5c51f124SMoriah Waterland usage(); 954*5c51f124SMoriah Waterland break; 955*5c51f124SMoriah Waterland } 956*5c51f124SMoriah Waterland 957*5c51f124SMoriah Waterland (void) pkgparam(NULL, NULL); /* close up prior pkg file if needed */ 958*5c51f124SMoriah Waterland 959*5c51f124SMoriah Waterland /* 960*5c51f124SMoriah Waterland * Initialize installation admin parameters by reading 961*5c51f124SMoriah Waterland * the adminfile. 962*5c51f124SMoriah Waterland */ 963*5c51f124SMoriah Waterland 964*5c51f124SMoriah Waterland if (!askflag && !live_continue) { 965*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_ADMINFILE, admnfile ? admnfile : ""); 966*5c51f124SMoriah Waterland setadminFile(admnfile); 967*5c51f124SMoriah Waterland } 968*5c51f124SMoriah Waterland 969*5c51f124SMoriah Waterland /* 970*5c51f124SMoriah Waterland * about to perform first operation that could be modified by the 971*5c51f124SMoriah Waterland * preinstall check option - if preinstall check is selected (that is, 972*5c51f124SMoriah Waterland * only gathering dependencies), then output a debug message to 973*5c51f124SMoriah Waterland * indicate that the check is beginning. Also turn echo() output 974*5c51f124SMoriah Waterland * off and set various other flags. 975*5c51f124SMoriah Waterland */ 976*5c51f124SMoriah Waterland 977*5c51f124SMoriah Waterland if (preinstallCheck == B_TRUE) { 978*5c51f124SMoriah Waterland (void) echoSetFlag(B_FALSE); 979*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_PREINSCHK, 980*5c51f124SMoriah Waterland pkginst ? pkginst : (srcinst ? srcinst : ""), 981*5c51f124SMoriah Waterland zoneName ? zoneName : "global"); 982*5c51f124SMoriah Waterland cksetPreinstallCheck(B_TRUE); 983*5c51f124SMoriah Waterland cksetZoneName(zoneName); 984*5c51f124SMoriah Waterland /* inform quit that the install has started */ 985*5c51f124SMoriah Waterland quitSetInstallStarted(B_TRUE); 986*5c51f124SMoriah Waterland } 987*5c51f124SMoriah Waterland 988*5c51f124SMoriah Waterland /* 989*5c51f124SMoriah Waterland * validate the "rscriptalt" admin file setting 990*5c51f124SMoriah Waterland * The rscriptalt admin file parameter may be set to either 991*5c51f124SMoriah Waterland * RSCRIPTALT_ROOT or RSCRIPTALT_NOACCESS: 992*5c51f124SMoriah Waterland * --> If rscriptalt is not set, or is set to RSCRIPTALT_NOACCESS, 993*5c51f124SMoriah Waterland * --> or is set to any value OTHER than RSCRIPTALT_ROOT, then 994*5c51f124SMoriah Waterland * --> assume that the parameter is set to RSCRIPTALT_NOACCESS 995*5c51f124SMoriah Waterland * If rscriptalt is set to RSCRIPTALT_ROOT, then run request scripts 996*5c51f124SMoriah Waterland * as the "root" user if user "install" is not defined. 997*5c51f124SMoriah Waterland * Otherwise, assume rscriptalt is set to RSCRIPTALT_NOACCESS, and run 998*5c51f124SMoriah Waterland * request scripts as the "alternative" user if user "install" is not 999*5c51f124SMoriah Waterland * defined, as appropriate for the current setting of the NONABI_SCRIPTS 1000*5c51f124SMoriah Waterland * environment variable. 1001*5c51f124SMoriah Waterland */ 1002*5c51f124SMoriah Waterland 1003*5c51f124SMoriah Waterland if (ADMSET(RSCRIPTALT)) { 1004*5c51f124SMoriah Waterland p = adm.RSCRIPTALT; 1005*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_RSCRIPT_SET_TO, RSCRIPTALT_KEYWORD, p); 1006*5c51f124SMoriah Waterland if (strcasecmp(p, RSCRIPTALT_ROOT) == 0) { 1007*5c51f124SMoriah Waterland /* rscriptalt=root */ 1008*5c51f124SMoriah Waterland run_request_as_root = B_TRUE; 1009*5c51f124SMoriah Waterland } else if (strcasecmp(p, RSCRIPTALT_NOACCESS) == 0) { 1010*5c51f124SMoriah Waterland /* rscriptalt=noaccess */ 1011*5c51f124SMoriah Waterland run_request_as_root = B_FALSE; 1012*5c51f124SMoriah Waterland } else { 1013*5c51f124SMoriah Waterland /* rscriptalt=??? */ 1014*5c51f124SMoriah Waterland logerr(WRN_RSCRIPTALT_BAD, RSCRIPTALT_KEYWORD, p, 1015*5c51f124SMoriah Waterland RSCRIPTALT_ROOT, RSCRIPTALT_NOACCESS); 1016*5c51f124SMoriah Waterland logerr(WRN_RSCRIPTALT_USING, RSCRIPTALT_KEYWORD, 1017*5c51f124SMoriah Waterland RSCRIPTALT_NOACCESS); 1018*5c51f124SMoriah Waterland run_request_as_root = B_FALSE; 1019*5c51f124SMoriah Waterland } 1020*5c51f124SMoriah Waterland } else { 1021*5c51f124SMoriah Waterland /* rscriptalt not set - assume rscriptalt=noaccess */ 1022*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_RSCRIPT_NOT_SET, RSCRIPTALT_KEYWORD); 1023*5c51f124SMoriah Waterland run_request_as_root = B_FALSE; 1024*5c51f124SMoriah Waterland } 1025*5c51f124SMoriah Waterland 1026*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_RSCRIPT_IS_ROOT, run_request_as_root); 1027*5c51f124SMoriah Waterland 1028*5c51f124SMoriah Waterland /* 1029*5c51f124SMoriah Waterland * hook SIGINT and SIGHUP interrupts into quit.c's trap handler 1030*5c51f124SMoriah Waterland */ 1031*5c51f124SMoriah Waterland 1032*5c51f124SMoriah Waterland /* hold SIGINT/SIGHUP interrupts */ 1033*5c51f124SMoriah Waterland 1034*5c51f124SMoriah Waterland (void) sighold(SIGHUP); 1035*5c51f124SMoriah Waterland (void) sighold(SIGINT); 1036*5c51f124SMoriah Waterland 1037*5c51f124SMoriah Waterland /* connect quit.c:trap() to SIGINT */ 1038*5c51f124SMoriah Waterland 1039*5c51f124SMoriah Waterland nact.sa_handler = quitGetTrapHandler(); 1040*5c51f124SMoriah Waterland nact.sa_flags = SA_RESTART; 1041*5c51f124SMoriah Waterland (void) sigemptyset(&nact.sa_mask); 1042*5c51f124SMoriah Waterland 1043*5c51f124SMoriah Waterland (void) sigaction(SIGINT, &nact, &oact); 1044*5c51f124SMoriah Waterland 1045*5c51f124SMoriah Waterland /* connect quit.c:trap() to SIGHUP */ 1046*5c51f124SMoriah Waterland 1047*5c51f124SMoriah Waterland nact.sa_handler = quitGetTrapHandler(); 1048*5c51f124SMoriah Waterland nact.sa_flags = SA_RESTART; 1049*5c51f124SMoriah Waterland (void) sigemptyset(&nact.sa_mask); 1050*5c51f124SMoriah Waterland 1051*5c51f124SMoriah Waterland (void) sigaction(SIGHUP, &nact, &oact); 1052*5c51f124SMoriah Waterland 1053*5c51f124SMoriah Waterland /* release hold on signals */ 1054*5c51f124SMoriah Waterland 1055*5c51f124SMoriah Waterland (void) sigrelse(SIGHUP); 1056*5c51f124SMoriah Waterland (void) sigrelse(SIGINT); 1057*5c51f124SMoriah Waterland 1058*5c51f124SMoriah Waterland /* 1059*5c51f124SMoriah Waterland * create required /var... directories if they do not exist; 1060*5c51f124SMoriah Waterland * this function will call quit(99) if any required path cannot 1061*5c51f124SMoriah Waterland * be created. 1062*5c51f124SMoriah Waterland */ 1063*5c51f124SMoriah Waterland 1064*5c51f124SMoriah Waterland ckdirs(); 1065*5c51f124SMoriah Waterland 1066*5c51f124SMoriah Waterland tzset(); 1067*5c51f124SMoriah Waterland 1068*5c51f124SMoriah Waterland /* 1069*5c51f124SMoriah Waterland * create path to temporary directory "installXXXXXX" - if TMPDIR 1070*5c51f124SMoriah Waterland * environment variable is set, create the directory in $TMPDIR; 1071*5c51f124SMoriah Waterland * otherwise, create the directory in P_tmpdir. 1072*5c51f124SMoriah Waterland */ 1073*5c51f124SMoriah Waterland 1074*5c51f124SMoriah Waterland pt = getenv("TMPDIR"); 1075*5c51f124SMoriah Waterland (void) snprintf(tmpdir, sizeof (tmpdir), "%s/installXXXXXX", 1076*5c51f124SMoriah Waterland ((pt != (char *)NULL) && (*pt != '\0')) ? pt : P_tmpdir); 1077*5c51f124SMoriah Waterland 1078*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_TMPDIR, tmpdir); 1079*5c51f124SMoriah Waterland 1080*5c51f124SMoriah Waterland if ((mktemp(tmpdir) == NULL) || mkdir(tmpdir, 0771)) { 1081*5c51f124SMoriah Waterland progerr(ERR_MKDIR, tmpdir); 1082*5c51f124SMoriah Waterland quit(99); 1083*5c51f124SMoriah Waterland /*NOTREACHED*/ 1084*5c51f124SMoriah Waterland } 1085*5c51f124SMoriah Waterland 1086*5c51f124SMoriah Waterland /* 1087*5c51f124SMoriah Waterland * if the package device is a file containing a package stream, 1088*5c51f124SMoriah Waterland * unpack the stream into a temporary directory 1089*5c51f124SMoriah Waterland */ 1090*5c51f124SMoriah Waterland 1091*5c51f124SMoriah Waterland if ((isdir(pkgdev.dirname) != 0) && 1092*5c51f124SMoriah Waterland (pkgdev.cdevice == (char *)NULL) && 1093*5c51f124SMoriah Waterland (pkgdev.bdevice == (char *)NULL) && 1094*5c51f124SMoriah Waterland (isfile((char *)NULL, pkgdev.dirname) == 0)) { 1095*5c51f124SMoriah Waterland 1096*5c51f124SMoriah Waterland char *idsName = (char *)NULL; 1097*5c51f124SMoriah Waterland char *pkgnames[2]; 1098*5c51f124SMoriah Waterland char *device = pkgdev.dirname; 1099*5c51f124SMoriah Waterland boolean_t b; 1100*5c51f124SMoriah Waterland 1101*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_DS_ISFILE, pkgdev.dirname); 1102*5c51f124SMoriah Waterland 1103*5c51f124SMoriah Waterland /* 1104*5c51f124SMoriah Waterland * validate the package source device - return pkgdev info that 1105*5c51f124SMoriah Waterland * describes the package source device. 1106*5c51f124SMoriah Waterland */ 1107*5c51f124SMoriah Waterland 1108*5c51f124SMoriah Waterland if (devtype(device, &pkgdev)) { 1109*5c51f124SMoriah Waterland progerr(ERR_BAD_DEVICE, device); 1110*5c51f124SMoriah Waterland quit(99); 1111*5c51f124SMoriah Waterland /* NOTREACHED */ 1112*5c51f124SMoriah Waterland } 1113*5c51f124SMoriah Waterland 1114*5c51f124SMoriah Waterland /* generate the list of packages to verify */ 1115*5c51f124SMoriah Waterland 1116*5c51f124SMoriah Waterland pkgnames[0] = srcinst; 1117*5c51f124SMoriah Waterland pkgnames[1] = (char *)NULL; 1118*5c51f124SMoriah Waterland 1119*5c51f124SMoriah Waterland b = open_package_datastream(1, pkgnames, (char *)NULL, 1120*5c51f124SMoriah Waterland pkgdev.dirname, (int *)NULL, &idsName, tmpdir, &pkgdev, 1121*5c51f124SMoriah Waterland 1); 1122*5c51f124SMoriah Waterland 1123*5c51f124SMoriah Waterland if (b == B_FALSE) { 1124*5c51f124SMoriah Waterland progerr(ERR_CANNOT_OPEN_PKG_STREAM, 1125*5c51f124SMoriah Waterland pkgdev.dirname ? pkgdev.dirname : "?"); 1126*5c51f124SMoriah Waterland quit(99); 1127*5c51f124SMoriah Waterland /*NOTREACHED*/ 1128*5c51f124SMoriah Waterland } 1129*5c51f124SMoriah Waterland 1130*5c51f124SMoriah Waterland /* make sure temporary directory is removed on exit */ 1131*5c51f124SMoriah Waterland 1132*5c51f124SMoriah Waterland quitSetDstreamTmpdir(pkgdev.dirname); 1133*5c51f124SMoriah Waterland 1134*5c51f124SMoriah Waterland /* unpack the package instance from the data stream */ 1135*5c51f124SMoriah Waterland 1136*5c51f124SMoriah Waterland b = unpack_package_from_stream(idsName, srcinst, 1137*5c51f124SMoriah Waterland pkgdev.dirname); 1138*5c51f124SMoriah Waterland if (b == B_FALSE) { 1139*5c51f124SMoriah Waterland progerr(ERR_CANNOT_UNPACK_PKGSTRM, 1140*5c51f124SMoriah Waterland srcinst ? srcinst : "?", 1141*5c51f124SMoriah Waterland idsName ? idsName : "?", 1142*5c51f124SMoriah Waterland pkgdev.dirname ? pkgdev.dirname : "?"); 1143*5c51f124SMoriah Waterland quit(99); 1144*5c51f124SMoriah Waterland /*NOTREACHED*/ 1145*5c51f124SMoriah Waterland } 1146*5c51f124SMoriah Waterland 1147*5c51f124SMoriah Waterland /* close the datastream - no longer needed */ 1148*5c51f124SMoriah Waterland 1149*5c51f124SMoriah Waterland echoDebug(DBG_CLOSING_STREAM, idsName, pkgdev.dirname); 1150*5c51f124SMoriah Waterland (void) ds_close(1); 1151*5c51f124SMoriah Waterland } 1152*5c51f124SMoriah Waterland 1153*5c51f124SMoriah Waterland if (snprintf(instdir, PATH_MAX, "%s/%s", pkgdev.dirname, srcinst) 1154*5c51f124SMoriah Waterland >= PATH_MAX) { 1155*5c51f124SMoriah Waterland progerr(ERR_SNPRINTF, instdir); 1156*5c51f124SMoriah Waterland quit(99); 1157*5c51f124SMoriah Waterland /*NOTREACHED*/ 1158*5c51f124SMoriah Waterland } 1159*5c51f124SMoriah Waterland 1160*5c51f124SMoriah Waterland zoneName = getenv(PKG_ZONENAME_VARIABLE); 1161*5c51f124SMoriah Waterland 1162*5c51f124SMoriah Waterland /* 1163*5c51f124SMoriah Waterland * If the environment has a CLIENT_BASEDIR, that takes precedence 1164*5c51f124SMoriah Waterland * over anything we will construct. We need to save it here because 1165*5c51f124SMoriah Waterland * in three lines, the current environment goes away. 1166*5c51f124SMoriah Waterland */ 1167*5c51f124SMoriah Waterland (void) set_env_cbdir(); /* copy over environ */ 1168*5c51f124SMoriah Waterland 1169*5c51f124SMoriah Waterland getuserlocale(); 1170*5c51f124SMoriah Waterland 1171*5c51f124SMoriah Waterland /* 1172*5c51f124SMoriah Waterland * current environment has been read; clear environment out 1173*5c51f124SMoriah Waterland * so putparam() can be used to populate the new environment 1174*5c51f124SMoriah Waterland * to be passed to any executables/scripts. 1175*5c51f124SMoriah Waterland */ 1176*5c51f124SMoriah Waterland 1177*5c51f124SMoriah Waterland environ = NULL; 1178*5c51f124SMoriah Waterland 1179*5c51f124SMoriah Waterland /* write parent condition information to environment */ 1180*5c51f124SMoriah Waterland 1181*5c51f124SMoriah Waterland putConditionInfo(parentZoneName, parentZoneType); 1182*5c51f124SMoriah Waterland 1183*5c51f124SMoriah Waterland putuserlocale(); 1184*5c51f124SMoriah Waterland 1185*5c51f124SMoriah Waterland if (init_install) { 1186*5c51f124SMoriah Waterland putparam("PKG_INIT_INSTALL", "TRUE"); 1187*5c51f124SMoriah Waterland } 1188*5c51f124SMoriah Waterland 1189*5c51f124SMoriah Waterland if (is_an_inst_root()) { 1190*5c51f124SMoriah Waterland export_client_env(get_inst_root()); 1191*5c51f124SMoriah Waterland } 1192*5c51f124SMoriah Waterland 1193*5c51f124SMoriah Waterland if (zoneName != (char *)NULL) { 1194*5c51f124SMoriah Waterland putparam(PKG_ZONENAME_VARIABLE, zoneName); 1195*5c51f124SMoriah Waterland } 1196*5c51f124SMoriah Waterland 1197*5c51f124SMoriah Waterland putparam("INST_DATADIR", pkgdev.dirname); 1198*5c51f124SMoriah Waterland 1199*5c51f124SMoriah Waterland if (non_abi_scripts) { 1200*5c51f124SMoriah Waterland putparam("NONABI_SCRIPTS", "TRUE"); 1201*5c51f124SMoriah Waterland } 1202*5c51f124SMoriah Waterland 1203*5c51f124SMoriah Waterland if (nonABI_symlinks()) { 1204*5c51f124SMoriah Waterland putparam("PKG_NONABI_SYMLINKS", "TRUE"); 1205*5c51f124SMoriah Waterland } 1206*5c51f124SMoriah Waterland 1207*5c51f124SMoriah Waterland if (get_ABI_namelngth()) { 1208*5c51f124SMoriah Waterland putparam("PKG_ABI_NAMELENGTH", "TRUE"); 1209*5c51f124SMoriah Waterland } 1210*5c51f124SMoriah Waterland 1211*5c51f124SMoriah Waterland /* establish path and oambase */ 1212*5c51f124SMoriah Waterland 1213*5c51f124SMoriah Waterland if (cmdbin[0] == '\0') { 1214*5c51f124SMoriah Waterland (void) strlcpy(cmdbin, PKGBIN, sizeof (cmdbin)); 1215*5c51f124SMoriah Waterland } 1216*5c51f124SMoriah Waterland 1217*5c51f124SMoriah Waterland (void) snprintf(path, sizeof (path), "%s:%s", DEFPATH, cmdbin); 1218*5c51f124SMoriah Waterland 1219*5c51f124SMoriah Waterland putparam("PATH", path); 1220*5c51f124SMoriah Waterland 1221*5c51f124SMoriah Waterland putparam("OAMBASE", OAMBASE); 1222*5c51f124SMoriah Waterland 1223*5c51f124SMoriah Waterland (void) snprintf(p_pkginfo, sizeof (p_pkginfo), 1224*5c51f124SMoriah Waterland "%s/%s", instdir, PKGINFO); 1225*5c51f124SMoriah Waterland (void) snprintf(p_pkgmap, sizeof (p_pkgmap), 1226*5c51f124SMoriah Waterland "%s/%s", instdir, PKGMAP); 1227*5c51f124SMoriah Waterland 1228*5c51f124SMoriah Waterland /* Read the environment (from pkginfo or '-e') ... */ 1229*5c51f124SMoriah Waterland abi_nm_ptr = getenv("PKG_ABI_NAMELENGTH"); 1230*5c51f124SMoriah Waterland 1231*5c51f124SMoriah Waterland /* Disable the 32 char name limit extension */ 1232*5c51f124SMoriah Waterland if (abi_nm_ptr && strncasecmp(abi_nm_ptr, "TRUE", 4) == 0) { 1233*5c51f124SMoriah Waterland (void) set_ABI_namelngth(); 1234*5c51f124SMoriah Waterland } 1235*5c51f124SMoriah Waterland 1236*5c51f124SMoriah Waterland /* 1237*5c51f124SMoriah Waterland * This tests the pkginfo and pkgmap files for validity and 1238*5c51f124SMoriah Waterland * puts all delivered pkginfo variables (except for PATH) into 1239*5c51f124SMoriah Waterland * our environment. This is where a delivered pkginfo BASEDIR 1240*5c51f124SMoriah Waterland * would come from. See set_basedirs() below. 1241*5c51f124SMoriah Waterland */ 1242*5c51f124SMoriah Waterland 1243*5c51f124SMoriah Waterland if (pkgenv(srcinst, p_pkginfo, p_pkgmap)) { 1244*5c51f124SMoriah Waterland quit(1); 1245*5c51f124SMoriah Waterland /*NOTREACHED*/ 1246*5c51f124SMoriah Waterland } 1247*5c51f124SMoriah Waterland 1248*5c51f124SMoriah Waterland echo("\n%s(%s) %s", pkgname, pkgarch, pkgvers); 1249*5c51f124SMoriah Waterland 1250*5c51f124SMoriah Waterland /* 1251*5c51f124SMoriah Waterland * If this script was invoked by 'pkgask', just 1252*5c51f124SMoriah Waterland * execute request script and quit (do_pkgask()). 1253*5c51f124SMoriah Waterland */ 1254*5c51f124SMoriah Waterland 1255*5c51f124SMoriah Waterland if (askflag) { 1256*5c51f124SMoriah Waterland do_pkgask(run_request_as_root); 1257*5c51f124SMoriah Waterland } 1258*5c51f124SMoriah Waterland 1259*5c51f124SMoriah Waterland /* validate package contents file */ 1260*5c51f124SMoriah Waterland 1261*5c51f124SMoriah Waterland if (vcfile() == 0) { 1262*5c51f124SMoriah Waterland quit(99); 1263*5c51f124SMoriah Waterland } 1264*5c51f124SMoriah Waterland 1265*5c51f124SMoriah Waterland /* if not in dryrun mode aquire packaging lock */ 1266*5c51f124SMoriah Waterland 1267*5c51f124SMoriah Waterland if (!in_dryrun_mode()) { 1268*5c51f124SMoriah Waterland /* acquire the package lock - at install initialization */ 1269*5c51f124SMoriah Waterland if (!lockinst(get_prog_name(), srcinst, "install-initial")) { 1270*5c51f124SMoriah Waterland quit(99); 1271*5c51f124SMoriah Waterland /*NOTREACHED*/ 1272*5c51f124SMoriah Waterland } 1273*5c51f124SMoriah Waterland } 1274*5c51f124SMoriah Waterland 1275*5c51f124SMoriah Waterland /* 1276*5c51f124SMoriah Waterland * Now do all the various setups based on ABI compliance 1277*5c51f124SMoriah Waterland */ 1278*5c51f124SMoriah Waterland 1279*5c51f124SMoriah Waterland /* Read the environment (from pkginfo or '-o') ... */ 1280*5c51f124SMoriah Waterland abi_comp_ptr = getenv("NONABI_SCRIPTS"); 1281*5c51f124SMoriah Waterland 1282*5c51f124SMoriah Waterland /* Read the environment (from pkginfo or '-y') ... */ 1283*5c51f124SMoriah Waterland abi_sym_ptr = getenv("PKG_NONABI_SYMLINKS"); 1284*5c51f124SMoriah Waterland 1285*5c51f124SMoriah Waterland /* bug id 4244631, not ABI compliant */ 1286*5c51f124SMoriah Waterland if (abi_comp_ptr && strncasecmp(abi_comp_ptr, "TRUE", 4) == 0) { 1287*5c51f124SMoriah Waterland script_in = PROC_XSTDIN; 1288*5c51f124SMoriah Waterland non_abi_scripts = 1; 1289*5c51f124SMoriah Waterland } 1290*5c51f124SMoriah Waterland 1291*5c51f124SMoriah Waterland #ifdef ALLOW_EXCEPTION_PKG_LIST 1292*5c51f124SMoriah Waterland /* 1293*5c51f124SMoriah Waterland * ********************************************************************* 1294*5c51f124SMoriah Waterland * this feature is removed starting with Solaris 10 - there is no built 1295*5c51f124SMoriah Waterland * in list of packages that should be run "the old way" 1296*5c51f124SMoriah Waterland * ********************************************************************* 1297*5c51f124SMoriah Waterland */ 1298*5c51f124SMoriah Waterland 1299*5c51f124SMoriah Waterland else if (exception_pkg(srcinst, SCRIPT)) { 1300*5c51f124SMoriah Waterland /* 1301*5c51f124SMoriah Waterland * Until on1095, set it from exception package names as 1302*5c51f124SMoriah Waterland * well. 1303*5c51f124SMoriah Waterland */ 1304*5c51f124SMoriah Waterland putparam("NONABI_SCRIPTS", "TRUE"); 1305*5c51f124SMoriah Waterland script_in = PROC_XSTDIN; 1306*5c51f124SMoriah Waterland non_abi_scripts = 1; 1307*5c51f124SMoriah Waterland } 1308*5c51f124SMoriah Waterland #endif 1309*5c51f124SMoriah Waterland 1310*5c51f124SMoriah Waterland /* Set symlinks to be processed the old way */ 1311*5c51f124SMoriah Waterland if (abi_sym_ptr && strncasecmp(abi_sym_ptr, "TRUE", 4) == 0) { 1312*5c51f124SMoriah Waterland set_nonABI_symlinks(); 1313*5c51f124SMoriah Waterland } 1314*5c51f124SMoriah Waterland /* 1315*5c51f124SMoriah Waterland * ********************************************************************* 1316*5c51f124SMoriah Waterland * this feature is removed starting with Solaris 10 - there is no built 1317*5c51f124SMoriah Waterland * in list of packages that should be run "the old way" 1318*5c51f124SMoriah Waterland * ********************************************************************* 1319*5c51f124SMoriah Waterland */ 1320*5c51f124SMoriah Waterland 1321*5c51f124SMoriah Waterland #ifdef ALLOW_EXCEPTION_PKG_LIST 1322*5c51f124SMoriah Waterland else if (exception_pkg(srcinst, LINK)) { 1323*5c51f124SMoriah Waterland /* Until 2.9, set it from the execption list */ 1324*5c51f124SMoriah Waterland putparam("PKG_NONABI_SYMLINKS", "TRUE"); 1325*5c51f124SMoriah Waterland set_nonABI_symlinks(); 1326*5c51f124SMoriah Waterland } 1327*5c51f124SMoriah Waterland #endif 1328*5c51f124SMoriah Waterland /* 1329*5c51f124SMoriah Waterland * At this point, script_in, non_abi_scripts & the environment are 1330*5c51f124SMoriah Waterland * all set correctly for the ABI status of the package. 1331*5c51f124SMoriah Waterland */ 1332*5c51f124SMoriah Waterland 1333*5c51f124SMoriah Waterland if (pt = getenv("MAXINST")) { 1334*5c51f124SMoriah Waterland maxinst = atol(pt); 1335*5c51f124SMoriah Waterland } 1336*5c51f124SMoriah Waterland 1337*5c51f124SMoriah Waterland /* 1338*5c51f124SMoriah Waterland * See if were are installing a package that only wants to update 1339*5c51f124SMoriah Waterland * the database or only install files associated with CAS's. We 1340*5c51f124SMoriah Waterland * only check the PKG_HOLLOW_VARIABLE variable if told to do so by 1341*5c51f124SMoriah Waterland * the caller. 1342*5c51f124SMoriah Waterland */ 1343*5c51f124SMoriah Waterland 1344*5c51f124SMoriah Waterland if (is_depend_pkginfo_DB()) { 1345*5c51f124SMoriah Waterland pt = getenv(PKG_HOLLOW_VARIABLE); 1346*5c51f124SMoriah Waterland if ((pt != NULL) && (strncasecmp(pt, "true", 4) == 0)) { 1347*5c51f124SMoriah Waterland echoDebug(DBG_PKGREMOVE_HOLLOW_ENABLED); 1348*5c51f124SMoriah Waterland if (disableAttributes) { 1349*5c51f124SMoriah Waterland disable_attribute_check(); 1350*5c51f124SMoriah Waterland } 1351*5c51f124SMoriah Waterland 1352*5c51f124SMoriah Waterland /* 1353*5c51f124SMoriah Waterland * this is a hollow package and hollow package support 1354*5c51f124SMoriah Waterland * is enabled -- override admin settings to suppress 1355*5c51f124SMoriah Waterland * checks that do not make sense since no scripts will 1356*5c51f124SMoriah Waterland * be executed and no files will be installed. 1357*5c51f124SMoriah Waterland */ 1358*5c51f124SMoriah Waterland 1359*5c51f124SMoriah Waterland setadminSetting("conflict", "nocheck"); 1360*5c51f124SMoriah Waterland setadminSetting("setuid", "nocheck"); 1361*5c51f124SMoriah Waterland setadminSetting("action", "nocheck"); 1362*5c51f124SMoriah Waterland setadminSetting("partial", "nocheck"); 1363*5c51f124SMoriah Waterland setadminSetting("space", "nocheck"); 1364*5c51f124SMoriah Waterland setadminSetting("authentication", "nocheck"); 1365*5c51f124SMoriah Waterland } else { 1366*5c51f124SMoriah Waterland echoDebug(DBG_PKGREMOVE_HOLLOW_DISABLED); 1367*5c51f124SMoriah Waterland set_depend_pkginfo_DB(B_FALSE); 1368*5c51f124SMoriah Waterland } 1369*5c51f124SMoriah Waterland } 1370*5c51f124SMoriah Waterland 1371*5c51f124SMoriah Waterland /* 1372*5c51f124SMoriah Waterland * if performing a fresh install to a non-global zone, and doing 1373*5c51f124SMoriah Waterland * more than just updating the package database (that is, the 1374*5c51f124SMoriah Waterland * package to install is NOT "hollow"), then set the global flag 1375*5c51f124SMoriah Waterland * that directs installation is from partially spooled packages 1376*5c51f124SMoriah Waterland * (that is, packages installed in the global zone). 1377*5c51f124SMoriah Waterland */ 1378*5c51f124SMoriah Waterland 1379*5c51f124SMoriah Waterland if (saveSpoolInstall && (!is_depend_pkginfo_DB())) { 1380*5c51f124SMoriah Waterland set_partial_inst(); 1381*5c51f124SMoriah Waterland } else { 1382*5c51f124SMoriah Waterland saveSpoolInstall = 0; 1383*5c51f124SMoriah Waterland } 1384*5c51f124SMoriah Waterland 1385*5c51f124SMoriah Waterland /* 1386*5c51f124SMoriah Waterland * verify that we are not trying to install an 1387*5c51f124SMoriah Waterland * INTONLY package with no interaction 1388*5c51f124SMoriah Waterland */ 1389*5c51f124SMoriah Waterland 1390*5c51f124SMoriah Waterland if (pt = getenv("INTONLY")) { 1391*5c51f124SMoriah Waterland if (askflag || nointeract) { 1392*5c51f124SMoriah Waterland progerr(ERR_INTONLY, pkgabrv ? pkgabrv : "?"); 1393*5c51f124SMoriah Waterland quit(1); 1394*5c51f124SMoriah Waterland /*NOTREACHED*/ 1395*5c51f124SMoriah Waterland } 1396*5c51f124SMoriah Waterland } 1397*5c51f124SMoriah Waterland 1398*5c51f124SMoriah Waterland if (!suppressCopyright && !pkgdev.cdevice) { 1399*5c51f124SMoriah Waterland copyright(); 1400*5c51f124SMoriah Waterland } 1401*5c51f124SMoriah Waterland 1402*5c51f124SMoriah Waterland /* 1403*5c51f124SMoriah Waterland * inspect the system to determine if any instances of the 1404*5c51f124SMoriah Waterland * package being installed already exist on the system 1405*5c51f124SMoriah Waterland */ 1406*5c51f124SMoriah Waterland 1407*5c51f124SMoriah Waterland prvinfo = (struct pkginfo *)calloc(MALSIZ, sizeof (struct pkginfo)); 1408*5c51f124SMoriah Waterland if (prvinfo == NULL) { 1409*5c51f124SMoriah Waterland progerr(ERR_MEMORY, errno); 1410*5c51f124SMoriah Waterland quit(99); 1411*5c51f124SMoriah Waterland /*NOTREACHED*/ 1412*5c51f124SMoriah Waterland } 1413*5c51f124SMoriah Waterland 1414*5c51f124SMoriah Waterland for (;;) { 1415*5c51f124SMoriah Waterland if (pkginfo(&prvinfo[npkgs], pkgwild, NULL, NULL)) { 1416*5c51f124SMoriah Waterland if ((errno == ESRCH) || (errno == ENOENT)) { 1417*5c51f124SMoriah Waterland break; 1418*5c51f124SMoriah Waterland } 1419*5c51f124SMoriah Waterland progerr(ERR_SYSINFO, errno); 1420*5c51f124SMoriah Waterland quit(99); 1421*5c51f124SMoriah Waterland /*NOTREACHED*/ 1422*5c51f124SMoriah Waterland } 1423*5c51f124SMoriah Waterland if ((++npkgs % MALSIZ) == 0) { 1424*5c51f124SMoriah Waterland prvinfo = (struct pkginfo *)realloc(prvinfo, 1425*5c51f124SMoriah Waterland (npkgs+MALSIZ) * sizeof (struct pkginfo)); 1426*5c51f124SMoriah Waterland if (prvinfo == NULL) { 1427*5c51f124SMoriah Waterland progerr(ERR_MEMORY, errno); 1428*5c51f124SMoriah Waterland quit(99); 1429*5c51f124SMoriah Waterland /*NOTREACHED*/ 1430*5c51f124SMoriah Waterland } 1431*5c51f124SMoriah Waterland } 1432*5c51f124SMoriah Waterland } 1433*5c51f124SMoriah Waterland 1434*5c51f124SMoriah Waterland /* 1435*5c51f124SMoriah Waterland * Determine the correct package instance based on how many packages are 1436*5c51f124SMoriah Waterland * already installed. If there are none (npkgs == 0), getinst() just 1437*5c51f124SMoriah Waterland * returns the package abbreviation. Otherwise, getinst() interacts with 1438*5c51f124SMoriah Waterland * the user (or reads the admin file) to determine if an instance which 1439*5c51f124SMoriah Waterland * is already installed should be overwritten, or possibly install a new 1440*5c51f124SMoriah Waterland * instance of this package 1441*5c51f124SMoriah Waterland */ 1442*5c51f124SMoriah Waterland 1443*5c51f124SMoriah Waterland pkginst = getinst(&update, prvinfo, npkgs, preinstallCheck); 1444*5c51f124SMoriah Waterland 1445*5c51f124SMoriah Waterland /* set "update flag" if updating an existing instance of this package */ 1446*5c51f124SMoriah Waterland 1447*5c51f124SMoriah Waterland if (update) { 1448*5c51f124SMoriah Waterland setUpdate(); 1449*5c51f124SMoriah Waterland } 1450*5c51f124SMoriah Waterland 1451*5c51f124SMoriah Waterland /* 1452*5c51f124SMoriah Waterland * Need to force UPDATE to be NULL in case a patch has been applied 1453*5c51f124SMoriah Waterland * before creating a zone. Some pkgs (SUNWcsr) already spooled 1454*5c51f124SMoriah Waterland * to the zone, check the value of UPDATE in their postinstall script. 1455*5c51f124SMoriah Waterland * After a pkg has been patched UPDATE exists statically in the 1456*5c51f124SMoriah Waterland * pkginfo file and this value must be reset when installing a zone. 1457*5c51f124SMoriah Waterland */ 1458*5c51f124SMoriah Waterland 1459*5c51f124SMoriah Waterland if (saveSpoolInstall != 0 && !isPatchUpdate() && !isUpdate()) { 1460*5c51f124SMoriah Waterland putparam("UPDATE", ""); 1461*5c51f124SMoriah Waterland } 1462*5c51f124SMoriah Waterland 1463*5c51f124SMoriah Waterland /* inform quit() if updating existing or installing new instance */ 1464*5c51f124SMoriah Waterland 1465*5c51f124SMoriah Waterland quitSetUpdatingExisting(update ? B_TRUE : B_FALSE); 1466*5c51f124SMoriah Waterland 1467*5c51f124SMoriah Waterland if (respfile) { 1468*5c51f124SMoriah Waterland (void) set_respfile(respfile, pkginst, RESP_RO); 1469*5c51f124SMoriah Waterland } 1470*5c51f124SMoriah Waterland 1471*5c51f124SMoriah Waterland (void) snprintf(pkgloc, sizeof (pkgloc), 1472*5c51f124SMoriah Waterland "%s/%s", get_PKGLOC(), pkginst); 1473*5c51f124SMoriah Waterland 1474*5c51f124SMoriah Waterland (void) snprintf(pkgbin, sizeof (pkgbin), 1475*5c51f124SMoriah Waterland "%s/install", pkgloc); 1476*5c51f124SMoriah Waterland 1477*5c51f124SMoriah Waterland (void) snprintf(pkgsav, sizeof (pkgsav), 1478*5c51f124SMoriah Waterland "%s/save", pkgloc); 1479*5c51f124SMoriah Waterland 1480*5c51f124SMoriah Waterland if (snprintf(saveSpoolInstallDir, PATH_MAX, "%s/pspool/%s", pkgsav, 1481*5c51f124SMoriah Waterland pkginst) < 0) { 1482*5c51f124SMoriah Waterland progerr(ERR_SNPRINTF, saveSpoolInstallDir); 1483*5c51f124SMoriah Waterland quit(99); 1484*5c51f124SMoriah Waterland /*NOTREACHED*/ 1485*5c51f124SMoriah Waterland } 1486*5c51f124SMoriah Waterland 1487*5c51f124SMoriah Waterland (void) snprintf(ilockfile, sizeof (ilockfile), 1488*5c51f124SMoriah Waterland "%s/!I-Lock!", pkgloc); 1489*5c51f124SMoriah Waterland (void) snprintf(rlockfile, sizeof (rlockfile), 1490*5c51f124SMoriah Waterland "%s/!R-Lock!", pkgloc); 1491*5c51f124SMoriah Waterland (void) snprintf(savlog, sizeof (savlog), 1492*5c51f124SMoriah Waterland "%s/logs/%s", get_PKGADM(), pkginst); 1493*5c51f124SMoriah Waterland 1494*5c51f124SMoriah Waterland putparam("PKGINST", pkginst); 1495*5c51f124SMoriah Waterland putparam("PKGSAV", pkgsav); 1496*5c51f124SMoriah Waterland 1497*5c51f124SMoriah Waterland /* 1498*5c51f124SMoriah Waterland * Be sure request script has access to PKG_INSTALL_ROOT if there is 1499*5c51f124SMoriah Waterland * one 1500*5c51f124SMoriah Waterland */ 1501*5c51f124SMoriah Waterland 1502*5c51f124SMoriah Waterland put_path_params(); 1503*5c51f124SMoriah Waterland 1504*5c51f124SMoriah Waterland if (!map_client) { 1505*5c51f124SMoriah Waterland putparam("PKG_NO_UNIFIED", "TRUE"); 1506*5c51f124SMoriah Waterland } 1507*5c51f124SMoriah Waterland 1508*5c51f124SMoriah Waterland /* 1509*5c51f124SMoriah Waterland * This maps the client filesystems into the server's space. 1510*5c51f124SMoriah Waterland */ 1511*5c51f124SMoriah Waterland 1512*5c51f124SMoriah Waterland if (map_client && !mount_client()) { 1513*5c51f124SMoriah Waterland logerr(MSG_MANMOUNT); 1514*5c51f124SMoriah Waterland } 1515*5c51f124SMoriah Waterland 1516*5c51f124SMoriah Waterland /* 1517*5c51f124SMoriah Waterland * If this is an UPDATE then either this is exactly the same version 1518*5c51f124SMoriah Waterland * and architecture of an installed package or a different package is 1519*5c51f124SMoriah Waterland * intended to entirely replace an installed package of the same name 1520*5c51f124SMoriah Waterland * with a different VERSION or ARCH string. 1521*5c51f124SMoriah Waterland * Don't merge any databases if only gathering dependencies. 1522*5c51f124SMoriah Waterland */ 1523*5c51f124SMoriah Waterland 1524*5c51f124SMoriah Waterland if ((preinstallCheck == B_FALSE) && (update)) { 1525*5c51f124SMoriah Waterland /* 1526*5c51f124SMoriah Waterland * If this version and architecture is already installed, 1527*5c51f124SMoriah Waterland * merge the installed and installing parameters and inform 1528*5c51f124SMoriah Waterland * all procedure scripts by defining UPDATE in the 1529*5c51f124SMoriah Waterland * environment. 1530*5c51f124SMoriah Waterland */ 1531*5c51f124SMoriah Waterland 1532*5c51f124SMoriah Waterland if (is_samepkg()) { 1533*5c51f124SMoriah Waterland /* 1534*5c51f124SMoriah Waterland * If it's the same ARCH and VERSION, then a merge 1535*5c51f124SMoriah Waterland * and copy operation is necessary. 1536*5c51f124SMoriah Waterland */ 1537*5c51f124SMoriah Waterland 1538*5c51f124SMoriah Waterland if (n = merg_pkginfos(pclass, &mergd_pclass)) { 1539*5c51f124SMoriah Waterland quit(n); 1540*5c51f124SMoriah Waterland /*NOTREACHED*/ 1541*5c51f124SMoriah Waterland } 1542*5c51f124SMoriah Waterland 1543*5c51f124SMoriah Waterland if (n = cp_pkgdirs()) { 1544*5c51f124SMoriah Waterland quit(n); 1545*5c51f124SMoriah Waterland /*NOTREACHED*/ 1546*5c51f124SMoriah Waterland } 1547*5c51f124SMoriah Waterland 1548*5c51f124SMoriah Waterland } else { 1549*5c51f124SMoriah Waterland /* 1550*5c51f124SMoriah Waterland * If it's a different ARCH and/or VERSION then this 1551*5c51f124SMoriah Waterland * is an "instance=overwrite" situation. The 1552*5c51f124SMoriah Waterland * installed base needs to be confirmed and the 1553*5c51f124SMoriah Waterland * package directories renamed. 1554*5c51f124SMoriah Waterland */ 1555*5c51f124SMoriah Waterland 1556*5c51f124SMoriah Waterland if (n = ck_instbase()) { 1557*5c51f124SMoriah Waterland quit(n); 1558*5c51f124SMoriah Waterland /*NOTREACHED*/ 1559*5c51f124SMoriah Waterland } 1560*5c51f124SMoriah Waterland 1561*5c51f124SMoriah Waterland if (n = mv_pkgdirs()) { 1562*5c51f124SMoriah Waterland quit(n); 1563*5c51f124SMoriah Waterland /*NOTREACHED*/ 1564*5c51f124SMoriah Waterland } 1565*5c51f124SMoriah Waterland } 1566*5c51f124SMoriah Waterland 1567*5c51f124SMoriah Waterland putparam("UPDATE", "yes"); 1568*5c51f124SMoriah Waterland 1569*5c51f124SMoriah Waterland } 1570*5c51f124SMoriah Waterland 1571*5c51f124SMoriah Waterland if (in_dryrun_mode()) { 1572*5c51f124SMoriah Waterland set_dryrun_dir_loc(); 1573*5c51f124SMoriah Waterland } 1574*5c51f124SMoriah Waterland 1575*5c51f124SMoriah Waterland if (preinstallCheck == B_FALSE) { 1576*5c51f124SMoriah Waterland /* 1577*5c51f124SMoriah Waterland * Determine if the package has been partially installed on or 1578*5c51f124SMoriah Waterland * removed from this system. 1579*5c51f124SMoriah Waterland */ 1580*5c51f124SMoriah Waterland ck_w_dryrun(ckpartial, PARTIAL); 1581*5c51f124SMoriah Waterland 1582*5c51f124SMoriah Waterland /* 1583*5c51f124SMoriah Waterland * make sure current runlevel is appropriate 1584*5c51f124SMoriah Waterland */ 1585*5c51f124SMoriah Waterland ck_w_dryrun(ckrunlevel, RUNLEVEL); 1586*5c51f124SMoriah Waterland } else { 1587*5c51f124SMoriah Waterland int r; 1588*5c51f124SMoriah Waterland 1589*5c51f124SMoriah Waterland /* 1590*5c51f124SMoriah Waterland * Just gathering dependencies - determine if the package has 1591*5c51f124SMoriah Waterland * been partially installed on or removed from this system and 1592*5c51f124SMoriah Waterland * output information to stdout 1593*5c51f124SMoriah Waterland */ 1594*5c51f124SMoriah Waterland r = ckpartial(); 1595*5c51f124SMoriah Waterland (void) fprintf(stdout, "ckpartialinstall=%d\n", r == 8 ? 1 : 0); 1596*5c51f124SMoriah Waterland (void) fprintf(stdout, "ckpartialremove=%d\n", r == 9 ? 1 : 0); 1597*5c51f124SMoriah Waterland 1598*5c51f124SMoriah Waterland /* 1599*5c51f124SMoriah Waterland * make sure current runlevel is appropriate 1600*5c51f124SMoriah Waterland */ 1601*5c51f124SMoriah Waterland r = ckrunlevel(); 1602*5c51f124SMoriah Waterland (void) fprintf(stdout, "ckrunlevel=%d\n", r); 1603*5c51f124SMoriah Waterland } 1604*5c51f124SMoriah Waterland 1605*5c51f124SMoriah Waterland if (pkgdev.cdevice) { 1606*5c51f124SMoriah Waterland /* get first volume which contains info files */ 1607*5c51f124SMoriah Waterland unpack(); 1608*5c51f124SMoriah Waterland if (!suppressCopyright) { 1609*5c51f124SMoriah Waterland copyright(); 1610*5c51f124SMoriah Waterland } 1611*5c51f124SMoriah Waterland } 1612*5c51f124SMoriah Waterland 1613*5c51f124SMoriah Waterland /* update the lock - at the request script */ 1614*5c51f124SMoriah Waterland 1615*5c51f124SMoriah Waterland lockupd("request"); 1616*5c51f124SMoriah Waterland 1617*5c51f124SMoriah Waterland /* 1618*5c51f124SMoriah Waterland * If no response file has been provided, initialize response file by 1619*5c51f124SMoriah Waterland * executing any request script provided by this package. Initialize 1620*5c51f124SMoriah Waterland * the response file if not gathering dependencies only. 1621*5c51f124SMoriah Waterland */ 1622*5c51f124SMoriah Waterland 1623*5c51f124SMoriah Waterland if ((!rdonly_respfile()) && (preinstallCheck == B_FALSE)) { 1624*5c51f124SMoriah Waterland (void) snprintf(path, sizeof (path), 1625*5c51f124SMoriah Waterland "%s/%s", instdir, REQUEST_FILE); 1626*5c51f124SMoriah Waterland n = reqexec(update, path, non_abi_scripts, 1627*5c51f124SMoriah Waterland run_request_as_root); 1628*5c51f124SMoriah Waterland if (in_dryrun_mode()) { 1629*5c51f124SMoriah Waterland set_dr_info(REQUESTEXITCODE, n); 1630*5c51f124SMoriah Waterland } 1631*5c51f124SMoriah Waterland 1632*5c51f124SMoriah Waterland ckreturn(n, ERR_REQUEST); 1633*5c51f124SMoriah Waterland } 1634*5c51f124SMoriah Waterland 1635*5c51f124SMoriah Waterland /* 1636*5c51f124SMoriah Waterland * Look for all parameters in response file which begin with a 1637*5c51f124SMoriah Waterland * capital letter, and place them in the environment. 1638*5c51f124SMoriah Waterland */ 1639*5c51f124SMoriah Waterland 1640*5c51f124SMoriah Waterland if ((is_a_respfile()) && (preinstallCheck == B_FALSE)) { 1641*5c51f124SMoriah Waterland if (n = merg_respfile()) { 1642*5c51f124SMoriah Waterland quit(n); 1643*5c51f124SMoriah Waterland /*NOTREACHED*/ 1644*5c51f124SMoriah Waterland } 1645*5c51f124SMoriah Waterland } 1646*5c51f124SMoriah Waterland 1647*5c51f124SMoriah Waterland /* 1648*5c51f124SMoriah Waterland * Run a checkinstall script if one is provided by the package. 1649*5c51f124SMoriah Waterland * Don't execute checkinstall script if we are only updating the DB. 1650*5c51f124SMoriah Waterland * Don't execute checkinstall script if only gathering dependencies. 1651*5c51f124SMoriah Waterland */ 1652*5c51f124SMoriah Waterland 1653*5c51f124SMoriah Waterland /* update the lock - at the checkinstall script */ 1654*5c51f124SMoriah Waterland lockupd("checkinstall"); 1655*5c51f124SMoriah Waterland 1656*5c51f124SMoriah Waterland /* Execute checkinstall script if one is provided. */ 1657*5c51f124SMoriah Waterland (void) snprintf(script, sizeof (script), "%s/install/checkinstall", 1658*5c51f124SMoriah Waterland instdir); 1659*5c51f124SMoriah Waterland if (access(script, F_OK) != 0) { 1660*5c51f124SMoriah Waterland /* no script present */ 1661*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_COC_NONE, pkginst, script, 1662*5c51f124SMoriah Waterland zoneName ? zoneName : "global"); 1663*5c51f124SMoriah Waterland } else if (is_depend_pkginfo_DB()) { 1664*5c51f124SMoriah Waterland /* updating db only: skip checkinstall script */ 1665*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_COC_DBUPD, pkginst, script, 1666*5c51f124SMoriah Waterland zoneName ? zoneName : "global"); 1667*5c51f124SMoriah Waterland } else if (preinstallCheck == B_TRUE) { 1668*5c51f124SMoriah Waterland /* only gathering dependencies: skip checkinstall script */ 1669*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_COC_NODEL, pkginst, script, 1670*5c51f124SMoriah Waterland zoneName ? zoneName : "global"); 1671*5c51f124SMoriah Waterland } else { 1672*5c51f124SMoriah Waterland /* script present and ok to run: run the script */ 1673*5c51f124SMoriah Waterland if (zoneName == (char *)NULL) { 1674*5c51f124SMoriah Waterland echo(MSG_PKGINSTALL_EXECOC_GZ); 1675*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_EXECOC_GZ, pkginst, script); 1676*5c51f124SMoriah Waterland } else { 1677*5c51f124SMoriah Waterland echo(MSG_PKGINSTALL_EXECOC_LZ, zoneName); 1678*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_EXECOC_LZ, pkginst, script, 1679*5c51f124SMoriah Waterland zoneName); 1680*5c51f124SMoriah Waterland } 1681*5c51f124SMoriah Waterland n = chkexec(update, script); 1682*5c51f124SMoriah Waterland if (in_dryrun_mode()) { 1683*5c51f124SMoriah Waterland set_dr_info(CHECKEXITCODE, n); 1684*5c51f124SMoriah Waterland } 1685*5c51f124SMoriah Waterland 1686*5c51f124SMoriah Waterland if (n == 3) { 1687*5c51f124SMoriah Waterland echo(WRN_CHKINSTALL); 1688*5c51f124SMoriah Waterland ckreturn(4, NULL); 1689*5c51f124SMoriah Waterland } else if (n == 7) { 1690*5c51f124SMoriah Waterland /* access returned error */ 1691*5c51f124SMoriah Waterland progerr(ERR_CHKINSTALL_NOSCRIPT, script); 1692*5c51f124SMoriah Waterland ckreturn(4, ERR_CHKINSTALL); 1693*5c51f124SMoriah Waterland } else { 1694*5c51f124SMoriah Waterland ckreturn(n, ERR_CHKINSTALL); 1695*5c51f124SMoriah Waterland } 1696*5c51f124SMoriah Waterland } 1697*5c51f124SMoriah Waterland 1698*5c51f124SMoriah Waterland /* 1699*5c51f124SMoriah Waterland * Now that the internal data structures are initialized, we can 1700*5c51f124SMoriah Waterland * initialize the dryrun files (which may be the same files). 1701*5c51f124SMoriah Waterland */ 1702*5c51f124SMoriah Waterland 1703*5c51f124SMoriah Waterland if (pkgdrtarg) { 1704*5c51f124SMoriah Waterland init_dryrunfile(pkgdrtarg); 1705*5c51f124SMoriah Waterland } 1706*5c51f124SMoriah Waterland 1707*5c51f124SMoriah Waterland /* 1708*5c51f124SMoriah Waterland * Look for all parameters in response file which begin with a 1709*5c51f124SMoriah Waterland * capital letter, and place them in the environment. 1710*5c51f124SMoriah Waterland */ 1711*5c51f124SMoriah Waterland if (is_a_respfile()) { 1712*5c51f124SMoriah Waterland if (n = merg_respfile()) { 1713*5c51f124SMoriah Waterland quit(n); 1714*5c51f124SMoriah Waterland /*NOTREACHED*/ 1715*5c51f124SMoriah Waterland } 1716*5c51f124SMoriah Waterland } 1717*5c51f124SMoriah Waterland 1718*5c51f124SMoriah Waterland /* update the lock - doing analysis */ 1719*5c51f124SMoriah Waterland 1720*5c51f124SMoriah Waterland lockupd("analysis"); 1721*5c51f124SMoriah Waterland 1722*5c51f124SMoriah Waterland /* 1723*5c51f124SMoriah Waterland * Determine package base directory and client base directory 1724*5c51f124SMoriah Waterland * if appropriate. Then encapsulate them for future retrieval. 1725*5c51f124SMoriah Waterland */ 1726*5c51f124SMoriah Waterland if ((err = set_basedirs(isreloc(instdir), adm.basedir, pkginst, 1727*5c51f124SMoriah Waterland nointeract)) != 0) { 1728*5c51f124SMoriah Waterland quit(err); 1729*5c51f124SMoriah Waterland /*NOTREACHED*/ 1730*5c51f124SMoriah Waterland } 1731*5c51f124SMoriah Waterland 1732*5c51f124SMoriah Waterland /* 1733*5c51f124SMoriah Waterland * Create the base directory if specified. 1734*5c51f124SMoriah Waterland * Don't create if we are only updating the DB. 1735*5c51f124SMoriah Waterland * Don't create if only gathering dependencies. 1736*5c51f124SMoriah Waterland */ 1737*5c51f124SMoriah Waterland 1738*5c51f124SMoriah Waterland if (!is_depend_pkginfo_DB() && 1739*5c51f124SMoriah Waterland !preinstallCheck && is_a_basedir()) { 1740*5c51f124SMoriah Waterland mkbasedir(!nointeract, get_basedir()); 1741*5c51f124SMoriah Waterland echo(MSG_BASE_USED, get_basedir()); 1742*5c51f124SMoriah Waterland } 1743*5c51f124SMoriah Waterland 1744*5c51f124SMoriah Waterland /* 1745*5c51f124SMoriah Waterland * Store PKG_INSTALL_ROOT, BASEDIR & CLIENT_BASEDIR in our 1746*5c51f124SMoriah Waterland * environment for later use by procedure scripts. 1747*5c51f124SMoriah Waterland */ 1748*5c51f124SMoriah Waterland put_path_params(); 1749*5c51f124SMoriah Waterland 1750*5c51f124SMoriah Waterland /* 1751*5c51f124SMoriah Waterland * the following two checks are done in the corresponding 1752*5c51f124SMoriah Waterland * ck() routine, but are repeated here to avoid re-processing 1753*5c51f124SMoriah Waterland * the database if we are administered to not include these 1754*5c51f124SMoriah Waterland * processes 1755*5c51f124SMoriah Waterland */ 1756*5c51f124SMoriah Waterland if (ADM(setuid, "nochange")) { 1757*5c51f124SMoriah Waterland nosetuid++; /* Clear setuid/gid bits. */ 1758*5c51f124SMoriah Waterland } 1759*5c51f124SMoriah Waterland 1760*5c51f124SMoriah Waterland if (ADM(conflict, "nochange")) { 1761*5c51f124SMoriah Waterland nocnflct++; /* Don't install conflicting files. */ 1762*5c51f124SMoriah Waterland } 1763*5c51f124SMoriah Waterland 1764*5c51f124SMoriah Waterland /* 1765*5c51f124SMoriah Waterland * Get the filesystem space information for the filesystem on which 1766*5c51f124SMoriah Waterland * the "contents" file resides. 1767*5c51f124SMoriah Waterland */ 1768*5c51f124SMoriah Waterland 1769*5c51f124SMoriah Waterland svfsb.f_bsize = 8192; 1770*5c51f124SMoriah Waterland svfsb.f_frsize = 1024; 1771*5c51f124SMoriah Waterland 1772*5c51f124SMoriah Waterland if (statvfs64(get_PKGADM(), &svfsb) == -1) { 1773*5c51f124SMoriah Waterland int lerrno = errno; 1774*5c51f124SMoriah Waterland if (!access(get_PKGADM(), F_OK)) { 1775*5c51f124SMoriah Waterland progerr(ERR_PKGINSTALL_STATVFS, get_PKGADM(), 1776*5c51f124SMoriah Waterland strerror(errno)); 1777*5c51f124SMoriah Waterland logerr("(errno %d)", lerrno); 1778*5c51f124SMoriah Waterland quit(99); 1779*5c51f124SMoriah Waterland /*NOTREACHED*/ 1780*5c51f124SMoriah Waterland } 1781*5c51f124SMoriah Waterland } 1782*5c51f124SMoriah Waterland 1783*5c51f124SMoriah Waterland /* 1784*5c51f124SMoriah Waterland * Get the number of blocks used by the pkgmap, ocfile() 1785*5c51f124SMoriah Waterland * needs this to properly determine its space requirements. 1786*5c51f124SMoriah Waterland */ 1787*5c51f124SMoriah Waterland 1788*5c51f124SMoriah Waterland if (stat(p_pkgmap, &statb) == -1) { 1789*5c51f124SMoriah Waterland progerr(ERR_PKGINSTALL_STATOF, p_pkgmap, strerror(errno)); 1790*5c51f124SMoriah Waterland quit(99); 1791*5c51f124SMoriah Waterland /*NOTREACHED*/ 1792*5c51f124SMoriah Waterland } 1793*5c51f124SMoriah Waterland 1794*5c51f124SMoriah Waterland pkgmap_blks = nblk(statb.st_size, svfsb.f_bsize, svfsb.f_frsize); 1795*5c51f124SMoriah Waterland 1796*5c51f124SMoriah Waterland /* 1797*5c51f124SMoriah Waterland * Merge information in memory with the "contents" file; this creates 1798*5c51f124SMoriah Waterland * a temporary version of the "contents" file. Note that in dryrun 1799*5c51f124SMoriah Waterland * mode, we still need to record the contents file data somewhere, 1800*5c51f124SMoriah Waterland * but we do it in the dryrun directory. 1801*5c51f124SMoriah Waterland */ 1802*5c51f124SMoriah Waterland 1803*5c51f124SMoriah Waterland if (in_dryrun_mode()) { 1804*5c51f124SMoriah Waterland if (n = set_cfdir(pkgdrtarg)) { 1805*5c51f124SMoriah Waterland quit(n); 1806*5c51f124SMoriah Waterland /*NOTREACHED*/ 1807*5c51f124SMoriah Waterland } 1808*5c51f124SMoriah Waterland } else { 1809*5c51f124SMoriah Waterland if (n = set_cfdir(NULL)) { 1810*5c51f124SMoriah Waterland quit(n); 1811*5c51f124SMoriah Waterland /*NOTREACHED*/ 1812*5c51f124SMoriah Waterland } 1813*5c51f124SMoriah Waterland } 1814*5c51f124SMoriah Waterland if (!ocfile(&cfVfp, &cfTmpVfp, pkgmap_blks)) { 1815*5c51f124SMoriah Waterland quit(99); 1816*5c51f124SMoriah Waterland /*NOTREACHED*/ 1817*5c51f124SMoriah Waterland } 1818*5c51f124SMoriah Waterland 1819*5c51f124SMoriah Waterland /* 1820*5c51f124SMoriah Waterland * if cpio is being used, tell pkgdbmerg since attributes will 1821*5c51f124SMoriah Waterland * have to be check and repaired on all file and directories 1822*5c51f124SMoriah Waterland */ 1823*5c51f124SMoriah Waterland for (np = cpio_names; *np != NULL; np++) { 1824*5c51f124SMoriah Waterland (void) snprintf(path, sizeof (path), 1825*5c51f124SMoriah Waterland "%s/%s", instdir, *np); 1826*5c51f124SMoriah Waterland if (iscpio(path, &is_comp_arch)) { 1827*5c51f124SMoriah Waterland is_WOS_arch(); 1828*5c51f124SMoriah Waterland break; 1829*5c51f124SMoriah Waterland } 1830*5c51f124SMoriah Waterland } 1831*5c51f124SMoriah Waterland 1832*5c51f124SMoriah Waterland /* Establish the class list and the class attributes. */ 1833*5c51f124SMoriah Waterland cl_sets(getenv("CLASSES")); 1834*5c51f124SMoriah Waterland find_CAS(I_ONLY, pkgbin, instdir); 1835*5c51f124SMoriah Waterland 1836*5c51f124SMoriah Waterland if (vfpOpen(&pkgmapVfp, p_pkgmap, "r", VFP_NEEDNOW) != 0) { 1837*5c51f124SMoriah Waterland progerr(ERR_PKGMAP, p_pkgmap); 1838*5c51f124SMoriah Waterland quit(99); 1839*5c51f124SMoriah Waterland /*NOTREACHED*/ 1840*5c51f124SMoriah Waterland } 1841*5c51f124SMoriah Waterland 1842*5c51f124SMoriah Waterland /* 1843*5c51f124SMoriah Waterland * This modifies the path list entries in memory to reflect 1844*5c51f124SMoriah Waterland * how they should look after the merg is complete 1845*5c51f124SMoriah Waterland */ 1846*5c51f124SMoriah Waterland 1847*5c51f124SMoriah Waterland nparts = sortmap(&extlist, pkgmapVfp, cfVfp, cfTmpVfp, zoneName); 1848*5c51f124SMoriah Waterland 1849*5c51f124SMoriah Waterland if ((n = files_installed()) > 0) { 1850*5c51f124SMoriah Waterland if (n > 1) { 1851*5c51f124SMoriah Waterland echo(MSG_INST_MANY, n); 1852*5c51f124SMoriah Waterland } else { 1853*5c51f124SMoriah Waterland echo(MSG_INST_ONE, n); 1854*5c51f124SMoriah Waterland } 1855*5c51f124SMoriah Waterland } 1856*5c51f124SMoriah Waterland 1857*5c51f124SMoriah Waterland /* 1858*5c51f124SMoriah Waterland * Check ulimit requirement (provided in pkginfo). The purpose of 1859*5c51f124SMoriah Waterland * this limit is to terminate pathological file growth resulting from 1860*5c51f124SMoriah Waterland * file edits in scripts. It does not apply to files in the pkgmap 1861*5c51f124SMoriah Waterland * and it does not apply to any database files manipulated by the 1862*5c51f124SMoriah Waterland * installation service. 1863*5c51f124SMoriah Waterland */ 1864*5c51f124SMoriah Waterland if (pt = getenv("ULIMIT")) { 1865*5c51f124SMoriah Waterland if (assign_ulimit(pt) == -1) { 1866*5c51f124SMoriah Waterland progerr(ERR_BADULIMIT, pt); 1867*5c51f124SMoriah Waterland quit(99); 1868*5c51f124SMoriah Waterland /*NOTREACHED*/ 1869*5c51f124SMoriah Waterland } 1870*5c51f124SMoriah Waterland putparam("PKG_ULIMIT", "TRUE"); 1871*5c51f124SMoriah Waterland } 1872*5c51f124SMoriah Waterland 1873*5c51f124SMoriah Waterland /* 1874*5c51f124SMoriah Waterland * If only gathering dependencies, check and output status of all 1875*5c51f124SMoriah Waterland * remaining dependencies and exit. 1876*5c51f124SMoriah Waterland */ 1877*5c51f124SMoriah Waterland 1878*5c51f124SMoriah Waterland if (preinstallCheck == B_TRUE) { 1879*5c51f124SMoriah Waterland /* update the lock file - final checking */ 1880*5c51f124SMoriah Waterland 1881*5c51f124SMoriah Waterland lockupd("preinstallcheck"); 1882*5c51f124SMoriah Waterland 1883*5c51f124SMoriah Waterland /* verify package information files are not corrupt */ 1884*5c51f124SMoriah Waterland 1885*5c51f124SMoriah Waterland (void) fprintf(stdout, "ckpkgfiles=%d\n", ckpkgfiles()); 1886*5c51f124SMoriah Waterland 1887*5c51f124SMoriah Waterland /* verify package dependencies */ 1888*5c51f124SMoriah Waterland 1889*5c51f124SMoriah Waterland (void) fprintf(stdout, "ckdepend=%d\n", ckdepend()); 1890*5c51f124SMoriah Waterland 1891*5c51f124SMoriah Waterland /* Check space requirements */ 1892*5c51f124SMoriah Waterland 1893*5c51f124SMoriah Waterland (void) fprintf(stdout, "ckspace=%d\n", ckspace()); 1894*5c51f124SMoriah Waterland 1895*5c51f124SMoriah Waterland /* 1896*5c51f124SMoriah Waterland * Determine if any objects provided by this package conflict 1897*5c51f124SMoriah Waterland * with the files of previously installed packages. 1898*5c51f124SMoriah Waterland */ 1899*5c51f124SMoriah Waterland 1900*5c51f124SMoriah Waterland (void) fprintf(stdout, "ckconflict=%d\n", ckconflct()); 1901*5c51f124SMoriah Waterland 1902*5c51f124SMoriah Waterland /* 1903*5c51f124SMoriah Waterland * Determine if any objects provided by this package will be 1904*5c51f124SMoriah Waterland * installed with setuid or setgid enabled. 1905*5c51f124SMoriah Waterland */ 1906*5c51f124SMoriah Waterland 1907*5c51f124SMoriah Waterland (void) fprintf(stdout, "cksetuid=%d\n", cksetuid()); 1908*5c51f124SMoriah Waterland 1909*5c51f124SMoriah Waterland /* 1910*5c51f124SMoriah Waterland * Determine if any packaging scripts provided with this package 1911*5c51f124SMoriah Waterland * will execute as a priviledged user. 1912*5c51f124SMoriah Waterland */ 1913*5c51f124SMoriah Waterland 1914*5c51f124SMoriah Waterland (void) fprintf(stdout, "ckpriv=%d\n", ckpriv()); 1915*5c51f124SMoriah Waterland 1916*5c51f124SMoriah Waterland /* Verify neccessary package installation directories exist */ 1917*5c51f124SMoriah Waterland 1918*5c51f124SMoriah Waterland (void) fprintf(stdout, "ckpkgdirs=%d\n", ckpkgdirs()); 1919*5c51f124SMoriah Waterland 1920*5c51f124SMoriah Waterland /* 1921*5c51f124SMoriah Waterland * ****** preinstall check done - exit ****** 1922*5c51f124SMoriah Waterland */ 1923*5c51f124SMoriah Waterland 1924*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_PREINSCHK_OK); 1925*5c51f124SMoriah Waterland quit(0); 1926*5c51f124SMoriah Waterland /*NOTREACHED*/ 1927*5c51f124SMoriah Waterland } 1928*5c51f124SMoriah Waterland 1929*5c51f124SMoriah Waterland /* 1930*5c51f124SMoriah Waterland * Not gathering dependencies only, proceed to check dependencies 1931*5c51f124SMoriah Waterland * and continue with the package installation operation. 1932*5c51f124SMoriah Waterland */ 1933*5c51f124SMoriah Waterland 1934*5c51f124SMoriah Waterland /* 1935*5c51f124SMoriah Waterland * verify package information files are not corrupt 1936*5c51f124SMoriah Waterland */ 1937*5c51f124SMoriah Waterland ck_w_dryrun(ckpkgfiles, PKGFILES); 1938*5c51f124SMoriah Waterland 1939*5c51f124SMoriah Waterland /* 1940*5c51f124SMoriah Waterland * verify package dependencies 1941*5c51f124SMoriah Waterland */ 1942*5c51f124SMoriah Waterland ck_w_dryrun(ckdepend, DEPEND); 1943*5c51f124SMoriah Waterland 1944*5c51f124SMoriah Waterland /* 1945*5c51f124SMoriah Waterland * Check space requirements. 1946*5c51f124SMoriah Waterland */ 1947*5c51f124SMoriah Waterland ck_w_dryrun(ckspace, SPACE); 1948*5c51f124SMoriah Waterland 1949*5c51f124SMoriah Waterland /* 1950*5c51f124SMoriah Waterland * Determine if any objects provided by this package conflict with 1951*5c51f124SMoriah Waterland * the files of previously installed packages. 1952*5c51f124SMoriah Waterland */ 1953*5c51f124SMoriah Waterland ck_w_dryrun(ckconflct, CONFLICT); 1954*5c51f124SMoriah Waterland 1955*5c51f124SMoriah Waterland /* 1956*5c51f124SMoriah Waterland * Determine if any objects provided by this package will be 1957*5c51f124SMoriah Waterland * installed with setuid or setgid enabled. 1958*5c51f124SMoriah Waterland */ 1959*5c51f124SMoriah Waterland ck_w_dryrun(cksetuid, SETUID); 1960*5c51f124SMoriah Waterland 1961*5c51f124SMoriah Waterland /* 1962*5c51f124SMoriah Waterland * Determine if any packaging scripts provided with this package will 1963*5c51f124SMoriah Waterland * execute as a priviledged user. 1964*5c51f124SMoriah Waterland */ 1965*5c51f124SMoriah Waterland ck_w_dryrun(ckpriv, PRIV); 1966*5c51f124SMoriah Waterland 1967*5c51f124SMoriah Waterland /* 1968*5c51f124SMoriah Waterland * Verify neccessary package installation directories exist. 1969*5c51f124SMoriah Waterland */ 1970*5c51f124SMoriah Waterland ck_w_dryrun(ckpkgdirs, PKGDIRS); 1971*5c51f124SMoriah Waterland 1972*5c51f124SMoriah Waterland /* 1973*5c51f124SMoriah Waterland * If we have assumed that we were installing setuid or conflicting 1974*5c51f124SMoriah Waterland * files, and the user chose to do otherwise, we need to read in the 1975*5c51f124SMoriah Waterland * package map again and re-merg with the "contents" file 1976*5c51f124SMoriah Waterland */ 1977*5c51f124SMoriah Waterland 1978*5c51f124SMoriah Waterland if (rprcflag) { 1979*5c51f124SMoriah Waterland nparts = sortmap(&extlist, pkgmapVfp, cfVfp, 1980*5c51f124SMoriah Waterland cfTmpVfp, zoneName); 1981*5c51f124SMoriah Waterland } 1982*5c51f124SMoriah Waterland 1983*5c51f124SMoriah Waterland (void) vfpClose(&pkgmapVfp); 1984*5c51f124SMoriah Waterland 1985*5c51f124SMoriah Waterland /* BEGIN INSTALLATION PHASE */ 1986*5c51f124SMoriah Waterland if (in_dryrun_mode()) { 1987*5c51f124SMoriah Waterland echo(MSG_PKGINSTALL_DRYRUN, pkgname, pkginst); 1988*5c51f124SMoriah Waterland } else if (zoneName == (char *)NULL) { 1989*5c51f124SMoriah Waterland echo(MSG_PKGINSTALL_INSIN_GZ, pkgname, pkginst); 1990*5c51f124SMoriah Waterland } else { 1991*5c51f124SMoriah Waterland echo(MSG_PKGINSTALL_INSIN_LZ, pkgname, pkginst, zoneName); 1992*5c51f124SMoriah Waterland } 1993*5c51f124SMoriah Waterland 1994*5c51f124SMoriah Waterland /* inform quit that the install has started */ 1995*5c51f124SMoriah Waterland 1996*5c51f124SMoriah Waterland quitSetInstallStarted(B_TRUE); 1997*5c51f124SMoriah Waterland 1998*5c51f124SMoriah Waterland /* 1999*5c51f124SMoriah Waterland * This replaces the contents file with recently created temp version 2000*5c51f124SMoriah Waterland * which contains information about the objects being installed. 2001*5c51f124SMoriah Waterland * Under old lock protocol it closes both files and releases the 2002*5c51f124SMoriah Waterland * locks. Beginning in Solaris 2.7, this lock method should be 2003*5c51f124SMoriah Waterland * reviewed. 2004*5c51f124SMoriah Waterland */ 2005*5c51f124SMoriah Waterland 2006*5c51f124SMoriah Waterland n = swapcfile(&cfVfp, &cfTmpVfp, pkginst, dbchg); 2007*5c51f124SMoriah Waterland if (n == RESULT_WRN) { 2008*5c51f124SMoriah Waterland warnflag++; 2009*5c51f124SMoriah Waterland } else if (n == RESULT_ERR) { 2010*5c51f124SMoriah Waterland quit(99); 2011*5c51f124SMoriah Waterland /*NOTREACHED*/ 2012*5c51f124SMoriah Waterland } 2013*5c51f124SMoriah Waterland 2014*5c51f124SMoriah Waterland /* 2015*5c51f124SMoriah Waterland * Create install-specific lockfile to indicate start of 2016*5c51f124SMoriah Waterland * installation. This is really just an information file. If the 2017*5c51f124SMoriah Waterland * process dies, the initial lockfile (from lockinst(), is 2018*5c51f124SMoriah Waterland * relinquished by the kernel, but this one remains in support of the 2019*5c51f124SMoriah Waterland * post-mortem. 2020*5c51f124SMoriah Waterland */ 2021*5c51f124SMoriah Waterland 2022*5c51f124SMoriah Waterland if (access(ilockfile, F_OK) == 0) { 2023*5c51f124SMoriah Waterland (void) remove(ilockfile); 2024*5c51f124SMoriah Waterland } 2025*5c51f124SMoriah Waterland 2026*5c51f124SMoriah Waterland if (open(ilockfile, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644) < 0) { 2027*5c51f124SMoriah Waterland progerr(ERR_LOCKFILE, ilockfile); 2028*5c51f124SMoriah Waterland quit(99); 2029*5c51f124SMoriah Waterland /*NOTREACHED*/ 2030*5c51f124SMoriah Waterland } 2031*5c51f124SMoriah Waterland 2032*5c51f124SMoriah Waterland (void) time(&clock); 2033*5c51f124SMoriah Waterland /* LINTED warning: do not use cftime(); ... */ 2034*5c51f124SMoriah Waterland (void) cftime(cbuf, "%b %d \045Y \045H:\045M", &clock); 2035*5c51f124SMoriah Waterland putparam("INSTDATE", qstrdup(cbuf)); 2036*5c51f124SMoriah Waterland 2037*5c51f124SMoriah Waterland /* 2038*5c51f124SMoriah Waterland * Store information about package being installed; 2039*5c51f124SMoriah Waterland * modify installation parameters as neccessary and 2040*5c51f124SMoriah Waterland * copy contents of 'install' directory into $pkgloc 2041*5c51f124SMoriah Waterland */ 2042*5c51f124SMoriah Waterland merginfo(mergd_pclass, saveSpoolInstall); 2043*5c51f124SMoriah Waterland 2044*5c51f124SMoriah Waterland /* If this was just a dryrun, then quit() will write out that file. */ 2045*5c51f124SMoriah Waterland if (in_dryrun_mode()) { 2046*5c51f124SMoriah Waterland quit(0); 2047*5c51f124SMoriah Waterland /*NOTREACHED*/ 2048*5c51f124SMoriah Waterland } 2049*5c51f124SMoriah Waterland 2050*5c51f124SMoriah Waterland if (opresvr4) { 2051*5c51f124SMoriah Waterland /* 2052*5c51f124SMoriah Waterland * we are overwriting a pre-svr4 package, so remove the file 2053*5c51f124SMoriah Waterland * in /usr/options now 2054*5c51f124SMoriah Waterland */ 2055*5c51f124SMoriah Waterland (void) snprintf(path, sizeof (path), 2056*5c51f124SMoriah Waterland "%s/%s.name", get_PKGOLD(), pkginst); 2057*5c51f124SMoriah Waterland if (remove(path) && (errno != ENOENT)) { 2058*5c51f124SMoriah Waterland progerr(ERR_OPRESVR4, path); 2059*5c51f124SMoriah Waterland warnflag++; 2060*5c51f124SMoriah Waterland } 2061*5c51f124SMoriah Waterland } 2062*5c51f124SMoriah Waterland 2063*5c51f124SMoriah Waterland /* 2064*5c51f124SMoriah Waterland * Execute preinstall script, if one was provided with the 2065*5c51f124SMoriah Waterland * package. We check the package to avoid running an old 2066*5c51f124SMoriah Waterland * preinstall script if one was provided with a prior instance. 2067*5c51f124SMoriah Waterland * Don't execute preinstall script if we are only updating the DB. 2068*5c51f124SMoriah Waterland */ 2069*5c51f124SMoriah Waterland 2070*5c51f124SMoriah Waterland /* update the lock - at the preinstall altscript */ 2071*5c51f124SMoriah Waterland lockupd("preinstall"); 2072*5c51f124SMoriah Waterland 2073*5c51f124SMoriah Waterland /* preinstall script in the media (package source) */ 2074*5c51f124SMoriah Waterland (void) snprintf(altscript, sizeof (altscript), "%s/install/preinstall", 2075*5c51f124SMoriah Waterland instdir); 2076*5c51f124SMoriah Waterland 2077*5c51f124SMoriah Waterland /* preinstall script in the pkgbin instead of media */ 2078*5c51f124SMoriah Waterland (void) snprintf(script, sizeof (script), "%s/preinstall", pkgbin); 2079*5c51f124SMoriah Waterland 2080*5c51f124SMoriah Waterland if (access(altscript, F_OK) != 0) { 2081*5c51f124SMoriah Waterland /* no script present */ 2082*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_POCALT_NONE, pkginst, altscript, 2083*5c51f124SMoriah Waterland zoneName ? zoneName : "global"); 2084*5c51f124SMoriah Waterland } else if (access(script, F_OK) != 0) { 2085*5c51f124SMoriah Waterland /* no script present */ 2086*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_POC_NONE, pkginst, script, 2087*5c51f124SMoriah Waterland zoneName ? zoneName : "global"); 2088*5c51f124SMoriah Waterland } else if (is_depend_pkginfo_DB()) { 2089*5c51f124SMoriah Waterland /* updating db only: skip preinstall script */ 2090*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_POC_DBUPD, pkginst, script, 2091*5c51f124SMoriah Waterland zoneName ? zoneName : "global"); 2092*5c51f124SMoriah Waterland } else { 2093*5c51f124SMoriah Waterland /* script present and ok to run: run the script */ 2094*5c51f124SMoriah Waterland assert(preinstallCheck == B_FALSE); 2095*5c51f124SMoriah Waterland 2096*5c51f124SMoriah Waterland set_ulimit("preinstall", ERR_PREINSTALL); 2097*5c51f124SMoriah Waterland if (zoneName == (char *)NULL) { 2098*5c51f124SMoriah Waterland echo(MSG_PKGINSTALL_EXEPOC_GZ); 2099*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_EXEPOC_GZ, pkginst, script); 2100*5c51f124SMoriah Waterland } else { 2101*5c51f124SMoriah Waterland echo(MSG_PKGINSTALL_EXEPOC_LZ, zoneName); 2102*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_EXEPOC_LZ, pkginst, script, 2103*5c51f124SMoriah Waterland zoneName); 2104*5c51f124SMoriah Waterland } 2105*5c51f124SMoriah Waterland putparam("PKG_PROC_script", "preinstall"); 2106*5c51f124SMoriah Waterland if (pkgverbose) { 2107*5c51f124SMoriah Waterland ckreturn(pkgexecl(script_in, PROC_STDOUT, 2108*5c51f124SMoriah Waterland PROC_USER, PROC_GRP, SHELL, "-x", 2109*5c51f124SMoriah Waterland script, NULL), ERR_PREINSTALL); 2110*5c51f124SMoriah Waterland } else { 2111*5c51f124SMoriah Waterland ckreturn(pkgexecl(script_in, PROC_STDOUT, 2112*5c51f124SMoriah Waterland PROC_USER, PROC_GRP, SHELL, script, 2113*5c51f124SMoriah Waterland NULL), ERR_PREINSTALL); 2114*5c51f124SMoriah Waterland } 2115*5c51f124SMoriah Waterland 2116*5c51f124SMoriah Waterland clr_ulimit(); 2117*5c51f124SMoriah Waterland (void) remove(script); /* no longer needed. */ 2118*5c51f124SMoriah Waterland } 2119*5c51f124SMoriah Waterland 2120*5c51f124SMoriah Waterland /* 2121*5c51f124SMoriah Waterland * Check delivered package for a postinstall script while 2122*5c51f124SMoriah Waterland * we're still on volume 1. 2123*5c51f124SMoriah Waterland */ 2124*5c51f124SMoriah Waterland 2125*5c51f124SMoriah Waterland (void) snprintf(script, sizeof (script), 2126*5c51f124SMoriah Waterland "%s/install/postinstall", instdir); 2127*5c51f124SMoriah Waterland if (access(script, F_OK) == 0) { 2128*5c51f124SMoriah Waterland (void) snprintf(script, sizeof (script), 2129*5c51f124SMoriah Waterland "%s/postinstall", pkgbin); 2130*5c51f124SMoriah Waterland } else { 2131*5c51f124SMoriah Waterland script[0] = '\0'; 2132*5c51f124SMoriah Waterland } 2133*5c51f124SMoriah Waterland 2134*5c51f124SMoriah Waterland /* update the lock - at the install phase */ 2135*5c51f124SMoriah Waterland 2136*5c51f124SMoriah Waterland lockupd("install"); 2137*5c51f124SMoriah Waterland 2138*5c51f124SMoriah Waterland /* 2139*5c51f124SMoriah Waterland * install package one part (volume) at a time 2140*5c51f124SMoriah Waterland */ 2141*5c51f124SMoriah Waterland 2142*5c51f124SMoriah Waterland part = 1; 2143*5c51f124SMoriah Waterland while (part <= nparts) { 2144*5c51f124SMoriah Waterland if ((part > 1) && pkgdev.cdevice) { 2145*5c51f124SMoriah Waterland unpack(); 2146*5c51f124SMoriah Waterland } 2147*5c51f124SMoriah Waterland 2148*5c51f124SMoriah Waterland instvol(extlist, srcinst, part, nparts, 2149*5c51f124SMoriah Waterland &cfVfp, &cfTmpVfp, &updated, 2150*5c51f124SMoriah Waterland &skipped, zoneName); 2151*5c51f124SMoriah Waterland 2152*5c51f124SMoriah Waterland if (part++ >= nparts) { 2153*5c51f124SMoriah Waterland break; 2154*5c51f124SMoriah Waterland } 2155*5c51f124SMoriah Waterland } 2156*5c51f124SMoriah Waterland 2157*5c51f124SMoriah Waterland z_destroyMountTable(); 2158*5c51f124SMoriah Waterland 2159*5c51f124SMoriah Waterland /* 2160*5c51f124SMoriah Waterland * Now that all install class action scripts have been used, we 2161*5c51f124SMoriah Waterland * delete them from the package directory. 2162*5c51f124SMoriah Waterland */ 2163*5c51f124SMoriah Waterland rm_icas(pkgbin); 2164*5c51f124SMoriah Waterland 2165*5c51f124SMoriah Waterland if ((globalZoneOnly) && (!patchPkgInstall) && (!patchPkgRemoval)) { 2166*5c51f124SMoriah Waterland boolean_t b; 2167*5c51f124SMoriah Waterland b = pkgAddPackageToGzonlyList(pkginst, get_inst_root()); 2168*5c51f124SMoriah Waterland if (b == B_FALSE) { 2169*5c51f124SMoriah Waterland progerr(ERR_PKGINSTALL_GZONLY_ADD, pkginst); 2170*5c51f124SMoriah Waterland ckreturn(1, NULL); 2171*5c51f124SMoriah Waterland } 2172*5c51f124SMoriah Waterland } 2173*5c51f124SMoriah Waterland 2174*5c51f124SMoriah Waterland /* 2175*5c51f124SMoriah Waterland * Execute postinstall script, if any 2176*5c51f124SMoriah Waterland * Don't execute postinstall script if we are only updating the DB. 2177*5c51f124SMoriah Waterland */ 2178*5c51f124SMoriah Waterland 2179*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_INSDONE, is_depend_pkginfo_DB(), 2180*5c51f124SMoriah Waterland is_depend_pkginfo_DB(), saveSpoolInstall, 2181*5c51f124SMoriah Waterland updated ? updated : "", 2182*5c51f124SMoriah Waterland skipped ? skipped : "", 2183*5c51f124SMoriah Waterland script ? script : "", 2184*5c51f124SMoriah Waterland script ? access(script, F_OK) : -1); 2185*5c51f124SMoriah Waterland 2186*5c51f124SMoriah Waterland /* update the lock - at the postinstall script */ 2187*5c51f124SMoriah Waterland lockupd("postinstall"); 2188*5c51f124SMoriah Waterland 2189*5c51f124SMoriah Waterland if ((script == (char *)NULL) || (*script == '\0')) { 2190*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_POIS_NOPATH, pkginst, 2191*5c51f124SMoriah Waterland zoneName ? zoneName : "global"); 2192*5c51f124SMoriah Waterland } else if (access(script, F_OK) != 0) { 2193*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_POIS_NONE, pkginst, script, 2194*5c51f124SMoriah Waterland zoneName ? zoneName : "global"); 2195*5c51f124SMoriah Waterland } else if (is_depend_pkginfo_DB()) { 2196*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_POIS_DBUPD, pkginst, script, 2197*5c51f124SMoriah Waterland zoneName ? zoneName : "global"); 2198*5c51f124SMoriah Waterland } else if ((saveSpoolInstall != 0) && (updated == (char *)NULL) && 2199*5c51f124SMoriah Waterland (skipped != (char *)NULL)) { 2200*5c51f124SMoriah Waterland /* 2201*5c51f124SMoriah Waterland * fresh installing into non-global zone, no object was 2202*5c51f124SMoriah Waterland * updated (installed/verified in non-inherited area), 2203*5c51f124SMoriah Waterland * and and at least one object was skipped (verified in 2204*5c51f124SMoriah Waterland * inherited area) - this means all objects were skipped 2205*5c51f124SMoriah Waterland * so do not run the postinstall script. 2206*5c51f124SMoriah Waterland */ 2207*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_POIS_SKIPPING, 2208*5c51f124SMoriah Waterland zoneName ? zoneName : "global", pkginst, script); 2209*5c51f124SMoriah Waterland } else { 2210*5c51f124SMoriah Waterland /* script present and ok to run: run the script */ 2211*5c51f124SMoriah Waterland set_ulimit("postinstall", ERR_POSTINSTALL); 2212*5c51f124SMoriah Waterland if (zoneName == (char *)NULL) { 2213*5c51f124SMoriah Waterland echo(MSG_PKGINSTALL_EXEPIC_GZ); 2214*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_EXEPIC_GZ, pkginst, script); 2215*5c51f124SMoriah Waterland } else { 2216*5c51f124SMoriah Waterland echo(MSG_PKGINSTALL_EXEPIC_LZ, zoneName); 2217*5c51f124SMoriah Waterland echoDebug(DBG_PKGINSTALL_EXEPIC_LZ, pkginst, script, 2218*5c51f124SMoriah Waterland zoneName); 2219*5c51f124SMoriah Waterland } 2220*5c51f124SMoriah Waterland putparam("PKG_PROC_SCRIPT", "postinstall"); 2221*5c51f124SMoriah Waterland putparam("TMPDIR", tmpdir); 2222*5c51f124SMoriah Waterland if (pkgverbose) { 2223*5c51f124SMoriah Waterland ckreturn(pkgexecl(script_in, PROC_STDOUT, 2224*5c51f124SMoriah Waterland PROC_USER, PROC_GRP, SHELL, "-x", 2225*5c51f124SMoriah Waterland script, NULL), ERR_POSTINSTALL); 2226*5c51f124SMoriah Waterland } else { 2227*5c51f124SMoriah Waterland ckreturn(pkgexecl(script_in, PROC_STDOUT, 2228*5c51f124SMoriah Waterland PROC_USER, PROC_GRP, SHELL, script, 2229*5c51f124SMoriah Waterland NULL), ERR_POSTINSTALL); 2230*5c51f124SMoriah Waterland } 2231*5c51f124SMoriah Waterland 2232*5c51f124SMoriah Waterland clr_ulimit(); 2233*5c51f124SMoriah Waterland (void) remove(script); /* no longer needed */ 2234*5c51f124SMoriah Waterland } 2235*5c51f124SMoriah Waterland 2236*5c51f124SMoriah Waterland if (!warnflag && !failflag) { 2237*5c51f124SMoriah Waterland if (pt = getenv("PREDEPEND")) 2238*5c51f124SMoriah Waterland predepend(pt); 2239*5c51f124SMoriah Waterland (void) remove(rlockfile); 2240*5c51f124SMoriah Waterland (void) remove(ilockfile); 2241*5c51f124SMoriah Waterland (void) remove(savlog); 2242*5c51f124SMoriah Waterland } 2243*5c51f124SMoriah Waterland 2244*5c51f124SMoriah Waterland /* release the generic package lock */ 2245*5c51f124SMoriah Waterland 2246*5c51f124SMoriah Waterland (void) unlockinst(); 2247*5c51f124SMoriah Waterland 2248*5c51f124SMoriah Waterland quit(0); 2249*5c51f124SMoriah Waterland /* LINTED: no return */ 2250*5c51f124SMoriah Waterland } 2251*5c51f124SMoriah Waterland 2252*5c51f124SMoriah Waterland /* 2253*5c51f124SMoriah Waterland * This function merges the environment data in the response file with the 2254*5c51f124SMoriah Waterland * current environment. 2255*5c51f124SMoriah Waterland */ 2256*5c51f124SMoriah Waterland static int 2257*5c51f124SMoriah Waterland merg_respfile() 2258*5c51f124SMoriah Waterland { 2259*5c51f124SMoriah Waterland int retcode = 0; 2260*5c51f124SMoriah Waterland char *resppath = get_respfile(); 2261*5c51f124SMoriah Waterland char *locbasedir; 2262*5c51f124SMoriah Waterland char param[MAX_PKG_PARAM_LENGTH], *value; 2263*5c51f124SMoriah Waterland FILE *fp; 2264*5c51f124SMoriah Waterland 2265*5c51f124SMoriah Waterland if ((fp = fopen(resppath, "r")) == NULL) { 2266*5c51f124SMoriah Waterland progerr(ERR_RESPONSE, resppath); 2267*5c51f124SMoriah Waterland return (99); 2268*5c51f124SMoriah Waterland } 2269*5c51f124SMoriah Waterland 2270*5c51f124SMoriah Waterland param[0] = '\0'; 2271*5c51f124SMoriah Waterland 2272*5c51f124SMoriah Waterland while (value = fpkgparam(fp, param)) { 2273*5c51f124SMoriah Waterland if (!isupper(param[0])) { 2274*5c51f124SMoriah Waterland param[0] = '\0'; 2275*5c51f124SMoriah Waterland continue; 2276*5c51f124SMoriah Waterland } 2277*5c51f124SMoriah Waterland 2278*5c51f124SMoriah Waterland if (rdonly(param)) { 2279*5c51f124SMoriah Waterland progerr(ERR_RDONLY, param); 2280*5c51f124SMoriah Waterland param[0] = '\0'; 2281*5c51f124SMoriah Waterland continue; 2282*5c51f124SMoriah Waterland } 2283*5c51f124SMoriah Waterland 2284*5c51f124SMoriah Waterland /* 2285*5c51f124SMoriah Waterland * If this is an update, and the response file 2286*5c51f124SMoriah Waterland * specifies the BASEDIR, make sure it matches the 2287*5c51f124SMoriah Waterland * existing installation base. If it doesn't, we have 2288*5c51f124SMoriah Waterland * to quit. 2289*5c51f124SMoriah Waterland */ 2290*5c51f124SMoriah Waterland if (update && strcmp("BASEDIR", param) == 0) { 2291*5c51f124SMoriah Waterland locbasedir = getenv("BASEDIR"); 2292*5c51f124SMoriah Waterland if (locbasedir && strcmp(value, locbasedir) != 0) { 2293*5c51f124SMoriah Waterland char *dotptr; 2294*5c51f124SMoriah Waterland /* Get srcinst down to a name. */ 2295*5c51f124SMoriah Waterland if (dotptr = strchr(srcinst, '.')) 2296*5c51f124SMoriah Waterland *dotptr = '\000'; 2297*5c51f124SMoriah Waterland progerr(ERR_NEWBD, srcinst, 2298*5c51f124SMoriah Waterland locbasedir, value); 2299*5c51f124SMoriah Waterland retcode = 99; 2300*5c51f124SMoriah Waterland } 2301*5c51f124SMoriah Waterland } 2302*5c51f124SMoriah Waterland 2303*5c51f124SMoriah Waterland putparam(param, value); 2304*5c51f124SMoriah Waterland param[0] = '\0'; 2305*5c51f124SMoriah Waterland } 2306*5c51f124SMoriah Waterland (void) fclose(fp); 2307*5c51f124SMoriah Waterland 2308*5c51f124SMoriah Waterland return (retcode); 2309*5c51f124SMoriah Waterland } 2310*5c51f124SMoriah Waterland 2311*5c51f124SMoriah Waterland /* 2312*5c51f124SMoriah Waterland * This scans the installed pkginfo file for the current BASEDIR. If this 2313*5c51f124SMoriah Waterland * BASEDIR is different from the current BASEDIR, there will definitely be 2314*5c51f124SMoriah Waterland * problems. 2315*5c51f124SMoriah Waterland */ 2316*5c51f124SMoriah Waterland static int 2317*5c51f124SMoriah Waterland ck_instbase(void) 2318*5c51f124SMoriah Waterland { 2319*5c51f124SMoriah Waterland int retcode = 0; 2320*5c51f124SMoriah Waterland char param[MAX_PKG_PARAM_LENGTH], *value; 2321*5c51f124SMoriah Waterland char pkginfo_path[PATH_MAX]; 2322*5c51f124SMoriah Waterland FILE *fp; 2323*5c51f124SMoriah Waterland 2324*5c51f124SMoriah Waterland /* Open the old pkginfo file. */ 2325*5c51f124SMoriah Waterland (void) snprintf(pkginfo_path, sizeof (pkginfo_path), 2326*5c51f124SMoriah Waterland "%s/%s", pkgloc, PKGINFO); 2327*5c51f124SMoriah Waterland if ((fp = fopen(pkginfo_path, "r")) == NULL) { 2328*5c51f124SMoriah Waterland progerr(ERR_PKGINFO, pkginfo_path); 2329*5c51f124SMoriah Waterland return (99); 2330*5c51f124SMoriah Waterland } 2331*5c51f124SMoriah Waterland 2332*5c51f124SMoriah Waterland param[0] = '\000'; 2333*5c51f124SMoriah Waterland 2334*5c51f124SMoriah Waterland while (value = fpkgparam(fp, param)) { 2335*5c51f124SMoriah Waterland if (strcmp("BASEDIR", param) == 0) { 2336*5c51f124SMoriah Waterland if (adm.basedir && *(adm.basedir) && 2337*5c51f124SMoriah Waterland strchr("/$", *(adm.basedir))) { 2338*5c51f124SMoriah Waterland char *dotptr; 2339*5c51f124SMoriah Waterland 2340*5c51f124SMoriah Waterland /* 2341*5c51f124SMoriah Waterland * Get srcinst down to a name. 2342*5c51f124SMoriah Waterland */ 2343*5c51f124SMoriah Waterland if (dotptr = strchr(srcinst, '.')) 2344*5c51f124SMoriah Waterland *dotptr = '\000'; 2345*5c51f124SMoriah Waterland if (strcmp(value, 2346*5c51f124SMoriah Waterland adm.basedir) != 0) { 2347*5c51f124SMoriah Waterland progerr(ERR_ADMBD, srcinst, 2348*5c51f124SMoriah Waterland value, adm.basedir); 2349*5c51f124SMoriah Waterland retcode = 4; 2350*5c51f124SMoriah Waterland break; 2351*5c51f124SMoriah Waterland } 2352*5c51f124SMoriah Waterland } else if (ADM(basedir, "ask")) 2353*5c51f124SMoriah Waterland /* 2354*5c51f124SMoriah Waterland * If it's going to ask later, let it know 2355*5c51f124SMoriah Waterland * that it *must* agree with the BASEDIR we 2356*5c51f124SMoriah Waterland * just picked up. 2357*5c51f124SMoriah Waterland */ 2358*5c51f124SMoriah Waterland adm.basedir = "update"; 2359*5c51f124SMoriah Waterland 2360*5c51f124SMoriah Waterland putparam(param, value); 2361*5c51f124SMoriah Waterland break; 2362*5c51f124SMoriah Waterland } 2363*5c51f124SMoriah Waterland 2364*5c51f124SMoriah Waterland param[0] = '\0'; 2365*5c51f124SMoriah Waterland } 2366*5c51f124SMoriah Waterland (void) fclose(fp); 2367*5c51f124SMoriah Waterland 2368*5c51f124SMoriah Waterland return (retcode); 2369*5c51f124SMoriah Waterland } 2370*5c51f124SMoriah Waterland 2371*5c51f124SMoriah Waterland /* 2372*5c51f124SMoriah Waterland * Since this is an overwrite of a different version of the package, none of 2373*5c51f124SMoriah Waterland * the old files should remain, so we rename them. 2374*5c51f124SMoriah Waterland */ 2375*5c51f124SMoriah Waterland static int 2376*5c51f124SMoriah Waterland mv_pkgdirs(void) 2377*5c51f124SMoriah Waterland { 2378*5c51f124SMoriah Waterland /* 2379*5c51f124SMoriah Waterland * If we're not in dryrun mode and we can find an old set of package 2380*5c51f124SMoriah Waterland * files over which the new ones will be written, do the rename. 2381*5c51f124SMoriah Waterland */ 2382*5c51f124SMoriah Waterland if (!in_dryrun_mode() && pkgloc[0] && !access(pkgloc, F_OK)) { 2383*5c51f124SMoriah Waterland (void) snprintf(pkgloc_sav, sizeof (pkgloc_sav), 2384*5c51f124SMoriah Waterland "%s/.save.%s", get_PKGLOC(), 2385*5c51f124SMoriah Waterland pkginst); 2386*5c51f124SMoriah Waterland if (pkgloc_sav[0] && !access(pkgloc_sav, F_OK)) { 2387*5c51f124SMoriah Waterland (void) rrmdir(pkgloc_sav); 2388*5c51f124SMoriah Waterland } 2389*5c51f124SMoriah Waterland 2390*5c51f124SMoriah Waterland if (rename(pkgloc, pkgloc_sav) == -1) { 2391*5c51f124SMoriah Waterland progerr(ERR_PKGBINREN, pkgloc, pkgloc_sav); 2392*5c51f124SMoriah Waterland return (99); 2393*5c51f124SMoriah Waterland } 2394*5c51f124SMoriah Waterland } 2395*5c51f124SMoriah Waterland 2396*5c51f124SMoriah Waterland return (0); 2397*5c51f124SMoriah Waterland } 2398*5c51f124SMoriah Waterland 2399*5c51f124SMoriah Waterland /* 2400*5c51f124SMoriah Waterland * Name: merg_pkginfos 2401*5c51f124SMoriah Waterland * Description: This function scans the installed pkginfo and merges that 2402*5c51f124SMoriah Waterland * environment with the installing environment according to 2403*5c51f124SMoriah Waterland * the following rules: 2404*5c51f124SMoriah Waterland * 2405*5c51f124SMoriah Waterland * 1. CLASSES is a union of the installed and installing CLASSES 2406*5c51f124SMoriah Waterland * lists. 2407*5c51f124SMoriah Waterland * 2. The installed BASEDIR takes precedence. If it doesn't agree 2408*5c51f124SMoriah Waterland * with an administratively imposed BASEDIR, an ERROR is issued. 2409*5c51f124SMoriah Waterland * 3. All other installing parameters are preserved. 2410*5c51f124SMoriah Waterland * 4. All installed parameters are added if they do not overwrite 2411*5c51f124SMoriah Waterland * an existing installing parameter. 2412*5c51f124SMoriah Waterland * 2413*5c51f124SMoriah Waterland * The current environment contains the pkginfo settings for the 2414*5c51f124SMoriah Waterland * new package to be installed or to be updated. 2415*5c51f124SMoriah Waterland * 2416*5c51f124SMoriah Waterland * Arguments: pclass - returned list of current classes involved in install 2417*5c51f124SMoriah Waterland * mpclass - pointer to returned list of current install classes 2418*5c51f124SMoriah Waterland * Returns: int 2419*5c51f124SMoriah Waterland * == 0 - all OK 2420*5c51f124SMoriah Waterland * != 0 - an error code if a fatal error occurred 2421*5c51f124SMoriah Waterland */ 2422*5c51f124SMoriah Waterland 2423*5c51f124SMoriah Waterland static int 2424*5c51f124SMoriah Waterland merg_pkginfos(struct cl_attr **pclass, struct cl_attr ***mpclass) 2425*5c51f124SMoriah Waterland { 2426*5c51f124SMoriah Waterland FILE *fp; 2427*5c51f124SMoriah Waterland char SUNW_PKG_ALLZONES[MAX_PKG_PARAM_LENGTH] = {'\0'}; 2428*5c51f124SMoriah Waterland char SUNW_PKG_HOLLOW[MAX_PKG_PARAM_LENGTH] = {'\0'}; 2429*5c51f124SMoriah Waterland char SUNW_PKG_THISZONE[MAX_PKG_PARAM_LENGTH] = {'\0'}; 2430*5c51f124SMoriah Waterland char *newValue; 2431*5c51f124SMoriah Waterland char *oldValue; 2432*5c51f124SMoriah Waterland char *pkgName; 2433*5c51f124SMoriah Waterland char *pkgVersion; 2434*5c51f124SMoriah Waterland char param[MAX_PKG_PARAM_LENGTH]; 2435*5c51f124SMoriah Waterland char pkginfo_path[PATH_MAX]; 2436*5c51f124SMoriah Waterland int retcode = 0; 2437*5c51f124SMoriah Waterland 2438*5c51f124SMoriah Waterland /* obtain the name of the package (for error messages) */ 2439*5c51f124SMoriah Waterland 2440*5c51f124SMoriah Waterland pkgName = getenv("PKG"); 2441*5c51f124SMoriah Waterland if (pkgName == NULL) { 2442*5c51f124SMoriah Waterland pkgName = "*current*"; /* default name */ 2443*5c51f124SMoriah Waterland } 2444*5c51f124SMoriah Waterland 2445*5c51f124SMoriah Waterland /* obtain the version of the package (for error messages) */ 2446*5c51f124SMoriah Waterland 2447*5c51f124SMoriah Waterland pkgVersion = getenv("VERSION"); 2448*5c51f124SMoriah Waterland if (pkgVersion == NULL) { 2449*5c51f124SMoriah Waterland pkgVersion = "*current*"; /* default version */ 2450*5c51f124SMoriah Waterland } 2451*5c51f124SMoriah Waterland 2452*5c51f124SMoriah Waterland /* open installed package pkginfo file */ 2453*5c51f124SMoriah Waterland 2454*5c51f124SMoriah Waterland (void) snprintf(pkginfo_path, sizeof (pkginfo_path), 2455*5c51f124SMoriah Waterland "%s/%s", pkgloc, PKGINFO); 2456*5c51f124SMoriah Waterland if ((fp = fopen(pkginfo_path, "r")) == NULL) { 2457*5c51f124SMoriah Waterland progerr(ERR_PKGINFO, pkginfo_path); 2458*5c51f124SMoriah Waterland return (99); 2459*5c51f124SMoriah Waterland } 2460*5c51f124SMoriah Waterland 2461*5c51f124SMoriah Waterland /* entry debugging info */ 2462*5c51f124SMoriah Waterland 2463*5c51f124SMoriah Waterland echoDebug(DBG_MERGINFOS_ENTRY, pkginfo_path); 2464*5c51f124SMoriah Waterland 2465*5c51f124SMoriah Waterland /* 2466*5c51f124SMoriah Waterland * cycle through the currently installed package's pkginfo parameters 2467*5c51f124SMoriah Waterland * and let the currently installed package's settings survive if the 2468*5c51f124SMoriah Waterland * update to the package does not provide an overriding value 2469*5c51f124SMoriah Waterland */ 2470*5c51f124SMoriah Waterland 2471*5c51f124SMoriah Waterland for (param[0] = '\0'; (oldValue = fpkgparam(fp, param)) != NULL; 2472*5c51f124SMoriah Waterland param[0] = '\0') { 2473*5c51f124SMoriah Waterland 2474*5c51f124SMoriah Waterland boolean_t setZoneAttribute = B_FALSE; 2475*5c51f124SMoriah Waterland 2476*5c51f124SMoriah Waterland /* debug info - attribute currently set to value */ 2477*5c51f124SMoriah Waterland 2478*5c51f124SMoriah Waterland echoDebug(DBG_MERGINFOS_SET_TO, param, oldValue); 2479*5c51f124SMoriah Waterland 2480*5c51f124SMoriah Waterland /* 2481*5c51f124SMoriah Waterland * if zone package attribute is present in the currently 2482*5c51f124SMoriah Waterland * installed package, then remember the value for the 2483*5c51f124SMoriah Waterland * specific zone package attribute, and set the flag that 2484*5c51f124SMoriah Waterland * indicates a zone package attribute is being processed. 2485*5c51f124SMoriah Waterland */ 2486*5c51f124SMoriah Waterland 2487*5c51f124SMoriah Waterland if (strcmp(param, PKG_THISZONE_VARIABLE) == 0) { 2488*5c51f124SMoriah Waterland /* SUNW_PKG_THISZONE currently set */ 2489*5c51f124SMoriah Waterland setZoneAttribute = B_TRUE; 2490*5c51f124SMoriah Waterland (void) strlcpy(SUNW_PKG_THISZONE, oldValue, 2491*5c51f124SMoriah Waterland sizeof (SUNW_PKG_THISZONE)); 2492*5c51f124SMoriah Waterland } else if (strcmp(param, PKG_ALLZONES_VARIABLE) == 0) { 2493*5c51f124SMoriah Waterland /* SUNW_PKG_ALLZONES currently set */ 2494*5c51f124SMoriah Waterland setZoneAttribute = B_TRUE; 2495*5c51f124SMoriah Waterland (void) strlcpy(SUNW_PKG_ALLZONES, oldValue, 2496*5c51f124SMoriah Waterland sizeof (SUNW_PKG_ALLZONES)); 2497*5c51f124SMoriah Waterland } else if (strcmp(param, PKG_HOLLOW_VARIABLE) == 0) { 2498*5c51f124SMoriah Waterland /* SUNW_PKG_THISZONE currently set */ 2499*5c51f124SMoriah Waterland setZoneAttribute = B_TRUE; 2500*5c51f124SMoriah Waterland (void) strlcpy(SUNW_PKG_HOLLOW, oldValue, 2501*5c51f124SMoriah Waterland sizeof (SUNW_PKG_HOLLOW)); 2502*5c51f124SMoriah Waterland } 2503*5c51f124SMoriah Waterland 2504*5c51f124SMoriah Waterland /* handle CLASSES currently being set */ 2505*5c51f124SMoriah Waterland 2506*5c51f124SMoriah Waterland if (strcmp(param, "CLASSES") == 0) { 2507*5c51f124SMoriah Waterland echoDebug(DBG_MERGINFOS_SET_CLASSES, oldValue); 2508*5c51f124SMoriah Waterland /* create a list of the current classes */ 2509*5c51f124SMoriah Waterland (void) setlist(&pclass, qstrdup(oldValue)); 2510*5c51f124SMoriah Waterland /* set pointer to list of current classes */ 2511*5c51f124SMoriah Waterland *mpclass = pclass; 2512*5c51f124SMoriah Waterland continue; 2513*5c51f124SMoriah Waterland } 2514*5c51f124SMoriah Waterland 2515*5c51f124SMoriah Waterland /* handle BASEDIR currently being set */ 2516*5c51f124SMoriah Waterland 2517*5c51f124SMoriah Waterland if (strcmp("BASEDIR", param) == 0) { 2518*5c51f124SMoriah Waterland if (adm.basedir && *(adm.basedir) && 2519*5c51f124SMoriah Waterland strchr("/$", *(adm.basedir))) { 2520*5c51f124SMoriah Waterland char *dotptr; 2521*5c51f124SMoriah Waterland 2522*5c51f124SMoriah Waterland /* Get srcinst down to a* name */ 2523*5c51f124SMoriah Waterland 2524*5c51f124SMoriah Waterland if (dotptr = strchr(srcinst, '.')) { 2525*5c51f124SMoriah Waterland *dotptr = '\000'; 2526*5c51f124SMoriah Waterland } 2527*5c51f124SMoriah Waterland if (strcmp(oldValue, adm.basedir) != 0) { 2528*5c51f124SMoriah Waterland progerr(ERR_ADMBD, srcinst, 2529*5c51f124SMoriah Waterland oldValue, adm.basedir); 2530*5c51f124SMoriah Waterland /* administration */ 2531*5c51f124SMoriah Waterland retcode = 4; 2532*5c51f124SMoriah Waterland break; 2533*5c51f124SMoriah Waterland } 2534*5c51f124SMoriah Waterland } else if (ADM(basedir, "ask")) { 2535*5c51f124SMoriah Waterland /* 2536*5c51f124SMoriah Waterland * If it's going to ask 2537*5c51f124SMoriah Waterland * later, let it know that it 2538*5c51f124SMoriah Waterland * *must* agree with the 2539*5c51f124SMoriah Waterland * BASEDIR we just picked up. 2540*5c51f124SMoriah Waterland */ 2541*5c51f124SMoriah Waterland adm.basedir = "update"; 2542*5c51f124SMoriah Waterland echoDebug(DBG_MERGINFOS_ASK_BASEDIR); 2543*5c51f124SMoriah Waterland } 2544*5c51f124SMoriah Waterland 2545*5c51f124SMoriah Waterland echoDebug(DBG_MERGINFOS_SET_BASEDIR, oldValue); 2546*5c51f124SMoriah Waterland putparam(param, oldValue); 2547*5c51f124SMoriah Waterland continue; 2548*5c51f124SMoriah Waterland } 2549*5c51f124SMoriah Waterland 2550*5c51f124SMoriah Waterland /* 2551*5c51f124SMoriah Waterland * determine if there is a new value for this attribute. 2552*5c51f124SMoriah Waterland */ 2553*5c51f124SMoriah Waterland 2554*5c51f124SMoriah Waterland newValue = getenv(param); 2555*5c51f124SMoriah Waterland 2556*5c51f124SMoriah Waterland /* 2557*5c51f124SMoriah Waterland * If zone attributes of patch packages haven't been verified 2558*5c51f124SMoriah Waterland * by pdo, if there is no new value, and a zone attribute 2559*5c51f124SMoriah Waterland * is being changed, it is the same as setting the zone package 2560*5c51f124SMoriah Waterland * attribute to 'false' - make sure current setting is 'false'. 2561*5c51f124SMoriah Waterland */ 2562*5c51f124SMoriah Waterland 2563*5c51f124SMoriah Waterland if ((patchPkgInstall == B_FALSE) && (newValue == NULL) && 2564*5c51f124SMoriah Waterland (setZoneAttribute == B_TRUE) && 2565*5c51f124SMoriah Waterland (strcasecmp(oldValue, "false") != 0)) { 2566*5c51f124SMoriah Waterland 2567*5c51f124SMoriah Waterland /* unset existing non-"false" zone pkg attr */ 2568*5c51f124SMoriah Waterland progerr(ERR_MERGINFOS_UNSET_ZONEATTR, 2569*5c51f124SMoriah Waterland pkgName, pkgVersion, param, oldValue); 2570*5c51f124SMoriah Waterland retcode = 1; 2571*5c51f124SMoriah Waterland break; 2572*5c51f124SMoriah Waterland } 2573*5c51f124SMoriah Waterland 2574*5c51f124SMoriah Waterland /* retain old value if no new value specified */ 2575*5c51f124SMoriah Waterland 2576*5c51f124SMoriah Waterland if (newValue == NULL) { 2577*5c51f124SMoriah Waterland /* no new value - retain the old value */ 2578*5c51f124SMoriah Waterland echoDebug(DBG_MERGINFOS_RETAIN_OLD, param, oldValue); 2579*5c51f124SMoriah Waterland putparam(param, oldValue); 2580*5c51f124SMoriah Waterland continue; 2581*5c51f124SMoriah Waterland } 2582*5c51f124SMoriah Waterland 2583*5c51f124SMoriah Waterland /* note if the old and new values are the same */ 2584*5c51f124SMoriah Waterland 2585*5c51f124SMoriah Waterland if (strcmp(newValue, oldValue) == 0) { 2586*5c51f124SMoriah Waterland /* set existing package parameter to same value */ 2587*5c51f124SMoriah Waterland echoDebug(DBG_MERGINFOS_SET_DUPLICATE, param, oldValue); 2588*5c51f124SMoriah Waterland continue; 2589*5c51f124SMoriah Waterland } 2590*5c51f124SMoriah Waterland 2591*5c51f124SMoriah Waterland /* 2592*5c51f124SMoriah Waterland * If zone attributes of patch packages haven't been verified 2593*5c51f124SMoriah Waterland * by pdo, check if old and new values differ. 2594*5c51f124SMoriah Waterland * Error if zone parameter 2595*5c51f124SMoriah Waterland */ 2596*5c51f124SMoriah Waterland 2597*5c51f124SMoriah Waterland if ((patchPkgInstall == B_FALSE) && 2598*5c51f124SMoriah Waterland (setZoneAttribute == B_TRUE)) { 2599*5c51f124SMoriah Waterland /* illegal change to zone attribute */ 2600*5c51f124SMoriah Waterland 2601*5c51f124SMoriah Waterland progerr(ERR_MERGINFOS_CHANGE_ZONEATTR, pkgName, 2602*5c51f124SMoriah Waterland pkgVersion, param, oldValue, newValue); 2603*5c51f124SMoriah Waterland 2604*5c51f124SMoriah Waterland /* set return code to "fatal error" */ 2605*5c51f124SMoriah Waterland retcode = 1; 2606*5c51f124SMoriah Waterland break; 2607*5c51f124SMoriah Waterland } 2608*5c51f124SMoriah Waterland 2609*5c51f124SMoriah Waterland /* note valid change to existing package parameter */ 2610*5c51f124SMoriah Waterland 2611*5c51f124SMoriah Waterland echoDebug(DBG_MERGINFOS_SET_CHANGE, param, 2612*5c51f124SMoriah Waterland oldValue, newValue); 2613*5c51f124SMoriah Waterland } 2614*5c51f124SMoriah Waterland 2615*5c51f124SMoriah Waterland /* close handle on currently installed package's pkginfo file */ 2616*5c51f124SMoriah Waterland 2617*5c51f124SMoriah Waterland (void) fclose(fp); 2618*5c51f124SMoriah Waterland 2619*5c51f124SMoriah Waterland /* return error if not successful up to this point */ 2620*5c51f124SMoriah Waterland 2621*5c51f124SMoriah Waterland if (retcode != 0) { 2622*5c51f124SMoriah Waterland echoDebug(DBG_MERGINFOS_EXIT, pkginfo_path, retcode); 2623*5c51f124SMoriah Waterland 2624*5c51f124SMoriah Waterland return (retcode); 2625*5c51f124SMoriah Waterland } 2626*5c51f124SMoriah Waterland 2627*5c51f124SMoriah Waterland /* 2628*5c51f124SMoriah Waterland * Skip this if() section, if zone attributes of patch packages 2629*5c51f124SMoriah Waterland * have been verified by pdo. 2630*5c51f124SMoriah Waterland */ 2631*5c51f124SMoriah Waterland 2632*5c51f124SMoriah Waterland if (patchPkgInstall == B_FALSE) { 2633*5c51f124SMoriah Waterland 2634*5c51f124SMoriah Waterland /* 2635*5c51f124SMoriah Waterland * verify that no zone attribute has been 2636*5c51f124SMoriah Waterland * set to an invalid value 2637*5c51f124SMoriah Waterland */ 2638*5c51f124SMoriah Waterland 2639*5c51f124SMoriah Waterland /* SUNW_PKG_ALLZONES */ 2640*5c51f124SMoriah Waterland 2641*5c51f124SMoriah Waterland newValue = getenv(PKG_ALLZONES_VARIABLE); 2642*5c51f124SMoriah Waterland 2643*5c51f124SMoriah Waterland /* 2644*5c51f124SMoriah Waterland * complain if setting SUNW_PKG_ALLZONES to other than "false" 2645*5c51f124SMoriah Waterland */ 2646*5c51f124SMoriah Waterland 2647*5c51f124SMoriah Waterland 2648*5c51f124SMoriah Waterland if ((newValue != NULL) && (*SUNW_PKG_ALLZONES == '\0') && 2649*5c51f124SMoriah Waterland (strcasecmp(newValue, "false") != 0)) { 2650*5c51f124SMoriah Waterland /* change ALLZONES from "true" to "false" (unset) */ 2651*5c51f124SMoriah Waterland progerr(ERR_MERGINFOS_SET_ZONEATTR, pkgName, 2652*5c51f124SMoriah Waterland pkgVersion, PKG_ALLZONES_VARIABLE, newValue); 2653*5c51f124SMoriah Waterland return (1); 2654*5c51f124SMoriah Waterland } 2655*5c51f124SMoriah Waterland 2656*5c51f124SMoriah Waterland /* SUNW_PKG_THISZONE */ 2657*5c51f124SMoriah Waterland 2658*5c51f124SMoriah Waterland newValue = getenv(PKG_THISZONE_VARIABLE); 2659*5c51f124SMoriah Waterland 2660*5c51f124SMoriah Waterland /* 2661*5c51f124SMoriah Waterland * complain if setting SUNW_PKG_THISZONE to other than "false" 2662*5c51f124SMoriah Waterland */ 2663*5c51f124SMoriah Waterland 2664*5c51f124SMoriah Waterland if ((newValue != NULL) && (*SUNW_PKG_THISZONE == '\0') && 2665*5c51f124SMoriah Waterland (strcasecmp(newValue, "false") != 0)) { 2666*5c51f124SMoriah Waterland /* change THISZONE from "true" to "false" (unset) */ 2667*5c51f124SMoriah Waterland progerr(ERR_MERGINFOS_SET_ZONEATTR, pkgName, 2668*5c51f124SMoriah Waterland pkgVersion, PKG_THISZONE_VARIABLE, newValue); 2669*5c51f124SMoriah Waterland return (1); 2670*5c51f124SMoriah Waterland } 2671*5c51f124SMoriah Waterland 2672*5c51f124SMoriah Waterland /* SUNW_PKG_HOLLOW */ 2673*5c51f124SMoriah Waterland 2674*5c51f124SMoriah Waterland newValue = getenv(PKG_HOLLOW_VARIABLE); 2675*5c51f124SMoriah Waterland 2676*5c51f124SMoriah Waterland /* complain if setting SUNW_PKG_HOLLOW to other than "false" */ 2677*5c51f124SMoriah Waterland 2678*5c51f124SMoriah Waterland if ((newValue != NULL) && (*SUNW_PKG_HOLLOW == '\0') && 2679*5c51f124SMoriah Waterland (strcasecmp(newValue, "false") != 0)) { 2680*5c51f124SMoriah Waterland /* change HOLLOW from "true" to 'false" (unset) */ 2681*5c51f124SMoriah Waterland progerr(ERR_MERGINFOS_SET_ZONEATTR, pkgName, 2682*5c51f124SMoriah Waterland pkgVersion, PKG_HOLLOW_VARIABLE, newValue); 2683*5c51f124SMoriah Waterland return (1); 2684*5c51f124SMoriah Waterland } 2685*5c51f124SMoriah Waterland 2686*5c51f124SMoriah Waterland } 2687*5c51f124SMoriah Waterland 2688*5c51f124SMoriah Waterland /* return */ 2689*5c51f124SMoriah Waterland 2690*5c51f124SMoriah Waterland echoDebug(DBG_MERGINFOS_EXIT, pkginfo_path, 0); 2691*5c51f124SMoriah Waterland 2692*5c51f124SMoriah Waterland return (0); 2693*5c51f124SMoriah Waterland } 2694*5c51f124SMoriah Waterland 2695*5c51f124SMoriah Waterland static void 2696*5c51f124SMoriah Waterland set_dryrun_dir_loc(void) 2697*5c51f124SMoriah Waterland { 2698*5c51f124SMoriah Waterland /* Set pkg location to the dryrun directory */ 2699*5c51f124SMoriah Waterland set_PKGLOC(pkgdrtarg); 2700*5c51f124SMoriah Waterland (void) snprintf(pkgloc, sizeof (pkgloc), 2701*5c51f124SMoriah Waterland "%s/%s", get_PKGLOC(), pkginst); 2702*5c51f124SMoriah Waterland (void) snprintf(pkgbin, sizeof (pkgbin), 2703*5c51f124SMoriah Waterland "%s/install", pkgloc); 2704*5c51f124SMoriah Waterland (void) snprintf(pkgsav, sizeof (pkgsav), 2705*5c51f124SMoriah Waterland "%s/save", pkgloc); 2706*5c51f124SMoriah Waterland (void) snprintf(ilockfile, sizeof (ilockfile), 2707*5c51f124SMoriah Waterland "%s/!I-Lock!", pkgloc); 2708*5c51f124SMoriah Waterland (void) snprintf(rlockfile, sizeof (rlockfile), 2709*5c51f124SMoriah Waterland "%s/!R-Lock!", pkgloc); 2710*5c51f124SMoriah Waterland (void) snprintf(savlog, sizeof (savlog), 2711*5c51f124SMoriah Waterland "%s/logs/%s", get_PKGADM(), pkginst); 2712*5c51f124SMoriah Waterland } 2713*5c51f124SMoriah Waterland 2714*5c51f124SMoriah Waterland /* 2715*5c51f124SMoriah Waterland * If we are updating a pkg, then we need to copy the "old" pkgloc so that 2716*5c51f124SMoriah Waterland * any scripts that got removed in the new version aren't left around. So we 2717*5c51f124SMoriah Waterland * copy it here to .save.pkgloc, then in quit() we can restore our state, or 2718*5c51f124SMoriah Waterland * remove it. 2719*5c51f124SMoriah Waterland */ 2720*5c51f124SMoriah Waterland static int 2721*5c51f124SMoriah Waterland cp_pkgdirs(void) 2722*5c51f124SMoriah Waterland { 2723*5c51f124SMoriah Waterland if (in_dryrun_mode()) { 2724*5c51f124SMoriah Waterland set_dryrun_dir_loc(); 2725*5c51f124SMoriah Waterland } 2726*5c51f124SMoriah Waterland 2727*5c51f124SMoriah Waterland /* 2728*5c51f124SMoriah Waterland * If we're not in dryrun mode and we can find an old set of package 2729*5c51f124SMoriah Waterland * files over which the new ones will be written, do the copy. 2730*5c51f124SMoriah Waterland */ 2731*5c51f124SMoriah Waterland if (!in_dryrun_mode() && pkgloc[0] && !access(pkgloc, F_OK)) { 2732*5c51f124SMoriah Waterland int status; 2733*5c51f124SMoriah Waterland int r; 2734*5c51f124SMoriah Waterland 2735*5c51f124SMoriah Waterland (void) snprintf(pkgloc_sav, sizeof (pkgloc_sav), "%s/.save.%s", 2736*5c51f124SMoriah Waterland get_PKGLOC(), pkginst); 2737*5c51f124SMoriah Waterland 2738*5c51f124SMoriah Waterland /* 2739*5c51f124SMoriah Waterland * Even though it takes a while, we use a recursive copy here 2740*5c51f124SMoriah Waterland * because if the current pkgadd fails for any reason, we 2741*5c51f124SMoriah Waterland * don't want to lose this data. 2742*5c51f124SMoriah Waterland */ 2743*5c51f124SMoriah Waterland r = e_ExecCmdList(&status, (char **)NULL, (char *)NULL, 2744*5c51f124SMoriah Waterland "/usr/bin/cp", "cp", "-r", pkgloc, pkgloc_sav, 2745*5c51f124SMoriah Waterland (char *)NULL); 2746*5c51f124SMoriah Waterland 2747*5c51f124SMoriah Waterland if ((r != 0) || (status == -1) || (WEXITSTATUS(status) != 0)) { 2748*5c51f124SMoriah Waterland progerr(ERR_PKGBINCP, pkgloc, pkgloc_sav); 2749*5c51f124SMoriah Waterland return (99); 2750*5c51f124SMoriah Waterland } 2751*5c51f124SMoriah Waterland } 2752*5c51f124SMoriah Waterland 2753*5c51f124SMoriah Waterland return (0); 2754*5c51f124SMoriah Waterland } 2755*5c51f124SMoriah Waterland 2756*5c51f124SMoriah Waterland /* 2757*5c51f124SMoriah Waterland * This implements the pkgask function. It just executes the request script 2758*5c51f124SMoriah Waterland * and stores the results in a response file. 2759*5c51f124SMoriah Waterland */ 2760*5c51f124SMoriah Waterland static void 2761*5c51f124SMoriah Waterland do_pkgask(boolean_t a_run_request_as_root) 2762*5c51f124SMoriah Waterland { 2763*5c51f124SMoriah Waterland if (pkgdev.cdevice) { 2764*5c51f124SMoriah Waterland unpack(); 2765*5c51f124SMoriah Waterland if (!suppressCopyright) { 2766*5c51f124SMoriah Waterland copyright(); 2767*5c51f124SMoriah Waterland } 2768*5c51f124SMoriah Waterland } 2769*5c51f124SMoriah Waterland (void) snprintf(path, sizeof (path), "%s/%s", instdir, REQUEST_FILE); 2770*5c51f124SMoriah Waterland if (access(path, F_OK)) { 2771*5c51f124SMoriah Waterland progerr(ERR_NOREQUEST); 2772*5c51f124SMoriah Waterland quit(1); 2773*5c51f124SMoriah Waterland /*NOTREACHED*/ 2774*5c51f124SMoriah Waterland } 2775*5c51f124SMoriah Waterland 2776*5c51f124SMoriah Waterland (void) set_respfile(respfile, srcinst, RESP_WR); 2777*5c51f124SMoriah Waterland 2778*5c51f124SMoriah Waterland if (is_a_respfile()) { 2779*5c51f124SMoriah Waterland ckreturn(reqexec(update, path, non_abi_scripts, 2780*5c51f124SMoriah Waterland a_run_request_as_root), ERR_REQUEST); 2781*5c51f124SMoriah Waterland } else { 2782*5c51f124SMoriah Waterland failflag++; 2783*5c51f124SMoriah Waterland } 2784*5c51f124SMoriah Waterland 2785*5c51f124SMoriah Waterland if (warnflag || failflag) { 2786*5c51f124SMoriah Waterland (void) remove(respfile); 2787*5c51f124SMoriah Waterland echo("\nResponse file <%s> was not created.", 2788*5c51f124SMoriah Waterland get_respfile()); 2789*5c51f124SMoriah Waterland } else { 2790*5c51f124SMoriah Waterland echo("\nResponse file <%s> was created.", 2791*5c51f124SMoriah Waterland get_respfile()); 2792*5c51f124SMoriah Waterland } 2793*5c51f124SMoriah Waterland 2794*5c51f124SMoriah Waterland quit(0); 2795*5c51f124SMoriah Waterland /*NOTREACHED*/ 2796*5c51f124SMoriah Waterland } 2797*5c51f124SMoriah Waterland 2798*5c51f124SMoriah Waterland /* 2799*5c51f124SMoriah Waterland * This function runs a check utility and acts appropriately based upon the 2800*5c51f124SMoriah Waterland * return code. It deals appropriately with the dryrun file if it is present. 2801*5c51f124SMoriah Waterland */ 2802*5c51f124SMoriah Waterland static void 2803*5c51f124SMoriah Waterland ck_w_dryrun(int (*func)(), int type) 2804*5c51f124SMoriah Waterland { 2805*5c51f124SMoriah Waterland int n; 2806*5c51f124SMoriah Waterland 2807*5c51f124SMoriah Waterland n = func(); 2808*5c51f124SMoriah Waterland if (in_dryrun_mode()) 2809*5c51f124SMoriah Waterland set_dr_info(type, !n); 2810*5c51f124SMoriah Waterland 2811*5c51f124SMoriah Waterland if (n) { 2812*5c51f124SMoriah Waterland quit(n); 2813*5c51f124SMoriah Waterland /*NOTREACHED*/ 2814*5c51f124SMoriah Waterland } 2815*5c51f124SMoriah Waterland } 2816*5c51f124SMoriah Waterland 2817*5c51f124SMoriah Waterland /* 2818*5c51f124SMoriah Waterland * This function deletes all install class action scripts from the package 2819*5c51f124SMoriah Waterland * directory on the root filesystem. 2820*5c51f124SMoriah Waterland */ 2821*5c51f124SMoriah Waterland static void 2822*5c51f124SMoriah Waterland rm_icas(char *cas_dir) 2823*5c51f124SMoriah Waterland { 2824*5c51f124SMoriah Waterland DIR *pdirfp; 2825*5c51f124SMoriah Waterland struct dirent *dp; 2826*5c51f124SMoriah Waterland char path[PATH_MAX]; 2827*5c51f124SMoriah Waterland 2828*5c51f124SMoriah Waterland if ((pdirfp = opendir(cas_dir)) == NULL) 2829*5c51f124SMoriah Waterland return; 2830*5c51f124SMoriah Waterland 2831*5c51f124SMoriah Waterland while ((dp = readdir(pdirfp)) != NULL) { 2832*5c51f124SMoriah Waterland if (dp->d_name[0] == '.') 2833*5c51f124SMoriah Waterland continue; 2834*5c51f124SMoriah Waterland 2835*5c51f124SMoriah Waterland if (dp->d_name[0] == 'i' && dp->d_name[1] == '.') { 2836*5c51f124SMoriah Waterland (void) snprintf(path, sizeof (path), 2837*5c51f124SMoriah Waterland "%s/%s", cas_dir, dp->d_name); 2838*5c51f124SMoriah Waterland (void) remove(path); 2839*5c51f124SMoriah Waterland } 2840*5c51f124SMoriah Waterland } 2841*5c51f124SMoriah Waterland (void) closedir(pdirfp); 2842*5c51f124SMoriah Waterland } 2843*5c51f124SMoriah Waterland 2844*5c51f124SMoriah Waterland void 2845*5c51f124SMoriah Waterland ckreturn(int retcode, char *msg) 2846*5c51f124SMoriah Waterland { 2847*5c51f124SMoriah Waterland switch (retcode) { 2848*5c51f124SMoriah Waterland case 2: 2849*5c51f124SMoriah Waterland case 12: 2850*5c51f124SMoriah Waterland case 22: 2851*5c51f124SMoriah Waterland warnflag++; 2852*5c51f124SMoriah Waterland if (msg) { 2853*5c51f124SMoriah Waterland progerr("%s", msg); 2854*5c51f124SMoriah Waterland } 2855*5c51f124SMoriah Waterland /*FALLTHRU*/ 2856*5c51f124SMoriah Waterland case 10: 2857*5c51f124SMoriah Waterland case 20: 2858*5c51f124SMoriah Waterland if (retcode >= 10 && retcode < 20) { 2859*5c51f124SMoriah Waterland dreboot++; 2860*5c51f124SMoriah Waterland } 2861*5c51f124SMoriah Waterland if (retcode >= 20) { 2862*5c51f124SMoriah Waterland ireboot++; 2863*5c51f124SMoriah Waterland } 2864*5c51f124SMoriah Waterland /*FALLTHRU*/ 2865*5c51f124SMoriah Waterland case 0: 2866*5c51f124SMoriah Waterland break; /* okay */ 2867*5c51f124SMoriah Waterland 2868*5c51f124SMoriah Waterland case -1: 2869*5c51f124SMoriah Waterland retcode = 99; 2870*5c51f124SMoriah Waterland /*FALLTHRU*/ 2871*5c51f124SMoriah Waterland case 99: 2872*5c51f124SMoriah Waterland case 1: 2873*5c51f124SMoriah Waterland case 11: 2874*5c51f124SMoriah Waterland case 21: 2875*5c51f124SMoriah Waterland case 4: 2876*5c51f124SMoriah Waterland case 14: 2877*5c51f124SMoriah Waterland case 24: 2878*5c51f124SMoriah Waterland case 5: 2879*5c51f124SMoriah Waterland case 15: 2880*5c51f124SMoriah Waterland case 25: 2881*5c51f124SMoriah Waterland if (msg) { 2882*5c51f124SMoriah Waterland progerr("%s", msg); 2883*5c51f124SMoriah Waterland } 2884*5c51f124SMoriah Waterland /*FALLTHRU*/ 2885*5c51f124SMoriah Waterland case 3: 2886*5c51f124SMoriah Waterland case 13: 2887*5c51f124SMoriah Waterland case 23: 2888*5c51f124SMoriah Waterland quit(retcode); 2889*5c51f124SMoriah Waterland /*NOTREACHED*/ 2890*5c51f124SMoriah Waterland default: 2891*5c51f124SMoriah Waterland if (msg) { 2892*5c51f124SMoriah Waterland progerr("%s", msg); 2893*5c51f124SMoriah Waterland } 2894*5c51f124SMoriah Waterland quit(1); 2895*5c51f124SMoriah Waterland /*NOTREACHED*/ 2896*5c51f124SMoriah Waterland } 2897*5c51f124SMoriah Waterland } 2898*5c51f124SMoriah Waterland 2899*5c51f124SMoriah Waterland static void 2900*5c51f124SMoriah Waterland copyright(void) 2901*5c51f124SMoriah Waterland { 2902*5c51f124SMoriah Waterland FILE *fp; 2903*5c51f124SMoriah Waterland char line[LSIZE]; 2904*5c51f124SMoriah Waterland char path[PATH_MAX]; 2905*5c51f124SMoriah Waterland 2906*5c51f124SMoriah Waterland /* Compose full path for copyright file */ 2907*5c51f124SMoriah Waterland (void) snprintf(path, sizeof (path), "%s/%s", instdir, COPYRIGHT_FILE); 2908*5c51f124SMoriah Waterland 2909*5c51f124SMoriah Waterland if ((fp = fopen(path, "r")) == NULL) { 2910*5c51f124SMoriah Waterland if (getenv("VENDOR") != NULL) 2911*5c51f124SMoriah Waterland echo(getenv("VENDOR")); 2912*5c51f124SMoriah Waterland } else { 2913*5c51f124SMoriah Waterland while (fgets(line, LSIZE, fp)) 2914*5c51f124SMoriah Waterland (void) fprintf(stdout, "%s", line); /* bug #1083713 */ 2915*5c51f124SMoriah Waterland (void) fclose(fp); 2916*5c51f124SMoriah Waterland } 2917*5c51f124SMoriah Waterland } 2918*5c51f124SMoriah Waterland 2919*5c51f124SMoriah Waterland static int 2920*5c51f124SMoriah Waterland rdonly(char *p) 2921*5c51f124SMoriah Waterland { 2922*5c51f124SMoriah Waterland int i; 2923*5c51f124SMoriah Waterland 2924*5c51f124SMoriah Waterland for (i = 0; ro_params[i]; i++) { 2925*5c51f124SMoriah Waterland if (strcmp(p, ro_params[i]) == 0) 2926*5c51f124SMoriah Waterland return (1); 2927*5c51f124SMoriah Waterland } 2928*5c51f124SMoriah Waterland return (0); 2929*5c51f124SMoriah Waterland } 2930*5c51f124SMoriah Waterland 2931*5c51f124SMoriah Waterland static void 2932*5c51f124SMoriah Waterland unpack(void) 2933*5c51f124SMoriah Waterland { 2934*5c51f124SMoriah Waterland /* 2935*5c51f124SMoriah Waterland * read in next part from stream, even if we decide 2936*5c51f124SMoriah Waterland * later that we don't need it 2937*5c51f124SMoriah Waterland */ 2938*5c51f124SMoriah Waterland if (dparts < 1) { 2939*5c51f124SMoriah Waterland progerr(ERR_DSTREAMCNT); 2940*5c51f124SMoriah Waterland quit(99); 2941*5c51f124SMoriah Waterland /*NOTREACHED*/ 2942*5c51f124SMoriah Waterland } 2943*5c51f124SMoriah Waterland if ((access(instdir, F_OK) == 0) && rrmdir(instdir)) { 2944*5c51f124SMoriah Waterland progerr(ERR_RMDIR, instdir); 2945*5c51f124SMoriah Waterland quit(99); 2946*5c51f124SMoriah Waterland /*NOTREACHED*/ 2947*5c51f124SMoriah Waterland } 2948*5c51f124SMoriah Waterland if (mkdir(instdir, 0755)) { 2949*5c51f124SMoriah Waterland progerr(ERR_MKDIR, instdir); 2950*5c51f124SMoriah Waterland quit(99); 2951*5c51f124SMoriah Waterland /*NOTREACHED*/ 2952*5c51f124SMoriah Waterland } 2953*5c51f124SMoriah Waterland if (chdir(instdir)) { 2954*5c51f124SMoriah Waterland progerr(ERR_CHDIR, instdir); 2955*5c51f124SMoriah Waterland quit(99); 2956*5c51f124SMoriah Waterland /*NOTREACHED*/ 2957*5c51f124SMoriah Waterland } 2958*5c51f124SMoriah Waterland if (!ds_fd_open()) { 2959*5c51f124SMoriah Waterland dparts = ds_findpkg(pkgdev.cdevice, srcinst); 2960*5c51f124SMoriah Waterland if (dparts < 1) { 2961*5c51f124SMoriah Waterland progerr(ERR_DSARCH, srcinst); 2962*5c51f124SMoriah Waterland quit(99); 2963*5c51f124SMoriah Waterland /*NOTREACHED*/ 2964*5c51f124SMoriah Waterland } 2965*5c51f124SMoriah Waterland } 2966*5c51f124SMoriah Waterland 2967*5c51f124SMoriah Waterland dparts--; 2968*5c51f124SMoriah Waterland 2969*5c51f124SMoriah Waterland if (ds_next(pkgdev.cdevice, instdir)) { 2970*5c51f124SMoriah Waterland progerr(ERR_DSTREAM); 2971*5c51f124SMoriah Waterland quit(99); 2972*5c51f124SMoriah Waterland /*NOTREACHED*/ 2973*5c51f124SMoriah Waterland } 2974*5c51f124SMoriah Waterland if (chdir(get_PKGADM())) { 2975*5c51f124SMoriah Waterland progerr(ERR_CHDIR, get_PKGADM()); 2976*5c51f124SMoriah Waterland quit(99); 2977*5c51f124SMoriah Waterland /*NOTREACHED*/ 2978*5c51f124SMoriah Waterland } 2979*5c51f124SMoriah Waterland ds_close(1); 2980*5c51f124SMoriah Waterland } 2981*5c51f124SMoriah Waterland 2982*5c51f124SMoriah Waterland static void 2983*5c51f124SMoriah Waterland usage(void) 2984*5c51f124SMoriah Waterland { 2985*5c51f124SMoriah Waterland (void) fprintf(stderr, ERR_USAGE_PKGINSTALL); 2986*5c51f124SMoriah Waterland exit(1); 2987*5c51f124SMoriah Waterland /*NOTREACHED*/ 2988*5c51f124SMoriah Waterland } 2989