# ================================================
APPNAME=`basename "$0"`
-MYVERSION=2.2.2+toward_3.0.0_20130203231825
+MYVERSION=2.2.2+toward_3.0.0_20130206071750
LOCALBASE=${LOCALBASE:-/usr/local}
PREFIX=${PREFIX:-${LOCALBASE}}
if [ "x$WITH_PKGNG" = xyes ]
then
- [ -x /usr/local/sbin/pkg ] || { echo "ERROR: WITH_PKGNG is set, but pkgng is not available" >&2; exit 1; }
+ [ -x /usr/local/sbin/pkg ] || { echo "ERROR: WITH_PKGNG is set, but pkgng is not available." >&2; exit 1; }
command_pkg_info='pkg info'
command_pkg_create='pkg create'
command_pkg_delete='pkg delete'
fi
if [ -z "$backup_pkg" ]
then
- echo "WARNING: Failed to create backup package for $pkgname" >&2
+ echo "WARNING: Failed to create backup package for $pkgname." >&2
return 1
fi
[ -d "$dstdir" ] || mkdir -p "$dstdir"
add_a_line_if_new ()
{
- local item dstpath pattern
+ local item dstpath pattern dstdir
item=$1
dstpath=$2
pattern=`str_escape_regexp "$item"`
- cp "$dstpath" "${DBDIR}/tmpfile:add_a_line_if_new"
- grep -m 1 -E "^$pattern$" "$dstpath" > /dev/null 2>&1 \
- || echo "$item" >> ${DBDIR}/tmpfile:add_a_line_if_new
+ if [ -e "$dstpath" ]
+ then
+ cp "$dstpath" "${DBDIR}/tmpfile:add_a_line_if_new"
+ grep -m 1 -E "^$pattern$" "$dstpath" > /dev/null 2>&1 \
+ || echo "$item" >> ${DBDIR}/tmpfile:add_a_line_if_new
+ else
+ dstdir=`dirname "$dstpath"`
+ [ -d "$dstdir" ] || mkdir -p "$dstdir"
+ echo "$item" > ${DBDIR}/tmpfile:add_a_line_if_new
+ fi
mv "${DBDIR}/tmpfile:add_a_line_if_new" "$dstpath"
}
add_lines_if_new ()
{
- local filepath origin advance
- filepath=$1
+ local dstpath origin advance dstdir
+ dstpath=$1
advance=$2
- while read origin
- do
- grep -m 1 -E "^`str_escape_regexp \"$origin\"`$" "$filepath" > /dev/null 2>&1 \
- || echo "$origin"
- done > ${TMPDIR}/add_lines_if_new:add
- if [ "@$advance" = @advance ]
+ if [ -e "$dstpath" ]
then
- cat "${TMPDIR}/add_lines_if_new:add" "$filepath"
+ while read origin
+ do
+ grep -m 1 -E "^`str_escape_regexp \"$origin\"`$" "$dstpath" > /dev/null 2>&1 \
+ || echo "$origin"
+ done > ${TMPDIR}/add_lines_if_new:add
+ if [ "@$advance" = @advance ]
+ then
+ cat "${TMPDIR}/add_lines_if_new:add" "$dstpath"
+ else
+ cat "$dstpath" "${TMPDIR}/add_lines_if_new:add"
+ fi > ${DBDIR}/tmpfile:add_lines_if_new:newfile
else
- cat "$filepath" "${TMPDIR}/add_lines_if_new:add"
- fi > ${DBDIR}/tmpfile:add_lines_if_new:newfile
- mv "${DBDIR}/tmpfile:add_lines_if_new:newfile" "$filepath"
+ dstdir=`dirname "$dstpath"`
+ [ -d "$dstdir" ] || mkdir -p "$dstdir"
+ cat > ${DBDIR}/tmpfile:add_lines_if_new:newfile
+ fi
+ mv "${DBDIR}/tmpfile:add_lines_if_new:newfile" "$dstpath"
}
record_success ()
origin=`ports_glob "$glob"`
[ `cat "${TMPDIR}"/register_globs:ports_glob | wc -l` -ge 1 ] || \
{
- echo "WARNING: No matching ports/package glob [$glob]" >&2
+ echo "WARNING: No matching ports/package glob [$glob]." >&2
continue
}
cat "${TMPDIR}"/register_globs:ports_glob
then
while read origin_requirement
do
+ echo "$origin_requirement"
get_recursive_dependency_table "$table" "$origin_requirement"
done < $dbpath/$table.direct | sort -u > ${DBDIR}/tmpfile:get_recursive_dependency_table:$origin_esc
mv "${DBDIR}/tmpfile:get_recursive_dependency_table:$origin_esc" "$dbpath/$table"
yes+no)
echo build;;
*)
- echo "ERROR: Invalid combination of option values for build-/run-time dependency evaluation" >&2
+ echo "ERROR: Option -B must be combined with -b." >&2
+ exit 1;;
+ esac
+}
+
+get_dependency_msgterm ()
+{
+ case $include_buildtime_dependencies+$include_runtime_dependencies in
+ yes+yes)
+ echo 'run- and build-time';;
+ no+yes)
+ echo 'run-time';;
+ yes+no)
+ echo 'build-time';;
+ *)
+ echo "ERROR: Invalid combination of option values for build-/run-time dependency evaluation." >&2
exit 1;;
esac
}
msg_stage ()
{
- echo -n "========== $* at `timestamp` =========="
+ echo "========== $* =========="
+ echo "[At `timestamp`]"
}
-msg_reinststage_info ()
-{
- echo -n "========== $counter [$*] ($position_msg at `timestamp`) =========="
-}
-
-
# ==================================================
# ==================== MAIN ========================
# ==================================================
elif [ $num_pkgng_versions -eq 1 ]
then
[ -d "${PORTSDIR}/ports-mgmt/pkg" ] \
- || { echo "ERROR: ${PORTSDIR}/ports-mgmt/pkg does not exist" >&2; exit 1; }
+ || { echo "ERROR: ${PORTSDIR}/ports-mgmt/pkg does not exist." >&2; exit 1; }
pkgng_pkg_current=`cat "${TMPDIR}"/pkgng_version`
pkgng_pkg_new=`make -C "${PORTSDIR}/ports-mgmt/pkg" package-name`
if [ -n "$pkgng_pkg_new" ]
fi
fi
else
- echo "WARNING: No port for ports-mgmt/pkg exists in the current ports tree" >&2
+ echo "WARNING: No port for ports-mgmt/pkg exists in the current ports tree." >&2
fi
fi
fi
then
self_origin=`pkg_info_qo "\`cat \"${TMPDIR}\"/self_version\`"`
[ -d "${PORTSDIR}/$self_origin" ] \
- || { echo "ERROR: ${PORTSDIR}/$self_origin does not exist" >&2; exit 1; }
+ || { echo "ERROR: ${PORTSDIR}/$self_origin does not exist." >&2; exit 1; }
self_pkg_current=`cat "${TMPDIR}"/self_version`
self_pkg_new=`make -C "${PORTSDIR}/$self_origin" package-name`
if [ -n "$self_pkg_new" ]
echo "INFO: Restarting with the new version..."
echo
. "${TMPDIR}"/restart_command.sh
- echo "ERROR: Failed to launch the new version" >&2
+ echo "ERROR: Failed to launch the new version." >&2
exit 1
else
echo "WARNING: Reinstallation failed. Restoring the old package..." >&2
fi
fi
else
- echo "WARNING: No port for ${APPNAME} exists in the current ports tree" >&2
+ echo "WARNING: No port for ${APPNAME} exists in the current ports tree." >&2
fi
else
echo "INFO: This version of ${APPNAME} has been installed not by ports/packages mechanism."
show)
[ -e "${DBDIR}/COMPLETE_PREPARATION" ] || { echo "ERROR: Database has not built yet." >&2; exit 1; }
warn_update_ports
+ [ -e "${DBDIR}"/saved_options.sh ] && . "${DBDIR}"/saved_options.sh
_filter_skip_unchanged=
_filter_only_target=
_for_each_matching_port=
_for_each_matching_port=y
;;
*)
- echo "ERROR: Invalid show argument [$1]" >&2
+ echo "ERROR: Invalid show argument [$1]." >&2
exit 1
;;
esac
if [ -n "${_for_each_matching_port}" ]
then
shift
- [ $# -gt 0 ] || { echo "ERROR: the argument as port glob is missing" >&2; exit 1; }
+ [ $# -gt 0 ] || { echo "ERROR: the argument as port glob is missing." >&2; exit 1; }
echo "[$grandtitle]"
+ echo "(Evaluated by `get_dependency_msgterm` dependency)"
echo
isfirst=y
for origin_target in `ports_glob "$@"`
fi
done < ${DBDIR}/requires/$origin_target/$list
done
- [ "$isfirst" = n ] || { echo "ERROR: no matching port for the glob" >&2; exit 1; }
+ [ "$isfirst" = n ] || { echo "ERROR: no matching port for the glob." >&2; exit 1; }
elif [ -n "${_filter_skip_unchanged}" -a $skip_unchanged = yes ]
then
while read origin
chk_privilege
;;
*)
- echo "ERROR: Invalid command [$command]" >&2
+ echo "ERROR: Invalid command [$command]." >&2
exit 1
;;
esac
echo
if [ $errno -eq 130 ]
then
- echo "INFO: Terminated at `timestamp`$msg_where"
+ echo "INFO: Terminated at `timestamp`$msg_where."
echo
echo " You can restart this process from the terminated point by"
else
- echo "INFO: Aborted at `timestamp`$msg_where"
+ echo "INFO: Aborted at `timestamp`$msg_where."
echo
echo " You may restart this process from the aborted point by"
fi
fi
elif [ $load_pkgtoolsconf != undef -a `which portupgrade | wc -l` -eq 0 ]
then
- echo "WARNING: pkgtools.conf is ignored because portupgrade is not installed" >&2
+ echo "WARNING: pkgtools.conf is ignored because portupgrade is not installed." >&2
load_pkgtoolsconf=no
fi
if [ -n "$target_dependent_ports$target_dependent_ports_form2$target_required_ports$target_required_ports_form2" ]
then
echo "INFO: Operations will be applied only to the targets:"
- case $include_buildtime_dependencies+$include_runtime_dependencies in
- yes+yes)
- dependency_type='run- and build-time';;
- no+yes)
- dependency_type='run-time';;
- yes+no)
- dependency_type='build-time';;
- *)
- echo "ERROR: Invalid combination of option values for build-/run-time dependency evaluation" >&2
- exit 1;;
- esac
+ dependency_type=`get_dependency_msgterm`
num_specified_dependents=`cat "${DBDIR}"/target_dependent_ports.specified | wc -l`
num_specified_requirements=`cat "${DBDIR}"/target_required_ports.specified | wc -l`
suffix=.
cat "${DBDIR}"/target_required_ports.specified
echo "----------------------------------------"
echo "and their $dependency_type requirements."
- else
+ fi
+ if [ $num_specified_dependents -eq 0 -a $num_specified_requirements -eq 0 ]
+ then
echo "ERROR: Target ports are specified but none of them is valid." >&2
exit 1
fi
do
set | grep -e "^${item}_" | sed 's/^/_CONF_/'
done > ${DBDIR}/confvars.sh
- ) || { echo "ERROR: Invalid syntax in [${CONFFILE}]" >&2; exit 1; }
+ ) || { echo "ERROR: Invalid syntax in [${CONFFILE}]." >&2; exit 1; }
touch "${DBDIR}/COMPLETE_PARSE_CONF"
fi
. "${DBDIR}/confvars.sh"
then
to=
else
- [ -d "${PORTSDIR}/$to" ] || echo "WARNING: replacement port [$to] is obsolete" >&2
+ [ -d "${PORTSDIR}/$to" ] || echo "WARNING: replacement port [$to] is obsolete." >&2
fi
str_escape_regexp_filter < ${TMPDIR}/origins.2.tmp \
| sed -E "s|^|s:^|; s/$/$:`str_escape_replaceval \"$to\"`:/" \
touch "${DBDIR}/target.inspected.list"
if [ -f "${DBDIR}/target_ports.remain" ]
then
- echo "INFO: Restarting from the previously terminated point"
+ echo "INFO: Restarting from the previously terminated point."
else
cp -p "${DBDIR}/target_ports" "${DBDIR}/target_ports.remain"
fi
echo "Starting conversion of requirements-lists to actual ones at `timestamp`"
if [ -f "${DBDIR}/convert_requirements_lists.remain" ]
then
- echo "INFO: Restarting from the previously terminated point"
+ echo "INFO: Restarting from the previously terminated point."
else
( set -e
cd "${DBDIR}/initial" && find . -depth 2 -type d
for dbtag in requires initial
do
target=${DBDIR}/$dbtag/$origin/${table}_${tag}
- [ -e "$target" ] || continue
+ [ -e "$target.src" ] || continue
sed -E -f "${DBDIR}/REPLACE.complete_replace_pattern" "$target.src" \
| grep -v '^$' | sort -u > $target
done
done
for tag in run build
do
- mv "${DBDIR}/requires/$origin/requirements_$tag" "${DBDIR}/requires/$origin/requirements_$tag.direct"
+ target=${DBDIR}/requires/$origin/requirements_$tag
+ [ -e "$target" ] && mv "$target" "$target.direct"
done
sed -i '' 1d "${DBDIR}/convert_requirements_lists.remain"
done < ${TMPDIR}/convert_requirements_lists
echo "Starting completion of run-time requirement lists at `timestamp`"
if [ -f "${DBDIR}/complete_runtime_reqlists.remain" ]
then
- echo "INFO: Restarting from the previously terminated point"
+ echo "INFO: Restarting from the previously terminated point."
else
find "${DBDIR}/requires" -depth 3 -type f -name requirements_run.direct \
> ${DBDIR}/complete_runtime_reqlists.remain
echo "Starting completion of build-time requirement lists at `timestamp`"
if [ -f "${DBDIR}/complete_buildtime_reqlists.remain" ]
then
- echo "INFO: Restarting from the previously terminated point"
+ echo "INFO: Restarting from the previously terminated point."
else
find "${DBDIR}/requires" -depth 3 -type f -name requirements_build.direct \
> ${DBDIR}/complete_buildtime_reqlists.remain
echo "Starting inspection of dependents at `timestamp`"
if [ -f "${DBDIR}/inspect_dependent.remain" ]
then
- echo "INFO: Restarting from the previously terminated point"
+ echo "INFO: Restarting from the previously terminated point."
else
find "${DBDIR}/requires" -depth 2 -type d > ${DBDIR}/inspect_dependent.remain
fi
origin=$catname/$portname
for tag in all run build
do
+ [ -e "$dbpath/requirements_$tag" ] || continue
sed -E "s/^/$dbrequires_valesc/; s|$|/dependents_$tag|" "$dbpath/requirements_$tag" \
| add_a_line_to_files_if_new "$origin"
done
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"
+ echo "INFO: Restarting from the previously terminated point."
else
find "${DBDIR}/requires" -depth 2 -type d > ${DBDIR}/prepare_matching_patterns_dependencies.remain
fi
done
done
chk_if_target currentorigin "$origin"
- [ -n "${currentorigin_is_relevant}" ] && touch "$dbpath/relevant_to_target"
+ [ -z "${currentorigin_is_all}" -a -n "${currentorigin_is_relevant}" ] \
+ && touch "$dbpath/relevant_to_target"
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 "Starting preparation of matching patterns of obsolete ports to be deleted at `timestamp`"
if [ -f "${DBDIR}/prepare_matching_patterns_obsolete_ports.remain" ]
then
- echo "INFO: Restarting from the previously terminated point"
+ echo "INFO: Restarting from the previously terminated point."
else
cp -p "${DBDIR}/moved_or_lost.list" "${DBDIR}/prepare_matching_patterns_obsolete_ports.remain"
fi
echo "Starting inspection of necessity at `timestamp`"
if [ -f "${DBDIR}/inspect_necessity.remain" ]
then
- echo "INFO: Restarting from the previously terminated point"
+ echo "INFO: Restarting from the previously terminated point."
else
find "${DBDIR}/requires" -depth 3 -type f \
\( -name installed_version -or -name relevant_to_target \) \
| sed 's|/[^/]*$||' | sort -u > ${DBDIR}/inspect_necessity.remain
fi
cp "${DBDIR}/inspect_necessity.remain" "${TMPDIR}/inspect_necessity"
- while read markerpath
+ while read dbpath
do
- dbpath=`dirname "$markerpath"`
portname=`basename "$dbpath"`
catpath=`dirname "$dbpath"`
catname=`basename "$catpath"`
echo "Starting inspection of necessary updates at `timestamp`"
if [ -f "${DBDIR}/necessary_updates.remain" ]
then
- echo "INFO: Restarting from the previously terminated point"
+ echo "INFO: Restarting from the previously terminated point."
else
find "${DBDIR}/requires" -depth 3 -type f -name necessary_port > ${DBDIR}/necessary_updates.remain
fi
if [ ! -e "${DBDIR}/COMPLETE_ORDERED_ALL_DEPENDENCIES" ]
then
echo "Starting ordering of dependencies at `timestamp`"
- [ ! -f "${DBDIR}/reinst_order.list.tmp" ] || echo "INFO: Restarting from the previously terminated point"
+ [ ! -f "${DBDIR}/reinst_order.list.tmp" ] || \
+ echo "INFO: Restarting from the previously terminated point."
touch "${DBDIR}/reinst_order.list.tmp"
cd "${DBDIR}/requires"
cat > ${TMPDIR}/order_dependencies.awk << eof
eof
find . -depth 3 -name requirements_all.remained -exec echo {} \; -exec cat {} \; -exec echo \; | \
env DBDIR=${DBDIR} awk -f "${TMPDIR}"/order_dependencies.awk || { \
- echo "ERROR: Unsatisfied dependencies are remained" >&2
+ echo "ERROR: Unsatisfied dependencies are remained:" >&2
cat "${DBDIR}/unsatisfied.list"
echo "*** Aborted by ${APPNAME}"
echo "The ports tree seems broken. You might have caught an incomplete version."
then
if [ -f "${DBDIR}/moved_or_lost.list.remained" ]
then
- echo "INFO: Restarting from the previously terminated point"
+ echo "INFO: Restarting from the previously terminated point."
else
cp -p "${DBDIR}/moved_or_lost.list" "${DBDIR}/moved_or_lost.list.remained"
fi
backup_pkg=`create_backup_pkg "$currentpkg" "${DBDIR}/backup_obsolete"` || :
if [ -n "$backup_pkg" ]
then
- echo "INFO: The backup is saved at $backup_pkg"
+ echo "INFO: The backup is saved at $backup_pkg."
else
echo "*** Continuating forcibly by keeping the installed package"
continue
[ -d "${DBDIR}/backup_failure" ] || mkdir -p "${DBDIR}/backup_failure"
if [ ! -e "${DBDIR}/MODE_REDO" -a -f "${DBDIR}/reinst_todo.list" ]
then
- echo "INFO: Restarting from the previously terminated point"
+ echo "INFO: Restarting from the previously terminated point."
else
cp -p "${DBDIR}/reinst_order.list" "${DBDIR}/reinst_todo.list"
fi
echo "$pkgtag" > $nodedir/pkgtag
position_msg="$origin ($pkgtag)"
deptag=`get_dependency_tag`
+ msg_stage "$counter $position_msg"
if grep -m 1 -E "^$origin_regexp_esc$" "${DBDIR}/success_$deptag.list" > /dev/null 2>&1
then
- msg_reinststage_info "Skipping an already reinstalled package"
+ echo "(Skipped because the reinstallation has been already completed)"
echo
rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
continue
fi
- if [ $skip_unchanged = yes -a $is_currentport_latest = yes ]
+ if [ $skip_unchanged = yes ]
then
if [ ! -e "$nodedir/necessary_update_$deptag" ]
then
if [ -e "$nodedir/installed_version" ]
then
- msg_reinststage_info "Skipping because being already latest as well as the all requirements"
+ echo "(Skipped because being already latest as well as the all requirements)"
else
- msg_reinststage_info "Skipping because being an only-build-time dependency of already latest packages"
+ echo "(Skipped because being an only-build-time dependency of already latest packages)"
fi
echo
rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
fi
if [ $need_update = no ]
then
- msg_reinststage_info "Skipping because being already latest or failed as well as the all requirements"
+ echo "(Skipped because being already latest or failed as well as the all requirements)"
echo
add_a_line_if_new "$origin" "${DBDIR}/todo_after_requirements_succeed_$deptag.list"
rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
[ -z "${currentorigin_is_former_required}" ] \
|| echo "(Former requirement of the target port(s))" >> ${TMPDIR}/msg_if_target
else
- msg_reinststage_info "Skipping because being irrelevant"
+ echo "(Skipped because being irrelevant)"
echo
rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
continue
fi
if grep -m 1 -E "^$origin_regexp_esc$" "${DBDIR}/HOLD_PORTS.conflist" > /dev/null 2>&1
then
- msg_reinststage_info "Skipping because being a hold package"
+ echo "(Skipped because being a hold package)"
cat ${TMPDIR}/msg_if_target
echo
rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
fi
if grep -m 1 -E "^$origin_regexp_esc$" "${DBDIR}/taboo.all.list" > /dev/null 2>&1
then
- msg_reinststage_info "Ignored because being taboo"
+ echo "(Ignored because being taboo)"
cat ${TMPDIR}/msg_if_target
echo
rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
fi
if grep -m 1 -E "^$origin_regexp_esc$" "${DBDIR}/manually_done.list" > /dev/null 2>&1
then
- msg_reinststage_info "Marking to be manually-done"
+ echo "(Marked to be manually-done)"
cat ${TMPDIR}/msg_if_target
echo
rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
fi
if [ -e "$nodedir/SUPPRESSED" ]
then
- msg_reinststage_info "Skipping because being suppressed"
+ echo "(Skipped because being suppressed)"
cat ${TMPDIR}/msg_if_target
echo
rm_a_line "$origin" "${DBDIR}/reinst_todo.list"
instdesc='an installation'
fi
_MSG_CURRENT_STAGE="$instdesc process for $position_msg $counter"
- msg_stage "$counter Starting $instdesc process for $position_msg"
+ echo "------- Starting $instdesc process --------"
cat ${TMPDIR}/msg_if_target
cd "${PORTSDIR}/$origin"
if [ -e "$nodedir/status/in_build" ]
[ -e "$nodedir/dependents_$tag" ] || continue
while read origin_dependent
do
- touch "$nodedir_dependent/need_reinstall_due_to_updated_requirements_$tag"
+ touch "${DBDIR}/requires/$origin_dependent/need_reinstall_due_to_updated_requirements_$tag"
done < $nodedir/dependents_$tag
done
touch "$nodedir/status/COMPLETE_TELL_UPDATE_TO_DEPANDENTS"