For System Packages, two new utilities, a subroutine library, and
a new list:
sets.subr -- The set-listing code that is common to makeplist,
makeflist, and regpkg has moved here.
syspkgdeps -- Compute naive dependencies for system packages based
on directory containment. I.e., if package A contains
path /p/q, and package B contains path /p, then B is
considered a dependency of A. As Jim Wise remarks,
this is not quite right: system-package dependencies
should indicate a functional dependency. Nevertheless,
these naive dependencies protect us from orphaning
files when pkg_delete'ing system packages.
culldeps -- Helper for syspkgdeps. Removes redundant dependencies
from a dependencies table. Essentially does the opposite
of a transitive closure on a dependencies table: if
the table contains A depends-on B, B depends-on C, and
A depends-on C, then A depends-on C is removed because
it can be derived from the prior two dependencies.
deps -- Dependencies computed by syspkgdeps.
2003-06-23 13:02:31 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# syspkgdeps [-a arch] [-m machine] [-s setsdir] [-p prefix] sets
|
|
|
|
#
|
|
|
|
# Compute naive package dependencies based on file & directory
|
|
|
|
# nesting. E.g., if pkg P contains /foo/bar and Q contains /foo,
|
|
|
|
# then Q is considered a dependency of P.
|
|
|
|
#
|
|
|
|
|
|
|
|
#set -u
|
|
|
|
|
2003-12-29 06:13:25 +03:00
|
|
|
: ${TOOL_DB=db}
|
|
|
|
DB="${TOOL_DB} -q"
|
For System Packages, two new utilities, a subroutine library, and
a new list:
sets.subr -- The set-listing code that is common to makeplist,
makeflist, and regpkg has moved here.
syspkgdeps -- Compute naive dependencies for system packages based
on directory containment. I.e., if package A contains
path /p/q, and package B contains path /p, then B is
considered a dependency of A. As Jim Wise remarks,
this is not quite right: system-package dependencies
should indicate a functional dependency. Nevertheless,
these naive dependencies protect us from orphaning
files when pkg_delete'ing system packages.
culldeps -- Helper for syspkgdeps. Removes redundant dependencies
from a dependencies table. Essentially does the opposite
of a transitive closure on a dependencies table: if
the table contains A depends-on B, B depends-on C, and
A depends-on C, then A depends-on C is removed because
it can be derived from the prior two dependencies.
deps -- Dependencies computed by syspkgdeps.
2003-06-23 13:02:31 +04:00
|
|
|
|
|
|
|
#
|
|
|
|
# set defaults and import setlist subroutines
|
|
|
|
#
|
|
|
|
. ./sets.subr
|
|
|
|
prefix=/
|
|
|
|
|
2003-12-29 06:13:25 +03:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat 1>&2 <<USAGE
|
|
|
|
Usage: ${0##*/} [-a arch] [-m machine] [-s setsdir] [-p prefix] setname [...]
|
2004-01-03 05:38:58 +03:00
|
|
|
-a arch set arch (e.g, m68k, mips, powerpc) [$MACHINE_ARCH]
|
|
|
|
-m machine set machine (e.g, amiga, i386, macppc) [$MACHINE]
|
2003-12-29 06:13:25 +03:00
|
|
|
-s setsdir directory to find sets [$setsdir]
|
|
|
|
-p prefix prefix for created plist [$prefix]
|
|
|
|
setname [...] sets to find dependencies for
|
|
|
|
USAGE
|
|
|
|
exit 1
|
For System Packages, two new utilities, a subroutine library, and
a new list:
sets.subr -- The set-listing code that is common to makeplist,
makeflist, and regpkg has moved here.
syspkgdeps -- Compute naive dependencies for system packages based
on directory containment. I.e., if package A contains
path /p/q, and package B contains path /p, then B is
considered a dependency of A. As Jim Wise remarks,
this is not quite right: system-package dependencies
should indicate a functional dependency. Nevertheless,
these naive dependencies protect us from orphaning
files when pkg_delete'ing system packages.
culldeps -- Helper for syspkgdeps. Removes redundant dependencies
from a dependencies table. Essentially does the opposite
of a transitive closure on a dependencies table: if
the table contains A depends-on B, B depends-on C, and
A depends-on C, then A depends-on C is removed because
it can be derived from the prior two dependencies.
deps -- Dependencies computed by syspkgdeps.
2003-06-23 13:02:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
# parse arguments
|
2003-12-29 06:13:25 +03:00
|
|
|
while getopts a:m:ps: ch; do
|
|
|
|
case ${ch} in
|
|
|
|
a)
|
2004-01-03 05:38:58 +03:00
|
|
|
MACHINE_ARCH=${OPTARG}
|
|
|
|
MACHINE_CPU=$(arch_to_cpu ${OPTARG})
|
For System Packages, two new utilities, a subroutine library, and
a new list:
sets.subr -- The set-listing code that is common to makeplist,
makeflist, and regpkg has moved here.
syspkgdeps -- Compute naive dependencies for system packages based
on directory containment. I.e., if package A contains
path /p/q, and package B contains path /p, then B is
considered a dependency of A. As Jim Wise remarks,
this is not quite right: system-package dependencies
should indicate a functional dependency. Nevertheless,
these naive dependencies protect us from orphaning
files when pkg_delete'ing system packages.
culldeps -- Helper for syspkgdeps. Removes redundant dependencies
from a dependencies table. Essentially does the opposite
of a transitive closure on a dependencies table: if
the table contains A depends-on B, B depends-on C, and
A depends-on C, then A depends-on C is removed because
it can be derived from the prior two dependencies.
deps -- Dependencies computed by syspkgdeps.
2003-06-23 13:02:31 +04:00
|
|
|
;;
|
2003-12-29 06:13:25 +03:00
|
|
|
m)
|
2004-01-03 05:38:58 +03:00
|
|
|
MACHINE=${OPTARG}
|
For System Packages, two new utilities, a subroutine library, and
a new list:
sets.subr -- The set-listing code that is common to makeplist,
makeflist, and regpkg has moved here.
syspkgdeps -- Compute naive dependencies for system packages based
on directory containment. I.e., if package A contains
path /p/q, and package B contains path /p, then B is
considered a dependency of A. As Jim Wise remarks,
this is not quite right: system-package dependencies
should indicate a functional dependency. Nevertheless,
these naive dependencies protect us from orphaning
files when pkg_delete'ing system packages.
culldeps -- Helper for syspkgdeps. Removes redundant dependencies
from a dependencies table. Essentially does the opposite
of a transitive closure on a dependencies table: if
the table contains A depends-on B, B depends-on C, and
A depends-on C, then A depends-on C is removed because
it can be derived from the prior two dependencies.
deps -- Dependencies computed by syspkgdeps.
2003-06-23 13:02:31 +04:00
|
|
|
;;
|
2003-12-29 06:13:25 +03:00
|
|
|
p)
|
|
|
|
prefix=${OPTARG}
|
For System Packages, two new utilities, a subroutine library, and
a new list:
sets.subr -- The set-listing code that is common to makeplist,
makeflist, and regpkg has moved here.
syspkgdeps -- Compute naive dependencies for system packages based
on directory containment. I.e., if package A contains
path /p/q, and package B contains path /p, then B is
considered a dependency of A. As Jim Wise remarks,
this is not quite right: system-package dependencies
should indicate a functional dependency. Nevertheless,
these naive dependencies protect us from orphaning
files when pkg_delete'ing system packages.
culldeps -- Helper for syspkgdeps. Removes redundant dependencies
from a dependencies table. Essentially does the opposite
of a transitive closure on a dependencies table: if
the table contains A depends-on B, B depends-on C, and
A depends-on C, then A depends-on C is removed because
it can be derived from the prior two dependencies.
deps -- Dependencies computed by syspkgdeps.
2003-06-23 13:02:31 +04:00
|
|
|
;;
|
2003-12-29 06:13:25 +03:00
|
|
|
s)
|
|
|
|
setsdir=${OPTARG}
|
For System Packages, two new utilities, a subroutine library, and
a new list:
sets.subr -- The set-listing code that is common to makeplist,
makeflist, and regpkg has moved here.
syspkgdeps -- Compute naive dependencies for system packages based
on directory containment. I.e., if package A contains
path /p/q, and package B contains path /p, then B is
considered a dependency of A. As Jim Wise remarks,
this is not quite right: system-package dependencies
should indicate a functional dependency. Nevertheless,
these naive dependencies protect us from orphaning
files when pkg_delete'ing system packages.
culldeps -- Helper for syspkgdeps. Removes redundant dependencies
from a dependencies table. Essentially does the opposite
of a transitive closure on a dependencies table: if
the table contains A depends-on B, B depends-on C, and
A depends-on C, then A depends-on C is removed because
it can be derived from the prior two dependencies.
deps -- Dependencies computed by syspkgdeps.
2003-06-23 13:02:31 +04:00
|
|
|
;;
|
|
|
|
*)
|
2003-12-29 06:13:25 +03:00
|
|
|
usage
|
For System Packages, two new utilities, a subroutine library, and
a new list:
sets.subr -- The set-listing code that is common to makeplist,
makeflist, and regpkg has moved here.
syspkgdeps -- Compute naive dependencies for system packages based
on directory containment. I.e., if package A contains
path /p/q, and package B contains path /p, then B is
considered a dependency of A. As Jim Wise remarks,
this is not quite right: system-package dependencies
should indicate a functional dependency. Nevertheless,
these naive dependencies protect us from orphaning
files when pkg_delete'ing system packages.
culldeps -- Helper for syspkgdeps. Removes redundant dependencies
from a dependencies table. Essentially does the opposite
of a transitive closure on a dependencies table: if
the table contains A depends-on B, B depends-on C, and
A depends-on C, then A depends-on C is removed because
it can be derived from the prior two dependencies.
deps -- Dependencies computed by syspkgdeps.
2003-06-23 13:02:31 +04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2003-12-29 06:13:25 +03:00
|
|
|
shift $((${OPTIND} - 1))
|
For System Packages, two new utilities, a subroutine library, and
a new list:
sets.subr -- The set-listing code that is common to makeplist,
makeflist, and regpkg has moved here.
syspkgdeps -- Compute naive dependencies for system packages based
on directory containment. I.e., if package A contains
path /p/q, and package B contains path /p, then B is
considered a dependency of A. As Jim Wise remarks,
this is not quite right: system-package dependencies
should indicate a functional dependency. Nevertheless,
these naive dependencies protect us from orphaning
files when pkg_delete'ing system packages.
culldeps -- Helper for syspkgdeps. Removes redundant dependencies
from a dependencies table. Essentially does the opposite
of a transitive closure on a dependencies table: if
the table contains A depends-on B, B depends-on C, and
A depends-on C, then A depends-on C is removed because
it can be derived from the prior two dependencies.
deps -- Dependencies computed by syspkgdeps.
2003-06-23 13:02:31 +04:00
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
sets=$@
|
|
|
|
|
|
|
|
# TBD clean up
|
|
|
|
SCRATCH=$(mktemp -d /var/tmp/$(basename $0).XXXXXX)
|
|
|
|
|
|
|
|
[ $? -ne 0 ] && { echo "Could not create scratch directory." 1>&2 ; exit 1 ; }
|
|
|
|
|
|
|
|
PATH_MEMBERSHIP=$SCRATCH/path-membership
|
|
|
|
PATH_TO_PKGNAME=$SCRATCH/pathpkg.db
|
|
|
|
PARENT_PKGNAMES=$SCRATCH/parent-pkgnames
|
|
|
|
PARENT_PATHNAMES=$SCRATCH/parent-pathnames
|
|
|
|
|
|
|
|
echo "indexing packages by pathnames" 1>&2
|
|
|
|
|
|
|
|
list_set_files $sets | sed 's/^\.\///' | \
|
|
|
|
env PREFIX=$prefix awk '{
|
|
|
|
if ($1 == ".") {
|
|
|
|
print ENVIRON["PREFIX"] " " $2;
|
|
|
|
} else {
|
|
|
|
print ENVIRON["PREFIX"] $1 " " $2;
|
|
|
|
}
|
|
|
|
}' | sort -k 1 -u > $PATH_MEMBERSHIP
|
|
|
|
|
|
|
|
$DB -w -f - btree $PATH_TO_PKGNAME < $PATH_MEMBERSHIP || echo "shit" 1>&2
|
|
|
|
|
|
|
|
echo "computing parent pathnames" 1>&2
|
|
|
|
|
|
|
|
while read pathname pkgname; do
|
|
|
|
# print parent pathname
|
|
|
|
dirname $pathname
|
|
|
|
done < $PATH_MEMBERSHIP > $PARENT_PATHNAMES
|
|
|
|
|
|
|
|
echo "selecting parent packages using parent pathnames" 1>&2
|
|
|
|
|
|
|
|
$DB -f - btree $PATH_TO_PKGNAME < $PARENT_PATHNAMES | \
|
|
|
|
paste $PATH_MEMBERSHIP - | \
|
|
|
|
awk '{ if ($2 != $4) print $2 " " $4; }' | sort -u | ./culldeps
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "error in parent-directory lookup, aborting" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|