#!/bin/sh -e
# ==================================================================================
# portsreinstall main script
-# Copyright (C) 2010-2013 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
+# Copyright (C) 2010-2014 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
# This software is distributed under the 2-Clause BSD License.
# ==================================================================================
# ============ Set up of environment =============
APPNAME=`basename "$0"`
-# MYVERSION=3.0.0
+# MYVERSION=3.0.6
# COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+)$'
# Template for development versions
-MYVERSION=3.0.0+toward_3.0.1_20130609060102
-COMPATIBLE_VERSIONS='^(3\.0\.0\+toward_3\.0\.1_[0-9]+|3\.0\.[0-9]+)$'
-
+MYVERSION=3.0.5+toward_3.0.6_20140527113705
+COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+\+toward_3\.0\.[0-9]+_[0-9]+|3\.0\.[0-9]+)$'
MYPREFIX=`dirname "\`dirname \"$0\"\`" | sed 's|/bin$||'`
MYPREFIX=${MYPREFIX:-/usr/local}
LIBDIR=${MYPREFIX}/lib/${APPNAME}
CONFFILE=${MYPREFIX}/etc/${APPNAME}.conf
PKGTOOLSCONF=${MYPREFIX}/etc/pkgtools.conf
-
# ==================================================
# ========= PARSING OPTIONS AND ARGUMENTS ==========
# ==================================================
# ================== TOOLS SET UP ==================
# ==================================================
+# ============= Termination messages during construction of the temporary database =============
+
+# Set termination messages
+temp_terminate_process_common ()
+{
+ local msg_where
+ [ $opt_batch_mode = yes ] && return
+ msg_where=`temp_get_msg_current_stage`
+ [ -n "$msg_where" ] && msg_where=" during $msg_where"
+ echo
+ if [ $errno -eq 130 ]
+ then
+ echo "INFO: Terminated at `message_timestamp`$msg_where."
+ echo
+ echo " You can restart this process from the terminated point by"
+ else
+ echo "INFO: Aborted at `message_timestamp`$msg_where."
+ echo
+ echo " You may restart this process from the aborted point by"
+ fi
+ echo "executing without options or arguments as:"
+ if [ -n "$COMMAND_RESTART" ]
+ then
+ echo " ${APPNAME} $COMMAND_RESTART"
+ else
+ echo " ${APPNAME}"
+ fi
+}
+
+temp_terminate_process ()
+{
+ [ $errno -eq 0 -o $opt_batch_mode = yes ] && return
+ temp_terminate_process_common
+ [ -n "$COMMAND_RESTART" ] || message_cat 3<< eof
+ Instead, if you only want to construct the temporary database so as to stop before the actual reinstallation, execute as:
+ ${APPNAME} prepare
+eof
+}
+
# ============= Opening title =============
message_credit
message_echo
fi
-# ============= Termination messages during construction of the temporary database =============
-
-# Set termination messages
-temp_terminate_process_common ()
-{
- local msg_where
- [ $opt_batch_mode = yes ] && return
- msg_where=`temp_get_msg_current_stage`
- [ -n "$msg_where" ] && msg_where=" during $msg_where"
- echo
- if [ $errno -eq 130 ]
- then
- echo "INFO: Terminated at `message_timestamp`$msg_where."
- echo
- echo " You can restart this process from the terminated point by"
- else
- echo "INFO: Aborted at `message_timestamp`$msg_where."
- echo
- echo " You may restart this process from the aborted point by"
- fi
- echo "executing without options or arguments as:"
- if [ -n "$COMMAND_RESTART" ]
- then
- echo " ${APPNAME} $COMMAND_RESTART"
- else
- echo " ${APPNAME}"
- fi
-}
-
-temp_terminate_process ()
-{
- [ $errno -eq 0 -o $opt_batch_mode = yes ] && return
- temp_terminate_process_common
- [ -n "$COMMAND_RESTART" ] || message_cat 3<< eof
- Instead, if you only want to construct the temporary database so as to stop before the actual reinstallation, execute as:
- ${APPNAME} prepare
-eof
-}
-
# ============= Configurations =============
# Save the previous configuration if exists
need_msg=no
rm -rf "${DBDIR}/conf"
mkdir -p "${DBDIR}/conf"
- [ "x`options_get_effective_opt_load_pkgtoolsconf`" != xno -a $opt_batch_mode = no ] \
+ [ "x`options_get_effective_opt_load_pkgtoolsconf 2> /dev/null`" != xno -a $opt_batch_mode = no ] \
&& need_msg=yes
[ $need_msg = yes ] && \
message_section_title "Parsing pkgtools.conf (by using installed portupgrade)"
reinstall_exec ports-mgmt/pkg
reinstall_restore_conflicts
rm -f "${DBDIR}/target_all"
+ temp_set_msg_current_stage
message_echo
}
program_exec_and_record_completion UPGRADE_PKGNG
reinstall_exec ports-mgmt/dialog4ports
reinstall_restore_conflicts
rm -f "${DBDIR}/target_all"
+ temp_set_msg_current_stage
message_echo
}
program_exec_and_record_completion UPGRADE_DIALOG4PORTS
reinstall_exec "$MYPORTORIGIN"
reinstall_restore_conflicts
rm -f "${DBDIR}/target_all"
+ temp_set_msg_current_stage
message_echo
}
program_exec_and_record_completion UPGRADE_SELF
PROGRAM_DEPENDS=''
_program_exec_and_record_completion__operation ()
{
+ local tag level dbsuffix
message_section_title "Determining specified targets"
cat "${DBDIR}/stage.loop_list/target_itself.specified" \
"${DBDIR}/stage.loop_list/target_dependents.specified" \
cat "${DBDIR}/stage.loop_list/target_itself.specified" \
"${DBDIR}/stage.loop_list/target_dependents.specified" \
"${DBDIR}/stage.loop_list/target_requirements.specified" \
- "${DBDIR}/need.list" 2> /dev/null \
+ | sort -u > ${TMPDIR}/DETERMINE_SPECIFIED_TARGETS.reset
+ cat "${TMPDIR}/DETERMINE_SPECIFIED_TARGETS.reset" "${DBDIR}/need.list" 2> /dev/null \
| sort -u > ${DBDIR}/need.list.tmp
mv "${DBDIR}/need.list.tmp" "${DBDIR}/need.list"
sort -u "${DBDIR}/need.list" "${DBDIR}/targets_specified_so_far" \
> ${DBDIR}/targets_specified_so_far.tmp
mv "${DBDIR}/targets_specified_so_far.tmp" "${DBDIR}/targets_specified_so_far"
+ for tag in all run build none
+ do
+ for level in direct full
+ do
+ dbsuffix=$tag.$level
+ {
+ cat "${TMPDIR}/DETERMINE_SPECIFIED_TARGETS.reset"
+ cat "${DBDIR}/stage.loop_list/target_dependents.specified" | while read origin
+ do
+ nodedir=${DBDIR}/requires/$origin
+ cat "$nodedir/dependents.$dbsuffix" 2> /dev/null
+ done
+ cat "${DBDIR}/stage.loop_list/target_requirements.specified" | while read origin
+ do
+ nodedir=${DBDIR}/requires/$origin
+ cat "$nodedir/requirements.$dbsuffix" 2> /dev/null
+ done
+ } | sort -u | while read origin
+ do
+ fileedit_rm_a_line "$origin" "${DBDIR}/success.$dbsuffix.list"
+ fileedit_rm_a_line "$origin" "${DBDIR}/todo_after_requirements_succeed.$dbsuffix.list"
+ rm -f "${DBDIR}/requires/$origin/succeeded_once"
+ done
+ done
+ done
fi
message_echo
}
for tag in all run build
do
target=${DBDIR}/$dbtag/$origin/${table}.${tag}.${level}
- [ -e "$target.src" ] || continue
- sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern" "$target.src" \
- | grep -v '^$' | sort -u > $target.tmp
- [ -e "$target" ] && ! diff "$target.tmp" "$target" > /dev/null \
- && echo "$origin" >> ${DBDIR}/update_dependencies
- mv "$target.tmp" "$target"
+ if [ -e "$target.src" ]
+ then
+ sed -E -f "${DBDIR}/REPLACE.complete_sed_pattern" "$target.src" \
+ | grep -v '^$' | sort -u > $target.tmp
+ [ -e "$target" ] && ! diff "$target.tmp" "$target" > /dev/null \
+ && echo "$origin" >> ${DBDIR}/update_dependencies
+ mv "$target.tmp" "$target"
+ else
+ [ -e "$target" ] && echo "$origin" >> ${DBDIR}/update_dependencies
+ rm -f "$target"
+ fi
done
done
done
program_exec_and_record_completion LIST_DEINST_PKGS
# Collect entire distfiles list
-if [ $opt_suppress_inspect_entire_distinfo = yes ]
+if [ $opt_inspect_entire_distinfo = yes ]
then
PROGRAM_DEPENDS=''
_program_exec_and_record_completion__operation ()
message_section_title "Reinstallation"
program_exec_restartable_loop_operation reinst_todo
reinstall_restore_conflicts
+ temp_set_msg_current_stage
message_echo
}
program_exec_and_record_completion REINSTALLATION