11.1Sjwise#!/bin/sh 21.1Sjwise# 31.1Sjwise# Print out the files in some or all lists. 41.19Sapb# Usage: makeplist [options] setname pkgname 51.19Sapb# options: 61.19Sapb# -a arch set arch (e.g, m68k, mips, powerpc) 71.19Sapb# -m machine set machine (e.g, amiga, i386, macppc) 81.19Sapb# -s setsdir directory to find sets 91.19Sapb# -p prefix prefix for package creation 101.19Sapb# -I realprefix prefix for eventual installation 111.19Sapb# setname pkgname set and package to build plist for 121.1Sjwise# 131.1Sjwise 141.18Sapbrundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/" 151.18Sapb. "${rundir}/sets.subr" 161.1Sjwiseprefix=/ 171.19Sapbrealprefix=/ 181.19Sapbgot_realprefix=false 191.1Sjwise 201.19Sapbusage() { 211.12Slukem cat 1>&2 <<USAGE 221.19SapbUsage: $0 [options] setname pkgname" 231.19Sapboptions:" 241.18Sapb -a arch set arch (e.g, m68k, mips, powerpc) [${MACHINE_ARCH}] 251.18Sapb -m machine set machine (e.g, amiga, i386, macppc) [${MACHINE}] 261.18Sapb -s setsdir directory to find sets [${setsdir}] 271.18Sapb -p prefix prefix for created plist [${prefix}] 281.19Sapb -I realprefix prefix for eventual installation [${realprefix}] 291.12Slukem setname pkgname set and package to build plist for 301.12SlukemUSAGE 311.12Slukem exit 1 321.1Sjwise} 331.1Sjwise 341.23Schristosumask 022 351.1Sjwise# handle args 361.19Sapbwhile getopts a:I:m:p:s: ch; do 371.12Slukem case ${ch} in 381.12Slukem a) 391.18Sapb MACHINE_ARCH="${OPTARG}" 401.18Sapb MACHINE_CPU="$(arch_to_cpu "${OPTARG}")" 411.1Sjwise ;; 421.19Sapb I) 431.19Sapb realprefix=${OPTARG} 441.19Sapb got_realprefix=true 451.19Sapb ;; 461.12Slukem m) 471.18Sapb MACHINE="${OPTARG}" 481.1Sjwise ;; 491.12Slukem p) 501.18Sapb prefix="${OPTARG}" 511.1Sjwise ;; 521.12Slukem s) 531.18Sapb setsdir="${OPTARG}" 541.1Sjwise ;; 551.12Slukem *) 561.1Sjwise usage 571.1Sjwise ;; 581.1Sjwise esac 591.1Sjwisedone 601.12Slukemshift $((${OPTIND} - 1)) 611.12Slukemif [ $# -ne 2 ]; then 621.1Sjwise usage 631.1Sjwisefi 641.12Slukemsetname="$1" 651.18Sapbpkgname="$2" 661.7Sagc 671.19Sapbif ! ${got_realprefix}; then 681.19Sapb realprefix="${prefix}" 691.19Sapbfi 701.19Sapb 711.18Sapbfilename="/tmp/makeplist.$$" 721.18Sapbffilename="/tmp/makeplist.files.$$" 731.18Sapbdfilename="/tmp/makeplist.dirs.$$" 741.7Sagc 751.18Sapblist_set_files "${setname}" | \ 761.18Sapb ${ENV_CMD} PLISTPKG="${pkgname}" ${AWK} ' 771.12Slukem $2 == ENVIRON["PLISTPKG"] { 781.12Slukem sub("^\\./", "", $1); 791.12Slukem print $1 801.18Sapb }' | ${SORT} -u > "${filename}" 811.8Sdyoung 821.16SdyoungSELECTDIRS="-prune -type d" 831.16SdyoungSELECTNONDIRS="! -type d -print -o ( -type d -prune )" 841.8Sdyoung 851.19Sapb# 861.19Sapb# XXX: The "lists" do not differentiate between directories and files. 871.19Sapb# But we need to differentiate between them, so we do so by checking 881.19Sapb# what's actually present in the file system. Files or directories that 891.19Sapb# are listed in the "lists" but that do not exist in the file system end 901.19Sapb# up not appearing in our output, and this subverts a large part of the 911.19Sapb# purpose of the "lists". 921.19Sapb# 931.19Sapb# XXX: Given that we have to figure out what is or is not a directory 941.19Sapb# without assistance from the "lists", it would be much more efficient 951.19Sapb# to consult the metalog instead of the file system. 961.19Sapb# 971.19Sapb 981.20Sapb( 991.18Sapbcd "${prefix}" 1001.20Sapb 1011.8Sdyoung# 1021.16Sdyoung# Match the directories. Use find(1) to avoid repeat calls to 1031.16Sdyoung# 'test -d'. 1041.16Sdyoung# 1051.16Sdyoung# This is a little clever. I cannot use 'xargs find', because 1061.16Sdyoung# find wants for the option arguments to follow the path arguments. 1071.18Sapb# So I use 'xargs echo ${SELECTDIRS}' to make a maximum-length proto-command 1081.16Sdyoung# line. I use 'read' to peel the options off the front of the 1091.18Sapb# command-line, and 'find ${args} ${SELECTDIRS}' to put them at the end. 1101.8Sdyoung# 1111.18Sapbxargs echo ${SELECTDIRS} < "${filename}" | \ 1121.16Sdyoungwhile read ignore ignore ignore args; do 1131.18Sapb [ -z "${args}" ] && break 1141.18Sapb ${FIND} ${args} ${SELECTDIRS} 1151.21Sukidone | ${AWK} '{ print "@pkgdir " $1; }' > "${dfilename}" 1161.8Sdyoung 1171.8Sdyoung# 1181.16Sdyoung# Match the non-directories. Use find(1) to avoid repeat calls to 1191.16Sdyoung# 'test ! -d'. See 'Match the directories' for an explanation of the 1201.16Sdyoung# cleverness. 1211.8Sdyoung# 1221.18Sapbxargs echo ${SELECTNONDIRS} < "${filename}" | \ 1231.16Sdyoungwhile read ignore ignore ignore ignore ignore ignore ignore ignore ignore \ 1241.16Sdyoung ignore args; do 1251.18Sapb [ -z "${args}" ] && break 1261.18Sapb ${FIND} ${args} ${SELECTNONDIRS} 1271.18Sapbdone > "${ffilename}" 1281.8Sdyoung 1291.20Sapb) 1301.7Sagc 1311.19Sapbecho "@cwd ${realprefix}" 1321.18Sapbif [ -s "${ffilename}" ]; then 1331.18Sapb cat "${ffilename}" 1341.1Sjwisefi 1351.18Sapbif [ -s "${dfilename}" ]; then 1361.18Sapb ${SORT} -r "${dfilename}" 1371.7Sagcfi 1381.7Sagc 1391.18Sapbrm -f "${filename}" "${ffilename}" "${dfilename}" 1401.7Sagc 1411.7Sagcexit 0 142