[prev in list] [next in list] [prev in thread] [next in thread] 

List:       crux
Subject:    Reconciliate rejected files
From:       Florian Weber <Florian.Weber () pfaffenhofen ! de>
Date:       2002-06-20 22:04:32
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all!

While doing a system-wide update today, I collected quite some files in 
/var/lib/pkg/rejected. (Great feature, Per!)

Being not only lazy but extremely lazy, I refused to check those files by 
hand. Instead, I hacked together a small script that you might be interested 
in:
It compares the rejected and installed files, presents a diff and applies that 
diff, if so desired. If a file gets updated, it's entry in 
/var/lib/pkg/rejected is removed.

Dependencies: sh, find, diff, vi, dialog, rm
License: GPL
Contributions: more than welcome :-)

Have fun,
Florian
- -- 
PGP key ID: 3C4E74DC
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9ElFwm8fasDxOdNwRAu17AKCNF/eH++l/bxfAVVsQFbVWYKRiIwCg1NAe
Tpl0IVFYcyW4QPO5NjnifwU=
=tXmt
-----END PGP SIGNATURE-----

["reconcile.sh" (application/x-shellscript)]

# reconciliate.sh:
# Look at all files in /var/lib/pkg/rejected, show differences to installed
# files, ask whether to update the installed files and do it
# If a file is updated, it is deleted in /var/lib/pkg/rejected. In all other
# cases, the "new" version will stay.

#-----------------------------------------------------------------------------
#REQUEST:
# If anybody knows an *easy* way to do a 3-way (or 4-way) selection with
# dialog (or otherwise) please tell me
#-----------------------------------------------------------------------------

# Author : Florian Weber <Florian.Weber@pfaffenhofen.de>
# Depends: bash, dialog
# License: GPL Version 2
# Changelog:
# - 2002-06-20
#   initial release

#!/bin/sh

EDITOR=/usr/bin/vi

#iterate over all (real) files in /var/lib/pkg/rejected
for i in `find /var/lib/pkg/rejected -type f`; do

	#funky version of "basename"
	j=`echo $i | cut -b 23-`
	
	diff -u /$j $j > /tmp/reconcile.patch

	#edit the patchfile until it's OK
	AGAIN=yes
	USE=no
	while [ "$AGAIN" == "yes" ]; do
		dialog --title "Changes for /$j" --textbox /tmp/reconcile.patch 22 70 
		dialog --yesno "Use this patchfile ?" 0 0
		case $? in
		0)
			#user selected: YES
			AGAIN=no
			USE=yes
			;;
		1)
			#user selected: NO
			$EDITOR /tmp/reconcile.patch
			;;
		255)
			#user hit ESC
			rm /tmp/reconcile.patch
			echo "Reconciliation canceled"
			exit
			;;
		esac
	done
	
	#if patchfile is OK, should it be applied?
	if [ "$USE" == "yes" ]; then
		dialog --yesno "Apply patchfile?" 0 0	
		case $? in
		0)
			#user selected: YES
			patch /$j < /tmp/reconcile.patch
			rm $j
			;;
		1)
			#user selected: NO
			#leave the original file
			;;
		255)
			#user hit ESC
			rm /tmp/reconcile.patch
			echo "Reconciliation canceled"
			exit
			;;
		esac
	fi
	
	rm /tmp/reconcile.patch
done


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic