#!/bin/csh
#:se ts=4

exit

I havent used this in ages, it needs demolishing,
might be useful for syntax, or older releases & smaller discs

# ~/bin/.csh/make_ports_all	by Julian H. Stacey
# Copyright Julian H. Stacey, Munich 1993-6. Use freely. Liability Disclaimed.

# Make many of the 9000+ ports on a system with non infinite disc !
#	See also:	~/bin/.csh/make_ports_jhs

# Ensure /modules is up to date, else will fail to make linux_base-6.1.tgz
# from emulators/linux_base which will prevent may others, saying
#	can't load linux: Exec format error

set TAG_JHS_PKG=.package_done_jhs
cat << EOF
- This shell should later be replace by EG:
	http://people.freebsd.org/~steve/release-scripts.tgz
	http://www.freebsd.org/doc/en_US.ISO8859-1/articles/\
		releng-packages/article.html
- Run as root.
- Use a tiny font & maximal length xterm, to avoid ports like
  comms/hylafax & comms/zmtx-zmrx that send their install through more,
  become interactive, & hang the build.
- Environment: Set one of: BATCH=yes INTERACTIVE=yes
- Sizes & Directory Paths:
  - Ensure /var/db/pkg is on a big filesystem, to avoid running out of inodes.
  - Ensure /usr/ports/distfiles is a sym link, else it will pull in over 5G.
    & bloat /var/log/ftp.log & maybe /var/log/named
  - /usr/compat/linux bloats out to 255Meg (or maybe more) !
  - Use temporary strippable /usr/local & /usr/X11R6, that are not NFS'd on to
    other live hosts, as these will grow enormously & need to be stripped.
    /usr/X11R6 4.9=963M, /usr/local 4.9=5.5Gig
    /usr/share/doc 40M share in all 76M
  - /usr/ports will grow to many gig. You will need periodic Ctl Z
    & selectively manualy clean.
  - Ensure /usr/ports/packages goes somewhere meaningful,
    else packages will not be delivered & will bloat /usr/ports/.
- Make package dependency (decision to run):
  - does not depend on existance of EG /usr/packages/All/9e-1.0.tgz
  - depends on /usr/ports/archivers/9e/work/.package_done.9e-1.0
  - depends on /var/db/pkg/9e-1.0/ (over- ride with FORCE_PKG_REGISTER=yes)
  - because I need to do intermittent pkg_delete -a to purge /usr/local
    & make clean to purge /usr/ports, I use my own tag: ${TAG_JHS_PKG}
    to avoid rebuilding packages I already have.
- Monsters & Screwers:
  - XFree86-4 may screw the build of other things eg chimera mozilla etc,
    do it last after other packages are built.
  - x11/gnome-fifth-toe depends on mozilla ... big !
  - x11/gnome
EOF

set target_d=/pub/FreeBSD/ports/i386/packages-`uname -r | dd conv=lcase`
mkdir -p ${target_d}
set USR_PORTS=/usr/ports
# echo "PORTSDIR is $PORTSDIR"	# not yet imported, for later addition.
cd $USR_PORTS
set LOG=$USR_PORTS/jhs.log
touch $LOG		# An abreviated log to see where we are up to
			# remember a 2nd version may be running backward,
			# with reversed SUBDIRS on a 2nd build host.
pushd packages ; pwd ; popd

set SUBDIR=""

# SUBDIR can be put in reverse alphabetic order, with
#	vi	!}sort -r	#{
# for if I''ve previously started a top level make in normal order.

# This list below has been verified against a 4.9 ports tree Nov 2003.

set SUBDIR="$SUBDIR archivers"
set SUBDIR="$SUBDIR audio"
set SUBDIR="$SUBDIR benchmarks"
set SUBDIR="$SUBDIR cad"
set SUBDIR="$SUBDIR comms"
set SUBDIR="$SUBDIR converters"
set SUBDIR="$SUBDIR databases"
set SUBDIR="$SUBDIR deskutils"
set SUBDIR="$SUBDIR devel"
set SUBDIR="$SUBDIR dns"	# Needs a 2nd build for 4.9
set SUBDIR="$SUBDIR editors"
set SUBDIR="$SUBDIR emulators"
set SUBDIR="$SUBDIR finance"	# Needs a 2nd build for 4.9
set SUBDIR="$SUBDIR ftp"
set SUBDIR="$SUBDIR graphics"
set SUBDIR="$SUBDIR irc"
set SUBDIR="$SUBDIR java"
set SUBDIR="$SUBDIR lang"
set SUBDIR="$SUBDIR mail"
set SUBDIR="$SUBDIR mbone"
set SUBDIR="$SUBDIR misc"
set SUBDIR="$SUBDIR multimedia"	# Needs a 2nd build for 4.9
set SUBDIR="$SUBDIR net"
set SUBDIR="$SUBDIR news"
set SUBDIR="$SUBDIR palm"
set SUBDIR="$SUBDIR picobsd"
set SUBDIR="$SUBDIR print"
set SUBDIR="$SUBDIR science"
set SUBDIR="$SUBDIR security"
set SUBDIR="$SUBDIR shells"
set SUBDIR="$SUBDIR sysutils"
set SUBDIR="$SUBDIR textproc"
set SUBDIR="$SUBDIR www"
set SUBDIR="$SUBDIR x11"
set SUBDIR="$SUBDIR x11-clocks"
set SUBDIR="$SUBDIR x11-fm"
set SUBDIR="$SUBDIR x11-fonts"
set SUBDIR="$SUBDIR x11-wm"

# Some of this stuff will pollute with later versions,
# really need to switch to chroot, but for now just do last
set SUBDIR="$SUBDIR x11-toolkits"
set SUBDIR="$SUBDIR x11-servers"

# Big & specialist/minority stuff.
set SUBDIR="$SUBDIR math"
set SUBDIR="$SUBDIR biology"
set SUBDIR="$SUBDIR astro"
set SUBDIR="$SUBDIR games"

# National minorities stuff.
set SUBDIR="$SUBDIR german"
# set SUBDIR="$SUBDIR chinese"
# set SUBDIR="$SUBDIR french"
# set SUBDIR="$SUBDIR hebrew"
# set SUBDIR="$SUBDIR hungarian"
# set SUBDIR="$SUBDIR japanese"
# set SUBDIR="$SUBDIR korean"
# set SUBDIR="$SUBDIR polish"
# set SUBDIR="$SUBDIR portuguese"
# set SUBDIR="$SUBDIR russian"
# set SUBDIR="$SUBDIR ukrainian"
# set SUBDIR="$SUBDIR vietnamese"

foreach i ( ${SUBDIR} ) #{	OR foreach i ( [a-z]*/Makefile )
	set ii = $i	# 			OR set ii = `dirname $i`
	echo " " ; echo "==={> Starting ${ii}"
	pushd ${ii}	#{
		if ( -f ${TAG_JHS_PKG} ) then #{
			echo " " ; echo "Skipping make ${ii}"
		else	#}{
			foreach j ( [a-zA-Z]*/Makefile ) #{
				set jj = `dirname $j`
				echo " " ; echo "---{> Starting ${ii}/${jj}"
				echo "${ii}/${jj} `date -u +%Y-%m-%dT%H:%M:%SZ`" >> $LOG
				pushd ${jj}	#{
					if ( -f ${TAG_JHS_PKG} ) then	#{
						echo " " ; echo "Skipping ${ii}/${jj}"
					else	#}{
						echo " "
						echo "Making ${ii}/${jj}"
						make package \
							FOR_CDROM=yes PACKAGES=$target_d && \
						  touch ${TAG_JHS_PKG}
						  # Just make a tag if make package exits OK.
						  # Q? what if /var/db/pkg/ already exists ?
							# FOR_CDROM is to avoid Makefiles with
							#	NO_CDROM
							# Makefiles with
							#	NO_PACKAGE
							# will not be packaged by default,
							# unless you force it with
							#	FORCE_PACKAGE
							# ports/Mk/bsd.port.mk says:
							#	NO_CDROM -Port may not go on CDROM.
							#	NO_PACKAGE - Port should not be packaged but
							#	  distfiles can be put on ftp sites and CDROMs.
						# df so if overflow occurs, I know what to remake
						#	devel/[A-Za-p]* on 4.2 has a 2.6 G compile tree !
						#	but as ports often borrow from one before,
						df /usr/local $USR_PORTS /usr/packages
						df /usr/local $USR_PORTS /usr/packages	>> $LOG
					endif	#}
					# If we now do make clean it will slow down the build of
					# adjacent ports EG x11-servers/XttXF86srv-S3 that use
					#	MASTERDIR= ${.CURDIR}/../something
					# but if we do Not make clean, then big directories like
					# devel/ will flood.
					# We do the clean outside the above if-else, in case
					# another make not called from this shell has left residue.
					if ( "${jj}" != "x11-servers" )	then #{
						# clean, unless avoiding EG the Xtt* that all use
						# the same base.
						make clean NOCLEANDEPENDS=yes
						endif	#}
				popd	# ${jj} }
				echo "<}--- Finished ${ii}/${jj}" ; echo " "
			end	# $j }
			touch ${TAG_JHS_PKG}
		endif	#}
		if ( -f ${TAG_JHS_PKG} ) then #{
			echo " " ; echo "Skipping make clean NOCLEANDEPENDS=yes"
		else    #}{
			# Next clean is half redundant if earlier
			# clean is not commented out.  but done anyway,
			# to help remove residue from other makes not
			# called from this shell.
			make clean NOCLEANDEPENDS=yes
		endif   #}
	popd	#}
	# save space in /usr/local suspend & do this manually, occasionaly
	# pkg_delete -a -f
	echo "<}=== Finished ${ii}" ; echo " "
end	#}
