# ================================================
APPNAME=`basename $0`
-MYVERSION=1.1.0+toward_1.2.0_20120729234736
+MYVERSION=1.1.0+toward_1.2.0_20120731060658
PREFIX=${PREFIX:-/usr/local}
CONFFILE=${PREFIX}/etc/${APPNAME}.conf
globlist1=$1
globlist2=$2
listpath=$3
- mode=$3
+ mode=$4
dirpath=`dirname "$listpath"`
- for glob in `echo $globlist1 | sed 's/,/ /g'` $globlist2
+ echo "`echo "$globlist1" | sed 's/,/ /g'`" "$globlist2" | sed -E 's/ +/\
+/g' | grep -v '^$' | while read glob
do
if expr "@$glob" : '^@[^/][^/]*/[^/][^/]*$' > /dev/null 2> /dev/null
then
pkg=`pkg_info -qO "$origin"`
if [ -n "$pkg" ]
then
- $target_dir=${DBDIR}/initial/$origin
+ target_dir=${DBDIR}/initial/$origin
[ -d "$target_dir" ] || mkdir -p "$target_dir"
echo $pkg > $target_dir/installed_version
pkg_info -qr "$pkg" | grep '^@pkgdep ' | sed 's/^@pkgdep[[:space:]]*//' | while read requirement
do
- pkg_info -o "$requirement"
- done > $target_dir/requires
+ pkg_info -e "$requirement" || continue
+ pkg_info -qo "$requirement" >> $target_dir/requires
+ done
pkg_info -qR "$pkg" | grep -v '^$' | while read dependent
do
- pkg_info -o "$dependent"
- done > $target_dir/dependents
+ pkg_info -e "$dependent" || continue
+ pkg_info -qo "$dependent" >> $target_dir/dependents
+ done
fi
origin_src=
if [ `echo $origin | grep -m 1 -E -f "${DBDIR}/REPLACE.grep_from_pattern.conflist" | wc -l` -eq 1 ]
local prefix _is_all _is_target _is_required _is_former_required _is_dependent _is_former_dependent _is_relevant
prefix=$1
origin=$2
- _is_all=y
- _is_target=
- _is_required=
- _is_former_required=
- _is_dependent=
- _is_former_dependent=
- _is_relevant=y
- if [ `cat "${DBDIR}/target_required_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
+ if [ -e "${DBDIR}/requires/$origin/chk_if_target.param" ]
then
- _is_all=
- if [ ! -f "${DBDIR}/requires/$origin/dependents.pattern" ]
- then
- str_escape_regexp_filter < "${DBDIR}/requires/$origin/dependents" | sed 's/^/^/;s/$/$/' > "${DBDIR}/requires/$origin/dependents.pattern" 2> /dev/null || :
- fi
- if [ -e "${DBDIR}/initial/$origin/dependents" -a ! -f "${DBDIR}/initial/$origin/dependents.pattern" ]
- then
- str_escape_regexp_filter < "${DBDIR}/initial/$origin/dependents" | sed 's/^/^/;s/$/$/' > "${DBDIR}/initial/$origin/dependents.pattern" 2> /dev/null || :
- fi
- if grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
- then
- _is_target=y
- elif grep -m 1 -E -f "${DBDIR}/requires/$origin/dependents.pattern" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
- then
- _is_required=y
- elif [ -e "${DBDIR}/initial/$origin/dependents.pattern" ]
+ . "${DBDIR}/requires/$origin/chk_if_target.param"
+ else
+ _is_all=y
+ _is_target=
+ _is_required=
+ _is_former_required=
+ _is_dependent=
+ _is_former_dependent=
+ _is_relevant=y
+ if [ `cat "${DBDIR}/target_required_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
then
- if grep -m 1 -E -f "${DBDIR}/initial/$origin/dependents.pattern" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
+ _is_all=
+ if grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
+ then
+ _is_target=y
+ elif [ -e "${DBDIR}/requires/$origin/dependents.pattern" ] && grep -m 1 -E -f "${DBDIR}/requires/$origin/dependents.pattern" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
+ then
+ _is_required=y
+ elif [ -e "${DBDIR}/initial/$origin/dependents.pattern" ] && grep -m 1 -E -f "${DBDIR}/initial/$origin/dependents.pattern" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
then
_is_former_required=y
fi
fi
- fi
- if [ `cat "${DBDIR}/target_dependent_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
- then
- _is_all=
- if [ ! -f "${DBDIR}/requires/$origin/requires.pattern" ]
- then
- str_escape_regexp_filter < "${DBDIR}/requires/$origin/requires" | sed 's/^/^/;s/$/$/' > "${DBDIR}/requires/$origin/requires.pattern" 2> /dev/null || :
- fi
- if [ -e "${DBDIR}/initial/$origin/requires" -a ! -f "${DBDIR}/initial/$origin/requires.pattern" ]
- then
- str_escape_regexp_filter < "${DBDIR}/initial/$origin/requires" | sed 's/^/^/;s/$/$/' > "${DBDIR}/initial/$origin/requires.pattern" 2> /dev/null || :
- fi
- if [ -n "${_is_target}" ] || grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
- then
- _is_target=y
- elif grep -m 1 -E -f "${DBDIR}/requires/$origin/requires.pattern" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
+ if [ `cat "${DBDIR}/target_dependent_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
then
- _is_dependent=y
- fi
- elif [ -e "${DBDIR}/initial/$origin/requires.pattern" ]
- then
- if grep -m 1 -E -f "${DBDIR}/initial/$origin/requires.pattern" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
+ _is_all=
+ if [ -n "${_is_target}" ] || grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
+ then
+ _is_target=y
+ elif [ -e "${DBDIR}/requires/$origin/requires.pattern" ] && grep -m 1 -E -f "${DBDIR}/requires/$origin/requires.pattern" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
+ then
+ _is_dependent=y
+ elif [ -e "${DBDIR}/initial/$origin/requires.pattern" ] && grep -m 1 -E -f "${DBDIR}/initial/$origin/requires.pattern" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
then
_is_former_dependent=y
fi
fi
+ [ -n "${_is_all}${_is_target}${_is_required}${_is_former_required}${_is_dependent}${_is_former_dependent}" ] || _is_relevant=
+ echo _is_all=${_is_all} > ${TMPDIR}/chk_if_target:results
+ echo _is_target=${_is_target} >> ${TMPDIR}/chk_if_target:results
+ echo _is_required=${_is_required} >> ${TMPDIR}/chk_if_target:results
+ echo _is_former_required=${_is_former_required} >> ${TMPDIR}/chk_if_target:results
+ echo _is_dependent=${_is_dependent} >> ${TMPDIR}/chk_if_target:results
+ echo _is_former_dependent=${_is_former_dependent} >> ${TMPDIR}/chk_if_target:results
+ echo _is_relevant=${_is_relevant} >> ${TMPDIR}/chk_if_target:results
+ mv "${TMPDIR}"/chk_if_target:results "${DBDIR}/requires/$origin/chk_if_target.param"
fi
- [ -n "${_is_all}${_is_target}${_is_required}${_is_former_required}${_is_dependent}${_is_former_dependent}" ] || _is_relevant=
eval ${prefix}_is_all=\$\{_is_all\}
eval ${prefix}_is_target=\$\{_is_target\}
eval ${prefix}_is_required=\$\{_is_required\}
eval ${prefix}_is_relevant=\$\{_is_relevant\}
}
+register_globs_only_installed ()
+{
+ local src1 src2
+ src1=$1
+ src2=$2
+ rm -f "${TMPDIR}/register_globs_only_installed:origins"
+ register_globs "$src1" "$src2" "${TMPDIR}/register_globs_only_installed:origins"
+ [ -e "${TMPDIR}/register_globs_only_installed:origins" ] || return 0
+ while read origin
+ do
+ [ -z `pkg_info -qO "$origin"` ] || echo $origin
+ done < ${TMPDIR}/register_globs_only_installed:origins
+}
+
+
# ==================================================
# ==================== MAIN ========================
# ==================================================
exit
;;
show)
- [ -d "${DBDIR}" ] || { echo "ERROR: Database has not built yet." >&2; exit 1; }
+ [ -e "${DBDIR}/COMPLETE_PREPARATION" ] || { echo "ERROR: Database has not built yet." >&2; exit 1; }
warn_update_ports
_filter_skip_unchanged=
_filter_only_target=
_filter_only_target=y
;;
requirements)
+ grandtitle="Dependencies based on the latest ports tree"
title="The following ports are required by %s:"
list=requires
_for_each_matching_port=y
;;
dependents)
-
+ grandtitle="Dependencies based on the latest ports tree"
title="The following ports depend on %s:"
list=dependents
_for_each_matching_port=y
exit 1
;;
esac
- [ -r "${DBDIR}/$list" ] || exit 0
+ [ -n "${_for_each_matching_port}" -o -r "${DBDIR}/$list" ] || exit 0
[ -e "${DBDIR}"/saved_options.sh ] && . "${DBDIR}"/saved_options.sh
if [ -n "${_for_each_matching_port}" ]
then
shift
[ $# -gt 0 ] || { echo "ERROR: the argument as port glob is missing" >&2; exit 1; }
+ echo "[$grandtitle]"
+ echo
isfirst=y
for origin_target in `ports_glob "$@"`
do
+ [ -e "${DBDIR}/requires/$origin_target/pkgtag" ] || continue
[ "$isfirst" = y ] || echo
isfirst=n
- [ -e "${DBDIR}/requires/$origin_target/pkgtag" ] || { echo "WARNING: the database for $origin_target is not ready" >&2; continue; }
- pkg_target=`cat "${DBDIR}/$pkgnamedb/$origin/pkgtag"`
+ pkg_target=`cat "${DBDIR}/$pkgnamedb/$origin_target/pkgtag"`
printf "$title\n" "$origin_target ($pkg_target)"
[ -e "${DBDIR}/requires/$origin_target/$list" ] || continue
while read origin
if [ ! -e "${DBDIR}/COMPLETE_PARSE_OPTION_TARGET_PORTS" ]
then
rm -f "${DBDIR}/target_dependent_ports.specified" "${DBDIR}/target_required_ports.specified"
- register_globs "$target_dependent_ports" "$target_dependent_ports_form2" "${DBDIR}/target_dependent_ports.specified"
- register_globs "$target_required_ports" "$target_required_ports_form2" "${DBDIR}/target_required_ports.specified"
+ register_globs_only_installed "$target_dependent_ports" "$target_dependent_ports_form2" > ${DBDIR}/target_dependent_ports.specified
+ register_globs_only_installed "$target_required_ports" "$target_required_ports_form2" > ${DBDIR}/target_required_ports.specified
+ if [ `cat "${DBDIR}"/target_dependent_ports.specified | wc -l` -gt 0 -a `cat "${DBDIR}"/target_required_ports.specified | wc -l` -gt 0 ]
+ then
+ echo "INFO: Ports/packages irrelevant to"
+ echo "----------------------------------------"
+ cat "${DBDIR}"/target_dependent_ports.specified
+ echo "----------------------------------------"
+ echo "nor their dependents, and irrelevant to"
+ echo "----------------------------------------"
+ cat "${DBDIR}"/target_required_ports.specified
+ echo "----------------------------------------"
+ echo "nor their requirements are skipped."
+ elif [ `cat "${DBDIR}"/target_dependent_ports.specified | wc -l` -gt 0 ]
+ then
+ echo "INFO: Ports/packages irrelevant to"
+ echo "----------------------------------------"
+ cat "${DBDIR}"/target_dependent_ports.specified
+ echo "----------------------------------------"
+ echo "nor their dependents are skipped."
+ elif [ `cat "${DBDIR}"/target_required_ports.specified | wc -l` -gt 0 ]
+ then
+ echo "INFO: Ports/packages irrelevant to"
+ echo "----------------------------------------"
+ cat "${DBDIR}"/target_required_ports.specified
+ echo "----------------------------------------"
+ echo "nor their requirements are skipped."
+ elif [ -n "$target_dependent_ports$target_dependent_ports_form2$target_required_ports$target_required_ports_form2" ]
+ then
+ echo "ERROR: Target ports are specified but none of them is valid." >&2
+ exit 1
+ fi
touch "${DBDIR}/COMPLETE_PARSE_OPTION_TARGET_PORTS"
fi
# Inspection of all dependencies
if [ ! -e "${DBDIR}/COMPLETE_COLLECED_ALL_DEPENDENCIES" ]
then
- echo "Starting to inspect dependencies of installed packages at `timestamp`"
+ echo "Starting to inspect dependencies of the all installed packages at `timestamp`"
+ [ -z "$target_dependent_ports$target_dependent_ports_form2$target_required_ports$target_required_ports_form2" ] || \
+ echo "INFO: Ports irrelevant to the targets are also inspected in order to get complete information."
[ -d "${DBDIR}/requires" ] || mkdir -p "${DBDIR}/requires"
touch "${DBDIR}/moved_or_lost.list"
touch "${DBDIR}/target.inspected.list"
echo
fi
+# Preparation of matching patterns of dependencies
+if [ ! -e "${DBDIR}/COMPLETE_PREPARATION_OF_MATCHING_PATTERNS_OF_DEPENDENCIES" ]
+then
+ echo "Starting preparation of matching patterns of dependencies at `timestamp`"
+ if [ -f "${DBDIR}/prepare_matching_patterns_dependencies.remain" ]
+ then
+ echo "INFO: Restarting from the previously terminated point"
+ else
+ find "${DBDIR}/requires" -depth 2 -type d > ${DBDIR}/prepare_matching_patterns_dependencies.remain
+ fi
+ cp "${DBDIR}/prepare_matching_patterns_dependencies.remain" "${DBDIR}/prepare_matching_patterns_dependencies"
+ while read dbpath
+ do
+ portname=`basename "$dbpath"`
+ catpath=`dirname "$dbpath"`
+ catname=`basename "$catpath"`
+ origin=$catname/$portname
+ [ ! -e "${DBDIR}/requires/$origin/dependents" ] || str_escape_regexp_filter < ${DBDIR}/requires/$origin/dependents | sed 's/^/^/;s/$/$/' > ${DBDIR}/requires/$origin/dependents.pattern
+ [ ! -e "${DBDIR}/initial/$origin/dependents" ] || str_escape_regexp_filter < ${DBDIR}/initial/$origin/dependents | sed 's/^/^/;s/$/$/' > ${DBDIR}/initial/$origin/dependents.pattern
+ [ ! -e "${DBDIR}/requires/$origin/requires" ] || str_escape_regexp_filter < ${DBDIR}/requires/$origin/requires | sed 's/^/^/;s/$/$/' > ${DBDIR}/requires/$origin/requires.pattern
+ [ ! -e "${DBDIR}/initial/$origin/requires" ] || str_escape_regexp_filter < ${DBDIR}/initial/$origin/requires | sed 's/^/^/;s/$/$/' > ${DBDIR}/initial/$origin/requires.pattern
+ chk_if_target currentorigin "$origin"
+ sed -i '' 1d "${DBDIR}/prepare_matching_patterns_dependencies.remain"
+ done < ${DBDIR}/prepare_matching_patterns_dependencies
+ touch "${DBDIR}/COMPLETE_PREPARATION_OF_MATCHING_PATTERNS_OF_DEPENDENCIES"
+ echo
+fi
+
# Inspection of necessary updates
if [ ! -e "${DBDIR}/COMPLETE_NECESSARY_UPDATES" ]
then
# ------- Main operations -------
+if [ ! -e "${DBDIR}/COMPLETE_PREPARATION" ]
+then
+ touch "${DBDIR}/COMPLETE_PREPARATION"
+fi
+
if [ "$command" = prepare ]
then
echo "Done (skipped reinstallation) at `timestamp`"
\fB\-N\fR
Renew option settings.
This option is effective only with \fBredo\fR command.
-Option settings for \fB\-s\fR, \fB\-q\fR and \fB\-d\R are reset according to the simultaneously given ones.
+Option settings for \fB\-s\fR, \fB\-q\fR and \fB\-d\fR are reset according to the simultaneously given ones.
.SH DETAILS
This utility realizes smart reinstallation of a large number of ports by allowing you to run when when the machine is free and terminate when busy.
Concretely, you can stop the process by CTRL+C anytime and restart quickly.
.I glob
where \fIglob\fR is the ports glob of the concerned port, and then restart this utility by
.B portsreinstall redo
-\.
+command.
.PP
If you are familiar to the mechanism of Ports Collections system, in order to minimize package conflictions, it may be a good idea to delete packages which you don't think necessary before starting to use this utility.
Don't be afraid to delete necessary dependencies because all required ports are automatically installed.
.SH HISTORY
\fBportsreinstall\fR has been developed as below.
.TP
-1.2.0 (29 July 2012)
+1.2.0 (31 July 2012)
[BUG FIX] Termination message is corrected (portsreinstall ok => portsreinstall ok add).
[CHANGE] Functionalities of options \fB\-t\fR and \fB\-T\fR are changed so as to prevent deinstallation of irrelevant packages and detect obsolete installed dependencies.
\fB\-N\fR
Renew option settings.
This option is effective only with \fBredo\fR command.
-Option settings for \fB\-s\fR, \fB\-q\fR and \fB\-d\R are reset according to the simultaneously given ones.
+Option settings for \fB\-s\fR, \fB\-q\fR and \fB\-d\fR are reset according to the simultaneously given ones.
.SH DETAILS
This utility realizes smart reinstallation of a large number of ports by allowing you to run when when the machine is free and terminate when busy.
Concretely, you can stop the process by CTRL+C anytime and restart quickly.
.I glob
where \fIglob\fR is the ports glob of the concerned port, and then restart this utility by
.B portsreinstall redo
-\.
+command.
.PP
If you are familiar to the mechanism of Ports Collections system, in order to minimize package conflictions, it may be a good idea to delete packages which you don't think necessary before starting to use this utility.
Don't be afraid to delete necessary dependencies because all required ports are automatically installed.
1.2.0 (29 July 2012)
[BUG FIX] Termination message is corrected (portsreinstall ok => portsreinstall ok add).
-[CHANGE] Functionalities of options \fB\-t\fR and \fB\-T\fR are changed so as to prevent deinstallation of irrelevant packages.
+[CHANGE] Functionalities of options \fB\-t\fR and \fB\-T\fR are changed so as to prevent deinstallation of irrelevant packages and detect obsolete installed dependencies.
[NEW] Options \fB\-X\fR, \fB\-r\fR and \fB\-R\fR are added so as to compensate a fact that \fB\-x\fR, \fB\-t\fR and \fB\-T\fR cannot specify package names with commas.
# ================================================
APPNAME=`basename $0`
-MYVERSION=1.1.0+toward_1.2.0_20120729213245
+MYVERSION=1.1.0+toward_1.2.0_20120731055210
PREFIX=${PREFIX:-/usr/local}
CONFFILE=${PREFIX}/etc/${APPNAME}.conf
globlist1=$1
globlist2=$2
listpath=$3
- mode=$3
+ mode=$4
dirpath=`dirname "$listpath"`
- for glob in `echo $globlist1 | sed 's/,/ /g'` $globlist2
+ echo "`echo "$globlist1" | sed 's/,/ /g'`" "$globlist2" | sed -E 's/ +/\
+/g' | grep -v '^$' | while read glob
do
if expr "@$glob" : '^@[^/][^/]*/[^/][^/]*$' > /dev/null 2> /dev/null
then
pkg=`pkg_info -qO "$origin"`
if [ -n "$pkg" ]
then
- $target_dir=${DBDIR}/initial/$origin
+ target_dir=${DBDIR}/initial/$origin
[ -d "$target_dir" ] || mkdir -p "$target_dir"
echo $pkg > $target_dir/installed_version
pkg_info -qr "$pkg" | grep '^@pkgdep ' | sed 's/^@pkgdep[[:space:]]*//' | while read requirement
do
- pkg_info -o "$requirement"
- done > $target_dir/requires
+ pkg_info -e "$requirement" || continue
+ pkg_info -qo "$requirement" >> $target_dir/requires
+ done
pkg_info -qR "$pkg" | grep -v '^$' | while read dependent
do
- pkg_info -o "$dependent"
- done > $target_dir/dependents
+ pkg_info -e "$dependent" || continue
+ pkg_info -qo "$dependent" >> $target_dir/dependents
+ done
fi
origin_src=
if [ `echo $origin | grep -m 1 -E -f "${DBDIR}/REPLACE.grep_from_pattern.conflist" | wc -l` -eq 1 ]
local prefix _is_all _is_target _is_required _is_former_required _is_dependent _is_former_dependent _is_relevant
prefix=$1
origin=$2
- _is_all=y
- _is_target=
- _is_required=
- _is_former_required=
- _is_dependent=
- _is_former_dependent=
- _is_relevant=y
- if [ `cat "${DBDIR}/target_required_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
+ if [ -e "${DBDIR}/requires/$origin/chk_if_target.param" ]
then
- _is_all=
- if [ ! -f "${DBDIR}/requires/$origin/dependents.pattern" ]
- then
- str_escape_regexp_filter < "${DBDIR}/requires/$origin/dependents" | sed 's/^/^/;s/$/$/' > "${DBDIR}/requires/$origin/dependents.pattern" 2> /dev/null || :
- fi
- if [ -e "${DBDIR}/initial/$origin/dependents" -a ! -f "${DBDIR}/initial/$origin/dependents.pattern" ]
- then
- str_escape_regexp_filter < "${DBDIR}/initial/$origin/dependents" | sed 's/^/^/;s/$/$/' > "${DBDIR}/initial/$origin/dependents.pattern" 2> /dev/null || :
- fi
- if grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
- then
- _is_target=y
- elif grep -m 1 -E -f "${DBDIR}/requires/$origin/dependents.pattern" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
- then
- _is_required=y
- elif [ -e "${DBDIR}/initial/$origin/dependents.pattern" ]
+ . "${DBDIR}/requires/$origin/chk_if_target.param"
+ else
+ _is_all=y
+ _is_target=
+ _is_required=
+ _is_former_required=
+ _is_dependent=
+ _is_former_dependent=
+ _is_relevant=y
+ if [ `cat "${DBDIR}/target_required_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
then
- if grep -m 1 -E -f "${DBDIR}/initial/$origin/dependents.pattern" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
+ _is_all=
+ if grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
+ then
+ _is_target=y
+ elif [ -e "${DBDIR}/requires/$origin/dependents.pattern" ] && grep -m 1 -E -f "${DBDIR}/requires/$origin/dependents.pattern" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
+ then
+ _is_required=y
+ elif [ -e "${DBDIR}/initial/$origin/dependents.pattern" ] && grep -m 1 -E -f "${DBDIR}/initial/$origin/dependents.pattern" "${DBDIR}/target_required_ports.specified" > /dev/null 2> /dev/null
then
_is_former_required=y
fi
fi
- fi
- if [ `cat "${DBDIR}/target_dependent_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
- then
- _is_all=
- if [ ! -f "${DBDIR}/requires/$origin/requires.pattern" ]
- then
- str_escape_regexp_filter < "${DBDIR}/requires/$origin/requires" | sed 's/^/^/;s/$/$/' > "${DBDIR}/requires/$origin/requires.pattern" 2> /dev/null || :
- fi
- if [ -e "${DBDIR}/initial/$origin/requires" -a ! -f "${DBDIR}/initial/$origin/requires.pattern" ]
- then
- str_escape_regexp_filter < "${DBDIR}/initial/$origin/requires" | sed 's/^/^/;s/$/$/' > "${DBDIR}/initial/$origin/requires.pattern" 2> /dev/null || :
- fi
- if [ -n "${_is_target}" ] || grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
- then
- _is_target=y
- elif grep -m 1 -E -f "${DBDIR}/requires/$origin/requires.pattern" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
+ if [ `cat "${DBDIR}/target_dependent_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
then
- _is_dependent=y
- fi
- elif [ -e "${DBDIR}/initial/$origin/requires.pattern" ]
- then
- if grep -m 1 -E -f "${DBDIR}/initial/$origin/requires.pattern" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
+ _is_all=
+ if [ -n "${_is_target}" ] || grep -m 1 -E "^`str_escape_regexp $origin`$" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
+ then
+ _is_target=y
+ elif [ -e "${DBDIR}/requires/$origin/requires.pattern" ] && grep -m 1 -E -f "${DBDIR}/requires/$origin/requires.pattern" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
+ then
+ _is_dependent=y
+ elif [ -e "${DBDIR}/initial/$origin/requires.pattern" ] && grep -m 1 -E -f "${DBDIR}/initial/$origin/requires.pattern" "${DBDIR}/target_dependent_ports.specified" > /dev/null 2> /dev/null
then
_is_former_dependent=y
fi
fi
+ [ -n "${_is_all}${_is_target}${_is_required}${_is_former_required}${_is_dependent}${_is_former_dependent}" ] || _is_relevant=
+ echo _is_all=${_is_all} > ${TMPDIR}/chk_if_target:results
+ echo _is_target=${_is_target} >> ${TMPDIR}/chk_if_target:results
+ echo _is_required=${_is_required} >> ${TMPDIR}/chk_if_target:results
+ echo _is_former_required=${_is_former_required} >> ${TMPDIR}/chk_if_target:results
+ echo _is_dependent=${_is_dependent} >> ${TMPDIR}/chk_if_target:results
+ echo _is_former_dependent=${_is_former_dependent} >> ${TMPDIR}/chk_if_target:results
+ echo _is_relevant=${_is_relevant} >> ${TMPDIR}/chk_if_target:results
+ mv "${TMPDIR}"/chk_if_target:results "${DBDIR}/requires/$origin/chk_if_target.param"
fi
- [ -n "${_is_all}${_is_target}${_is_required}${_is_former_required}${_is_dependent}${_is_former_dependent}" ] || _is_relevant=
eval ${prefix}_is_all=\$\{_is_all\}
eval ${prefix}_is_target=\$\{_is_target\}
eval ${prefix}_is_required=\$\{_is_required\}
eval ${prefix}_is_relevant=\$\{_is_relevant\}
}
+register_globs_only_installed ()
+{
+ local src1 src2
+ src1=$1
+ src2=$2
+ rm -f "${TMPDIR}/register_globs_only_installed:origins"
+ register_globs "$src1" "$src2" "${TMPDIR}/register_globs_only_installed:origins"
+ [ -e "${TMPDIR}/register_globs_only_installed:origins" ] || return 0
+ while read origin
+ do
+ [ -z `pkg_info -qO "$origin"` ] || echo $origin
+ done < ${TMPDIR}/register_globs_only_installed:origins
+}
+
+
# ==================================================
# ==================== MAIN ========================
# ==================================================
exit
;;
show)
- [ -d "${DBDIR}" ] || { echo "ERROR: Database has not built yet." >&2; exit 1; }
+ [ -e "${DBDIR}/COMPLETE_PREPARATION" ] || { echo "ERROR: Database has not built yet." >&2; exit 1; }
warn_update_ports
_filter_skip_unchanged=
_filter_only_target=
_filter_only_target=y
;;
requirements)
+ grandtitle="Dependencies based on the latest ports tree"
title="The following ports are required by %s:"
list=requires
_for_each_matching_port=y
;;
dependents)
-
+ grandtitle="Dependencies based on the latest ports tree"
title="The following ports depend on %s:"
list=dependents
_for_each_matching_port=y
exit 1
;;
esac
- [ -r "${DBDIR}/$list" ] || exit 0
+ [ -n "${_for_each_matching_port}" -o -r "${DBDIR}/$list" ] || exit 0
[ -e "${DBDIR}"/saved_options.sh ] && . "${DBDIR}"/saved_options.sh
if [ -n "${_for_each_matching_port}" ]
then
shift
[ $# -gt 0 ] || { echo "ERROR: the argument as port glob is missing" >&2; exit 1; }
+ echo "[$grandtitle]"
+ echo
isfirst=y
for origin_target in `ports_glob "$@"`
do
+ [ -e "${DBDIR}/requires/$origin_target/pkgtag" ] || continue
[ "$isfirst" = y ] || echo
isfirst=n
- [ -e "${DBDIR}/requires/$origin_target/pkgtag" ] || { echo "WARNING: the database for $origin_target is not ready" >&2; continue; }
- pkg_target=`cat "${DBDIR}/$pkgnamedb/$origin/pkgtag"`
+ pkg_target=`cat "${DBDIR}/$pkgnamedb/$origin_target/pkgtag"`
printf "$title\n" "$origin_target ($pkg_target)"
[ -e "${DBDIR}/requires/$origin_target/$list" ] || continue
while read origin
if [ ! -e "${DBDIR}/COMPLETE_PARSE_OPTION_TARGET_PORTS" ]
then
rm -f "${DBDIR}/target_dependent_ports.specified" "${DBDIR}/target_required_ports.specified"
- register_globs "$target_dependent_ports" "$target_dependent_ports_form2" "${DBDIR}/target_dependent_ports.specified"
- register_globs "$target_required_ports" "$target_required_ports_form2" "${DBDIR}/target_required_ports.specified"
+ register_globs_only_installed "$target_dependent_ports" "$target_dependent_ports_form2" > ${DBDIR}/target_dependent_ports.specified
+ register_globs_only_installed "$target_required_ports" "$target_required_ports_form2" > ${DBDIR}/target_required_ports.specified
+ if [ `cat "${DBDIR}"/target_dependent_ports.specified | wc -l` -gt 0 -a `cat "${DBDIR}"/target_required_ports.specified | wc -l` -gt 0 ]
+ then
+ echo "INFO: Ports/packages irrelevant to"
+ echo "----------------------------------------"
+ cat "${DBDIR}"/target_dependent_ports.specified
+ echo "----------------------------------------"
+ echo "nor their dependents, and irrelevant to"
+ echo "----------------------------------------"
+ cat "${DBDIR}"/target_required_ports.specified
+ echo "----------------------------------------"
+ echo "nor their requirements are skipped."
+ elif [ `cat "${DBDIR}"/target_dependent_ports.specified | wc -l` -gt 0 ]
+ then
+ echo "INFO: Ports/packages irrelevant to"
+ echo "----------------------------------------"
+ cat "${DBDIR}"/target_dependent_ports.specified
+ echo "----------------------------------------"
+ echo "nor their dependents are skipped."
+ elif [ `cat "${DBDIR}"/target_required_ports.specified | wc -l` -gt 0 ]
+ then
+ echo "INFO: Ports/packages irrelevant to"
+ echo "----------------------------------------"
+ cat "${DBDIR}"/target_required_ports.specified
+ echo "----------------------------------------"
+ echo "nor their requirements are skipped."
+ elif [ -n "$target_dependent_ports$target_dependent_ports_form2$target_required_ports$target_required_ports_form2" ]
+ then
+ echo "ERROR: Target ports are specified but none of them is valid." >&2
+ exit 1
+ fi
touch "${DBDIR}/COMPLETE_PARSE_OPTION_TARGET_PORTS"
fi
# Inspection of all dependencies
if [ ! -e "${DBDIR}/COMPLETE_COLLECED_ALL_DEPENDENCIES" ]
then
- echo "Starting to inspect dependencies of installed packages at `timestamp`"
+ echo "Starting to inspect dependencies of the all installed packages at `timestamp`"
+ [ -z "$target_dependent_ports$target_dependent_ports_form2$target_required_ports$target_required_ports_form2" ] || \
+ echo "INFO: Ports irrelevant to the targets are also inspected in order to get complete information."
[ -d "${DBDIR}/requires" ] || mkdir -p "${DBDIR}/requires"
touch "${DBDIR}/moved_or_lost.list"
touch "${DBDIR}/target.inspected.list"
echo
fi
+# Preparation of matching patterns of dependencies
+if [ ! -e "${DBDIR}/COMPLETE_PREPARATION_OF_MATCHING_PATTERNS_OF_DEPENDENCIES" ]
+then
+ echo "Starting preparation of matching patterns of dependencies at `timestamp`"
+ if [ -f "${DBDIR}/prepare_matching_patterns_dependencies.remain" ]
+ then
+ echo "INFO: Restarting from the previously terminated point"
+ else
+ find "${DBDIR}/requires" -depth 2 -type d > ${DBDIR}/prepare_matching_patterns_dependencies.remain
+ fi
+ cp "${DBDIR}/prepare_matching_patterns_dependencies.remain" "${DBDIR}/prepare_matching_patterns_dependencies"
+ while read dbpath
+ do
+ portname=`basename "$dbpath"`
+ catpath=`dirname "$dbpath"`
+ catname=`basename "$catpath"`
+ origin=$catname/$portname
+ [ ! -e "${DBDIR}/requires/$origin/dependents" ] || str_escape_regexp_filter < ${DBDIR}/requires/$origin/dependents | sed 's/^/^/;s/$/$/' > ${DBDIR}/requires/$origin/dependents.pattern
+ [ ! -e "${DBDIR}/initial/$origin/dependents" ] || str_escape_regexp_filter < ${DBDIR}/initial/$origin/dependents | sed 's/^/^/;s/$/$/' > ${DBDIR}/initial/$origin/dependents.pattern
+ [ ! -e "${DBDIR}/requires/$origin/requires" ] || str_escape_regexp_filter < ${DBDIR}/requires/$origin/requires | sed 's/^/^/;s/$/$/' > ${DBDIR}/requires/$origin/requires.pattern
+ [ ! -e "${DBDIR}/initial/$origin/requires" ] || str_escape_regexp_filter < ${DBDIR}/initial/$origin/requires | sed 's/^/^/;s/$/$/' > ${DBDIR}/initial/$origin/requires.pattern
+ chk_if_target currentorigin "$origin"
+ sed -i '' 1d "${DBDIR}/prepare_matching_patterns_dependencies.remain"
+ done < ${DBDIR}/prepare_matching_patterns_dependencies
+ touch "${DBDIR}/COMPLETE_PREPARATION_OF_MATCHING_PATTERNS_OF_DEPENDENCIES"
+ echo
+fi
+
# Inspection of necessary updates
if [ ! -e "${DBDIR}/COMPLETE_NECESSARY_UPDATES" ]
then
# ------- Main operations -------
+if [ ! -e "${DBDIR}/COMPLETE_PREPARATION" ]
+then
+ touch "${DBDIR}/COMPLETE_PREPARATION"
+fi
+
if [ "$command" = prepare ]
then
echo "Done (skipped reinstallation) at `timestamp`"