From owner-svn-ports-head@FreeBSD.ORG Sat Mar 23 13:41:16 2013 Return-Path: Delivered-To: svn-ports-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D94E981D; Sat, 23 Mar 2013 13:41:16 +0000 (UTC) (envelope-from crees@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id BCED2658; Sat, 23 Mar 2013 13:41:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2NDfGnW046320; Sat, 23 Mar 2013 13:41:16 GMT (envelope-from crees@svn.freebsd.org) Received: (from crees@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2NDfGoO046318; Sat, 23 Mar 2013 13:41:16 GMT (envelope-from crees@svn.freebsd.org) Message-Id: <201303231341.r2NDfGoO046318@svn.freebsd.org> From: Chris Rees Date: Sat, 23 Mar 2013 13:41:16 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r315031 - in head/ports-mgmt/portdowngrade: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Mar 2013 13:41:16 -0000 Author: crees Date: Sat Mar 23 13:41:16 2013 New Revision: 315031 URL: http://svnweb.freebsd.org/changeset/ports/315031 Log: Update to 1.3 - Add recurse option, to recover ports that the recovered port depends on - Add recurse option, to recover ports that the recovered port depends on Modified: head/ports-mgmt/portdowngrade/Makefile head/ports-mgmt/portdowngrade/files/portdowngrade Modified: head/ports-mgmt/portdowngrade/Makefile ============================================================================== --- head/ports-mgmt/portdowngrade/Makefile Sat Mar 23 13:29:33 2013 (r315030) +++ head/ports-mgmt/portdowngrade/Makefile Sat Mar 23 13:41:16 2013 (r315031) @@ -2,7 +2,7 @@ # $FreeBSD$ PORTNAME= portdowngrade -PORTVERSION= 1.2 +PORTVERSION= 1.3 CATEGORIES= ports-mgmt MASTER_SITES= # empty DISTFILES= # none Modified: head/ports-mgmt/portdowngrade/files/portdowngrade ============================================================================== --- head/ports-mgmt/portdowngrade/files/portdowngrade Sat Mar 23 13:29:33 2013 (r315030) +++ head/ports-mgmt/portdowngrade/files/portdowngrade Sat Mar 23 13:41:16 2013 (r315031) @@ -5,9 +5,6 @@ # Fetch a port directory from an older version; # easy to use wrapper around Subversion -# Copyright 2013 Chris Rees -# crees@FreeBSD.org - # This script is in the public domain # $FreeBSD$ @@ -15,7 +12,7 @@ usage() { </dev/stderr cat -Usage: $0 port-directory|port [revision/date] +Usage: $0 [-r] port-directory|port [revision/date] When called without a revision to restore, svn log is called on the port's directory so that relevant revisions can be identified. Look for lines @@ -23,29 +20,76 @@ containing "Update to X.X". You may wis When called with a port name instead of directory/origin, INDEX is grepped for the correct origins and a list is presented. + +When called with -r, make describe is called in the restored port and all +of the ports that the restored port depended on are also checked out at the +same date. EOF exit 1 } err() { - echo "${@:-An unknown error has occurred}" > /dev/stderr + echo "${@:-An unknown error has occurred}" | fold -s > /dev/stderr exit 1 } +getport_recursive() +{ + # getport_recursive portorigin + # "This function is recursive" + echo -n "==> Fetching $1 ..." + [ -d $tmpdir/${1%/*} ] || \ + $svn -q up --depth files "$tmpdir/${1%/*}@$rev" || \ + err "Something went wrong with fetching category for $1. Ensure you have the correct revision!" + $svn -q up "$tmpdir/$1@$rev" || \ + err "Something went wrong with fetching port files for $1." + echo " [DONE]" + echo "$1" >> $tmpdir/portdowngrade.originlist + deps=$(make PORTSDIR=$(pwd)/$tmpdir -C $tmpdir/$1 -V_DEPEND_DIRS:N\*/pkg:S,${PORTSDIR}/,,) + if [ -n "$deps" ]; then + for port in $deps; do + if [ ! -d $tmpdir/$port ]; then + echo "===> $1@$rev depends on $port." + getport_recursive $port + fi + done + echo "===> All dependencies of $1@$rev fetched." + fi +} + svn=$(which svn 2>/dev/null) || err "Where is Subversion??" PORTSDIR="$(make -f /usr/share/mk/bsd.port.mk -VPORTSDIR)" [ -d $PORTSDIR ] || err "Where is your ports tree??" +args=$(getopt c:r $*) || usage + +set -- $args + +for arg; do + case $arg in + -r) + recurse=true + shift + ;; + --) + shift + break + ;; + -*) + usage + ;; + esac +done + case ${1-NULL} in -NULL|-*) +NULL) usage ;; */*) # Contains a directory, so we're ready for the next stage - # noop ;; @@ -100,13 +144,66 @@ NULL) ;; esac - $svn co "$svnroot/$portdir@$rev" || \ - err "Something went wrong with svn... Ensure you have the correct revision!" + case ${recurse:-false} in + false) + $svn co "$svnroot/$portdir@$rev" || \ + err "Something went wrong with svn... Ensure you have the correct revision!" + destination=${portdir#*/} + < Fetching empty ports tree... " + $svn -q co --depth files "$svnroot@$rev" $tmpdir || \ + err "Something went wrong with svn checkout... Ensure you have the correct revision!" + echo "[DONE]" + echo -n "=> Fetching important directories... " + important=$($svn ls $tmpdir@$rev | \ + sed -ne "s/^\([A-Z][^/]*\)\//$tmpdir\/\1@${rev}/p") + $svn -q up $important || \ + err "Could not fetch ^[A-Z] directories @$rev" + echo "[DONE]" + case x$(make -VWITH_PKGNG -f /usr/share/mk/bsd.port.mk) in + x) + ;; + *) + echo -n "=> Fetching current pkg... " + $svn -q up --depth empty $tmpdir/ports-mgmt + $svn -q up $tmpdir/ports-mgmt/pkg@. + echo "[DONE]" + ;; + esac + getport_recursive $portdir + destination=$tmpdir/$portdir + << EOF cat > $tmpdir/portdowngrade.recurse +echo "This script will recursively reinstall all of the ports fetched" +echo "that $portdir depended on. This is possibly dangerous and they may" +echo "not build." +echo "If you are sure that you know how to recover from this, answer 'yes'" +echo "to the following question." +echo +echo "Do you wish to remove all of the ports that $portdir depends on, and" +echo "reinstall with the versions just checked out?" +read var +[ "\$var" = "yes" ] || exit 1 +for dir in \$(cat portdowngrade.originlist); do + make PORTSDIR=\$(pwd) -C \$dir deinstall +done +make PORTSDIR=\$(pwd) -C $portdir install clean +EOF + << EOF fold -s +You should now be done-- now cd to $tmpdir, and check that the file portdowngrade.originlist has the correct ports in, then use - echo - echo "You should be done-- now cd into ${portdir#*/} and you can run" - echo "make deinstall install clean" - echo +# sh portdowngrade.recurse - exit 0 +Really... only use this option if you are desperate! + +EOF + ;; + esac esac + +exit 0