OSDN Git Service

Version 3.0.5+toward_3.0.6_20140531202509
[portsreinstall/current.git] / bin / portsreinstall
index 9e26003..7185855 100755 (executable)
@@ -1,7 +1,7 @@
 #!/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.4
-COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+)$'
+# MYVERSION=3.0.6
+COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+)$'
 # Template for development versions
-# MYVERSION=3.0.3+toward_3.0.4_20131115074959
-COMPATIBLE_VERSIONS='^(3\.0\.[0-9]+\+toward_3\.0\.[0-9]+_[0-9]+|3\.0\.[0-9]+)$'
+MYVERSION=3.0.5+toward_3.0.6_20140531202509
+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}
@@ -40,12 +40,10 @@ 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 ==========
 # ==================================================
@@ -94,6 +92,10 @@ then
        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 "$@"
 
@@ -109,6 +111,49 @@ shift "${COMMAND_SHIFT}"
 # ================== 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
@@ -169,45 +214,6 @@ then
        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