summaryrefslogtreecommitdiff
path: root/prtrej
blob: e631a56740d6f84a3272af32028dd6152402b152 (plain)
    1 #!/bin/bash
    2 #
    3 # $Id: prtrej,v 1.4 2004/02/06 11:30:00 opel Exp $
    4 # (c) 2003,2004 by Martin Opel <mo@obbl-net.de>
    5 # (c) 2002 by Markus Ackermann <maol@symlink.ch>
    6 #
    7 # may be redistributed and modified under the terms of the GPL
    8 # only usable with CRUX Linux, version 0.9.2 or higher
    9 #
   10 # USE AT YOUR OWN RISK
   11 #
   12 # Interactive tool to ask user what he/she wants to do with a rejected file
   13 # in /var/lib/pkg/rejected requires opt/dialog to be installed. All
   14 # identical files are removed without a user's interaction
   15 
   16 TMP=/tmp/pkgrej$$
   17 OUT=/tmp/pkgout$$
   18 REJ=/var/lib/pkg/rejected
   19 
   20 cleanup() {
   21     echo "Removed $count identical files"
   22     rm -f $TMP $OUT
   23 }
   24 
   25 interrupted() {
   26     echo "Interrupted..."
   27     cleanup
   28     exit 1
   29 }
   30 
   31 trap "interrupted" SIGHUP SIGINT SIGQUIT SIGTERM
   32 
   33 count=0
   34 
   35 if [ ! -d "$REJ" ]; then
   36   echo "$REJ not found. Exiting"
   37   exit 1
   38 fi
   39 
   40 for reject in `find $REJ -type f`; do
   41     real=`echo $reject | sed -e "s#^$REJ##"`
   42     if diff $real $reject >/dev/null; then
   43 	rm $reject
   44 	count=`expr $count + 1`
   45     else
   46 	echo $reject differs
   47     fi
   48 done
   49 
   50 cd $REJ
   51 for FILE in `find . -type f`; do
   52     diff -u /$FILE $PWD/$FILE &> $TMP
   53 
   54     dialog --no-shadow \
   55 	--title "diff `echo /$FILE $PWD/$FILE | sed 's#/\.##g'`" \
   56 	--textbox $TMP -1 -1 \
   57 	--menu "Make your selection:" 11 40 4 \
   58 	KEEP "Keep old file." \
   59 	INST "Install new file." \
   60 	EXIT "Exit immediately." \
   61 	"  " "Do nothing now." \
   62 	2> $OUT
   63     
   64     ACTION=`cat $OUT`
   65     if [ "$ACTION" = "KEEP" ]; then
   66 	echo "Keeping old file, removing $PWD/$FILE."
   67 	rm $PWD/$FILE
   68     elif [ "$ACTION" = "INST" ]; then
   69 	echo "Installing new file, overwriting /$FILE with $PWD/$FILE."
   70 	mv $PWD/$FILE /$FILE
   71     elif [ "$ACTION" = "EXIT" ]; then
   72 	echo "Exiting..."
   73 	cleanup
   74 	exit 0
   75     else
   76 	echo "not doing anything with $PWD/$1"
   77     fi
   78 done
   79 
   80 cleanup

Generated by cgit