Home | History | Annotate | Line # | Download | only in sets
makeplist revision 1.12
      1   1.1   jwise #!/bin/sh
      2   1.1   jwise #
      3   1.1   jwise # Print out the files in some or all lists.
      4   1.4  dyoung # Usage: makeplist [-a arch] [-m machine] [-s setsdir] [-p prefix] setname pkgname
      5   1.1   jwise #
      6   1.1   jwise 
      7   1.8  dyoung . ./sets.subr
      8   1.1   jwise prefix=/
      9   1.1   jwise 
     10  1.12   lukem usage()
     11  1.12   lukem {
     12  1.12   lukem 	cat 1>&2 <<USAGE
     13  1.12   lukem Usage: ${0##*/} [-a arch] [-m machine] [-s setsdir] [-p prefix] setname pkgname
     14  1.12   lukem 	-a arch		set arch (e.g, m68k, mips, powerpc)	[$machine_arch]
     15  1.12   lukem 	-m machine	set machine (e.g, amiga, i386, macppc)	[$machine]
     16  1.12   lukem 	-s setsdir	directory to find sets			[$setsdir]
     17  1.12   lukem 	-p prefix	prefix for created plist		[$prefix]
     18  1.12   lukem 	setname pkgname	set and package to build plist for
     19  1.12   lukem USAGE
     20  1.12   lukem 	exit 1
     21   1.1   jwise }
     22   1.1   jwise 
     23   1.1   jwise # handle args
     24  1.12   lukem while getopts a:m:ps: ch; do
     25  1.12   lukem 	case ${ch} in
     26  1.12   lukem 	a)
     27  1.12   lukem 		machine_arch=${OPTARG}
     28  1.12   lukem 		machine_cpu=$(arch_to_cpu ${OPTARG})
     29   1.1   jwise 		;;
     30  1.12   lukem 	m)
     31  1.12   lukem 		machine=${OPTARG}
     32   1.1   jwise 		;;
     33  1.12   lukem 	p)
     34  1.12   lukem 		prefix=${OPTARG}
     35   1.1   jwise 		;;
     36  1.12   lukem 	s)
     37  1.12   lukem 		setsdir=${OPTARG}
     38   1.1   jwise 		;;
     39  1.12   lukem 	*)
     40   1.1   jwise 		usage
     41   1.1   jwise 		;;
     42   1.1   jwise 	esac
     43   1.1   jwise done
     44  1.12   lukem shift $((${OPTIND} - 1))
     45  1.12   lukem if [ $# -ne 2 ]; then
     46   1.1   jwise 	usage
     47   1.1   jwise fi
     48  1.12   lukem setname="$1"
     49  1.12   lukem pkgname=$2
     50   1.7     agc 
     51   1.7     agc filename=/tmp/makeplist.$$ 
     52   1.7     agc ffilename=/tmp/makeplist.files.$$ 
     53   1.7     agc dfilename=/tmp/makeplist.dirs.$$ 
     54   1.7     agc 
     55   1.8  dyoung list_set_files $setname | \
     56  1.12   lukem     env PLISTPKG=$pkgname awk '
     57  1.12   lukem 	$2 == ENVIRON["PLISTPKG"] {
     58  1.12   lukem 		sub("^\\./", "", $1);
     59  1.12   lukem 		print $1
     60  1.12   lukem 	}' | sort -u > $filename
     61   1.8  dyoung 
     62   1.8  dyoung SELECTDIRS="-maxdepth 0 -type d"
     63   1.8  dyoung SELECTNONDIRS="-maxdepth 0 ! -type d"
     64   1.8  dyoung 
     65   1.8  dyoung cd $prefix
     66   1.8  dyoung #
     67   1.8  dyoung # match the directories
     68   1.8  dyoung #
     69   1.8  dyoung xargs echo $SELECTDIRS < $filename | \
     70   1.8  dyoung while read ignore ignore ignore ignore args; do
     71   1.8  dyoung 	[ -z "$args" ] && break 
     72   1.8  dyoung 	find $args $SELECTDIRS
     73   1.8  dyoung done | awk '{ print "@dirrm " $1; }' > $dfilename
     74   1.8  dyoung 
     75   1.8  dyoung #
     76   1.8  dyoung # match the non-directories
     77   1.8  dyoung #
     78   1.8  dyoung xargs echo $SELECTNONDIRS < $filename | \
     79   1.8  dyoung while read ignore ignore ignore ignore ignore args; do
     80   1.8  dyoung 	[ -z "$args" ] && break 
     81   1.8  dyoung 	find $args $SELECTNONDIRS
     82   1.8  dyoung done > $ffilename
     83   1.8  dyoung 
     84   1.8  dyoung cd -
     85   1.7     agc 
     86   1.7     agc echo "@cwd $prefix"
     87   1.7     agc if [ -s $ffilename ]; then
     88   1.7     agc 	cat $ffilename
     89   1.1   jwise fi
     90   1.7     agc if [ -s $dfilename ]; then
     91   1.7     agc         sort -r $dfilename
     92   1.7     agc fi
     93   1.7     agc 
     94   1.7     agc rm -f $filename $ffilename $dfilename
     95   1.7     agc 
     96   1.7     agc exit 0
     97