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
|
|
|
|
#
|
|
|
|
# culldeps
|
|
|
|
#
|
|
|
|
# Filter redundant dependencies.
|
|
|
|
#
|
2006-01-08 13:19:07 +03:00
|
|
|
# Each line of input and output contains two syspkg names,
|
|
|
|
# where the first syspkg depends on the second syspkg.
|
|
|
|
#
|
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
|
|
|
# Emit all the dependencies on the standard input to the standard
|
|
|
|
# output EXCEPT the dependencies which can be derived from other
|
|
|
|
# dependencies by the transitive rule. For example, omit both A C
|
|
|
|
# and A D from
|
|
|
|
#
|
|
|
|
# A B
|
|
|
|
# B C
|
|
|
|
# C D
|
|
|
|
# A C
|
|
|
|
# A D
|
|
|
|
#
|
|
|
|
# because A C can be derived from A B and B C by transitivity,
|
|
|
|
# and A D can be derived from A B, B C, C D by transitivity.
|
|
|
|
#
|
|
|
|
|
2006-01-03 21:31:09 +03:00
|
|
|
prog="${0##*/}"
|
2006-01-04 16:38:18 +03:00
|
|
|
rundir="$(dirname "$0")" # ${0%/*} isn't good enough when there's no "/"
|
|
|
|
. "${rundir}/sets.subr"
|
|
|
|
|
2006-01-03 21:31:09 +03:00
|
|
|
SCRATCH="$(${MKTEMP} -d "/var/tmp/${prog}.XXXXXX")"
|
|
|
|
NEXTLEFTOVERS="${SCRATCH}/leftovers0"
|
|
|
|
LASTJOIN="${SCRATCH}/join0"
|
|
|
|
NEXTJOIN="${SCRATCH}/join1"
|
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
|
|
|
TAB=" "
|
|
|
|
|
2006-01-03 21:31:09 +03:00
|
|
|
${SORT} -k 1 > "${LASTJOIN}"
|
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
|
|
|
|
2006-01-03 21:31:09 +03:00
|
|
|
LEFTOVERS="${LASTJOIN}"
|
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
|
|
|
|
2006-01-03 21:31:09 +03:00
|
|
|
while [ "$(${WC} -l "${LASTJOIN}" | ${AWK} '{ print $1; }')" -ne 0 ]; do
|
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
|
|
|
|
|
|
|
#
|
2006-01-03 21:31:09 +03:00
|
|
|
# From dependencies X-requires-Y in ${LEFTOVERS} and Y-requires-Z in
|
|
|
|
# ${LASTJOIN}, produce dependencies X-requires-Z and write them to
|
|
|
|
# ${NEXTJOIN}.
|
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
|
|
|
#
|
2006-01-03 21:31:09 +03:00
|
|
|
${SORT} -k 2 < "${LEFTOVERS}" | \
|
|
|
|
${JOIN} -1 2 -2 1 -o '1.1 2.2' - "${LASTJOIN}" | \
|
|
|
|
${SORT} -u > "${NEXTJOIN}"
|
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 [ ${DEBUG:-0} -gt 0 ]; then
|
2006-01-08 13:10:03 +03:00
|
|
|
echo >&2 "${prog}: ### begin filtered results ###"
|
2006-01-03 21:31:09 +03:00
|
|
|
${JOIN} -t "${TAB}" "${NEXTJOIN}" "${LEFTOVERS}" | ${SORT} 1>&2
|
2006-01-08 13:10:03 +03:00
|
|
|
echo >&2 "${prog}: ### end filtered results ###"
|
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
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
2006-01-03 21:31:09 +03:00
|
|
|
# Filter out of ${LEFTOVERS} all of the dependencies X-requires-Z, which
|
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
|
|
|
# were produced in the previous step. Write the new leftovers to
|
2006-01-03 21:31:09 +03:00
|
|
|
# ${NEXTLEFTOVERS}.
|
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
|
|
|
#
|
2006-01-03 21:31:09 +03:00
|
|
|
${JOIN} -v 2 -t "${TAB}" "${NEXTJOIN}" "${LEFTOVERS}" | \
|
|
|
|
${SORT} -u > "${NEXTLEFTOVERS}"
|
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
|
|
|
|
|
|
|
#
|
|
|
|
# Swap output files before repeating.
|
|
|
|
#
|
2006-01-03 21:31:09 +03:00
|
|
|
LASTJOIN="${NEXTJOIN}"
|
|
|
|
if [ "$(basename "${NEXTJOIN}")" = join0 ]; then
|
|
|
|
NEXTJOIN="${SCRATCH}/join1"
|
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
|
|
|
else
|
2006-01-03 21:31:09 +03:00
|
|
|
NEXTJOIN="${SCRATCH}/join0"
|
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
|
|
|
fi
|
2006-01-03 21:31:09 +03:00
|
|
|
LEFTOVERS="${NEXTLEFTOVERS}"
|
|
|
|
if [ "$(basename "${NEXTLEFTOVERS}")" = leftovers0 ]; then
|
|
|
|
NEXTLEFTOVERS="${SCRATCH}/leftovers1"
|
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
|
|
|
else
|
2006-01-03 21:31:09 +03:00
|
|
|
NEXTLEFTOVERS="${SCRATCH}/leftovers0"
|
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
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
#
|
|
|
|
# Output all of the dependencies that were not culled and clean up.
|
|
|
|
#
|
2006-01-03 21:31:09 +03:00
|
|
|
cat "${LEFTOVERS}"
|
|
|
|
rm -r "${SCRATCH}"
|