diff options
author | crees <crees@FreeBSD.org> | 2013-03-23 21:41:16 +0800 |
---|---|---|
committer | crees <crees@FreeBSD.org> | 2013-03-23 21:41:16 +0800 |
commit | cfa13e08da44375b1a65110843df2282fcb0643e (patch) | |
tree | 442d5c839cc4ef670aaecd9bb46fe3f36b62bcd6 /ports-mgmt/portdowngrade | |
parent | ee0780bf951e5846d5b9a3b0d2c49767455645d9 (diff) | |
download | freebsd-ports-gnome-cfa13e08da44375b1a65110843df2282fcb0643e.tar.gz freebsd-ports-gnome-cfa13e08da44375b1a65110843df2282fcb0643e.tar.zst freebsd-ports-gnome-cfa13e08da44375b1a65110843df2282fcb0643e.zip |
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
Diffstat (limited to 'ports-mgmt/portdowngrade')
-rw-r--r-- | ports-mgmt/portdowngrade/Makefile | 2 | ||||
-rw-r--r-- | ports-mgmt/portdowngrade/files/portdowngrade | 125 |
2 files changed, 112 insertions, 15 deletions
diff --git a/ports-mgmt/portdowngrade/Makefile b/ports-mgmt/portdowngrade/Makefile index 56a5cec3fa55..5f3d7461d15d 100644 --- a/ports-mgmt/portdowngrade/Makefile +++ b/ports-mgmt/portdowngrade/Makefile @@ -2,7 +2,7 @@ # $FreeBSD$ PORTNAME= portdowngrade -PORTVERSION= 1.2 +PORTVERSION= 1.3 CATEGORIES= ports-mgmt MASTER_SITES= # empty DISTFILES= # none diff --git a/ports-mgmt/portdowngrade/files/portdowngrade b/ports-mgmt/portdowngrade/files/portdowngrade index db1870f0b27c..733d4934dfb4 100644 --- a/ports-mgmt/portdowngrade/files/portdowngrade +++ b/ports-mgmt/portdowngrade/files/portdowngrade @@ -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() { <<EOF >/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 wish to filter it through ${PAGER:-less}. 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#*/} + <<EOF cat +You should be done-- now cd into ${destination} and you can run +# make deinstall install clean +EOF + ;; + true) + tmpdir=$(mktemp -d portdowngrade.XXXXXXX) + echo -n "=> 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 |