#!/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.1
+# MYVERSION=3.0.6
# COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+)$'
# Template for development versions
-MYVERSION=3.0.1+toward_3.0.2_20130703211449
-COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+\+toward_3\.0\.1_[0-9]+|3\.0\.[0-9]+)$'
+MYVERSION=3.0.5+toward_3.0.6_20140707110837
+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}
misc_init_vardefs
temp_trap_init
-conf_setup_envs
DBDIR=/var/tmp/${APPNAME}.db
CONFFILE=${MYPREFIX}/etc/${APPNAME}.conf
PKGTOOLSCONF=${MYPREFIX}/etc/pkgtools.conf
-
# ==================================================
# ========= PARSING OPTIONS AND ARGUMENTS ==========
# ==================================================
exit
elif [ $opt_help_mode -eq 2 ]
then
- usage_long | less
+ usage_long | less -r
exit
fi
exit
fi
+# ============= Set up variables for environment of ports and packages =============
+conf_setup_ports_envs
+conf_setup_packages_envs
+
# ============= Execute command operations before getting the temporary database ready =============
command_exec_before_db_creation "$@"
# ================== 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 ()
+{
+ local tmp_msg
+ tmp_msg=${TMPDIR}/temp_terminate_process:msg
+ [ $errno -eq 0 -o $opt_batch_mode = yes ] && return
+ temp_terminate_process_common
+ [ -n "$COMMAND_RESTART" ] && return
+ cat > $tmp_msg << eof
+ Instead, if you only want to construct the temporary database so as to stop before the actual reinstallation, execute as:
+ ${APPNAME} prepare
+eof
+ message_cat "$tmp_msg"
+}
+
# ============= Opening title =============
message_credit
options_chk_invalid_optvals_renewal non_renewable || optcomb_err=$?
if [ \( $opt_reload_conf = yes -o $opt_reset_targets = yes \) -a "x$COMMAND_MODE" != xredo ]
then
- message_echo "ERROR: Option -N is available only in the initial run of redo command." >&2
+ message_echo "ERROR: Options -L and -N are available only in the initial run of redo command." >&2
message_echo >&2
optcomb_err=1
fi
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='CONVERT_REQUIREMENTS_LIST'
_program_exec_restartable_loop_operation__routine ()
{
- local tag dbpath origin
+ local tag dbpath origin suffix
tag=${_REQUIREMENT_LISTS_tag}
dbpath=$1
origin=`str_dirpath_to_origin "$dbpath"`
- database_build_get_complete_recursive_dependency requirements.${tag} "$origin" > /dev/null
+ for suffix in '' .orig
+ do
+ database_build_get_complete_recursive_dependency requirements.${tag} "$origin" "$suffix" > /dev/null
+ done
}
_program_exec_and_record_completion__operation ()
{
program_exec_restartable_loop_operation complete_${tag}time_reqlists
message_echo
}
- program_exec_and_record_completion REQUIREMENT_LISTS:${_REQUIREMENT_LISTS_tag}
+ program_exec_and_record_completion RECURSIVE_REQUIREMENT_LISTS:${_REQUIREMENT_LISTS_tag}
done
# Trim dependency lists by removing uninspected ports
PROGRAM_DEPENDS='INSPECT_ALL_DEPENDENCIES CONVERT_REQUIREMENTS_LIST TRIM_DEPENDENCY_LISTS_RM_UNINSPECTED_PORTS'
_program_exec_restartable_loop_operation__routine ()
{
- local dbpath origin tag level srcdb dstdb
+ local dbpath origin tag level suffix srcdb dstdb
dbpath=$1
origin=`str_dirpath_to_origin "$dbpath"`
for tag in all run build
do
for level in direct full
do
- srcdb=requirements.${tag}.${level}
- dstdb=dependents.${tag}.${level}
- [ -e "$dbpath/$srcdb" ] || continue
- while read origin_requirement
+ for suffix in '' .orig
do
- dstpath=${DBDIR}/requires/$origin_requirement
- echo "$dstpath/$dstdb" >> ${DBDIR}/dependents_files.tmp
- [ "$dstpath/$dstdb" -nt "$dbpath/$srcdb" ] && continue
- [ -d "$dstpath" ] || mkdir -p "$dstpath"
- echo "$origin" >> $dstpath/$dstdb.raw
- echo "$dstpath/$dstdb" >> ${DBDIR}/stage.loop_list/make_dependents_lists_unique.tmp
- done < $dbpath/$srcdb
+ srcdb=requirements.${tag}.${level}${suffix}
+ dstdb=dependents.${tag}.${level}${suffix}
+ [ -e "$dbpath/$srcdb" ] || continue
+ while read origin_requirement
+ do
+ dstpath=${DBDIR}/requires/$origin_requirement
+ echo "$dstpath/$dstdb" >> ${DBDIR}/dependents_files.tmp
+ [ "$dstpath/$dstdb" -nt "$dbpath/$srcdb" ] && continue
+ [ -d "$dstpath" ] || mkdir -p "$dstpath"
+ echo "$origin" >> $dstpath/$dstdb.raw
+ echo "$dstpath/$dstdb" >> ${DBDIR}/stage.loop_list/make_dependents_lists_unique.tmp
+ done < $dbpath/$srcdb
+ done
done
done
}
program_exec_and_record_completion PARSE_TARGET_ATTR_INFO
# Inspection of necessity
-PROGRAM_DEPENDS='TARGET_ATTR_INFO_POSTPROCESS REQUIREMENT_LISTS:run-time REQUIREMENT_LISTS:build-time INSPECT_ALL_DEPENDENCIES'
+PROGRAM_DEPENDS='TARGET_ATTR_INFO_POSTPROCESS RECURSIVE_REQUIREMENT_LISTS:run RECURSIVE_REQUIREMENT_LISTS:build INSPECT_ALL_DEPENDENCIES'
_program_exec_restartable_loop_operation__routine ()
{
local origin
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