diff options
| author | Mike Kupfer <Mike.Kupfer@Oracle.COM> | 2010-08-07 15:19:49 -0700 | 
|---|---|---|
| committer | Mike Kupfer <Mike.Kupfer@Oracle.COM> | 2010-08-07 15:19:49 -0700 | 
| commit | 84d8c05b8aec0c78c7207612a6378181d130900c (patch) | |
| tree | 3c0ff351493754696a1b843930a0719aa457feff /usr/src | |
| parent | b7de80ed83be7d7a6c226533d3dfa88b4e2d85c1 (diff) | |
| download | illumos-joyent-84d8c05b8aec0c78c7207612a6378181d130900c.tar.gz | |
6952783 Install: makefile rules aren't robust with respect to dirname
Diffstat (limited to 'usr/src')
| -rw-r--r-- | usr/src/tools/scripts/Install.sh | 105 | ||||
| -rw-r--r-- | usr/src/uts/Makefile.targ | 44 | 
2 files changed, 92 insertions, 57 deletions
| diff --git a/usr/src/tools/scripts/Install.sh b/usr/src/tools/scripts/Install.sh index bef11e3a7f..0632846b8b 100644 --- a/usr/src/tools/scripts/Install.sh +++ b/usr/src/tools/scripts/Install.sh @@ -20,8 +20,7 @@  # CDDL HEADER END  #  # -# Copyright 2010 Sun Microsystems, Inc.  All rights reserved. -# Use is subject to license terms. +# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.  #  # Author:  Jeff Bonwick  # @@ -240,24 +239,24 @@ function fixglom {  	    -v glomname=$2 \  	    -v karch=$KARCH '   	$1 == "MOD" || $1 == "SYMLINK" { -		sub(/^platform.*kernel/, "platform/" karch "/" glomname, $3) -		sub(/^kernel/, "platform/" karch "/" glomname, $3) -		sub(/^usr.kernel/, "platform/" karch "/" glomname, $3) -		print -	} -	$1 == "LINK" { -		sub(/^platform.*kernel/, "platform/" karch "/" glomname, $2) -		sub(/^kernel/, "platform/" karch "/" glomname, $2) -		sub(/^usr.kernel/, "platform/" karch "/" glomname, $2)  		sub(/^platform.*kernel/, "platform/" karch "/" glomname, $4)  		sub(/^kernel/, "platform/" karch "/" glomname, $4)  		sub(/^usr.kernel/, "platform/" karch "/" glomname, $4)  		print  	} +	$1 == "LINK" { +		sub(/^platform.*kernel/, "platform/" karch "/" glomname, $3) +		sub(/^kernel/, "platform/" karch "/" glomname, $3) +		sub(/^usr.kernel/, "platform/" karch "/" glomname, $3) +		sub(/^platform.*kernel/, "platform/" karch "/" glomname, $5) +		sub(/^kernel/, "platform/" karch "/" glomname, $5) +		sub(/^usr.kernel/, "platform/" karch "/" glomname, $5) +		print +	}  	$1 == "CONF" { -		sub(/^platform.*kernel/, "platform/" karch "/" glomname, $2) -		sub(/^kernel/, "platform/" karch "/" glomname, $2) -		sub(/^usr.kernel/, "platform/" karch "/" glomname, $2) +		sub(/^platform.*kernel/, "platform/" karch "/" glomname, $3) +		sub(/^kernel/, "platform/" karch "/" glomname, $3) +		sub(/^usr.kernel/, "platform/" karch "/" glomname, $3)  		print  	}  	' $1 > $1.new @@ -265,7 +264,8 @@ function fixglom {  }  # -# Remove entries from  +# Filter out implementation-specific modules, unless that +# implementation was requested by the user.  # usage: filtimpl listfile implname  # @@ -273,15 +273,15 @@ function filtimpl {  	nawk \  	    -v impl=$2 '  	$1 == "MOD" || $1 == "SYMLINK" { -		if ($5 == "all" || $5 == impl) +		if ($6 == "all" || $6 == impl)  			print  	}  	$1 == "CONF" { -		if ($4 == "all" || $4 == impl) +		if ($5 == "all" || $5 == impl)  			print  	}  	$1 == "LINK" { -		if ($6 == "all" || $6 == impl) +		if ($7 == "all" || $7 == impl)  			print  	}  	' $1 > $1.new @@ -316,19 +316,19 @@ function filtmod {  			reqmods[tmpmods[i]] = 1  	}  	$1 == "MOD" { -		if (modmatch($2)) +		if (modmatch($3))  			print  	}  	$1 == "CONF" { -		if (modmatch($5)) +		if (modmatch($6))  			print  	}  	$1 == "SYMLINK" { -		if (modmatch($6)) +		if (modmatch($7))  			print  	}  	$1 == "LINK" { -		if (modmatch($3)) +		if (modmatch($4))  			print  	}  	' $1 > $1.new @@ -386,7 +386,7 @@ function fixcrypto {  	[ "$OBJD" = obj ] && root=root_$MACH-nd  	grep -v ^MOD $listfile > $listfile.no-mod -	grep ^MOD $listfile | while read tag module targdir size impl srcdir; do +	grep ^MOD $listfile | while read tag srcdir module targdir size impl; do  		#  		# We don't just grep for ${OBJD}$size/$module because  		# there can be generic and platform-dependent versions @@ -410,42 +410,40 @@ function fixcrypto {  #  # Copy a module, or create a link, as needed. -# See $SRC/uts/Makefile.targ ($(MODLIST_DEPS) target) for the format -# of the different input lines.  #  function copymod {  	case $1 in  	MOD) -		targdir=$INSTALL_FILES/$3 +		targdir=$INSTALL_FILES/$4  		tstmkdir $targdir -		target=$targdir/$2 -		verbose "$INSTALL_CP $6/${OBJD}$4/$2 $target" -		$INSTALL_CP $6/${OBJD}$4/$2 $target || \ +		target=$targdir/$3 +		verbose "$INSTALL_CP $2/${OBJD}$5/$3 $target" +		$INSTALL_CP $2/${OBJD}$5/$3 $target || \  		    fail "can't create $target"  		;;  	SYMLINK) -		targdir=$INSTALL_FILES/$3 +		targdir=$INSTALL_FILES/$4  		tstmkdir $targdir -		target=$targdir/$4 +		target=$targdir/$5  		rm -f $target -		verbose "ln -s $2 $target" -		ln -s $2 $target || fail "can't create $target" +		verbose "ln -s $3 $target" +		ln -s $3 $target || fail "can't create $target"  		;;  	LINK) -		targdir=$INSTALL_FILES/$4 +		targdir=$INSTALL_FILES/$5  		tstmkdir $targdir -		target=$targdir/$5 +		target=$targdir/$6  		rm -f $target -		verbose "ln $INSTALL_FILES/$2/$3 $target" -		ln $INSTALL_FILES/$2/$3 $target || fail "can't create $target" +		verbose "ln $INSTALL_FILES/$3/$4 $target" +		ln $INSTALL_FILES/$3/$4 $target || fail "can't create $target"  		;;  	CONF) -		target=$INSTALL_FILES/$2 +		target=$INSTALL_FILES/$3  		tstmkdir `dirname $target` -		conffile=`basename $2` -		verbose "$INSTALL_CP $3/$conffile $target" -		$INSTALL_CP $3/$conffile $target +		conffile=`basename $3` +		verbose "$INSTALL_CP $4/$conffile $target" +		$INSTALL_CP $4/$conffile $target  		;;  	*)  		fail "unrecognized modlist entry: $*" @@ -453,6 +451,30 @@ function copymod {  	esac  } +# Sanity-check the given module list. +function check_modlist { +	nawk ' +	BEGIN { +		nfields["MOD"] = 6 +		nfields["CONF"] = 6 +		nfields["LINK"] = 7 +		nfields["SYMLINK"] = 7 +	} +	{ +		# This also catches unknown tags. +		if (nfields[$1] != NF) { +			print "error: invalid modlist record:" +			print $0 +			print "expected", nfields[$1], "fields, found", NF +			status=1 +		} +	} +	END { +		exit status +	} +	' $1 || fail "Errors in kernel module list" +} +  #  # Copy kernel modules to $INSTALL_DIR  # @@ -519,6 +541,7 @@ function copy_kernel {  	(cd $KARCH; MAKEFLAGS=e $make -K $MODSTATE modlist.karch) | \  	    egrep "^MOD|^CONF|^LINK|^SYMLINK" > $modlist  	[ "$VERBOSE" = "V" ] && cat $modlist +	check_modlist $modlist  	if [ -n "$ON_CRYPTO_BINS" ]; then  		cryptotar="$ON_CRYPTO_BINS"  		if [ "$OBJD" = obj ]; then diff --git a/usr/src/uts/Makefile.targ b/usr/src/uts/Makefile.targ index 21ef9c8c5d..8915cc2547 100644 --- a/usr/src/uts/Makefile.targ +++ b/usr/src/uts/Makefile.targ @@ -19,8 +19,7 @@  # CDDL HEADER END  #  # -# Copyright 2009 Sun Microsystems, Inc.  All rights reserved. -# Use is subject to license terms. +# Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.  #  #	This Makefiles contains the common targets and definitions for  #	all kernels. It is to be included in the Makefiles for specific @@ -381,18 +380,31 @@ RELSOFTLINKS = $(ROOTSOFTLINKS:$(ROOT)/%=%)  MODSRC:sh=		pwd  # +# Generate module information for Install.sh, i.e., specify what files +# Install.sh should include.  Each line looks like +#   <tag> <srcdir> <arg1> <arg2> ... +# where <tag> specifies the type of file, <srcdir> gives the source +# path (useful if there is an error), and <argN> is one or more +# additional bits of information that Install.sh needs (e.g., source +# directory, install directory, filtering tags).  See Install.sh for +# details on the arguments for each tag type, especially the functions +# copymod, filtmod, and filtimpl. +#  # Changes to this target may require corresponding changes to  # Install.sh. +#  # Don't issue a MOD entry if it's not in the install list.  # +  $(MODLIST_DEPS): FRC  	@case $@ in \  	*32) \  		class=32; \ -		relmodule=`dirname $(RELMODULE)`;; \ +		[ -n "$(RELMODULE)" ] && relmodule=`dirname $(RELMODULE)`;; \  	*64) \  		class=64; \ -		relmodule=`dirname $(RELMODULE)`/$(SUBDIR64);; \ +		[ -n "$(RELMODULE)" ] && \ +		    relmodule=`dirname $(RELMODULE)`/$(SUBDIR64);; \  	esac; \  	if [ -z "$(THISIMPL)" ]; then \  		impl=all; \ @@ -408,8 +420,8 @@ $(MODLIST_DEPS): FRC  		tinstall="$(INSTALL_TARGET)"; \  		for t in $$tinstall; do \  			if [ "$(ROOTMODULE)" = $$t ]; then \ -				echo MOD $$module $$relmodule \ -				    $$class $$impl $(MODSRC); \ +				echo MOD $(MODSRC) $$module $$relmodule \ +				    $$class $$impl; \  				break; \  			fi \  		done \ @@ -418,7 +430,7 @@ $(MODLIST_DEPS): FRC  		tinstall="$(INSTALL_TARGET)"; \  		for t in $$tinstall; do \  			if [ $(ROOT_CONFFILE) = $$t ]; then \ -				echo CONF $(RELCONF) \ +				echo CONF $(MODSRC) $(RELCONF) \  				    $(MODSRC)/$(CONF_SRCDIR) $$impl $$module; \  				break; \  			fi \ @@ -427,17 +439,17 @@ $(MODLIST_DEPS): FRC  	if [ -n "$(ROOTLINK)" ]; then \  		rellinks="$(RELLINK)"; \  		for r in $$rellinks; do \ -		if [ $$class = 32 ]; then \ -			linkdir=`dirname $$r`; \ -		else \ -			linkdir=`dirname $$r`/$(SUBDIR64); \ -		fi; \ -		echo LINK $$relmodule $$module \ -			$$linkdir `basename $$r` $$impl; \ +			if [ $$class = 32 ]; then \ +				linkdir=`dirname $$r`; \ +			else \ +				linkdir=`dirname $$r`/$(SUBDIR64); \ +			fi; \ +			echo LINK $(MODSRC) $$relmodule $$module \ +				$$linkdir `basename $$r` $$impl; \  		done \  	fi; \  	if [ -n "$(UNIX32_LINK)" ]; then \ -		echo SYMLINK $(SUBDIR64)/$(UNIX) \ +		echo SYMLINK $(MODSRC) $(SUBDIR64)/$(UNIX) \  		    `dirname $(RELUNIX)` unix $$impl $$module; \  	fi; \  	trelsoftlinks="$(RELSOFTLINKS)"; \ @@ -448,7 +460,7 @@ $(MODLIST_DEPS): FRC  			linkdir=`dirname $$t`/$(SUBDIR64); \  		fi; \  		linkname=`basename $$t`; \ -		echo SYMLINK $(MODULE) $$linkdir $$linkname \ +		echo SYMLINK $(MODSRC) $(MODULE) $$linkdir $$linkname \  		    $$impl $$module; \  	done | 
