From: Mamoru Sakaue / MwGhennndo Date: Sat, 19 Jan 2013 11:09:45 +0000 (+0900) Subject: [NEW] Option of -g is added. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5a3976ee3bc153d6da9b00b51fd7409474545d46;p=portsreinstall%2Fcurrent.git [NEW] Option of -g is added. [IMPROVED] A change is made so as to carry out update of ports-mgmt/pkg in advanced to everything in case of pkgng. modified: portsreinstall modified: portsreinstall.8 --- diff --git a/portsreinstall b/portsreinstall index ce2dc98..bd3568a 100755 --- a/portsreinstall +++ b/portsreinstall @@ -10,7 +10,7 @@ # ================================================ 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 @@ -56,6 +56,7 @@ skip_unchanged=no keep_distfiles=no renew_options=no supress_self_upadte=no +supress_pkgng_upadte=no supress_obsolete_db_clean=no while : do @@ -127,6 +128,10 @@ 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 @@ -180,6 +185,7 @@ USAGE: ${APPNAME} [OPTIONS] [command] -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] @@ -286,6 +292,9 @@ USAGE: ${APPNAME} [OPTIONS] [command] -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 @@ -1187,6 +1196,47 @@ else _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 @@ -1201,7 +1251,7 @@ 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` ] @@ -1212,9 +1262,9 @@ then 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..." @@ -1228,8 +1278,8 @@ then 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 diff --git a/portsreinstall.8 b/portsreinstall.8 index 0cad9d7..60fd59f 100644 --- a/portsreinstall.8 +++ b/portsreinstall.8 @@ -189,6 +189,10 @@ Option settings for \fB\-s\fR, \fB\-q\fR and \fB\-d\fR are reset according to th Keep portsreinstall itself untouched. This option supresses update, deinstallation and reinstallation of the currently installed portsreinstall. .TP +\fB\-g\fR +Keep ports-mgmt/pkg untouched. +This option supresses update, deinstallation and reinstallation of the currently installed ports-mgmt/pkg (pkgng). +.TP \fB\-c\fR 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 portsreinstall itself is to be updated. @@ -288,6 +292,10 @@ Configuration file of portupgrade(1). \fBportsreinstall\fR has been developed as below. .TP 2.2.3 (? January 2013) +[NEW] Option of \fB-g\fR is added. + +[IMPROVED] A change is made so as to carry out update of ports-mgmt/pkg in advanced to everything in case of pkgng. + [IMPROVED] The treatment of backup packages is modified to be safer by considering possible format fluctuation in case of pkgng. [MISC] Line feeds of the help and information messages are improved.