#!/bin/csh
# ~/bin/.csh/distfiles_touch	by Julian H. Stacey
# See also distfiles_index & distfiles2cd.csh

# Creates a fake tree of zero size ports/distfiles, to
# represent distfiles I already have.
# So I can run on another host: "cd /usr/ports;make fetch" to collect additions.
# 2 scenarios:
# 	Old use:
#		For my finite size laptop disc, when visiting a site that
#		has good access to lots of extra distfiles.
#	New use:
#		On internal hosts. Before I run another fetch direct on gate
#		(as proxy on gate breaks ftp & some cvs fetch).

set source="/public/freebsd/dists"
# if on home net, take latest list fron NFS'd host,
# & if off site work from own local ${source}/kit files,
# periodicaly hand copied there.

# Create zero size dummies on localhost target.
if ( $1.x == ".x" ) then	#{
	set target="/usr/ftp/public/freebsd/dists/touched_dummies"
else	# }{
	set target=$1
endif	#}

cd ${source}/kit/dirs
foreach i ( * )
	foreach j ( `cat $i`)
		echo "Calling mkdir -p ${target}/$j"
		(mkdir -p ${target}/$j )
		end
	end
cd ../files
foreach i ( * )
	foreach j ( `cat $i`)
		echo "Calling touch ${target}/$j"
		touch "${target}/$j"
		# Quotes are used as there are some horrible file names EG:
		#	pkg_tarup?rev=1.2&content-type=text%2fplain
		#	ruby/TZFile-0.1.tar.gz?tarball=1&only_with_tag\
		#		=tzfile-0_1&cvsroot=ruby&.tar.gz
		end
	end
