When dpkg updates a package and it detects that it should update
a config file that has been changed locally, it offers several
solutions---use local version, use official version or use diff as
external program. Usage of diff is hardwired into program - running
other program is not possible.

    I have modified dpkg to offer option of simultaneous editing of
both local and maintainer's file using vimdiff. As I realize that for
novice user it is dangerous to run vim accidentally, to enable the
feature is necessary to use the commandline/configfile option
--vimdiff.

    This option has shown to be an useful facility to me and I think
it may be worth of adding into official version of dpkg.

    If desirable, I might try to enhance it to use some configuration
file for adding the possibility of running even other external
programs (maybe emacsdiff or joediff :-)

    Regards
        Petr Skovron <[EMAIL PROTECTED]>
diff -u --recursive dpkg-1.9.19-orig/main/configure.c 
dpkg-1.9.19/main/configure.c
--- dpkg-1.9.19-orig/main/configure.c   Thu Apr 26 20:48:49 2001
+++ dpkg-1.9.19/main/configure.c        Tue Feb 12 17:50:26 2002
@@ -278,6 +278,10 @@
                   "    N or O  : keep your currently-installed version\n"
                   "      D     : show the differences between the versions\n"
                   "      Z     : background this process to examine the 
situation\n"));
+         if(f_vimdiff) {
+                 fprintf(stderr,
+                  _("      V     : vimdiff the differences between the 
versions\n"));
+         }
 
           if (what & cfof_keep)
             fprintf(stderr, _(" The default action is to keep your current 
version.\n"));
@@ -286,8 +290,9 @@
 
           s= strrchr(conff->name,'/');
           if (!s || !*++s) s= conff->name;
-          fprintf(stderr, "*** %s (Y/I/N/O/D/Z) %s ? ",
+          fprintf(stderr, "*** %s (Y/I/N/O/D/Z%s) %s ? ",
                   s,
+                 (f_vimdiff? "/V":""),
                   (what & cfof_keep) ? _("[default=N]") :
                   (what & cfof_install) ? _("[default=Y]") : _("[no 
default]"));
 
@@ -321,6 +326,20 @@
               if (!s || !*s) s= DEFAULTSHELL;
              execlp(s,s,"-c", cmdbuf, NULL);
               ohshite(_("failed to run diff (%.250s)"), cmdbuf);
+           }
+            while ((r= waitpid(c1,&status,0)) == -1 && errno == EINTR);
+            if (r != c1) { onerr_abort++; ohshite(_("wait for shell failed")); 
}
+         }
+
+          if ((cc == 'v') && (f_vimdiff)) {
+           if (!(c1= m_fork())) {
+             const char* p;
+             char cmdbuf[1024];
+             sprintf(cmdbuf, "vimdiff %.250s %.250s", cdr.buf, cdr2.buf);
+              s= getenv(SHELLENV);
+              if (!s || !*s) s= DEFAULTSHELL;
+             execlp(s,s,"-c", cmdbuf, NULL);
+              ohshite(_("failed to run vimdiff (%.250s)"), cmdbuf);
            }
             while ((r= waitpid(c1,&status,0)) == -1 && errno == EINTR);
             if (r != c1) { onerr_abort++; ohshite(_("wait for shell failed")); 
}
diff -u --recursive dpkg-1.9.19-orig/main/main.c dpkg-1.9.19/main/main.c
--- dpkg-1.9.19-orig/main/main.c        Tue Apr 24 17:32:39 2001
+++ dpkg-1.9.19/main/main.c     Fri Feb  8 00:19:30 2002
@@ -105,6 +105,7 @@
   --force-...                    Override problems - see --force-help\n\
   --no-force-...|--refuse-...    Stop when problems encountered\n\
   --abort-after <n>              Abort after encountering <n> errors\n\
+  --vimdiff                  Allow using vimdiff on local configuration 
files\n\
 \n\
 Comparison operators for --compare-versions are:\n\
  lt le eq ne ge gt       (treat no version as earlier than any version);\n\
@@ -130,6 +131,7 @@
 const struct cmdinfo *cipaction= 0;
 int f_pending=0, f_recursive=0, f_alsoselect=1, f_skipsame=0, f_noact=0;
 int f_autodeconf=0, f_nodebsig=0;
+int f_vimdiff=0;
 unsigned long f_debug=0;
 /* Change fc_overwrite to 1 to enable force-overwrite by default */
 int fc_downgrade=1, fc_configureany=0, fc_hold=0, fc_removereinstreq=0, 
fc_overwrite=0;
@@ -397,6 +399,7 @@
   { "recursive",         'R',  0,  &f_recursive,   0,  0,             1        
      },
   { "no-act",             0,   0,  &f_noact,       0,  0,             1        
      },
   { "no-debsig",          0,   0,  &f_nodebsig,    0,  0,             1        
      },
+  { "vimdiff",            0,   0,  &f_vimdiff,     0,  0,             1        
      },
   {  0,                  'G',  0,  &fc_downgrade,  0,  0, /* alias for 
--refuse */ 0 },
   { "selected-only",     'O',  0,  &f_alsoselect,  0,  0,             0        
      },
   { "no-also-select",    'N',  0,  &f_alsoselect,  0,0,0 /* fixme: remove 
sometime */ },
diff -u --recursive dpkg-1.9.19-orig/main/main.h dpkg-1.9.19/main/main.h
--- dpkg-1.9.19-orig/main/main.h        Tue Apr 24 00:06:03 2001
+++ dpkg-1.9.19/main/main.h     Fri Feb  8 00:21:12 2002
@@ -80,6 +80,7 @@
 extern const struct cmdinfo *cipaction;
 extern int f_pending, f_recursive, f_alsoselect, f_skipsame, f_noact;
 extern int f_autodeconf, f_largemem, f_nodebsig;
+extern int f_vimdiff;
 extern unsigned long f_debug;
 extern int fc_downgrade, fc_configureany, fc_hold, fc_removereinstreq, 
fc_overwrite;
 extern int fc_removeessential, fc_conflicts, fc_depends, fc_dependsversion;

Reply via email to