#!/bin/sh # # pkgupdate - backup, then update packages cleverly from pkgsrc # # Copyright (c) 2004, 2005, 2006 Karsten Kruse tecneeq(at)tecneeq(dot)de # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # 3. Neither the name of the author nor the names of its contributors # may be used to endorse or promote products derived from this # software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. my_pkg_backups="/tmp/pkgbackup" my_pkg_list="/usr/pkgsrc/pkgchk.conf" my_temp="/tmp/saveupdate" die() { echo Error: $1 exit 1 } mkdir -p $my_temp || die "could not create the directory $my_temp" # needed software for i in pkglint pkgdepgraph pkg_tarup ; do pkg_info -qe $i || die "$i is needed but not yet installed" done # find newer packages lintpkgsrc -i > $my_temp/update.txt echo "Generating list of packages to backup and delete" pkgdepgraph -D $my_temp/update.txt > $my_temp/delete.txt echo "Generating list of packages to rebuild" pkgdepgraph -R $my_temp/update.txt > $my_temp/rebuild.sh export PKGREPOSITORY=${PKGREPOSITORY:-$my_pkg_backups} echo "Backing up installed packages to $PKGREPOSITORY" mkdir -p $PKGREPOSITORY || die "could not create $PKGREPOSITORY" pkg_tarup `cat $my_temp/delete.txt` | egrep -v "^Registering |^Creating binary" echo "In case something goes wrong you can install your old packages wich" echo "are saved to $PKGREPOSITORY" echo "Deleting old, installed packages" pkg_delete `cat $my_temp/delete.txt` echo "Rebuilding the new packages" sh $my_temp/rebuild.sh rm -rf $my_temp || die "could not remove the directory $my_temp" # eof