syspkgdeps revision 1.3
1#!/bin/sh 2# 3# syspkgdeps [-a arch] [-m machine] [-s setsdir] [-p prefix] sets 4# 5# Compute naive package dependencies based on file & directory 6# nesting. E.g., if pkg P contains /foo/bar and Q contains /foo, 7# then Q is considered a dependency of P. 8# 9 10#set -u 11 12: ${TOOL_DB=db} 13DB="${TOOL_DB} -q" 14 15# 16# set defaults and import setlist subroutines 17# 18. ./sets.subr 19prefix=/ 20 21usage() 22{ 23 cat 1>&2 <<USAGE 24Usage: ${0##*/} [-a arch] [-m machine] [-s setsdir] [-p prefix] setname [...] 25 -a arch set arch (e.g, m68k, mips, powerpc) [$machine_arch] 26 -m machine set machine (e.g, amiga, i386, macppc) [$machine] 27 -s setsdir directory to find sets [$setsdir] 28 -p prefix prefix for created plist [$prefix] 29 setname [...] sets to find dependencies for 30USAGE 31 exit 1 32} 33 34# parse arguments 35while getopts a:m:ps: ch; do 36 case ${ch} in 37 a) 38 machine_arch=${OPTARG} 39 machine_cpu=$(arch_to_cpu ${OPTARG}) 40 ;; 41 m) 42 machine=${OPTARG} 43 ;; 44 p) 45 prefix=${OPTARG} 46 ;; 47 s) 48 setsdir=${OPTARG} 49 ;; 50 *) 51 usage 52 ;; 53 esac 54done 55shift $((${OPTIND} - 1)) 56if [ $# -lt 1 ]; then 57 usage 58fi 59 60sets=$@ 61 62# TBD clean up 63SCRATCH=$(mktemp -d /var/tmp/$(basename $0).XXXXXX) 64 65[ $? -ne 0 ] && { echo "Could not create scratch directory." 1>&2 ; exit 1 ; } 66 67PATH_MEMBERSHIP=$SCRATCH/path-membership 68PATH_TO_PKGNAME=$SCRATCH/pathpkg.db 69PARENT_PKGNAMES=$SCRATCH/parent-pkgnames 70PARENT_PATHNAMES=$SCRATCH/parent-pathnames 71 72echo "indexing packages by pathnames" 1>&2 73 74list_set_files $sets | sed 's/^\.\///' | \ 75env PREFIX=$prefix awk '{ 76 if ($1 == ".") { 77 print ENVIRON["PREFIX"] " " $2; 78 } else { 79 print ENVIRON["PREFIX"] $1 " " $2; 80 } 81}' | sort -k 1 -u > $PATH_MEMBERSHIP 82 83$DB -w -f - btree $PATH_TO_PKGNAME < $PATH_MEMBERSHIP || echo "shit" 1>&2 84 85echo "computing parent pathnames" 1>&2 86 87while read pathname pkgname; do 88 # print parent pathname 89 dirname $pathname 90done < $PATH_MEMBERSHIP > $PARENT_PATHNAMES 91 92echo "selecting parent packages using parent pathnames" 1>&2 93 94$DB -f - btree $PATH_TO_PKGNAME < $PARENT_PATHNAMES | \ 95 paste $PATH_MEMBERSHIP - | \ 96 awk '{ if ($2 != $4) print $2 " " $4; }' | sort -u | ./culldeps 97 98if [ $? -ne 0 ]; then 99 echo "error in parent-directory lookup, aborting" 1>&2 100 exit 1 101fi 102