17c478bd9Sstevel@tonic-gate#!/bin/ksh 27c478bd9Sstevel@tonic-gate# 37c478bd9Sstevel@tonic-gate# CDDL HEADER START 47c478bd9Sstevel@tonic-gate# 57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 67c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only 77c478bd9Sstevel@tonic-gate# (the "License"). You may not use this file except in compliance 87c478bd9Sstevel@tonic-gate# with the License. 97c478bd9Sstevel@tonic-gate# 107c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 117c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 127c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 137c478bd9Sstevel@tonic-gate# and limitations under the License. 147c478bd9Sstevel@tonic-gate# 157c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 167c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 177c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 187c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 197c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 207c478bd9Sstevel@tonic-gate# 217c478bd9Sstevel@tonic-gate# CDDL HEADER END 227c478bd9Sstevel@tonic-gate# 237c478bd9Sstevel@tonic-gate# 247c478bd9Sstevel@tonic-gate# Copyright 2005 Sun Microsystems, Inc. All rights reserved. 257c478bd9Sstevel@tonic-gate# Use is subject to license terms. 267c478bd9Sstevel@tonic-gate# 277c478bd9Sstevel@tonic-gate#From: "@(#)Install 1.56 96/10/11 SMI" 287c478bd9Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" 297c478bd9Sstevel@tonic-gate# 307c478bd9Sstevel@tonic-gate# Author: Jeff Bonwick 317c478bd9Sstevel@tonic-gate# 327c478bd9Sstevel@tonic-gate# Please report any bugs to bonwick@eng. 337c478bd9Sstevel@tonic-gate# 347c478bd9Sstevel@tonic-gate# How Install works: 357c478bd9Sstevel@tonic-gate# 367c478bd9Sstevel@tonic-gate# Install performs the following steps: 377c478bd9Sstevel@tonic-gate# 387c478bd9Sstevel@tonic-gate# 1. Figure out how to construct /kernel by looking at Makefile.uts, 397c478bd9Sstevel@tonic-gate# Makefile.$ISA (sparc default), Makefile.$KARCH and the Makefiles 407c478bd9Sstevel@tonic-gate# in the module directories (uts/arch/*/Makefile). 417c478bd9Sstevel@tonic-gate# 427c478bd9Sstevel@tonic-gate# 2. Create the requested subset of /kernel in Install's temp space 437c478bd9Sstevel@tonic-gate# (/tmp/Install.username by default.) 447c478bd9Sstevel@tonic-gate# 457c478bd9Sstevel@tonic-gate# 3. Create a tar file (/tmp/Install.username/Install.tar) based on (3). 467c478bd9Sstevel@tonic-gate# 477c478bd9Sstevel@tonic-gate# 4. If -n was specified, exit. If a target was specified using -T, 487c478bd9Sstevel@tonic-gate# rcp the tarfile to the target and exit. If a target was specified 497c478bd9Sstevel@tonic-gate# using -t, rsh to the target machine and untar the tarfile in the 507c478bd9Sstevel@tonic-gate# target directory. 517c478bd9Sstevel@tonic-gate# 527c478bd9Sstevel@tonic-gate# If any of these steps fail, Install will give you an error message and, 537c478bd9Sstevel@tonic-gate# in most cases, suggest corrective measures. Then, you can recover the 547c478bd9Sstevel@tonic-gate# install with "Install -R". (This is not required; it's just faster than 557c478bd9Sstevel@tonic-gate# starting from scratch.) 567c478bd9Sstevel@tonic-gate# 577c478bd9Sstevel@tonic-gate# One final comment: Unfortunately, tar and I disagree on what 587c478bd9Sstevel@tonic-gate# constitutes a fatal error. (tar -x will exit 0 even if it can't write 597c478bd9Sstevel@tonic-gate# anything in the current directory.) Thus, I am reduced to grepping stderr 607c478bd9Sstevel@tonic-gate# for (what I consider) fatal and nonfatal error messages. If you run into 617c478bd9Sstevel@tonic-gate# a situation where this doesn't behave the way you think it should (either 627c478bd9Sstevel@tonic-gate# an "Install failed" message after a successful install, or an "Install 637c478bd9Sstevel@tonic-gate# complete" message after it bombs), please let me know. 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate# 667c478bd9Sstevel@tonic-gate# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout 677c478bd9Sstevel@tonic-gate# under certain circumstances, which can really screw things up; unset it. 687c478bd9Sstevel@tonic-gate# 697c478bd9Sstevel@tonic-gateunset CDPATH 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gateINSTALL=`basename $0` 727c478bd9Sstevel@tonic-gateDOT=`pwd` 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gateTRAILER="Install.$LOGNAME" 757c478bd9Sstevel@tonic-gateINSTALL_STATE=${INSTALL_STATE-$HOME/.Install.state} 767c478bd9Sstevel@tonic-gateexport INSTALL_STATE 777c478bd9Sstevel@tonic-gateINSTALL_DIR=${INSTALL_DIR-/tmp/$TRAILER} 787c478bd9Sstevel@tonic-gateif [ "`basename $INSTALL_DIR`" != "$TRAILER" ]; then 797c478bd9Sstevel@tonic-gate INSTALL_DIR="$INSTALL_DIR/$TRAILER" 807c478bd9Sstevel@tonic-gatefi 817c478bd9Sstevel@tonic-gateexport INSTALL_DIR 827c478bd9Sstevel@tonic-gateINSTALL_LIB=${INSTALL_LIB-$HOME/LibInstall} 837c478bd9Sstevel@tonic-gateexport INSTALL_LIB 847c478bd9Sstevel@tonic-gateINSTALL_RC=${INSTALL_RC-$HOME/.Installrc} 857c478bd9Sstevel@tonic-gateexport INSTALL_RC 867c478bd9Sstevel@tonic-gateINSTALL_CP=${INSTALL_CP-"cp -p"} 877c478bd9Sstevel@tonic-gateexport INSTALL_CP 887c478bd9Sstevel@tonic-gateINSTALL_RCP=${INSTALL_RCP-"rcp -p"} 897c478bd9Sstevel@tonic-gateexport INSTALL_RCP 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gateSTATE=0 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gateDEFAULT_OPTIONS="-naqX" 947c478bd9Sstevel@tonic-gateGLOM=no 957c478bd9Sstevel@tonic-gateGLOMNAME=kernel 967c478bd9Sstevel@tonic-gateIMPL="default" 977c478bd9Sstevel@tonic-gateWANT32="yes" 987c478bd9Sstevel@tonic-gateWANT64="yes" 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gatetrap 'fail "User Interrupt" "You can resume by typing \"$INSTALL -R\""' 1 2 3 15 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gateusage() { 1037c478bd9Sstevel@tonic-gate echo "" 1047c478bd9Sstevel@tonic-gate echo $1 1057c478bd9Sstevel@tonic-gate echo ' 1067c478bd9Sstevel@tonic-gateUsage: Install [ -w workspace ] 1077c478bd9Sstevel@tonic-gate [ -s srcdir (default: usr/src/uts) ] 1087c478bd9Sstevel@tonic-gate [ -k karch (e.g. sun4u; required if not deducible from pwd) ] 1097c478bd9Sstevel@tonic-gate [ -t target (extract tar file on target, e.g. user@machine:/) ] 1107c478bd9Sstevel@tonic-gate [ -T target (copy tar file to target, e.g. user@machine:/tmp) ] 1117c478bd9Sstevel@tonic-gate [ -n (no target, just create tar file in /tmp (default)) ] 1127c478bd9Sstevel@tonic-gate [ -u (install unix only) ] 1137c478bd9Sstevel@tonic-gate [ -m (install modules only) ] 1147c478bd9Sstevel@tonic-gate [ -a (install everything, i.e. unix + modules (default)) ] 1157c478bd9Sstevel@tonic-gate [ -v (verbose output) ] 1167c478bd9Sstevel@tonic-gate [ -V (REALLY verbose output) ] 1177c478bd9Sstevel@tonic-gate [ -q (quiet (default)) ] 1187c478bd9Sstevel@tonic-gate [ -c (clean up (remove temp files) when done (default) ] 1197c478bd9Sstevel@tonic-gate [ -p (preserve temp files -- useful for debugging) ] 1207c478bd9Sstevel@tonic-gate [ -L (library create: put tarfile in $INSTALL_LIB/env.karch) ] 1217c478bd9Sstevel@tonic-gate [ -l lib (library extract: use $INSTALL_LIB/lib as source) ] 1227c478bd9Sstevel@tonic-gate [ -D libdir (default: $HOME/LibInstall) ] 1237c478bd9Sstevel@tonic-gate [ -d tempdir (Install work area (default: /tmp)) ] 1247c478bd9Sstevel@tonic-gate [ -G glomname (put all files under platform/karch/glomname) ] 1257c478bd9Sstevel@tonic-gate [ -i impl (e.g. sunfire; recommended with -G) ] 1267c478bd9Sstevel@tonic-gate [ -x (update /etc/name_to_major et al) ] 1277c478bd9Sstevel@tonic-gate [ -X (do not update /etc/name_to_major et al (default)) ] 1287c478bd9Sstevel@tonic-gate [ -P (update /etc/path_to_inst -- generally not advisable) ] 1297c478bd9Sstevel@tonic-gate [ -h (help -- prints this message) ] 1307c478bd9Sstevel@tonic-gate [ -R (recover a previous Install) ] 1317c478bd9Sstevel@tonic-gate [ -o objdir (object directory - either obj or debug (the default)) ] 1327c478bd9Sstevel@tonic-gate [ -K (do not copy kmdb) ] 1337c478bd9Sstevel@tonic-gate [ -3 32-bit modules only ] 1347c478bd9Sstevel@tonic-gate [ -6 64-bit modules only ] 1357c478bd9Sstevel@tonic-gate [ list of modules to install ] 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gateFor full details: 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate man -M /ws/on297-gate/public/docs Install 1407c478bd9Sstevel@tonic-gate' 1417c478bd9Sstevel@tonic-gate exit 1 1427c478bd9Sstevel@tonic-gate} 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate# 1457c478bd9Sstevel@tonic-gate# Save the current state of Install 1467c478bd9Sstevel@tonic-gate# 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gatesave_state() { 1497c478bd9Sstevel@tonic-gate rm -f $INSTALL_STATE 1507c478bd9Sstevel@tonic-gate (echo "# State of previous Install 1517c478bd9Sstevel@tonic-gateTARGET=$TARGET 1527c478bd9Sstevel@tonic-gateENV_PATH=$ENV_PATH 1537c478bd9Sstevel@tonic-gateENV_NAME=$ENV_NAME 1547c478bd9Sstevel@tonic-gateKARCH=$KARCH 1557c478bd9Sstevel@tonic-gateUTS=$UTS 1567c478bd9Sstevel@tonic-gateINSTALL_DIR=$INSTALL_DIR 1577c478bd9Sstevel@tonic-gateINSTALL_LIB=$INSTALL_LIB 1587c478bd9Sstevel@tonic-gateIMODE=$IMODE 1597c478bd9Sstevel@tonic-gateLIBCREATE=$LIBCREATE 1607c478bd9Sstevel@tonic-gateLIBSRC=$LIBSRC 1617c478bd9Sstevel@tonic-gateVERBOSE=$VERBOSE 1627c478bd9Sstevel@tonic-gateCLEANUP=$CLEANUP 1637c478bd9Sstevel@tonic-gateGLOM=$GLOM 1647c478bd9Sstevel@tonic-gateGLOMNAME=$GLOMNAME 1657c478bd9Sstevel@tonic-gateKMDB=$KMDB 1667c478bd9Sstevel@tonic-gateXFLAG=$XFLAG 1677c478bd9Sstevel@tonic-gatefiles='$files' 1687c478bd9Sstevel@tonic-gateSTATE=$STATE" >$INSTALL_STATE) || verbose "Warning: cannot save state" 1697c478bd9Sstevel@tonic-gate} 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate# 1727c478bd9Sstevel@tonic-gate# Restore the previous state of Install 1737c478bd9Sstevel@tonic-gate# 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gaterestore_state() { 1767c478bd9Sstevel@tonic-gate test -s $INSTALL_STATE || fail "Can't find $INSTALL_STATE" 1777c478bd9Sstevel@tonic-gate eval "`cat $INSTALL_STATE`" 1787c478bd9Sstevel@tonic-gate} 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate# 1817c478bd9Sstevel@tonic-gate# Install failed -- print error messages and exit 2 1827c478bd9Sstevel@tonic-gate# 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gatefail() { 1857c478bd9Sstevel@tonic-gate save_state 1867c478bd9Sstevel@tonic-gate while [ $# -gt 0 ] 1877c478bd9Sstevel@tonic-gate do 1887c478bd9Sstevel@tonic-gate echo $1 1897c478bd9Sstevel@tonic-gate shift 1907c478bd9Sstevel@tonic-gate done 1917c478bd9Sstevel@tonic-gate echo "Install failed" 1927c478bd9Sstevel@tonic-gate exit 2 1937c478bd9Sstevel@tonic-gate} 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate# 1967c478bd9Sstevel@tonic-gate# Echo a string in verbose mode only 1977c478bd9Sstevel@tonic-gate# 1987c478bd9Sstevel@tonic-gate 1997c478bd9Sstevel@tonic-gateverbose() { 2007c478bd9Sstevel@tonic-gate test "$VERBOSE" != "q" && echo $1 2017c478bd9Sstevel@tonic-gate} 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate# 2047c478bd9Sstevel@tonic-gate# hack for tmpfs bug -- remove files gradually 2057c478bd9Sstevel@tonic-gate# 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gateremove_dir() { 2087c478bd9Sstevel@tonic-gate test -d $1 || return 2097c478bd9Sstevel@tonic-gate local_dot=`pwd` 2107c478bd9Sstevel@tonic-gate cd $1 2117c478bd9Sstevel@tonic-gate touch foo 2127c478bd9Sstevel@tonic-gate rm -f `find . -type f -print` 2137c478bd9Sstevel@tonic-gate cd $local_dot 2147c478bd9Sstevel@tonic-gate rm -rf $1 2157c478bd9Sstevel@tonic-gate} 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate# 2187c478bd9Sstevel@tonic-gate# Copy kernel modules to $INSTALL_DIR 2197c478bd9Sstevel@tonic-gate# 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gatecopy_kernel() { 2227c478bd9Sstevel@tonic-gate # The awk script below looks in Makefile.uts to find out what module 2237c478bd9Sstevel@tonic-gate # subdirectories to make. It then looks in Makefile.$KARCH (for root 2247c478bd9Sstevel@tonic-gate # modules) and Makefile.$ISA (for usr modules) to create a list of 2257c478bd9Sstevel@tonic-gate # all possible modules. Finally, it looks at each module's Makefile 2267c478bd9Sstevel@tonic-gate # to determine where it belongs and what links are required. 2277c478bd9Sstevel@tonic-gate # This script makes three assumptions: 2287c478bd9Sstevel@tonic-gate # 2297c478bd9Sstevel@tonic-gate # 1) Module subdirectories are specified in Makefile.uts by lines of the 2307c478bd9Sstevel@tonic-gate # form: 2317c478bd9Sstevel@tonic-gate # 2327c478bd9Sstevel@tonic-gate # ROOT_FOO_DIR = $(ROOT_MOD_DIR)/foo 2337c478bd9Sstevel@tonic-gate # USR_BAR_DIR = $(USR_MOD_DIR)/bar 2347c478bd9Sstevel@tonic-gate # 2357c478bd9Sstevel@tonic-gate # 2) The corresponding lists of modules appear in Makefile.$KARCH and 2367c478bd9Sstevel@tonic-gate # Makefile.$ISA on one or more lines of the form: 2377c478bd9Sstevel@tonic-gate # 2387c478bd9Sstevel@tonic-gate # FOO_KMODS = foo bar 2397c478bd9Sstevel@tonic-gate # FOO_KMODS += red white blue 2407c478bd9Sstevel@tonic-gate # 2417c478bd9Sstevel@tonic-gate # 3) Each module directory has a Makefile with lines of the form: 2427c478bd9Sstevel@tonic-gate # 2437c478bd9Sstevel@tonic-gate # ROOTMODULE = $(ROOT_FOO_DIR)/$(MODULE) 2447c478bd9Sstevel@tonic-gate # USRMODULE = $(USR_FOO_DIR)/$(MODULE) 2457c478bd9Sstevel@tonic-gate # ROOTLINK* = $(ROOT_BAR_DIR)/something 2467c478bd9Sstevel@tonic-gate # USRLINK* = $(USR_BAR_DIR)/something 2477c478bd9Sstevel@tonic-gate # 2487c478bd9Sstevel@tonic-gate # If the structure of Makefile.{$KARCH,uts,$ISA} changes in a way that 2497c478bd9Sstevel@tonic-gate # invalidates these assumptions, you'll need to pick up a new version of 2507c478bd9Sstevel@tonic-gate # Install. 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate case $KARCH in 2537c478bd9Sstevel@tonic-gate sun4*) ISA=sparc; MACH=sparc; SUBISA_MAKE=;; 2547c478bd9Sstevel@tonic-gate i86pc) ISA=intel; MACH=i386; SUBISA_MAKE=$ISA/ia32/Makefile.ia32;; 2557c478bd9Sstevel@tonic-gate *) fail "${KARCH}: invalid kernel architecture";; 2567c478bd9Sstevel@tonic-gate esac 2577c478bd9Sstevel@tonic-gate 2587c478bd9Sstevel@tonic-gate if [ "$GLOM" = "no" ]; then 2597c478bd9Sstevel@tonic-gate verbose "Source = $UTS, ISA = $ISA, kernel = $KARCH" 2607c478bd9Sstevel@tonic-gate else 2617c478bd9Sstevel@tonic-gate verbose "Source = $UTS, ISA = $ISA, kernel = $KARCH, impl = $IMPL" 2627c478bd9Sstevel@tonic-gate fi 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate UTS_MAKE=Makefile.uts 2657c478bd9Sstevel@tonic-gate ISA_MAKE=$ISA/Makefile.$ISA 2667c478bd9Sstevel@tonic-gate KARCH_MAKE=$KARCH/Makefile.$KARCH 2677c478bd9Sstevel@tonic-gate PSM_MAKE=$UTS/../Makefile.psm 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate test -d $KARCH || fail "${KARCH}: invalid kernel architecture" 2707c478bd9Sstevel@tonic-gate test -d $ISA || fail "${ISA}: invalid instruction set architecture" 2717c478bd9Sstevel@tonic-gate test -s $UTS_MAKE || fail "Can't find $UTS_MAKE" 2727c478bd9Sstevel@tonic-gate test -s $ISA_MAKE || fail "Can't find $ISA_MAKE" 2737c478bd9Sstevel@tonic-gate test -s $KARCH_MAKE || fail "Can't find $KARCH_MAKE" 2747c478bd9Sstevel@tonic-gate test -s $PSM_MAKE || fail "Can't find $PSM_MAKE" 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate # 2777c478bd9Sstevel@tonic-gate # For 5.8 and 5.9 we used to build a few x86 things in an ia32 subdirectory 2787c478bd9Sstevel@tonic-gate # 2797c478bd9Sstevel@tonic-gate [[ -n "$SUBISA_MAKE" && -s "$SUBISA_MAKE" ]] || SUBISA_MAKE=; 2807c478bd9Sstevel@tonic-gate 2817c478bd9Sstevel@tonic-gate if [ $GLOM = "yes" ]; then 2827c478bd9Sstevel@tonic-gate if [ -f $KARCH/$IMPL/Makefile.$IMPL ]; then 2837c478bd9Sstevel@tonic-gate IMPL_MAKE="$KARCH/$IMPL/Makefile.$IMPL" 2847c478bd9Sstevel@tonic-gate fi 2857c478bd9Sstevel@tonic-gate else 2867c478bd9Sstevel@tonic-gate IMPL_MAKE=`nawk -v karch="$KARCH" ' 2877c478bd9Sstevel@tonic-gate $1 == "IMPLEMENTATIONS" { 2887c478bd9Sstevel@tonic-gate for (i = 3; i <= NF; i++) 2897c478bd9Sstevel@tonic-gate if ($i != ".WAIT") 2907c478bd9Sstevel@tonic-gate printf("%s ", karch "/" $i "/Makefile." $i) 2917c478bd9Sstevel@tonic-gate }' $KARCH_MAKE` 2927c478bd9Sstevel@tonic-gate fi 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate DEVFS="./$ISA/devfs/Makefile" 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate verbose "Copying files to ${INSTALL_FILES}..." 2977c478bd9Sstevel@tonic-gate test -d $INSTALL_FILES || mkdir -p $INSTALL_FILES 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate nawk \ 3007c478bd9Sstevel@tonic-gate -v isa="$ISA" \ 3017c478bd9Sstevel@tonic-gate -v mach="$MACH" \ 3027c478bd9Sstevel@tonic-gate -v insd="$INSTALL_FILES" \ 3037c478bd9Sstevel@tonic-gate -v files="$files" \ 3047c478bd9Sstevel@tonic-gate -v verbose=$VERBOSE \ 3057c478bd9Sstevel@tonic-gate -v karch=$KARCH \ 3067c478bd9Sstevel@tonic-gate -v copy="$INSTALL_CP" \ 3077c478bd9Sstevel@tonic-gate -v devfs=$DEVFS \ 3087c478bd9Sstevel@tonic-gate -v auxfiles=$XFLAG \ 3097c478bd9Sstevel@tonic-gate -v ptiflag=$PFLAG \ 3107c478bd9Sstevel@tonic-gate -v glom=$GLOM \ 3117c478bd9Sstevel@tonic-gate -v glomname=$GLOMNAME \ 3127c478bd9Sstevel@tonic-gate -v impl=$IMPL \ 3137c478bd9Sstevel@tonic-gate -v objd=$OBJD \ 3147c478bd9Sstevel@tonic-gate -v want32=$WANT32 \ 3157c478bd9Sstevel@tonic-gate -v want64=$WANT64 \ 3167c478bd9Sstevel@tonic-gate ' 3177c478bd9Sstevel@tonic-gate function run(s) { 3187c478bd9Sstevel@tonic-gate if (verbose != "q") 3197c478bd9Sstevel@tonic-gate print s 3207c478bd9Sstevel@tonic-gate if (system(s)) 3217c478bd9Sstevel@tonic-gate exit 1 3227c478bd9Sstevel@tonic-gate } 3237c478bd9Sstevel@tonic-gate function cpf(f1,f2) { 3247c478bd9Sstevel@tonic-gate if (verbose != "q") 3257c478bd9Sstevel@tonic-gate print copy " " f1 " " f2 3267c478bd9Sstevel@tonic-gate if (system(copy " " f1 " " f2)) 3277c478bd9Sstevel@tonic-gate print "WARNING: copy of " f1 " failed" 3287c478bd9Sstevel@tonic-gate } 3297c478bd9Sstevel@tonic-gate function mkdir(dir) { 3307c478bd9Sstevel@tonic-gate if (!touched[dir]) { 3317c478bd9Sstevel@tonic-gate run("test -d " dir " || mkdir -p " dir) 3327c478bd9Sstevel@tonic-gate touched[dir]=1 3337c478bd9Sstevel@tonic-gate } 3347c478bd9Sstevel@tonic-gate return dir 3357c478bd9Sstevel@tonic-gate } 3367c478bd9Sstevel@tonic-gate function vprint(s) { 3377c478bd9Sstevel@tonic-gate if (verbose == "V") 3387c478bd9Sstevel@tonic-gate print s 3397c478bd9Sstevel@tonic-gate } 3407c478bd9Sstevel@tonic-gate function try_run(s) { 3417c478bd9Sstevel@tonic-gate if (verbose != "q") 3427c478bd9Sstevel@tonic-gate print s 3437c478bd9Sstevel@tonic-gate if (system(s)) 3447c478bd9Sstevel@tonic-gate return 1 3457c478bd9Sstevel@tonic-gate return 0 3467c478bd9Sstevel@tonic-gate } 3477c478bd9Sstevel@tonic-gate function exist(s) { 3487c478bd9Sstevel@tonic-gate if (verbose != "q") 3497c478bd9Sstevel@tonic-gate print "test -f " s 3507c478bd9Sstevel@tonic-gate return !system("test -f " s) 3517c478bd9Sstevel@tonic-gate } 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate function copymod(src, targ, om) { 3547c478bd9Sstevel@tonic-gate if (om) { 3557c478bd9Sstevel@tonic-gate run("if [ -f " src " ] ; then " \ 3567c478bd9Sstevel@tonic-gate copy " " src " " targ " ; fi") 3577c478bd9Sstevel@tonic-gate } else { 3587c478bd9Sstevel@tonic-gate run(copy " " src " " targ) 3597c478bd9Sstevel@tonic-gate } 3607c478bd9Sstevel@tonic-gate } 3617c478bd9Sstevel@tonic-gate 3627c478bd9Sstevel@tonic-gate function copymod32(idx, modtarg) { 3637c478bd9Sstevel@tonic-gate modsrc = modsrcd[idx] "/" objd32 "/" modname[idx] 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate if (!exist(modsrc)) 3667c478bd9Sstevel@tonic-gate return (0) 3677c478bd9Sstevel@tonic-gate 3687c478bd9Sstevel@tonic-gate copymod(modsrc, modtarg, optmod[idx]) 3697c478bd9Sstevel@tonic-gate return (1) 3707c478bd9Sstevel@tonic-gate } 3717c478bd9Sstevel@tonic-gate 3727c478bd9Sstevel@tonic-gate function copymod64(idx, modtarg) { 3737c478bd9Sstevel@tonic-gate modsrc = modsrcd[idx] "/" objd64 "/" modname[idx] 3747c478bd9Sstevel@tonic-gate 3757c478bd9Sstevel@tonic-gate if (!exist(modsrc)) 3767c478bd9Sstevel@tonic-gate return (0) 3777c478bd9Sstevel@tonic-gate 3787c478bd9Sstevel@tonic-gate copymod(modsrc, modtarg subdir64, optmod[idx]) 3797c478bd9Sstevel@tonic-gate return (1) 3807c478bd9Sstevel@tonic-gate } 3817c478bd9Sstevel@tonic-gate 3827c478bd9Sstevel@tonic-gate function linkmod(lmod, idx, modtarg, did32, did64) { 3837c478bd9Sstevel@tonic-gate if (lmod ~ /^...MODULE.$/) 3847c478bd9Sstevel@tonic-gate lmod = "/" modname[idx] 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate if (did32 == "yes") { 3877c478bd9Sstevel@tonic-gate m = modtarg "/" modname[i] 3887c478bd9Sstevel@tonic-gate run("rm -f " dir lmod "; ln " m " " dir lmod) 3897c478bd9Sstevel@tonic-gate } 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate if (did64 == "yes") { 3927c478bd9Sstevel@tonic-gate m = modtarg subdir64 "/" modname[i] 3937c478bd9Sstevel@tonic-gate run("rm -f " dir subdir64 lmod "; ln " m " " \ 3947c478bd9Sstevel@tonic-gate dir subdir64 lmod) 3957c478bd9Sstevel@tonic-gate } 3967c478bd9Sstevel@tonic-gate } 3977c478bd9Sstevel@tonic-gate 3987c478bd9Sstevel@tonic-gate function slinkmod(slinktarg, idx, modtarg, did32, did64) { 3997c478bd9Sstevel@tonic-gate if (did32 == "yes") { 4007c478bd9Sstevel@tonic-gate slink = modtarg "/" slinktarg 4017c478bd9Sstevel@tonic-gate run("rm -f " slink "; ln -s " modname[i] " " slink) 4027c478bd9Sstevel@tonic-gate } 4037c478bd9Sstevel@tonic-gate 4047c478bd9Sstevel@tonic-gate if (did64 == "yes") { 4057c478bd9Sstevel@tonic-gate slink = modtarg subdir64 "/" slinktarg 4067c478bd9Sstevel@tonic-gate run("rm -f " slink "; ln -s " modname[i] " " slink) 4077c478bd9Sstevel@tonic-gate } 4087c478bd9Sstevel@tonic-gate } 4097c478bd9Sstevel@tonic-gate 4107c478bd9Sstevel@tonic-gate BEGIN { 4117c478bd9Sstevel@tonic-gate # If you do NOT want the SVVS modules, set svvs to 0. 4127c478bd9Sstevel@tonic-gate svvs=1 4137c478bd9Sstevel@tonic-gate # If you do NOT want the excluded modules, set xmods to 0. 4147c478bd9Sstevel@tonic-gate xmods=1 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate machkernel = "/platform/" karch "/" glomname 4177c478bd9Sstevel@tonic-gate 4187c478bd9Sstevel@tonic-gate nmods=0 4197c478bd9Sstevel@tonic-gate do32="no" 4207c478bd9Sstevel@tonic-gate do64="no" 4217c478bd9Sstevel@tonic-gate objd32=objd "32" 4227c478bd9Sstevel@tonic-gate objd64=objd "64" 4237c478bd9Sstevel@tonic-gate build64and32="no" 4247c478bd9Sstevel@tonic-gate } 4257c478bd9Sstevel@tonic-gate 4267c478bd9Sstevel@tonic-gate $1 == "SUBDIR64_" mach { 4277c478bd9Sstevel@tonic-gate vprint($0) 4287c478bd9Sstevel@tonic-gate subdir64="/" $3 4297c478bd9Sstevel@tonic-gate subdir64_relative=$3 4307c478bd9Sstevel@tonic-gate } 4317c478bd9Sstevel@tonic-gate 4327c478bd9Sstevel@tonic-gate FILENAME == "Makefile.uts" && $1 == "ALL_BUILDS64" { 4337c478bd9Sstevel@tonic-gate vprint($0) 4347c478bd9Sstevel@tonic-gate if ($0 ~ /32/) 4357c478bd9Sstevel@tonic-gate build64and32="yes" 4367c478bd9Sstevel@tonic-gate } 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate FILENAME == karch "/Makefile." karch && $1 == "ALL_BUILDS" { 4397c478bd9Sstevel@tonic-gate vprint($0) 4407c478bd9Sstevel@tonic-gate if ($3 ~ /32/) 4417c478bd9Sstevel@tonic-gate do32=want32 4427c478bd9Sstevel@tonic-gate if ($4 ~ /32/) 4437c478bd9Sstevel@tonic-gate build64and32="yes" 4447c478bd9Sstevel@tonic-gate if ($3 ~ /ALL_BUILDS64/ && build64and32 == "yes") 4457c478bd9Sstevel@tonic-gate do32=want32 4467c478bd9Sstevel@tonic-gate if ($3 ~ /64/ && want64) 4477c478bd9Sstevel@tonic-gate do64=want64 4487c478bd9Sstevel@tonic-gate } 4497c478bd9Sstevel@tonic-gate 4507c478bd9Sstevel@tonic-gate $1 ~ /^(ROOT|USR)_.+_DIR(_32)?$/ { 4517c478bd9Sstevel@tonic-gate vprint($0) 4527c478bd9Sstevel@tonic-gate if ($3 ~ /_..CLASS..$/) 4537c478bd9Sstevel@tonic-gate next 4547c478bd9Sstevel@tonic-gate slash=index($3,"/") 4557c478bd9Sstevel@tonic-gate sub(/_32$/,"",$1) 4567c478bd9Sstevel@tonic-gate if (!slash) 4577c478bd9Sstevel@tonic-gate slash=length($3)+1 4587c478bd9Sstevel@tonic-gate parent=substr($3,3,slash-4) 4597c478bd9Sstevel@tonic-gate subdir=substr($3,slash) 4607c478bd9Sstevel@tonic-gate if (parent == "ROOT") 4617c478bd9Sstevel@tonic-gate child=subdir 4627c478bd9Sstevel@tonic-gate else if (moddirs[parent]) { 4637c478bd9Sstevel@tonic-gate if ($3 ~ /..PLATFORM.$/) 4647c478bd9Sstevel@tonic-gate child=moddirs[parent] "/" karch 4657c478bd9Sstevel@tonic-gate else 4667c478bd9Sstevel@tonic-gate child=moddirs[parent] subdir 4677c478bd9Sstevel@tonic-gate } else { 4687c478bd9Sstevel@tonic-gate print "missing mod dir " parent 4697c478bd9Sstevel@tonic-gate exit 1 4707c478bd9Sstevel@tonic-gate } 4717c478bd9Sstevel@tonic-gate moddirs[$1]=child 4727c478bd9Sstevel@tonic-gate sub(/^.*kernel/,machkernel,child) 4737c478bd9Sstevel@tonic-gate glomdirs[$1]=child 4747c478bd9Sstevel@tonic-gate n=split($1,foo,"_") 4757c478bd9Sstevel@tonic-gate if (n == 4 && foo[2] != "PSM") 4767c478bd9Sstevel@tonic-gate notdef[$1]=tolower(foo[2]) 4777c478bd9Sstevel@tonic-gate } 4787c478bd9Sstevel@tonic-gate 4797c478bd9Sstevel@tonic-gate FILENAME != isa "/Makefile." isa && $1 ~ /^(GENLIB|UNIX)_DIR$/ { 4807c478bd9Sstevel@tonic-gate vprint($0) 4817c478bd9Sstevel@tonic-gate n=split($3,foo,"/") 4827c478bd9Sstevel@tonic-gate slash=index($3,"/") 4837c478bd9Sstevel@tonic-gate dir="." substr($3,slash) 4847c478bd9Sstevel@tonic-gate sub(/..PLATFORM./,karch,dir) 4857c478bd9Sstevel@tonic-gate nmods++ 4867c478bd9Sstevel@tonic-gate modsrcd[nmods]=dir 4877c478bd9Sstevel@tonic-gate modname[nmods]=foo[n] 4887c478bd9Sstevel@tonic-gate unixmod[nmods]=1 4897c478bd9Sstevel@tonic-gate } 4907c478bd9Sstevel@tonic-gate 4917c478bd9Sstevel@tonic-gate FILENAME != "Makefile.uts" && $1 ~ /KMODS|XMODS/ && 4927c478bd9Sstevel@tonic-gate $1 != "GENUNIX_KMODS" { 4937c478bd9Sstevel@tonic-gate dir = FILENAME; 4947c478bd9Sstevel@tonic-gate sub(/\/Makefile.*$/, "", dir); 4957c478bd9Sstevel@tonic-gate if ($1 ~ "^SVVS_") 4967c478bd9Sstevel@tonic-gate if (svvs == 0) 4977c478bd9Sstevel@tonic-gate next 4987c478bd9Sstevel@tonic-gate else 4997c478bd9Sstevel@tonic-gate dir = dir "/svvs" 5007c478bd9Sstevel@tonic-gate if ($1 ~ "XMODS" && xmods == 0) 5017c478bd9Sstevel@tonic-gate next 5027c478bd9Sstevel@tonic-gate if ($0 !~ /\$/) { 5037c478bd9Sstevel@tonic-gate vprint($0) 5047c478bd9Sstevel@tonic-gate for (i = 3; i <= NF; i++) { 5057c478bd9Sstevel@tonic-gate if ($i ~ /^(ramdisk|wsdrv|vdi)$/) 5067c478bd9Sstevel@tonic-gate continue; 5077c478bd9Sstevel@tonic-gate nmods++ 5087c478bd9Sstevel@tonic-gate modname[nmods]=$i 5097c478bd9Sstevel@tonic-gate modsrcd[nmods]="./" dir "/" $i 5107c478bd9Sstevel@tonic-gate if ($1 ~ "^MPSAS_") 5117c478bd9Sstevel@tonic-gate optmod[nmods] = 1 5127c478bd9Sstevel@tonic-gate } 5137c478bd9Sstevel@tonic-gate } 5147c478bd9Sstevel@tonic-gate } 5157c478bd9Sstevel@tonic-gate 5167c478bd9Sstevel@tonic-gate FILENAME == karch "/Makefile." karch && $1 == "PLATFORMS" && 5177c478bd9Sstevel@tonic-gate $3 !~ /\(/ { 5187c478bd9Sstevel@tonic-gate for (i = 3; i <= NF; i++) 5197c478bd9Sstevel@tonic-gate mkdir(insd "/platform/" $i) 5207c478bd9Sstevel@tonic-gate } 5217c478bd9Sstevel@tonic-gate 5227c478bd9Sstevel@tonic-gate FILENAME == karch "/Makefile." karch && ($1 == "IMPLEMENTED_PLATFORM" || 5237c478bd9Sstevel@tonic-gate $1 == "LINKED_PLATFORMS") { 5247c478bd9Sstevel@tonic-gate for (i = 3; i <= NF; i++) 5257c478bd9Sstevel@tonic-gate mkdir(insd "/platform/" $i) 5267c478bd9Sstevel@tonic-gate } 5277c478bd9Sstevel@tonic-gate 5287c478bd9Sstevel@tonic-gate FILENAME != "Makefile.uts" && $1 == "CONFS" { 5297c478bd9Sstevel@tonic-gate for (i = 3; i <= NF; i++) { 5307c478bd9Sstevel@tonic-gate kbi_brain_damage[$i] = "yes" 5317c478bd9Sstevel@tonic-gate } 5327c478bd9Sstevel@tonic-gate } 5337c478bd9Sstevel@tonic-gate 5347c478bd9Sstevel@tonic-gate END { 5357c478bd9Sstevel@tonic-gate split(files, modlist) 5367c478bd9Sstevel@tonic-gate for (m in modlist) { 5377c478bd9Sstevel@tonic-gate mm = modlist[m] 5387c478bd9Sstevel@tonic-gate if (mm == "modules") { 5397c478bd9Sstevel@tonic-gate for (i = 1; i <= nmods; i++) 5407c478bd9Sstevel@tonic-gate if (unixmod[i] == 0) 5417c478bd9Sstevel@tonic-gate modcopy[i]=1 5427c478bd9Sstevel@tonic-gate continue 5437c478bd9Sstevel@tonic-gate } 5447c478bd9Sstevel@tonic-gate nomodfound = 1 5457c478bd9Sstevel@tonic-gate for (i = 1; i <= nmods; i++) { 5467c478bd9Sstevel@tonic-gate if (modname[i] == mm) { 5477c478bd9Sstevel@tonic-gate modcopy[i]=1 5487c478bd9Sstevel@tonic-gate nomodfound = 0 5497c478bd9Sstevel@tonic-gate } 5507c478bd9Sstevel@tonic-gate } 5517c478bd9Sstevel@tonic-gate if (nomodfound) { 5527c478bd9Sstevel@tonic-gate print mm ": invalid module" 5537c478bd9Sstevel@tonic-gate exit 1 5547c478bd9Sstevel@tonic-gate } 5557c478bd9Sstevel@tonic-gate } 5567c478bd9Sstevel@tonic-gate 5577c478bd9Sstevel@tonic-gate for(i = 1; i <= nmods; i++) { 5587c478bd9Sstevel@tonic-gate if (!modcopy[i]) 5597c478bd9Sstevel@tonic-gate continue 5607c478bd9Sstevel@tonic-gate 5617c478bd9Sstevel@tonic-gate confsrc = "" 5627c478bd9Sstevel@tonic-gate drvfiles[1] = "" 5637c478bd9Sstevel@tonic-gate classfile = "" 5647c478bd9Sstevel@tonic-gate ptifile = "" 5657c478bd9Sstevel@tonic-gate did32=do32 5667c478bd9Sstevel@tonic-gate did64=do64 5677c478bd9Sstevel@tonic-gate no_builds="false" 5687c478bd9Sstevel@tonic-gate modmake=modsrcd[i] "/Makefile" 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gate while (getline <modmake > 0) { 5717c478bd9Sstevel@tonic-gate if ($1 == "NO_BUILDS") { 5727c478bd9Sstevel@tonic-gate vprint($0) 5737c478bd9Sstevel@tonic-gate no_builds="true" 5747c478bd9Sstevel@tonic-gate } 5757c478bd9Sstevel@tonic-gate 5767c478bd9Sstevel@tonic-gate if ($1 == "ALL_BUILDS" && $3 ~ /64/) { 5777c478bd9Sstevel@tonic-gate vprint($0) 5787c478bd9Sstevel@tonic-gate did32="ok" 5797c478bd9Sstevel@tonic-gate } 5807c478bd9Sstevel@tonic-gate 5817c478bd9Sstevel@tonic-gate if ($1 == "ALL_BUILDS" && $3 ~ /32/) { 5827c478bd9Sstevel@tonic-gate vprint($0) 5837c478bd9Sstevel@tonic-gate did64="ok" 5847c478bd9Sstevel@tonic-gate } 5857c478bd9Sstevel@tonic-gate 5867c478bd9Sstevel@tonic-gate if ($1 ~ /^(MODULE|UNIX)$/) { 5877c478bd9Sstevel@tonic-gate vprint($0) 5887c478bd9Sstevel@tonic-gate modname[i] = $3 5897c478bd9Sstevel@tonic-gate } 5907c478bd9Sstevel@tonic-gate 5917c478bd9Sstevel@tonic-gate if ($1 ~ /^(ROOT|USR)(LINK|MODULE$)/) { 5927c478bd9Sstevel@tonic-gate vprint($0) 5937c478bd9Sstevel@tonic-gate slash=index($3,"/") 5947c478bd9Sstevel@tonic-gate parent=substr($3,3,slash-4) 5957c478bd9Sstevel@tonic-gate 5967c478bd9Sstevel@tonic-gate if (notdef[parent] && 5977c478bd9Sstevel@tonic-gate notdef[parent] != impl && 5987c478bd9Sstevel@tonic-gate glom == "yes") { 5997c478bd9Sstevel@tonic-gate confsrc = "" 6007c478bd9Sstevel@tonic-gate break 6017c478bd9Sstevel@tonic-gate } 6027c478bd9Sstevel@tonic-gate 6037c478bd9Sstevel@tonic-gate dir = (glom == "no") ? \ 6047c478bd9Sstevel@tonic-gate moddirs[parent] : glomdirs[parent] 6057c478bd9Sstevel@tonic-gate if (!dir) { 6067c478bd9Sstevel@tonic-gate print "no parent for " modname[i] 6077c478bd9Sstevel@tonic-gate exit 1 6087c478bd9Sstevel@tonic-gate } 6097c478bd9Sstevel@tonic-gate 6107c478bd9Sstevel@tonic-gate dir=insd dir 6117c478bd9Sstevel@tonic-gate mkdir(dir) 6127c478bd9Sstevel@tonic-gate 6137c478bd9Sstevel@tonic-gate if (do64 == "yes") 6147c478bd9Sstevel@tonic-gate mkdir(dir subdir64) 6157c478bd9Sstevel@tonic-gate 6167c478bd9Sstevel@tonic-gate if ($1 ~ /^(ROOT|USR)MODULE$/) { 6177c478bd9Sstevel@tonic-gate modtarg=dir 6187c478bd9Sstevel@tonic-gate conftarg=dir 6197c478bd9Sstevel@tonic-gate if (modname[i] in \ 6207c478bd9Sstevel@tonic-gate kbi_brain_damage) { 6217c478bd9Sstevel@tonic-gate confsrc = "./" karch \ 6227c478bd9Sstevel@tonic-gate "/io" 6237c478bd9Sstevel@tonic-gate conftarg = insd \ 6247c478bd9Sstevel@tonic-gate machkernel "/drv" 6257c478bd9Sstevel@tonic-gate 6267c478bd9Sstevel@tonic-gate mkdir(conftarg) 6277c478bd9Sstevel@tonic-gate 6287c478bd9Sstevel@tonic-gate if (do64 == "yes") { 6297c478bd9Sstevel@tonic-gate mkdir(conftarg \ 6307c478bd9Sstevel@tonic-gate subdir64) 6317c478bd9Sstevel@tonic-gate } 6327c478bd9Sstevel@tonic-gate } 6337c478bd9Sstevel@tonic-gate 6347c478bd9Sstevel@tonic-gate if (do32 == "yes" && 6357c478bd9Sstevel@tonic-gate !copymod32(i, modtarg)) 6367c478bd9Sstevel@tonic-gate did32="no" 6377c478bd9Sstevel@tonic-gate 6387c478bd9Sstevel@tonic-gate if (do64 == "yes" && 6397c478bd9Sstevel@tonic-gate !copymod64(i, modtarg)) 6407c478bd9Sstevel@tonic-gate did64="no" 6417c478bd9Sstevel@tonic-gate 6427c478bd9Sstevel@tonic-gate } else { 6437c478bd9Sstevel@tonic-gate linkmod(substr($3, slash), 6447c478bd9Sstevel@tonic-gate i, modtarg, did32, did64) 6457c478bd9Sstevel@tonic-gate } 6467c478bd9Sstevel@tonic-gate } 6477c478bd9Sstevel@tonic-gate 6487c478bd9Sstevel@tonic-gate if ($1 == "SOFTLINKS") { 6497c478bd9Sstevel@tonic-gate vprint($0) 6507c478bd9Sstevel@tonic-gate for (j = 3; j <= NF; j++) { 6517c478bd9Sstevel@tonic-gate slinkmod($j, i, modtarg, did32, 6527c478bd9Sstevel@tonic-gate did64) 6537c478bd9Sstevel@tonic-gate } 6547c478bd9Sstevel@tonic-gate } 6557c478bd9Sstevel@tonic-gate 6567c478bd9Sstevel@tonic-gate if ($1 == "CONF_SRCDIR") { 6577c478bd9Sstevel@tonic-gate vprint($0) 6587c478bd9Sstevel@tonic-gate slash = index($3, "/") 6597c478bd9Sstevel@tonic-gate confsrc = "." substr($3, slash) 6607c478bd9Sstevel@tonic-gate } 6617c478bd9Sstevel@tonic-gate } 6627c478bd9Sstevel@tonic-gate 6637c478bd9Sstevel@tonic-gate if (do32 == "yes" && did32 == "no" && 6647c478bd9Sstevel@tonic-gate no_builds == "false") { 6657c478bd9Sstevel@tonic-gate print "missing 32b file " confsrc "/" modname[i] 6667c478bd9Sstevel@tonic-gate exit 1 6677c478bd9Sstevel@tonic-gate } 6687c478bd9Sstevel@tonic-gate 6697c478bd9Sstevel@tonic-gate if (do64 == "yes" && did64 == "no" && 6707c478bd9Sstevel@tonic-gate no_builds == "false") { 6717c478bd9Sstevel@tonic-gate print "missing 64b file " confsrc "/" modname[i] 6727c478bd9Sstevel@tonic-gate exit 1 6737c478bd9Sstevel@tonic-gate } 6747c478bd9Sstevel@tonic-gate 6757c478bd9Sstevel@tonic-gate if (confsrc != "") { 6767c478bd9Sstevel@tonic-gate conffile = confsrc "/" modname[i] ".conf" 6777c478bd9Sstevel@tonic-gate cpf(conffile, conftarg) 6787c478bd9Sstevel@tonic-gate } 6797c478bd9Sstevel@tonic-gate 6807c478bd9Sstevel@tonic-gate close(modmake) 6817c478bd9Sstevel@tonic-gate } 6827c478bd9Sstevel@tonic-gate 6837c478bd9Sstevel@tonic-gate # 6847c478bd9Sstevel@tonic-gate # Make symlinks for KBI for different root node names for a 6857c478bd9Sstevel@tonic-gate # given platform 6867c478bd9Sstevel@tonic-gate # 6877c478bd9Sstevel@tonic-gate km = "./" karch "/Makefile" 6887c478bd9Sstevel@tonic-gate while (getline <km > 0) { 6897c478bd9Sstevel@tonic-gate if ($1 == "PLAT_LINKS") { 6907c478bd9Sstevel@tonic-gate for (i = 3; i <= NF; i++) { 6917c478bd9Sstevel@tonic-gate mkdir(insd "/platform") 6927c478bd9Sstevel@tonic-gate run("ln -s " karch " " insd \ 6937c478bd9Sstevel@tonic-gate "/platform/" $i) 6947c478bd9Sstevel@tonic-gate } 6957c478bd9Sstevel@tonic-gate } 6967c478bd9Sstevel@tonic-gate } 6977c478bd9Sstevel@tonic-gate close(km) 6987c478bd9Sstevel@tonic-gate 6997c478bd9Sstevel@tonic-gate if (did64 == "yes" && build64and32 == "no" && 7007c478bd9Sstevel@tonic-gate (try_run("test -f " insd "/platform/" karch "/" \ 7017c478bd9Sstevel@tonic-gate glomname "/" subdir64_relative "/unix") == 0)) 7027c478bd9Sstevel@tonic-gate { 7037c478bd9Sstevel@tonic-gate run("ln -s " subdir64_relative "/unix " insd \ 7047c478bd9Sstevel@tonic-gate "/platform/" karch "/" glomname "/unix") 7057c478bd9Sstevel@tonic-gate 7067c478bd9Sstevel@tonic-gate if (isa == "sparc" && glom == "no" && 7077c478bd9Sstevel@tonic-gate (try_run("test -f " insd \ 7087c478bd9Sstevel@tonic-gate "/platform/SUNW,Ultra-Enterprise-10000/" glomname \ 7097c478bd9Sstevel@tonic-gate "/" subdir64_relative "/unix") == 0)) { 7107c478bd9Sstevel@tonic-gate run("ln -s " subdir64_relative "/unix " insd \ 7117c478bd9Sstevel@tonic-gate "/platform/SUNW,Ultra-Enterprise-10000/" \ 7127c478bd9Sstevel@tonic-gate glomname "/unix") 7137c478bd9Sstevel@tonic-gate } 7147c478bd9Sstevel@tonic-gate } 7157c478bd9Sstevel@tonic-gate 7167c478bd9Sstevel@tonic-gate while (getline <devfs > 0) { 7177c478bd9Sstevel@tonic-gate if ($1 == "SRCDIR") 7187c478bd9Sstevel@tonic-gate configdir = "." substr($3, index($3, "/")) "/" 7197c478bd9Sstevel@tonic-gate if ($1 == "CLASSFILE") 7207c478bd9Sstevel@tonic-gate classfile = $3 7217c478bd9Sstevel@tonic-gate if ($1 == "PTIFILE") 7227c478bd9Sstevel@tonic-gate ptifile = $3 7237c478bd9Sstevel@tonic-gate if ($1 == "DRVFILES") 7247c478bd9Sstevel@tonic-gate split(substr($0, index($0, $3)), drvfiles) 7257c478bd9Sstevel@tonic-gate } 7267c478bd9Sstevel@tonic-gate close(devfs) 7277c478bd9Sstevel@tonic-gate 7287c478bd9Sstevel@tonic-gate if (classfile != "" && auxfiles == 1) { 7297c478bd9Sstevel@tonic-gate dir = mkdir(targ["ROOT_DRV"]) 7307c478bd9Sstevel@tonic-gate cpf(configdir classfile, dir) 7317c478bd9Sstevel@tonic-gate } 7327c478bd9Sstevel@tonic-gate 7337c478bd9Sstevel@tonic-gate if (ptifile != "" && ptiflag == 1) { 7347c478bd9Sstevel@tonic-gate dir = mkdir(insd "/etc") 7357c478bd9Sstevel@tonic-gate cpf(configdir ptifile, dir) 7367c478bd9Sstevel@tonic-gate } 7377c478bd9Sstevel@tonic-gate 7387c478bd9Sstevel@tonic-gate if (drvfiles[1] != "" && auxfiles == 1) { 7397c478bd9Sstevel@tonic-gate dir = mkdir(insd "/etc") 7407c478bd9Sstevel@tonic-gate for (file in drvfiles) 7417c478bd9Sstevel@tonic-gate cpf(configdir drvfiles[file], dir) 7427c478bd9Sstevel@tonic-gate } 7437c478bd9Sstevel@tonic-gate }' $UTS_MAKE $PSM_MAKE $ISA_MAKE $SUBISA_MAKE $KARCH_MAKE $IMPL_MAKE 7447c478bd9Sstevel@tonic-gate [[ $? -ne 0 ]] && fail "Files missing in environment" 7457c478bd9Sstevel@tonic-gate 7467c478bd9Sstevel@tonic-gate # 7477c478bd9Sstevel@tonic-gate # on x86, add the glommed kernel name to the root archive 7487c478bd9Sstevel@tonic-gate # 7497c478bd9Sstevel@tonic-gate if [[ $KARCH = "i86pc" && $GLOM == "yes" ]]; then 7507c478bd9Sstevel@tonic-gate filelist="$INSTALL_FILES/etc/boot/solaris/filelist.ramdisk" 7517c478bd9Sstevel@tonic-gate mkdir -p `dirname $filelist` 7527c478bd9Sstevel@tonic-gate echo "platform/$KARCH/$GLOMNAME" >$filelist 7537c478bd9Sstevel@tonic-gate fi 7547c478bd9Sstevel@tonic-gate 7557c478bd9Sstevel@tonic-gate STATE=1 # all kernel modules copied correctly 7567c478bd9Sstevel@tonic-gate save_state 7577c478bd9Sstevel@tonic-gate} 7587c478bd9Sstevel@tonic-gate 7597c478bd9Sstevel@tonic-gatekmdb_copy() { 7607c478bd9Sstevel@tonic-gate typeset src="$1" 7617c478bd9Sstevel@tonic-gate typeset destdir="$2" 7627c478bd9Sstevel@tonic-gate 7637c478bd9Sstevel@tonic-gate if [[ ! -d $dest ]] ; then 7647c478bd9Sstevel@tonic-gate [[ $VERBOSE != "q" ]] && echo "mkdir -p $destdir" 7657c478bd9Sstevel@tonic-gate 7667c478bd9Sstevel@tonic-gate mkdir -p $destdir || fail "failed to create $destdir" 7677c478bd9Sstevel@tonic-gate fi 7687c478bd9Sstevel@tonic-gate 7697c478bd9Sstevel@tonic-gate [[ $VERBOSE != "q" ]] && echo "cp $src $destdir" 7707c478bd9Sstevel@tonic-gate 7717c478bd9Sstevel@tonic-gate cp $src $destdir || fail "failed to copy $src to $destdir" 7727c478bd9Sstevel@tonic-gate} 7737c478bd9Sstevel@tonic-gate 7747c478bd9Sstevel@tonic-gatekmdb_copy_machkmods() { 7757c478bd9Sstevel@tonic-gate typeset modbase="$1" 7767c478bd9Sstevel@tonic-gate typeset destdir="$2" 7777c478bd9Sstevel@tonic-gate typeset dir= 7787c478bd9Sstevel@tonic-gate typeset kmod= 7797c478bd9Sstevel@tonic-gate 7807c478bd9Sstevel@tonic-gate [[ ! -d $modbase ]] && return 7817c478bd9Sstevel@tonic-gate 7827c478bd9Sstevel@tonic-gate for dir in $(find $modbase -name kmod) ; do 7837c478bd9Sstevel@tonic-gate set -- $(echo $dir |tr '/' ' ') 7847c478bd9Sstevel@tonic-gate 7857c478bd9Sstevel@tonic-gate [[ $# -lt 2 ]] && fail "invalid mach kmod dir $dir" 7867c478bd9Sstevel@tonic-gate 7877c478bd9Sstevel@tonic-gate shift $(($# - 2)) 7887c478bd9Sstevel@tonic-gate kmod=$1 7897c478bd9Sstevel@tonic-gate 7907c478bd9Sstevel@tonic-gate [[ ! -f $dir/$kmod ]] && continue 7917c478bd9Sstevel@tonic-gate 7927c478bd9Sstevel@tonic-gate kmdb_copy $dir/$kmod $destdir 7937c478bd9Sstevel@tonic-gate done 7947c478bd9Sstevel@tonic-gate} 7957c478bd9Sstevel@tonic-gate 7967c478bd9Sstevel@tonic-gatekmdb_copy_karchkmods() { 7977c478bd9Sstevel@tonic-gate typeset modbase="$1" 7987c478bd9Sstevel@tonic-gate typeset destdir="$2" 7997c478bd9Sstevel@tonic-gate typeset bitdir="$3" 8007c478bd9Sstevel@tonic-gate typeset dir= 8017c478bd9Sstevel@tonic-gate typeset kmod= 8027c478bd9Sstevel@tonic-gate typeset karch= 8037c478bd9Sstevel@tonic-gate 8047c478bd9Sstevel@tonic-gate [[ ! -d $modbase ]] && return 8057c478bd9Sstevel@tonic-gate 8067c478bd9Sstevel@tonic-gate for dir in $(find $modbase -name kmod) ; do 8077c478bd9Sstevel@tonic-gate set -- $(echo $dir | tr '/' ' ') 8087c478bd9Sstevel@tonic-gate 8097c478bd9Sstevel@tonic-gate [[ $# -lt 3 ]] && fail "invalid karch kmod dir $dir" 8107c478bd9Sstevel@tonic-gate 8117c478bd9Sstevel@tonic-gate shift $(($# - 3)) 8127c478bd9Sstevel@tonic-gate kmod=$1 8137c478bd9Sstevel@tonic-gate bdir=$2 8147c478bd9Sstevel@tonic-gate 8157c478bd9Sstevel@tonic-gate [[ $bdir != $bitdir ]] && continue 8167c478bd9Sstevel@tonic-gate [[ ! -f $dir/$1 ]] && continue 8177c478bd9Sstevel@tonic-gate 8187c478bd9Sstevel@tonic-gate kmdb_copy $dir/$kmod $destdir 8197c478bd9Sstevel@tonic-gate done 8207c478bd9Sstevel@tonic-gate} 8217c478bd9Sstevel@tonic-gate 8227c478bd9Sstevel@tonic-gatekmdb_copy_kmdbmod() { 8237c478bd9Sstevel@tonic-gate typeset kmdbpath="$1" 8247c478bd9Sstevel@tonic-gate typeset destdir="$2" 8257c478bd9Sstevel@tonic-gate 8267c478bd9Sstevel@tonic-gate [[ ! -f $kmdbpath ]] && return 1 8277c478bd9Sstevel@tonic-gate 8287c478bd9Sstevel@tonic-gate kmdb_copy $kmdbpath $destdir 8297c478bd9Sstevel@tonic-gate 8307c478bd9Sstevel@tonic-gate return 0 8317c478bd9Sstevel@tonic-gate} 8327c478bd9Sstevel@tonic-gate 8337c478bd9Sstevel@tonic-gatecopy_kmdb() { 8347c478bd9Sstevel@tonic-gate typeset kmdbtgtdir=$INSTALL_FILES/platform/$KARCH/$GLOMNAME/misc 8357c478bd9Sstevel@tonic-gate typeset bitdirs= 8367c478bd9Sstevel@tonic-gate typeset isadir= 8377c478bd9Sstevel@tonic-gate typeset b64srcdir= 8387c478bd9Sstevel@tonic-gate typeset b64tgtdir= 8397c478bd9Sstevel@tonic-gate typeset b32srcdir= 8407c478bd9Sstevel@tonic-gate typeset b32tgtdir= 8417c478bd9Sstevel@tonic-gate typeset machdir= 8427c478bd9Sstevel@tonic-gate typeset platdir= 8437c478bd9Sstevel@tonic-gate 8447c478bd9Sstevel@tonic-gate if [[ $KMDB = "no" || ! -d $SRC/cmd/mdb ]] ; then 8457c478bd9Sstevel@tonic-gate # The kmdb copy was suppressed or the workspace doesn't contain 8467c478bd9Sstevel@tonic-gate # the mdb subtree. Either way, there's nothing to do. 8477c478bd9Sstevel@tonic-gate STATE=2 8487c478bd9Sstevel@tonic-gate save_state 8497c478bd9Sstevel@tonic-gate return 8507c478bd9Sstevel@tonic-gate fi 8517c478bd9Sstevel@tonic-gate 8527c478bd9Sstevel@tonic-gate if [[ $(mach) = "i386" ]] ; then 8537c478bd9Sstevel@tonic-gate isadir="intel" 8547c478bd9Sstevel@tonic-gate b64srcdir="amd64" 8557c478bd9Sstevel@tonic-gate b64tgtdir="amd64" 8567c478bd9Sstevel@tonic-gate b32srcdir="ia32" 8577c478bd9Sstevel@tonic-gate b32tgtdir="." 8587c478bd9Sstevel@tonic-gate else 8597c478bd9Sstevel@tonic-gate isadir="sparc" 8607c478bd9Sstevel@tonic-gate b64srcdir="v9" 8617c478bd9Sstevel@tonic-gate b64tgtdir="sparcv9" 8627c478bd9Sstevel@tonic-gate b32srcdir="v7" 8637c478bd9Sstevel@tonic-gate b32tgtdir="." 8647c478bd9Sstevel@tonic-gate fi 8657c478bd9Sstevel@tonic-gate 8667c478bd9Sstevel@tonic-gate typeset foundkmdb=no 8677c478bd9Sstevel@tonic-gate typeset kmdbpath= 868*a9857382Sae112802 typeset destdir= 8697c478bd9Sstevel@tonic-gate 8707c478bd9Sstevel@tonic-gate platdir=$INSTALL_FILES/platform/$KARCH/$GLOMNAME 8717c478bd9Sstevel@tonic-gate if [[ $GLOM = "yes" ]] ; then 8727c478bd9Sstevel@tonic-gate machdir=$platdir 8737c478bd9Sstevel@tonic-gate else 8747c478bd9Sstevel@tonic-gate machdir=$INSTALL_FILES/kernel 8757c478bd9Sstevel@tonic-gate fi 8767c478bd9Sstevel@tonic-gate 8777c478bd9Sstevel@tonic-gate if [[ $WANT64 = "yes" ]] ; then 878*a9857382Sae112802 # kmdbmod for sparc and x86 are built and installed 879*a9857382Sae112802 # in different places 880*a9857382Sae112802 if [[ $(mach) = "i386" ]] ; then 881*a9857382Sae112802 kmdbpath=$SRC/cmd/mdb/$isadir/$b64srcdir/kmdb/kmdbmod 882*a9857382Sae112802 destdir=$machdir/misc/$b64tgtdir 883*a9857382Sae112802 else 884*a9857382Sae112802 kmdbpath=$SRC/cmd/mdb/$KARCH/$b64srcdir/kmdb/kmdbmod 885*a9857382Sae112802 destdir=$platdir/misc/$b64tgtdir 886*a9857382Sae112802 fi 887*a9857382Sae112802 888*a9857382Sae112802 if kmdb_copy_kmdbmod $kmdbpath $destdir ; then 8897c478bd9Sstevel@tonic-gate foundkmdb="yes" 8907c478bd9Sstevel@tonic-gate 8917c478bd9Sstevel@tonic-gate kmdb_copy_machkmods $SRC/cmd/mdb/$isadir/$b64srcdir \ 8927c478bd9Sstevel@tonic-gate $machdir/kmdb/$b64tgtdir 8937c478bd9Sstevel@tonic-gate kmdb_copy_karchkmods $SRC/cmd/mdb/$KARCH \ 8947c478bd9Sstevel@tonic-gate $platdir/kmdb/$b64tgtdir $b64srcdir 8957c478bd9Sstevel@tonic-gate fi 8967c478bd9Sstevel@tonic-gate fi 8977c478bd9Sstevel@tonic-gate 8987c478bd9Sstevel@tonic-gate if [[ $WANT32 = "yes" ]] ; then 899*a9857382Sae112802 kmdbpath=$SRC/cmd/mdb/$isadir/$b32srcdir/kmdb/kmdbmod 900*a9857382Sae112802 destdir=$machdir/misc/$b32tgtdir 901*a9857382Sae112802 902*a9857382Sae112802 if kmdb_copy_kmdbmod $kmdbpath $destdir ; then 9037c478bd9Sstevel@tonic-gate foundkmdb="yes" 9047c478bd9Sstevel@tonic-gate 9057c478bd9Sstevel@tonic-gate kmdb_copy_machkmods $SRC/cmd/mdb/$isadir/$b32srcdir \ 9067c478bd9Sstevel@tonic-gate $machdir/kmdb/$b32tgtdir 9077c478bd9Sstevel@tonic-gate kmdb_copy_karchkmods $SRC/cmd/mdb/$KARCH \ 9087c478bd9Sstevel@tonic-gate $platdir/kmdb/$b32tgtdir $b32srcdir 9097c478bd9Sstevel@tonic-gate fi 9107c478bd9Sstevel@tonic-gate fi 9117c478bd9Sstevel@tonic-gate 9127c478bd9Sstevel@tonic-gate # A kmdb-less workspace isn't fatal, but it is potentially problematic, 9137c478bd9Sstevel@tonic-gate # as the changes made to uts may have altered something upon which kmdb 9147c478bd9Sstevel@tonic-gate # depends. We will therefore remind the user that they haven't built it 9157c478bd9Sstevel@tonic-gate # yet. 9167c478bd9Sstevel@tonic-gate if [[ $foundkmdb != "yes" ]] ; then 9177c478bd9Sstevel@tonic-gate echo "WARNING: kmdb isn't built, and won't be included" 9187c478bd9Sstevel@tonic-gate fi 9197c478bd9Sstevel@tonic-gate 9207c478bd9Sstevel@tonic-gate STATE=2 9217c478bd9Sstevel@tonic-gate save_state 9227c478bd9Sstevel@tonic-gate return 9237c478bd9Sstevel@tonic-gate} 9247c478bd9Sstevel@tonic-gate 9257c478bd9Sstevel@tonic-gate# 9267c478bd9Sstevel@tonic-gate# Make tarfile 9277c478bd9Sstevel@tonic-gate# 9287c478bd9Sstevel@tonic-gate 9297c478bd9Sstevel@tonic-gatemake_tarfile() { 9307c478bd9Sstevel@tonic-gate echo "Creating tarfile $TARFILE" 9317c478bd9Sstevel@tonic-gate test -d $INSTALL_FILES || fail "Can't find $INSTALL_FILES" 9327c478bd9Sstevel@tonic-gate cd $INSTALL_FILES 9337c478bd9Sstevel@tonic-gate rm -f $TARFILE files 9347c478bd9Sstevel@tonic-gate 9357c478bd9Sstevel@tonic-gate # We don't want to change the permissions or ownership of pre-existing 9367c478bd9Sstevel@tonic-gate # directories on the target machine, so we're going to take care to 9377c478bd9Sstevel@tonic-gate # avoid including directories in the tarfile. On extraction, tar won't 9387c478bd9Sstevel@tonic-gate # modify pre-existing directories, and will create non-existent ones as 9397c478bd9Sstevel@tonic-gate # the user doing the extraction. 9407c478bd9Sstevel@tonic-gate find . ! -type d -print |fgrep -vx './files' >files 9417c478bd9Sstevel@tonic-gate tar cf $TARFILE -I files || fail "Couldn't create tarfile $TARFILE" 9427c478bd9Sstevel@tonic-gate STATE=3 9437c478bd9Sstevel@tonic-gate} 9447c478bd9Sstevel@tonic-gate 9457c478bd9Sstevel@tonic-gate# 9467c478bd9Sstevel@tonic-gate# Routines to copy files to the target machine 9477c478bd9Sstevel@tonic-gate# 9487c478bd9Sstevel@tonic-gate 9497c478bd9Sstevel@tonic-gateremote_fail() { 9507c478bd9Sstevel@tonic-gate fail "" "$1" "" \ 9517c478bd9Sstevel@tonic-gate "Make sure that $TARGET_MACHINE is up." \ 9527c478bd9Sstevel@tonic-gate"Check .rhosts in the home directory of user $TARGET_USER on $TARGET_MACHINE." \ 9537c478bd9Sstevel@tonic-gate "Check /etc/hosts.equiv, /etc/passwd, and /etc/shadow." \ 9547c478bd9Sstevel@tonic-gate "Change permissions on $TARGET_MACHINE as necessary." \ 9557c478bd9Sstevel@tonic-gate "Then, use \"$INSTALL -R\" to resume the install." "" 9567c478bd9Sstevel@tonic-gate} 9577c478bd9Sstevel@tonic-gate 9587c478bd9Sstevel@tonic-gateremote_install() { 9597c478bd9Sstevel@tonic-gate if [ "$IMODE" = "n" ]; then 9607c478bd9Sstevel@tonic-gate STATE=4 9617c478bd9Sstevel@tonic-gate return 0 9627c478bd9Sstevel@tonic-gate fi 9637c478bd9Sstevel@tonic-gate test -s $TARFILE || fail "$TARFILE missing or empty" 9647c478bd9Sstevel@tonic-gate verbose "Installing system on $TARGET" 9657c478bd9Sstevel@tonic-gate test -d $INSTALL_DIR || fail "Can't find $INSTALL_DIR" 9667c478bd9Sstevel@tonic-gate cd $INSTALL_DIR 9677c478bd9Sstevel@tonic-gate rm -f errors fatal nonfatal 9687c478bd9Sstevel@tonic-gate if [ "$IMODE" = "T" ]; then 9697c478bd9Sstevel@tonic-gate EMESG="Can't rcp to $TARGET" 9707c478bd9Sstevel@tonic-gate touch errors 9717c478bd9Sstevel@tonic-gate sh -e${SHV}c "$INSTALL_RCP $TARFILE $TARGET/Install.tar" 9727c478bd9Sstevel@tonic-gate else 9737c478bd9Sstevel@tonic-gate EMESG="Can't rsh to $TARGET_MACHINE" 9747c478bd9Sstevel@tonic-gate rsh -l $TARGET_USER $TARGET_MACHINE \ 9757c478bd9Sstevel@tonic-gate "(cd $TARGET_DIR; /usr/bin/tar x${V}f -)" \ 9767c478bd9Sstevel@tonic-gate <$TARFILE 2>errors 9777c478bd9Sstevel@tonic-gate fi 9787c478bd9Sstevel@tonic-gate test $? -ne 0 && remote_fail "$EMESG" 9797c478bd9Sstevel@tonic-gate cd $INSTALL_DIR 9807c478bd9Sstevel@tonic-gate egrep "set time|warning|blocksize" errors >nonfatal 9817c478bd9Sstevel@tonic-gate egrep -v "set time|warning|blocksize" errors >fatal 9827c478bd9Sstevel@tonic-gate if [ -s fatal ]; then 9837c478bd9Sstevel@tonic-gate echo "Fatal errors from rsh:" 9847c478bd9Sstevel@tonic-gate cat fatal 9857c478bd9Sstevel@tonic-gate remote_fail "Can't install on $TARGET_MACHINE" 9867c478bd9Sstevel@tonic-gate fi 9877c478bd9Sstevel@tonic-gate if [ -s nonfatal -a "$VERBOSE" != "q" ]; then 9887c478bd9Sstevel@tonic-gate echo "Non-fatal errors from rsh:" 9897c478bd9Sstevel@tonic-gate cat nonfatal 9907c478bd9Sstevel@tonic-gate fi 9917c478bd9Sstevel@tonic-gate rm -f fatal nonfatal errors 9927c478bd9Sstevel@tonic-gate test "$IMODE" = "T" && echo "Files can be extracted on \ 9937c478bd9Sstevel@tonic-gate$TARGET_MACHINE using 'tar xvf $TARGET_DIR/Install.tar'" 9947c478bd9Sstevel@tonic-gate STATE=4 9957c478bd9Sstevel@tonic-gate} 9967c478bd9Sstevel@tonic-gate 9977c478bd9Sstevel@tonic-gateokexit() { 9987c478bd9Sstevel@tonic-gate cd /tmp 9997c478bd9Sstevel@tonic-gate test "$CLEANUP" = c && remove_dir $INSTALL_DIR 10007c478bd9Sstevel@tonic-gate save_state 10017c478bd9Sstevel@tonic-gate verbose "Install complete" 10027c478bd9Sstevel@tonic-gate exit 0 10037c478bd9Sstevel@tonic-gate} 10047c478bd9Sstevel@tonic-gate 10057c478bd9Sstevel@tonic-gate# 10067c478bd9Sstevel@tonic-gate# Process options 10077c478bd9Sstevel@tonic-gate# 10087c478bd9Sstevel@tonic-gate 10097c478bd9Sstevel@tonic-gateRCOPTS="" 10107c478bd9Sstevel@tonic-gateLIBCREATE="no" 10117c478bd9Sstevel@tonic-gateLIBSRC="" 10127c478bd9Sstevel@tonic-gatePFLAG=0 10137c478bd9Sstevel@tonic-gateENV_PATH=$CODEMGR_WS 10147c478bd9Sstevel@tonic-gateOBJD="debug" 10157c478bd9Sstevel@tonic-gateKMDB="yes" 10167c478bd9Sstevel@tonic-gate 10177c478bd9Sstevel@tonic-gatetest -s $INSTALL_RC && RCOPTS=`cat $INSTALL_RC` 10187c478bd9Sstevel@tonic-gateset $INSTALL $DEFAULT_OPTIONS $RCOPTS $* 10197c478bd9Sstevel@tonic-gateshift 10207c478bd9Sstevel@tonic-gate 10217c478bd9Sstevel@tonic-gatewhile getopts acd:D:G:hi:k:Kl:Lmno:pPqRs:t:T:uvVw:xX36 opt 10227c478bd9Sstevel@tonic-gatedo 10237c478bd9Sstevel@tonic-gate case $opt in 10247c478bd9Sstevel@tonic-gate w) ENV_PATH="$OPTARG"; SRC="$ENV_PATH/usr/src";; 10257c478bd9Sstevel@tonic-gate s) UTS="$OPTARG";; 10267c478bd9Sstevel@tonic-gate k) KARCH="$OPTARG";; 10277c478bd9Sstevel@tonic-gate t|T) TARGET="$OPTARG"; IMODE=$opt; CLEANUP="c";; 10287c478bd9Sstevel@tonic-gate n) TARGET=""; IMODE="n"; CLEANUP="p";; 10297c478bd9Sstevel@tonic-gate u) files="unix genunix";; 10307c478bd9Sstevel@tonic-gate m) files="modules";; 10317c478bd9Sstevel@tonic-gate a) files="unix genunix modules";; 10327c478bd9Sstevel@tonic-gate v|V|q) VERBOSE=$opt;; 10337c478bd9Sstevel@tonic-gate c|p) CLEANUP=$opt;; 10347c478bd9Sstevel@tonic-gate L) LIBCREATE="yes"; CLEANUP="c";; 10357c478bd9Sstevel@tonic-gate l) LIBSRC="$OPTARG";; 10367c478bd9Sstevel@tonic-gate D) INSTALL_LIB="$OPTARG";; 10377c478bd9Sstevel@tonic-gate d) INSTALL_DIR="$OPTARG/$TRAILER";; 10387c478bd9Sstevel@tonic-gate G) GLOM=yes; GLOMNAME="$OPTARG";; 10397c478bd9Sstevel@tonic-gate x) XFLAG=1;; 10407c478bd9Sstevel@tonic-gate X) XFLAG=0;; 10417c478bd9Sstevel@tonic-gate P) PFLAG=1;; 10427c478bd9Sstevel@tonic-gate h) usage "${INSTALL}: installs unix and modules";; 10437c478bd9Sstevel@tonic-gate R) x=$OPTIND; restore_state; OPTIND=$x;; 10447c478bd9Sstevel@tonic-gate i) IMPL="$OPTARG";; 10457c478bd9Sstevel@tonic-gate o) OBJD="$OPTARG";; 10467c478bd9Sstevel@tonic-gate K) KMDB="no";; 10477c478bd9Sstevel@tonic-gate 3) WANT64="no";; 10487c478bd9Sstevel@tonic-gate 6) WANT32="no";; 10497c478bd9Sstevel@tonic-gate \?) usage "Illegal option";; 10507c478bd9Sstevel@tonic-gate esac 10517c478bd9Sstevel@tonic-gatedone 10527c478bd9Sstevel@tonic-gateshift `expr $OPTIND - 1` 10537c478bd9Sstevel@tonic-gate 10547c478bd9Sstevel@tonic-gateENV_NAME=`basename $ENV_PATH` 10557c478bd9Sstevel@tonic-gate 10567c478bd9Sstevel@tonic-gate# 10577c478bd9Sstevel@tonic-gate# The rest of the command line is a list of individual files to copy. 10587c478bd9Sstevel@tonic-gate# If non-null, this list overrides the -uma options. 10597c478bd9Sstevel@tonic-gate# 10607c478bd9Sstevel@tonic-gate 10617c478bd9Sstevel@tonic-gateif [[ $# -gt 0 ]] ; then 10627c478bd9Sstevel@tonic-gate files="$*" 10637c478bd9Sstevel@tonic-gate KMDB="no" 10647c478bd9Sstevel@tonic-gatefi 10657c478bd9Sstevel@tonic-gate 10667c478bd9Sstevel@tonic-gatecase $VERBOSE in 10677c478bd9Sstevel@tonic-gate v) V="v"; SHV="x";; 10687c478bd9Sstevel@tonic-gate V) V="v"; SHV="x"; set -x;; 10697c478bd9Sstevel@tonic-gate q) V=""; SHV="";; 10707c478bd9Sstevel@tonic-gateesac 10717c478bd9Sstevel@tonic-gate 10727c478bd9Sstevel@tonic-gate# 10737c478bd9Sstevel@tonic-gate# Create temp directory for Install's files 10747c478bd9Sstevel@tonic-gate# 10757c478bd9Sstevel@tonic-gate 10767c478bd9Sstevel@tonic-gatetest -d $INSTALL_DIR || mkdir -p $INSTALL_DIR || fail "Can't mkdir $INSTALL_DIR" 10777c478bd9Sstevel@tonic-gate 10787c478bd9Sstevel@tonic-gateTARFILE=$INSTALL_DIR/Install.${KARCH}.tar 10797c478bd9Sstevel@tonic-gateINSTALL_FILES=$INSTALL_DIR/$KARCH 10807c478bd9Sstevel@tonic-gate 10817c478bd9Sstevel@tonic-gate# 10827c478bd9Sstevel@tonic-gate# Extract the target machine and target directory from a target of the 10837c478bd9Sstevel@tonic-gate# form [user@]machine:/dir . 10847c478bd9Sstevel@tonic-gate# 10857c478bd9Sstevel@tonic-gate 10867c478bd9Sstevel@tonic-gateif [ "$IMODE" != "n" ]; then 10877c478bd9Sstevel@tonic-gate eval `echo $TARGET | nawk -F':' '{ 10887c478bd9Sstevel@tonic-gate if (NF != 2 || !length($1) || !length($2)) 10897c478bd9Sstevel@tonic-gate print "usage \"Invalid target\"" 10907c478bd9Sstevel@tonic-gate m = $1; d = $2 10917c478bd9Sstevel@tonic-gate if ($1 ~ /@/) { 10927c478bd9Sstevel@tonic-gate k = split($1, f, "@"); 10937c478bd9Sstevel@tonic-gate if (k != 2 || !length(f[1]) || !length (f[2])) 10947c478bd9Sstevel@tonic-gate print "usage \"Invalid target\"" 10957c478bd9Sstevel@tonic-gate u = f[1]; m = f[2] 10967c478bd9Sstevel@tonic-gate } 10977c478bd9Sstevel@tonic-gate print "TARGET_USER=" u ";" 10987c478bd9Sstevel@tonic-gate print "TARGET_MACHINE=" m ";" 10997c478bd9Sstevel@tonic-gate print "TARGET_DIR=" d ";" 11007c478bd9Sstevel@tonic-gate }'` 11017c478bd9Sstevel@tonic-gate if [ -z "$TARGET_USER" ]; then 11027c478bd9Sstevel@tonic-gate TARGET_USER=$LOGNAME 11037c478bd9Sstevel@tonic-gate fi 11047c478bd9Sstevel@tonic-gatefi 11057c478bd9Sstevel@tonic-gate 11067c478bd9Sstevel@tonic-gate# 11077c478bd9Sstevel@tonic-gate# Allow the use of library source or target for the install 11087c478bd9Sstevel@tonic-gate# 11097c478bd9Sstevel@tonic-gate 11107c478bd9Sstevel@tonic-gateif [ -n "$LIBSRC" ]; then 11117c478bd9Sstevel@tonic-gate LIBSRC="`basename $LIBSRC .tar`.tar" 11127c478bd9Sstevel@tonic-gate TARFILE=$INSTALL_LIB/$LIBSRC 11137c478bd9Sstevel@tonic-gate test -s $TARFILE || fail "Can't find tarfile $TARFILE" 11147c478bd9Sstevel@tonic-gate verbose "Installing from library tarfile $TARFILE" 11157c478bd9Sstevel@tonic-gate STATE=3 11167c478bd9Sstevel@tonic-gateelif [ "$LIBCREATE" = "yes" ]; then 11177c478bd9Sstevel@tonic-gate test -d $INSTALL_LIB \ 11187c478bd9Sstevel@tonic-gate || mkdir -p $INSTALL_LIB \ 11197c478bd9Sstevel@tonic-gate || fail "Can't mkdir $INSTALL_LIB" 11207c478bd9Sstevel@tonic-gate TARFILE="$INSTALL_LIB/${ENV_NAME}.${KARCH}.tar" 11217c478bd9Sstevel@tonic-gatefi 11227c478bd9Sstevel@tonic-gate 11237c478bd9Sstevel@tonic-gate# 11247c478bd9Sstevel@tonic-gate# The next three lines allow recovery and activation with -R, 11257c478bd9Sstevel@tonic-gate# and library installs with -l. 11267c478bd9Sstevel@tonic-gate# 11277c478bd9Sstevel@tonic-gate 11287c478bd9Sstevel@tonic-gate[[ $STATE -eq 1 ]] && copy_kmdb 11297c478bd9Sstevel@tonic-gate[[ $STATE -eq 2 ]] && make_tarfile 11307c478bd9Sstevel@tonic-gate[[ $STATE -eq 3 ]] && remote_install 11317c478bd9Sstevel@tonic-gate[[ $STATE -eq 4 ]] && okexit 11327c478bd9Sstevel@tonic-gate 11337c478bd9Sstevel@tonic-gatesave_state 11347c478bd9Sstevel@tonic-gate 11357c478bd9Sstevel@tonic-gatecd $DOT 11367c478bd9Sstevel@tonic-gateDOTDOT=`cd ..; pwd` 11377c478bd9Sstevel@tonic-gate 11387c478bd9Sstevel@tonic-gate# 11397c478bd9Sstevel@tonic-gate# Try to be smart: if DOTDOT ends in uts, then infer UTS and KARCH from DOT 11407c478bd9Sstevel@tonic-gate# Otherwise, if SRC is set, infer UTS = $SRC/uts. 11417c478bd9Sstevel@tonic-gate# 11427c478bd9Sstevel@tonic-gate 11437c478bd9Sstevel@tonic-gateif [ "`basename $DOTDOT`" = "uts" ]; then 11447c478bd9Sstevel@tonic-gate UTS=$DOTDOT 11457c478bd9Sstevel@tonic-gate KARCH=`basename $DOT` 11467c478bd9Sstevel@tonic-gatefi 11477c478bd9Sstevel@tonic-gate 11487c478bd9Sstevel@tonic-gateif [ -z "$UTS" -a -n "$SRC" ]; then 11497c478bd9Sstevel@tonic-gate UTS="${SRC}/uts" 11507c478bd9Sstevel@tonic-gate test -n "$KARCH" || fail "no karch specified (e.g. -k sun4u)" 11517c478bd9Sstevel@tonic-gatefi 11527c478bd9Sstevel@tonic-gate 11537c478bd9Sstevel@tonic-gateif [ "$LIBCREATE" = "yes" ]; then 11547c478bd9Sstevel@tonic-gate TARFILE=$INSTALL_LIB/${ENV_NAME}.${KARCH}.tar 11557c478bd9Sstevel@tonic-gateelse 11567c478bd9Sstevel@tonic-gate TARFILE=$INSTALL_DIR/Install.${KARCH}.tar 11577c478bd9Sstevel@tonic-gatefi 11587c478bd9Sstevel@tonic-gateINSTALL_FILES=$INSTALL_DIR/$KARCH 11597c478bd9Sstevel@tonic-gatesave_state 11607c478bd9Sstevel@tonic-gate 11617c478bd9Sstevel@tonic-gatecd $DOT 11627c478bd9Sstevel@tonic-gatetest -z "$UTS" && fail 'Cannot find kernel sources -- $SRC not set' 11637c478bd9Sstevel@tonic-gatetest -d "$UTS" || fail "${UTS}: no such directory" 11647c478bd9Sstevel@tonic-gate 11657c478bd9Sstevel@tonic-gate# 11667c478bd9Sstevel@tonic-gate# Convert UTS into an absolute path. 11677c478bd9Sstevel@tonic-gate# 11687c478bd9Sstevel@tonic-gate 11697c478bd9Sstevel@tonic-gatecd $UTS 11707c478bd9Sstevel@tonic-gateUTS=`pwd` 11717c478bd9Sstevel@tonic-gate 11727c478bd9Sstevel@tonic-gatetest "`basename $UTS`" = "uts" || \ 11737c478bd9Sstevel@tonic-gate verbose "Warning: source path $UTS doesn't end in 'uts'" 11747c478bd9Sstevel@tonic-gate 11757c478bd9Sstevel@tonic-gateremove_dir $INSTALL_DIR/$KARCH 11767c478bd9Sstevel@tonic-gaterm -f $TARFILE 11777c478bd9Sstevel@tonic-gate 11787c478bd9Sstevel@tonic-gatecopy_kernel # sets STATE=1 if successful 11797c478bd9Sstevel@tonic-gatecopy_kmdb # sets STATE=2 if successful 11807c478bd9Sstevel@tonic-gatemake_tarfile # sets STATE=3 if successful 11817c478bd9Sstevel@tonic-gateremote_install # sets STATE=4 if successful 11827c478bd9Sstevel@tonic-gate 11837c478bd9Sstevel@tonic-gateokexit 1184