# ================================================
APPNAME=`basename $0`
-MYVERSION=1.1.0+toward_1.2.0_20120729195830
+MYVERSION=1.1.0+toward_1.2.0_20120729234736
PREFIX=${PREFIX:-/usr/local}
CONFFILE=${PREFIX}/etc/${APPNAME}.conf
then
[ -d "${PORTSDIR}/$glob" ] && { echo $glob; continue; }
fi
+ ports_glob "$glob" > ${TMPDIR}/register_globs:ports_glob
origin=`ports_glob "$glob"`
- [ -n "$origin" ] || \
+ [ `cat "${TMPDIR}"/register_globs:ports_glob | wc -l` -ge 1 ] || \
{
- echo "ERROR: Invalid ports/package glob [$glob]" >&2
- exit 1;
+ echo "WARNING: No matching ports/package glob [$glob]" >&2
+ continue
}
- echo $origin
+ cat "${TMPDIR}"/register_globs:ports_glob
done | while read origin
do
[ -d "$dirpath" ] || mkdir -p "$dirpath"
DEPTH_INDEX="${DEPTH_INDEX}--"
echo "${DEPTH_INDEX} $origin"
origin_id=`echo $origin | tr / :`
+ pkg=`pkg_info -qO "$origin"`
+ if [ -n "$pkg" ]
+ then
+ $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 -qR "$pkg" | grep -v '^$' | while read dependent
+ do
+ pkg_info -o "$dependent"
+ done > $target_dir/dependents
+ fi
origin_src=
if [ `echo $origin | grep -m 1 -E -f "${DBDIR}/REPLACE.grep_from_pattern.conflist" | wc -l` -eq 1 ]
then
done < ${DBDIR}/failed.list
}
-_chk_if_target ()
+chk_if_target ()
{
+ 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 ]
then
_is_all=
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" ]
+ then
+ if 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
- _is_required=
if [ `cat "${DBDIR}/target_dependent_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
then
_is_all=
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
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
+ then
+ _is_former_dependent=y
+ fi
+ fi
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_former_required=\$\{_is_former_required\}
+ eval ${prefix}_is_dependent=\$\{_is_dependent\}
+ eval ${prefix}_is_former_dependent=\$\{_is_former_dependent\}
+ eval ${prefix}_is_relevant=\$\{_is_relevant\}
}
# ==================================================
[ -e "${DBDIR}/requires/$origin/${_filter_skip_unchanged}" ] || continue
if [ -n "${_filter_only_target}" ]
then
- _chk_if_target "$origin"
- [ -n "${_is_all}${_is_target}${_is_dependent}${_is_required}" ] || continue
+ chk_if_target currentorigin "$origin"
+ [ -n "${currentorigin_is_relevant}" ] || continue
fi
if [ -e "${DBDIR}/$pkgnamedb/$origin/pkgtag" ]
then
do
if [ -n "${_filter_only_target}" ]
then
- _chk_if_target "$origin"
- [ -n "${_is_all}${_is_target}${_is_dependent}${_is_required}" ] || continue
+ chk_if_target currentorigin "$origin"
+ [ -n "${currentorigin_is_relevant}" ] || continue
fi
if [ -e "${DBDIR}/$pkgnamedb/$origin/pkgtag" ]
then
iline=$(($iline+1))
currentpkg=`pkg_info -qO "$origin" 2> /dev/null`
[ -n "$currentpkg" ] || continue
- _chk_if_target "$origin"
- if [ -z "${_is_all}" -a -z "${_is_target}${_is_dependent}${_is_required}" ]
+ chk_if_target currentorigin "$origin"
+ if [ -z "${currentorigin_is_relevant}" ]
then
- echo "-- (Skipping an irrelative package for obsolete port $origin as $currentpkg)"
+ echo "-- (Skipping an irrelevant package for obsolete port $origin as $currentpkg)"
continue
fi
origin_ptn=`str_escape_regexp ${origin}`
fi
_MSG_CURRENT_STAGE=${_MSG_CURRENT_STAGE_general}
echo "========== Starting deinstallation process for obsolete port $origin as $currentpkg =========="
- if [ -z "${_is_all}" -a -n "${_is_target}${_is_dependent}${_is_required}" ]
+ if [ -z "${currentorigin_is_all}" -a -n "${currentorigin_is_relevant}" ]
then
- [ "${_is_target}" = y ] && echo "(Target port)"
- [ "${_is_dependent}" = y ] && echo "(Dependent of the target port(s))"
- [ "${_is_required}" = y ] && echo "(Required by the target port(s))"
+ [ "${currentorigin_is_target}" = y ] && echo "(Target port)"
+ [ "${currentorigin_is_dependent}" = y ] && echo "(Dependent of the target port(s))"
+ [ "${currentorigin_is_required}" = y ] && echo "(Requirement of the target port(s))"
+ [ "${currentorigin_is_former_dependent}" = y ] && echo "(Former dependent of the target port(s))"
+ [ "${currentorigin_is_former_required}" = y ] && echo "(Former requirement of the target port(s))"
fi
echo "-- (Creating backup package for $origin as $currentpkg)"
tag=`echo $origin | sed 's|/|.|'`
rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
continue
fi
- _chk_if_target "$origin"
+ chk_if_target currentorigin "$origin"
cp /dev/null "${TMPDIR}"/msg_if_target
- if [ -z "${_is_all}" ]
+ if [ -z "${currentorigin_is_all}" ]
then
- if [ -n "${_is_target}${_is_dependent}${_is_required}" ]
+ if [ -n "${currentorigin_is_relevant}" ]
then
- [ "${_is_target}" = y ] && echo "(Target port)" > ${TMPDIR}/msg_if_target
- [ "${_is_dependent}" = y ] && echo "(Dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
- [ "${_is_required}" = y ] && echo "(Required by the target port(s))" >> ${TMPDIR}/msg_if_target
+ [ "${currentorigin_is_target}" = y ] && echo "(Target port)" > ${TMPDIR}/msg_if_target
+ [ "${currentorigin_is_dependent}" = y ] && echo "(Dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
+ [ "${currentorigin_is_required}" = y ] && echo "(Requirement of the target port(s))" >> ${TMPDIR}/msg_if_target
+ [ "${currentorigin_is_former_dependent}" = y ] && echo "(Former dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
+ [ "${currentorigin_is_former_required}" = y ] && echo "(Former requirement of the target port(s))" >> ${TMPDIR}/msg_if_target
else
- echo "========== $counter (Skipping an irrelative package for port $position_msg at `timestamp`) =========="
+ echo "========== $counter (Skipping an irrelevant package for port $position_msg at `timestamp`) =========="
echo
rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
continue
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.
.SH HISTORY
\fBportsreinstall\fR has been developed as below.
.TP
-1.2.0 (28 July 2012)
+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.
# ================================================
APPNAME=`basename $0`
-MYVERSION=1.1.0+toward_1.2.0_20120728230120
+MYVERSION=1.1.0+toward_1.2.0_20120729213245
PREFIX=${PREFIX:-/usr/local}
CONFFILE=${PREFIX}/etc/${APPNAME}.conf
then
[ -d "${PORTSDIR}/$glob" ] && { echo $glob; continue; }
fi
+ ports_glob "$glob" > ${TMPDIR}/register_globs:ports_glob
origin=`ports_glob "$glob"`
- [ -n "$origin" ] || \
+ [ `cat "${TMPDIR}"/register_globs:ports_glob | wc -l` -ge 1 ] || \
{
- echo "ERROR: Invalid ports/package glob [$glob]" >&2
- exit 1;
+ echo "WARNING: No matching ports/package glob [$glob]" >&2
+ continue
}
- echo $origin
+ cat "${TMPDIR}"/register_globs:ports_glob
done | while read origin
do
[ -d "$dirpath" ] || mkdir -p "$dirpath"
DEPTH_INDEX="${DEPTH_INDEX}--"
echo "${DEPTH_INDEX} $origin"
origin_id=`echo $origin | tr / :`
+ pkg=`pkg_info -qO "$origin"`
+ if [ -n "$pkg" ]
+ then
+ $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 -qR "$pkg" | grep -v '^$' | while read dependent
+ do
+ pkg_info -o "$dependent"
+ done > $target_dir/dependents
+ fi
origin_src=
if [ `echo $origin | grep -m 1 -E -f "${DBDIR}/REPLACE.grep_from_pattern.conflist" | wc -l` -eq 1 ]
then
done < ${DBDIR}/failed.list
}
-_chk_if_target ()
+chk_if_target ()
{
+ 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 ]
then
_is_all=
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" ]
+ then
+ if 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
- _is_required=
if [ `cat "${DBDIR}/target_dependent_ports.specified" 2> /dev/null | wc -l` -gt 0 ]
then
_is_all=
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
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
+ then
+ _is_former_dependent=y
+ fi
+ fi
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_former_required=\$\{_is_former_required\}
+ eval ${prefix}_is_dependent=\$\{_is_dependent\}
+ eval ${prefix}_is_former_dependent=\$\{_is_former_dependent\}
+ eval ${prefix}_is_relevant=\$\{_is_relevant\}
}
# ==================================================
[ -e "${DBDIR}/requires/$origin/${_filter_skip_unchanged}" ] || continue
if [ -n "${_filter_only_target}" ]
then
- _chk_if_target "$origin"
- [ -n "${_is_all}${_is_target}${_is_dependent}${_is_required}" ] || continue
+ chk_if_target currentorigin "$origin"
+ [ -n "${currentorigin_is_relevant}" ] || continue
fi
if [ -e "${DBDIR}/$pkgnamedb/$origin/pkgtag" ]
then
do
if [ -n "${_filter_only_target}" ]
then
- _chk_if_target "$origin"
- [ -n "${_is_all}${_is_target}${_is_dependent}${_is_required}" ] || continue
+ chk_if_target currentorigin "$origin"
+ [ -n "${currentorigin_is_relevant}" ] || continue
fi
if [ -e "${DBDIR}/$pkgnamedb/$origin/pkgtag" ]
then
iline=$(($iline+1))
currentpkg=`pkg_info -qO "$origin" 2> /dev/null`
[ -n "$currentpkg" ] || continue
- _chk_if_target "$origin"
- if [ -z "${_is_all}" -a -z "${_is_target}${_is_dependent}${_is_required}" ]
+ chk_if_target currentorigin "$origin"
+ if [ -z "${currentorigin_is_relevant}" ]
then
- echo "-- (Skipping an irrelative package for obsolete port $origin as $currentpkg)"
+ echo "-- (Skipping an irrelevant package for obsolete port $origin as $currentpkg)"
continue
fi
origin_ptn=`str_escape_regexp ${origin}`
fi
_MSG_CURRENT_STAGE=${_MSG_CURRENT_STAGE_general}
echo "========== Starting deinstallation process for obsolete port $origin as $currentpkg =========="
- if [ -z "${_is_all}" -a -n "${_is_target}${_is_dependent}${_is_required}" ]
+ if [ -z "${currentorigin_is_all}" -a -n "${currentorigin_is_relevant}" ]
then
- [ "${_is_target}" = y ] && echo "(Target port)"
- [ "${_is_dependent}" = y ] && echo "(Dependent of the target port(s))"
- [ "${_is_required}" = y ] && echo "(Required by the target port(s))"
+ [ "${currentorigin_is_target}" = y ] && echo "(Target port)"
+ [ "${currentorigin_is_dependent}" = y ] && echo "(Dependent of the target port(s))"
+ [ "${currentorigin_is_required}" = y ] && echo "(Requirement of the target port(s))"
+ [ "${currentorigin_is_former_dependent}" = y ] && echo "(Former dependent of the target port(s))"
+ [ "${currentorigin_is_former_required}" = y ] && echo "(Former requirement of the target port(s))"
fi
echo "-- (Creating backup package for $origin as $currentpkg)"
tag=`echo $origin | sed 's|/|.|'`
rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
continue
fi
- _chk_if_target "$origin"
+ chk_if_target currentorigin "$origin"
cp /dev/null "${TMPDIR}"/msg_if_target
- if [ -z "${_is_all}" ]
+ if [ -z "${currentorigin_is_all}" ]
then
- if [ -n "${_is_target}${_is_dependent}${_is_required}" ]
+ if [ -n "${currentorigin_is_relevant}" ]
then
- [ "${_is_target}" = y ] && echo "(Target port)" > ${TMPDIR}/msg_if_target
- [ "${_is_dependent}" = y ] && echo "(Dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
- [ "${_is_required}" = y ] && echo "(Required by the target port(s))" >> ${TMPDIR}/msg_if_target
+ [ "${currentorigin_is_target}" = y ] && echo "(Target port)" > ${TMPDIR}/msg_if_target
+ [ "${currentorigin_is_dependent}" = y ] && echo "(Dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
+ [ "${currentorigin_is_required}" = y ] && echo "(Requirement of the target port(s))" >> ${TMPDIR}/msg_if_target
+ [ "${currentorigin_is_former_dependent}" = y ] && echo "(Former dependent of the target port(s))" >> ${TMPDIR}/msg_if_target
+ [ "${currentorigin_is_former_required}" = y ] && echo "(Former requirement of the target port(s))" >> ${TMPDIR}/msg_if_target
else
- echo "========== $counter (Skipping an irrelative package for port $position_msg at `timestamp`) =========="
+ echo "========== $counter (Skipping an irrelevant package for port $position_msg at `timestamp`) =========="
echo
rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
continue