makeplist revision 1.15
11.1Sjwise#!/bin/sh
21.1Sjwise#
31.1Sjwise# Print out the files in some or all lists.
41.4Sdyoung# Usage: makeplist [-a arch] [-m machine] [-s setsdir] [-p prefix] setname pkgname
51.1Sjwise#
61.1Sjwise
71.15Serhrundir=${0%/*}
81.15Serh. ${rundir}/sets.subr
91.1Sjwiseprefix=/
101.1Sjwise
111.12Slukemusage()
121.12Slukem{
131.12Slukem	cat 1>&2 <<USAGE
141.12SlukemUsage: ${0##*/} [-a arch] [-m machine] [-s setsdir] [-p prefix] setname pkgname
151.13Slukem	-a arch		set arch (e.g, m68k, mips, powerpc)	[$MACHINE_ARCH]
161.13Slukem	-m machine	set machine (e.g, amiga, i386, macppc)	[$MACHINE]
171.12Slukem	-s setsdir	directory to find sets			[$setsdir]
181.12Slukem	-p prefix	prefix for created plist		[$prefix]
191.12Slukem	setname pkgname	set and package to build plist for
201.12SlukemUSAGE
211.12Slukem	exit 1
221.1Sjwise}
231.1Sjwise
241.1Sjwise# handle args
251.14Sdyoungwhile getopts a:m:p:s: ch; do
261.12Slukem	case ${ch} in
271.12Slukem	a)
281.13Slukem		MACHINE_ARCH=${OPTARG}
291.13Slukem		MACHINE_CPU=$(arch_to_cpu ${OPTARG})
301.1Sjwise		;;
311.12Slukem	m)
321.13Slukem		MACHINE=${OPTARG}
331.1Sjwise		;;
341.12Slukem	p)
351.12Slukem		prefix=${OPTARG}
361.1Sjwise		;;
371.12Slukem	s)
381.12Slukem		setsdir=${OPTARG}
391.1Sjwise		;;
401.12Slukem	*)
411.1Sjwise		usage
421.1Sjwise		;;
431.1Sjwise	esac
441.1Sjwisedone
451.12Slukemshift $((${OPTIND} - 1))
461.12Slukemif [ $# -ne 2 ]; then
471.1Sjwise	usage
481.1Sjwisefi
491.12Slukemsetname="$1"
501.12Slukempkgname=$2
511.7Sagc
521.7Sagcfilename=/tmp/makeplist.$$ 
531.7Sagcffilename=/tmp/makeplist.files.$$ 
541.7Sagcdfilename=/tmp/makeplist.dirs.$$ 
551.7Sagc
561.8Sdyounglist_set_files $setname | \
571.12Slukem    env PLISTPKG=$pkgname awk '
581.12Slukem	$2 == ENVIRON["PLISTPKG"] {
591.12Slukem		sub("^\\./", "", $1);
601.12Slukem		print $1
611.12Slukem	}' | sort -u > $filename
621.8Sdyoung
631.8SdyoungSELECTDIRS="-maxdepth 0 -type d"
641.8SdyoungSELECTNONDIRS="-maxdepth 0 ! -type d"
651.8Sdyoung
661.8Sdyoungcd $prefix
671.8Sdyoung#
681.8Sdyoung# match the directories
691.8Sdyoung#
701.8Sdyoungxargs echo $SELECTDIRS < $filename | \
711.8Sdyoungwhile read ignore ignore ignore ignore args; do
721.8Sdyoung	[ -z "$args" ] && break 
731.8Sdyoung	find $args $SELECTDIRS
741.8Sdyoungdone | awk '{ print "@dirrm " $1; }' > $dfilename
751.8Sdyoung
761.8Sdyoung#
771.8Sdyoung# match the non-directories
781.8Sdyoung#
791.8Sdyoungxargs echo $SELECTNONDIRS < $filename | \
801.8Sdyoungwhile read ignore ignore ignore ignore ignore args; do
811.8Sdyoung	[ -z "$args" ] && break 
821.8Sdyoung	find $args $SELECTNONDIRS
831.8Sdyoungdone > $ffilename
841.8Sdyoung
851.8Sdyoungcd -
861.7Sagc
871.7Sagcecho "@cwd $prefix"
881.7Sagcif [ -s $ffilename ]; then
891.7Sagc	cat $ffilename
901.1Sjwisefi
911.7Sagcif [ -s $dfilename ]; then
921.7Sagc        sort -r $dfilename
931.7Sagcfi
941.7Sagc
951.7Sagcrm -f $filename $ffilename $dfilename
961.7Sagc
971.7Sagcexit 0
98