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
PKGSYS_CMD_PKG_ADD='pkg add'
pkg_is_tool_available ()
{
- which -a pkg | grep -v '^/usr/sbin/pkg$' | grep -q '/sbin/pkg$' && return
- [ -x /usr/sbin/pkg ] || return
- /usr/sbin/pkg
- pkg_is_tool_available
+ if [ -x /usr/sbin/pkg ]
+ then
+ pkg -N 2> /dev/null && return
+ env ASSUME_ALWAYS_YES=yes pkg bootstrap -f
+ pkg_is_tool_available
+ else
+ which -s pkg && return
+ fi
}
pkg_info_Ea ()
{
}
pkg_rescue_tools ()
{
- local packagepath checksumpath pkgname
+ local packagepath checksumpath pkgname is_successful
packagepath=`pkgsys_get_backup_pkg ports-mgmt/pkg` && \
pkg_add_tools "$packagepath" && return
pkg_is_tool_available && return
message_echo "WARNING: WITH_PKGNG is set, but pkgng is still missing. It is installed now." >&2
pkgsys_ready_checksum_file || return
+ message_echo "INFO: Installing pkgng by legacy package tool."
checksumpath=`pkgsys_ready_checksum_file__fetched_file`
pkgname=`sed 's/^MD5[[:space:]]*(//;s/\.tbz)[[:space:]]*=[^=]*$//' "$checksumpath" \
| grep -m 1 -E -e "^pkg-[0-9]"` || :
- [ -z "$pkgname" ] && pkg_inst_remote_wild "$pkgname" nodepschk && return
- make -C "${PORTSDIR}/ports-mgmt/pkg" install clean && return
- message_echo "ERROR: WITH_PKGNG is set, but pkgng is missing. It is installed now." >&2
- :
+ [ -n "$pkgname" ] && pkg_inst_remote_wild "$pkgname" nodepschk && return
+ message_echo "INFO: Failed by package, so installing pkgng by port."
+ grep -v '^[[:space:]]*WITH_PKGNG=' /etc/make.conf > ${TMPDIR}/make.conf
+ echo WITHOUT_PKGNG=yes >> ${TMPDIR}/make.conf
+ ( set -e
+ unset WITH_PKGNG
+ unset WITHOUT_PKGNG
+
+ message_echo "INFO: Attempting deinstallation of ports-mgmt/pkg to make sure."
+ env __MAKE_CONF="${TMPDIR}/make.conf" make -C "${PORTSDIR}/ports-mgmt/pkg" deinstall || :
+ message_echo "INFO: Attempting (re)installation by ports-mgmt/pkg."
+ env __MAKE_CONF="${TMPDIR}/make.conf" make -C "${PORTSDIR}/ports-mgmt/pkg" reinstall clean
+ ) && {
+ pkg2ng || :
+ pkg_is_tool_available
+ }
}
- pkg_rescue_tools
+ if ! pkg_rescue_tools
+ then
+ message_echo "WARNING: Pkgng is still missing, but continuing for the time being." >&2
+ fi
pkg_loadconf
elif ! pkgsys_is_legacy_tool_available
then
message_echo "ERROR: Pkgng is disabled although the legacy packages tools are unavailable. Resolve the problem manually." >&2
+ exit 1
else
unset WITH_PKGNG
PKGSYS_USE_PKGNG=no