From owner-svn-ports-all@FreeBSD.ORG Thu Aug 21 15:56:15 2014 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4A2B9E6F; Thu, 21 Aug 2014 15:56:15 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1B7703640; Thu, 21 Aug 2014 15:56:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7LFuEY5041047; Thu, 21 Aug 2014 15:56:14 GMT (envelope-from mandree@FreeBSD.org) Received: (from mandree@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7LFuE0p041046; Thu, 21 Aug 2014 15:56:14 GMT (envelope-from mandree@FreeBSD.org) Message-Id: <201408211556.s7LFuE0p041046@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mandree set sender to mandree@FreeBSD.org using -f From: Matthias Andree Date: Thu, 21 Aug 2014 15:56:14 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r365566 - head/Tools/scripts X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2014 15:56:15 -0000 Author: mandree Date: Thu Aug 21 15:56:14 2014 New Revision: 365566 URL: http://svnweb.freebsd.org/changeset/ports/365566 QAT: https://qat.redports.org/buildarchive/r365566/ Log: Add a BerkeleyDB upgrade helper script in preparation of 4...4.7 removal. Added: head/Tools/scripts/BDB-upgrade-helper.sh (contents, props changed) Added: head/Tools/scripts/BDB-upgrade-helper.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/Tools/scripts/BDB-upgrade-helper.sh Thu Aug 21 15:56:14 2014 (r365566) @@ -0,0 +1,77 @@ +#!/bin/sh +# $Id$ +# ports/Tools/scripts/BDB-upgrade-helper.sh +# +# A helper script to upgrade applications that used to depend on +# BerkeleyDB ports 4.0...4.7 to use a newer version of BerkeleyDB. +# +# Written by Matthias Andree in 2014, and placed under the same +# license as FreeBSD itself, see /COPYRIGHT or /usr/src/COPYRIGHT. + +set -eu +: ${PREFIX:=/usr/local} +: ${LOCALBASE:=${PREFIX}} + +# check requisites +tool= +if [ -x ${LOCALBASE}/sbin/portmaster ] ; then tool=portmaster ; +elif [ -x ${LOCALBASE}/sbin/portupgrade ]; then tool=portupgrade; +else + echo >&2 "Neither portmaster nor portupgrade installed. Cannot continue." + echo >&2 "Please install ports-mgmt/portmaster before proceeding." + exit 1 +fi + +# check BerkeleyDB 4.0...4.7 versions +rx='db4[1-7]?(-nocrypto)?-4' +if pkg -N 2>/dev/null ; then pkg=yes ; else pkg= ; fi +if [ -n "$pkg" ] ; then + # pkg + dbnames=$(pkg info -x "$rx") +else + # old pkg_* + dbnames=$(pkg_info -E -X "$rx") +fi + +# due to set -e, the script will not reach this point +# unless there have been matched packages - without packages, +# pkg_info or pkg will exit with failure. + +# check if we need to pass in origins or package names +if [ "$tool" = portupgrade ] ; then + if [ -n "$pkg" ] ; then + dbnames=$(printf '%s\n' "$dbnames" | xargs -n1 pkg info -q -o) + else + dbnames=$(printf '%s\n' "$dbnames" | xargs -n1 pkg_info -q -o) + fi +fi + +# generate the upgrade command +case "$tool" in +portmaster) + cmd="portmaster -R" + for i in $dbnames ; do cmd="$cmd -r $i" ; done + ;; +portupgrade) + cmd="portupgrade -f -r" + for i in $dbnames ; do cmd="$cmd -x $i" ; done + for i in $dbnames ; do cmd="$cmd $i" ; done + ;; +*) + echo >&2 "Internal error in $0." ; exit 1 + ;; +esac + +echo "+ $cmd" +$cmd + +# due to set -e, the script will not reach this point +# if there was an error or failure with the upgrade tool + +if [ -n "$pkg" ] ; then + pkg delete $dbnames +else + pkg_delete $dbnames +fi + +echo "Success."