#	Called by do.new to do real work involved in topic installation.

# Send old nroffed topics to $oldmach under same name with .'s instead of /'s.

cd $subtree/cat
foreach f ($*)
	if (! -e $f)   continue
	set noslashes = `echo $f | sed s,/,.,g`
	tar cf - $f > /tmp/HM$$
	foreach m ($oldmach)
		if ($m == $thismach) then
			cp /tmp/HM$$ ../old/$noslashes
			continue
		endif
		$netcom[1] $m "cat > $netold/old/$noslashes" < /tmp/HM$$
		if ($status && $#netcom > 1) then
			$netcom[2] $m "cat > $netold/old/$noslashes" < /tmp/HM$$
		endif
	end
end

# Nroff new topics.  If first character is '#' or ':' treat it specially.

cd $subtree/src
foreach f ($*)
	if (-d $f) then
		if (! -e $subtree/cat/$f)   mkdir $subtree/cat/$f
		continue
	endif
	if ($f =~ index_*)   source $subtree/maint/mk.$f
	set line1 = `head -1 $f`
	if ("$line1" =~ \#* || "$line1" =~ \:*) then
		sed -e '/^##nroff/,/^##/{' -e '/^##/d' -e 'b' -e '}' \
			-e 's/^/\\\!/' $f | nroff -mayday > $subtree/cat/$f
	else
		nroff -mayday $f > $subtree/cat/$f
	endif
end

# Send newly nroffed topics to the machines in $catmach.

cd $subtree/cat
foreach f ($*)
	tar cf - $f > /tmp/HM$$
	foreach m ($catmach)
		if ($m == $thismach)   continue
		$netcom[1] $m "cd $netcat/cat ; tar xpBf -" < /tmp/HM$$
		if ($status && $#netcom > 1) then
			$netcom[2] $m "cd $netcat/cat ; tar xpBf -" < /tmp/HM$$
		endif
	end
end

# Send topic sources to the machines in $srcmach.

foreach f ($*)
	tar cf - $subtree/src/$f > /tmp/HM$$
	foreach m ($srcmach)
		if ($m == $thismach)   continue
		$netcom[1] $m "tar xpBf -" < /tmp/HM$$
		if ($status && $#netcom > 1) then
			$netcom[2] $m "tar xpBf -" < /tmp/HM$$
		endif
	end
end

# Tell the users in $tell of the installation.

mail $tell > /dev/null << %
~s $subject install (`whoami`) $*
%
rm -f /tmp/HM$$
