⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setld

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻
📖 第 1 页 / 共 5 页
字号:
	x)	InitDevice || Ferror 2 "cannot initialize $DEVICE"		LoadCtrlInfo ||			Ferror 2 "cannot load control information"		set -- $ARGV		[ $# = 0 ] &&		{			SplitByType || Exit $?			TickWhile PreSize extract $MAND ||			{				Error "There is not enough file system space to extract the mandatory subsets"				Exit 1			}			SelectSubsets || Exit $?			set -- $SBS		}		Extract $*		Exit $?		;;	esac	STAT=$OPTERRS	EMESG=	Exit 0}:	-NameParse#		parse a subset name into components##	given:	$1 - a variable name prefix to use#		$2 - a subset name to parse#	does:	parse the subset name in P (xxx), N (y*), & V (zzz) components#	return:	nothing#	effect:	assign the P component to ${1}P#		assign the N component to ${1}N#		assign the V component to ${1}VNameParse(){	[ $# -lt 2 ] &&	{		Error "NameParse(): too few arguments ($#)"		return 1	}	L_PREFIX=$1	# variable prefix to use	L_S=$2		# subset name to parse	#% Local Variables	L_N=		# temporary subset name	L_P=		# temporary product code	L_V=		# temporary version code	L_X=		# loop control	#% Local Code	# check to see if parse information has been cached	eval NPC=\$Np$L_S	[ "$NPC" ] &&	{		# assign cached values and return		eval `(			set $NPC			shift			echo "${L_PREFIX}P=$1 ${L_PREFIX}N=$2 ${L_PREFIX}V=$3"		)`		return 0	}	case "$L_S" in	.|..|...|....|.....|......)		Error "NameParse(): $L_S: subset names must be > 7 chars long"		return 1	esac	L_N=`expr $L_S : '^...\(.*\)...$'` ||	# name component	{		Error "NameParse($L_S): cannot parse subset name"		return 1	}	L_P=`expr $L_S : '^\(...\).*$'`	||	# product component	{		Error "NameParse($L_S): cannot parse product code"		return 1	}	L_V=`expr $L_S : '^.*\(...\)$'` ||	# version component	{		Error "NameParse($L_S): cannot parse version version"		return 1	}	# make the assignments	for L_X in N P V	{		eval $L_PREFIX$L_X=\$L_$L_X	}	# cache the resutls	NPC="$L_S $L_P $L_N $L_V"	eval Np$L_S='$NPC'	return 0}:	-OpenLog#		establish logfile##	given:	$LOGFLILE - default logfile#		$WHOAMI - user name running this process#		$DATE - invocation time as formatted by $DATFMT#	does:	establishes a log file for the session and writes initial#		entry for this invocation#	return:	0#	effect:	$LOGFILE - may modify#		$WHOAMI - will set from output of whoami(1) if not setOpenLog(){	WHOAMI=${WHOAMI:=`whoami`}	[ "$WHOAMI" != root ] && LOGFILE=/dev/null	# create initial entry for this run	Log "SETLD $$ $WHOAMI $DATE \c" 	return 0}:	-Parse#		separate into words using separator##	given:	$1 separator characters to use#		$2 - $n strings to separate#	does:	uses the separators to break the arglist into words#	return:	nothingParse(){ (	IFS=$1	shift	echo $*) }:	-PositionTape#		position tape to a specified location##	given:	$1 - volume number to position to#		$2 - setld readable file position on the tape to go to#		global $_CPOS - current tape position#	does:	position the tape to be able to read the specified volume#		and file#	return:	0 if all's well.#		1 on failure.#	effect:	global $_CVOL - may change to reflect new position#		global $_CPOS - may change to reflect new positionPositionTape(){	NEWVOL=$1		# desired volume	NEWPOS=$2		# desired position	case "$NEWPOS" in	-[123])	;;	-*)	Ferror 1 "Unaccessible tape position $NEWPOS"	esac	# make sure the tape drive isn't being used...	Wait MTPID	#  1. get the correct volume mounted	[ "$NEWVOL" != "$_CVOL" ] &&	{		# volume change logic		echo "Volume change. Rewinding tape...\c"		TickWhile "mt -f $RAW rew && mt -f $RAW offl" ||		{			Error "I can't dismount your tape. You will have to take thetape drive off line manually."		}		echo "Please remove tape volume $_CVOL and replace it with volume $NEWVOL."		while :		do			Ready			mt -f $RAW rew && break		done		_CVOL=$NEWVOL		_CPOS=-$T_0	}	#  2. get the correct position in the volume	MOVE=`Subtract $_CPOS $NEWPOS`	_CPOS=$NEWPOS	case "$MOVE" in	0)	# we're at it.		;;	-*)	# forward X files.		MOVE=`Parse - $MOVE`		TickWhile "mt -f $RAW fsf $MOVE"		;;	*)	MOVE=`expr $MOVE + 1`		TickWhile "mt -f $RAW bsf $MOVE && mt -f $RAW fsf"		;;	esac	return $?	# returns value of last exec in case}:	-PreSize#		determine is space is available to -l/-x a subset to#	the system.##	given:	$1 - operation description in {install,extract}#		$2... - names of objects to be operated upon#	does:	permit space to be measured before reading software#		onto the system#	return:	0 is operation can be performed in the available space,#		1 if not.#	effect:	none, closed context#PreSize(){ (	OPCODE=$1	shift	SUBSETS=$*	[ "$SUBSETS" ] || return 0	# no subsets.	case "$OPCODE" in	extract)		# use the image file information and sizes of .ctrl, .inv,		#  and .scp files to determine if subset		#  image will fit on the system		# for each subset being extracted, get its .image record.		#  place the image records in a temp file. At the same		#  time, gather size information about the ctrl, etc. files		> $TMP1		SIZES=0		for S in $SUBSETS		{			egrep $S $_TDIR/*.image >> $TMP1			SIZE=`ls -s $_TDIR/$S.* | awk '{print $1}'`			SIZES="$SIZES $SIZE"		}		# add up the sizes of all of the images		ISIZE=`awk '			BEGIN	{size=0}				{size += $2}			END	{print size}' < $TMP1`		# add up image size and all individual file sizes		SIZE=0		for X in $SIZES $ISIZE		{			SIZE=`expr $SIZE + $X`		}		# get freespace from system		FREESPACE=`df . | awk 'NR == 3 {print $4}'`		[ "$SIZE" -lt "$FREESPACE" ] && return 0		return 1		;;	install)		# cram all of the specified inventory files thru fitset		LIST=/dev/null		for S in $SUBSETS		{			LIST="$LIST $_TDIR/$S.inv"		}		cat $LIST | fitset $_R 2> /dev/null && return 0		return 1		;;	*)	Error "PreSize(): $OPCODE: unknown opcode"	esac) }:	-PrintTable#		Print a table of subset descriptions##	given:	$1 - a character to place in column 2 of output table#		$2..$n - subset codes for descriptions to be displayed#		global $SP - space padding for fields#		global $FW - field width string for fields#	does:	look up the description for each subset listed on the command#		line, format the descriptions 2 per line.#	return:	ignored#	effect:	none - context is privatePrintTable(){ (		BULLET=$1	# col 2 character	shift	SUBSETS=$*	DESC=		# current subset description	N="\c"		# newline suppressor, alternates with ""	PSTR=		# formatted string to print	SUBSET=		# current subset	for SUBSET in $SUBSETS	{		eval DESC='$DESC'$SUBSET		PSTR=`expr " $BULLET $DESC$SP" : '\('$FW'\).*'`		echo "$PSTR  $N"		case "$N" in		"\c")	N=			;;		*)	N="\c"		esac	}	echo "$N"	# will terminate line if needed.) }:	-Pwd#		print working directory, BSD style##	given:	nothing#	does:	print the working directory, using BSD symbolic link#		rules embodied in /bin/pwd#	return:	voidPwd(){	/bin/pwd}:	-ReadCtrlFile#		Initialize control file values##	given:	$1 - pathname for directory to search for control file#		$2 - name of subset#	does:	read the file and verify it's contents#		saves the control attributes#	return:	1 on error#	effect:	sets DESC, NVOLS, MTLOC, DEPS, FLAGS#			sets \$DESC$2....#ReadCtrlFile(){	# initialize, clean up residual values	DESC=	NVOLS=	MTLOC=	DEPS=	FLAGS=	[ $# = 2 ] ||	{		Error "ReadCtrlFile($*): expected 2 args, recieved $#"		return 1	}	L_DIR=$1	# directory to search	L_SUB=$2	# subset name	# check to see if the information is already cached	eval SET=\$SET$L_SUB	[ "$SET" = 1 ] &&	# retrieve the info	{		eval DESC=\$DESC$L_SUB		eval NVOLS=\$NVOLS$L_SUB		eval MTLOC=\$MTLOC$L_SUB		eval DEPS=\$DEPS$L_SUB		eval FLAGS=\$FLAGS$L_SUB		return 0	}	# info not cached, read and cache	[ -f $L_DIR/$L_SUB.ctrl ] ||	{		Error "ReadCtrlFile(): cannot find $L_DIR/$L_SUB.ctrl"		return 1	}	. $L_DIR/$L_SUB.ctrl ||	{		Error "ReadCtrlFile(): error reading $L_DIR/$L_SUB.ctrl"		return 1	}	# did we get it all?	case "~$DESC~$NVOLS~$MTLOC~$DEPS~$FLAGS~" in	*~~*)	# Control File appears to be incomplete		Error "ReadCtrlFile(): $L_DIR/$L_SUB.ctrl is incomplete"		return 1	esac	# preserve the information	eval DESC$L_SUB='$DESC'	eval NVOLS$L_SUB='$NVOLS'	eval MTLOC$L_SUB='$MTLOC'	eval DEPS$L_SUB='$DEPS'	eval FLAGS$L_SUB='$FLAGS'	# mark the subset as 'set'	eval SET$L_SUB=1	eval DIR$L_SUB=$L_DIR	return 0}:	-Ready#		affirm user readiness##	given:	nothing#	does:	wait for user to affirm readiness#	return:	VOIDReady(){ (	X=		# user input	while :	do		sleep 2		echo "Are you ready (y/n)? \c"		read X		[ "$X" = 'y' -o "$X" = 'Y' ] && return	done) }:	-RecoverChanges#		Perform post-update archiving activities##	given:	$1 subset to restore#		inventory data in $_TDIR/$1.res#	does:	propogate precedent changes back to the system#	return:	nothingRecoverChanges(){ (	S=$1	cd var/adm/install/archive	iff -p < $_TDIR/$S.res | awk '{print $10}' > $TMP1	BigTar $TMP1 $_R) }:	-RemoveDebris#		remove leftovers from a previous release##	given:	the name of a subset to clean up after#	does:	cleans up#	return:	nothingRemoveDebris(){ (	S=$1	frm < $_TDIR/$S.frm) }:	-Resident#		list installed copies of a subset.##	given:	$1 - a subset code without a version specifier#	does:	lists codes of all versions of the subset which are installed#	return:	nothingResident(){	L_PN=$1	L_OUT=		# output string	# search for control files of known versions.	#! expasion join - next expression has fixed version code length	L_OUT=`(cd $UAS; echo $L_PN???.lk | sed 's/\.lk//g' )`	case "$L_OUT" in	*'???')	return 1	# no match, no versions installed.	esac	echo "$L_OUT"	return 0}:	-RunScps#		run set of batched scps set up during LoadFromMedia##	given:	$1 - the environment key to use#		$2... the names of the subsets#	does:	runs them with the appropriate settings#	return:	nothingRunScps(){	KEY=$1	shift	for S in $*	{		Log "$S SCP $KEY \c"		[ -f $UAS/$S.scp ] ||			continue		ACT=$KEY $UAS/$S.scp ||		{			Error "The subset control program for subset $S failed."			[ -s $UAS/$S.lk ] &&			{				echo "This failure may adversely affect the operation of the following subsets:"				sort $UAS/$S.lk|uniq			}			rm -f $UAS/$S.lk			case "$ISOPT$ACT" in			0[AL])	OPTERRS=1				;;			1)	OPTERRS=`expr $OPTERRS + 2`			esac					continue		}		#! lock update operations do not belong here to be		#!  moved pending review of atomicity of operations		# update lock files		ReadCtrlFile $UAS $S		for K in $DEPS		{			[ "$K" = '.' ] && break			echo "$S" >> $UAS/$K.lk		}			[ "$DEFPATH" = 1 ] &&			ACT=C $UAS/$S.scp INSTALL		Log "SUCCEEDED"	}}:	-SelectSubsets#		select which subsets are to be installed/extracted##	given:	global $MAND - list of mandatory subsets to be listed before#			presenting selection menu#		global $OPT - list of optional subsets from which to select#	does:	display mandatory subsets. offer selection of optional subsets.#		recieve list of selected subsets. confirm selection#		of selected subsets. set global SBS to a concatenation#		of mandatory subsets and selected optional subsets#	return:	ignored#	effect: global $SBS - change to list mandatory subsets prepended to#		list of selected optional subsetsSelectSubsets(){	OPERATION=install	# set OPERATION to extracted if doing setld -x	[ "$CMDSW" = x ] &&		OPERATION=extract	# a note on table field formatting used here:	#  the string to be printed in the table is padded to	#  be AT LEAST as wide as the desired field and piped to sed.	#  Sed chops off anything following the fortieth character.	FW="......................................"	# 38 of them.	SP="                                        "	case "$OPT" in	"")	echo "The following subsets will be ${OPERATION}ed:"		PrintTable "*" $MAND		while :		do			echo "Do you wish to continue? (y/n): \c"			read X			X=`echo $X`			case "$X" in			[yY]*)	break				;;			[Nn]*)	return 2			esac		done		SBS=$MAND		return 0	esac	echo "*** Enter Subset Selections ***"	# list out mandatory subsets if any.	while :	do		[ "$MAND" != "" ] &&		{			echo "The following subsets are mandatory and will be ${OPERATION}ed automatically:"			PrintTable "*" $MAND		}		# this builds the selection table.		echo "The subsets listed below are optional:"		N="\c"		X=1		for _S in $OPT		{			eval ORD$X=$_S			eval DESC='$DESC'$_S			case "$X" in			?)	X=" $X"			esac			PSTR=`expr "$X) $DESC$SP" : '\('$FW'\).*'`			echo "$PSTR  $N"			X=`expr $X + 1`			case "$N" in			"\c")	N=				;;			*)	N="\c"			esac		}		echo "$N"		ALL=$X		NONE=`expr $X + 1`		EXIT=`expr $X + 2`		case "$ALL" in		?)	PALL=" $ALL"			;;		*)	PALL="$ALL"		esac		case "$NONE" in		?)	PNONE=" $NONE"			;;		*)	PNONE="$NONE"		esac		case "$EXIT" in		?)	PEXIT=" $EXIT"			;;		*)	PEXIT=$EXIT		esac		echo "$PALL) All of the Above$PNONE) None of the Above$PEXIT) Exit without ${OPERATION}ing subsetsEnter your choice(s): \c"		read X		# walk thru the input...		SORTED=		for I in $X		{			# is it a number?			J=`expr $I : '\([0-9][0-9]*\)'`			case $I in			$ALL|$NONE|$EXIT)				SORTED=$I				break				;;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -