# ================================================
APPNAME=`basename "$0"`
-MYVERSION=2.2.2+toward_2.2.3_20130117165752
+MYVERSION=2.2.2+toward_2.2.3_20130119200821
PREFIX=${PREFIX:-/usr/local}
CONFFILE=${PREFIX}/etc/${APPNAME}.conf
keep_distfiles=no
renew_options=no
supress_self_upadte=no
+supress_pkgng_upadte=no
supress_obsolete_db_clean=no
while :
do
then
supress_self_upadte=yes
shift
+ elif [ "$1" = "-g" ]
+ then
+ supress_pkgng_upadte=yes
+ shift
elif [ "$1" = "-c" ]
then
supress_obsolete_db_clean=yes
-d : Do not clean up obsolete or unused distfiles.
-N : Renew option settings (only for redo command).
-k : Keep ${APPNAME} itself untouched.
+ -g : Keep ports-mgmt/pkg untouched.
-c : Suppress cleaning the temporal database even if its obsolete.
[ARGUMENTS]
-k : Keep ${APPNAME} itself untouched.
This option supresses update, deinstallation and reinstallation of
the currently installed ${APPNAME}.
+ -g : Keep ports-mgmt/pkg untouched.
+ This option supresses update, deinstallation and reinstallation of
+ the currently installed ports-mgmt/pkg (pkgng).
-c : Suppress cleaning the temporal database even if its obsolete.
By default, the temporal database is automatically cleaned up if
it is older than the ports tree or ${APPNAME} itself is to be
_STATUS_DB_OBSOLETE=no
fi
+# Update ports-mgmt/pkg if it is newer in the ports tree
+if [ "x$WITH_PKGNG" = xyes -a $supress_pkgng_upadte = no -a `id -u` -eq 0 -a \( ! -e "${DBDIR}" -o ${_STATUS_DB_OBSOLETE} = yes \) ]
+then
+ pkg_info_qO ports-mgmt/pkg > ${TMPDIR}/pkgng_version || :
+ num_pkgng_versions=`cat "${TMPDIR}"/pkgng_version | wc -l`
+ if [ $num_pkgng_versions -gt 1 ]
+ then
+ echo "ERROR: Multiple versions of ports-mgmt/pkg are installed. This is unexpected." >&2
+ exit 1
+ elif [ $num_pkgng_versions -eq 1 ]
+ then
+ [ -d "${PORTSDIR}/ports-mgmt/pkg" ] || { 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" ]
+ then
+ if [ "$pkgng_pkg_new" != `cat "${TMPDIR}"/pkgng_version` ]
+ then
+ echo "INFO: The ports tree has a new version of ports-mgmt/pkg. It will be updated first."
+ echo "Updating ports-mgmt/pkg ($pkgng_pkg_current => $pkgng_pkg_new)..."
+ echo "Backing up the installed package..."
+ backup_pkg=`create_backup_pkg "$pkgng_pkg_current" "${PORTSDIR}"/packages/All` || :
+ echo "Reinstalling ports-mgmt/pkg..."
+ pkg_delete_f "$pkgng_pkg_current"
+ if make -C "${PORTSDIR}/ports-mgmt/pkg" reinstall
+ then
+ make -C "${PORTSDIR}/ports-mgmt/pkg" clean
+ else
+ echo "WARNING: Reinstallation failed. Restoring the old package..." >&2
+ make -C "${PORTSDIR}/ports-mgmt/pkg" deinstall || :
+ make -C "${PORTSDIR}/ports-mgmt/pkg" clean || :
+ [ -n "$backup_pkg" ] && pkg_add_f "$backup_pkg"
+ echo "INFO: Continuing with the old version..."
+ fi
+ fi
+ else
+ echo "WARNING: No port for ports-mgmt/pkg exists in the current ports tree" >&2
+ fi
+ fi
+fi
+
# Update portsreinstall itself if it is newer in the ports tree
if [ $supress_self_upadte = no -a `id -u` -eq 0 -a \( ! -e "${DBDIR}" -o ${_STATUS_DB_OBSOLETE} = yes \) ]
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; }
self_pkg_current=`cat "${TMPDIR}"/self_version`
- self_pkg_new=`( cd "${PORTSDIR}/$self_origin" && make package-name )`
+ self_pkg_new=`make -C "${PORTSDIR}/$self_origin" package-name`
if [ -n "$self_pkg_new" ]
then
if [ "$self_pkg_new" != `cat "${TMPDIR}"/self_version` ]
backup_pkg=`create_backup_pkg "$self_pkg_current" "${PORTSDIR}"/packages/All` || :
echo "Reinstalling ${APPNAME}..."
pkg_delete_f "$self_pkg_current"
- if ( cd "${PORTSDIR}/$self_origin" && make reinstall )
+ if make -C "${PORTSDIR}/$self_origin" reinstall
then
- ( cd "${PORTSDIR}/$self_origin" && make clean )
+ make -C "${PORTSDIR}/$self_origin" clean
if [ $supress_obsolete_db_clean = yes -a -d "${DBDIR}" ]
then
echo "INFO: Cleaning the temporal database..."
exit 1
else
echo "WARNING: Reinstallation failed. Restoring the old package..." >&2
- ( cd "${PORTSDIR}/$self_origin" && make deinstall ) || :
- ( cd "${PORTSDIR}/$self_origin" && make clean ) || :
+ make -C "${PORTSDIR}/$self_origin" deinstall || :
+ make -C "${PORTSDIR}/$self_origin" clean || :
[ -n "$backup_pkg" ] && pkg_add_f "$backup_pkg"
echo "INFO: Continuing with the old version..."
fi