From crux Thu Jun 20 22:04:32 2002 From: Florian Weber Date: Thu, 20 Jun 2002 22:04:32 +0000 To: crux Subject: Reconciliate rejected files X-MARC-Message: https://marc.info/?l=crux&m=102465043628986 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------Boundary-00=_KNY0559I2LL3LMUOSTDK" --------------Boundary-00=_KNY0559I2LL3LMUOSTDK Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all! While doing a system-wide update today, I collected quite some files in=20 /var/lib/pkg/rejected. (Great feature, Per!) Being not only lazy but extremely lazy, I refused to check those files by= =20 hand. Instead, I hacked together a small script that you might be interes= ted=20 in: It compares the rejected and installed files, presents a diff and applies= that=20 diff, if so desired. If a file gets updated, it's entry in=20 /var/lib/pkg/rejected is removed. Dependencies: sh, find, diff, vi, dialog, rm License: GPL Contributions: more than welcome :-) Have fun, Florian - --=20 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=3D =3DtXmt -----END PGP SIGNATURE----- --------------Boundary-00=_KNY0559I2LL3LMUOSTDK Content-Type: application/x-shellscript; name="reconcile.sh" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="reconcile.sh" # 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 # 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 --------------Boundary-00=_KNY0559I2LL3LMUOSTDK--