Просмотр исходного кода

Add an option to show the diff between old and new conffile

Wichert Akkerman лет назад: 27
Родитель
Сommit
4a1d09ae22
4 измененных файлов с 24 добавлено и 1 удалено
  1. 5 0
      ChangeLog
  2. 2 0
      include/dpkg.h.in
  3. 15 0
      main/configure.c
  4. 2 1
      split/info.c

+ 5 - 0
ChangeLog

@@ -8,6 +8,11 @@ Wed Oct 13 17:51:17 CEST 1999 Wichert Akkerman <wakkerma@debian.org>
       wrong package
     + fix findbreakcycle to remove cycles even for packages we are not changing
 
+Mon Oct 11 22:19:01 CEST 1999 Wichert Akkerman <wakkerma@debian.org>
+
+  * Add the option to show a diff of the old and new conffile when
+    configuring a package
+
 Tue Oct 12 17:15:08 CEST 1999 Wichert Akkerman <wakkerma@debian.org>
 
   * don't die if we can't open a package in dpkg-scanpackages, just print

+ 2 - 0
include/dpkg.h.in

@@ -91,6 +91,8 @@
 #define NOJOBCTRLSTOPENV    "DPKG_NO_TSTP"
 #define SHELLENV            "SHELL"
 #define DEFAULTSHELL        "sh"
+#define PAGERENV            "PAGER"
+#define DEFAULTPAGER        "pager"
 
 #define IMETHODMAXLEN        50
 #define IOPTIONMAXLEN        IMETHODMAXLEN

+ 15 - 0
main/configure.c

@@ -236,6 +236,7 @@ void deferred_configure(struct pkginfo *pkg) {
                   _("   What would you like to do about it ?  Your options are:\n"
                   "    Y or I  : install the package maintainer's version\n"
                   "    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 (what & cfof_keep)
@@ -269,6 +270,20 @@ void deferred_configure(struct pkginfo *pkg) {
           
           /* fixme: say something if silently not install */
 
+          if (cc == 'd') {
+	    if (!(c1= m_fork())) {
+	      const char* p;
+	      char cmdbuf[1024];
+	      p= getenv(PAGERENV);
+	      if (!p || !*p) p= DEFAULTPAGER;
+	      sprintf(cmdbuf, "diff -u %.250s %.250s | %.250s", cdr.buf, cdr2.buf, p);
+	      execlp(s,s,"-c", cmdbuf);
+              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 == 'z') {
 
             strcpy(cdr2rest, DPKGNEWEXT);

+ 2 - 1
split/info.c

@@ -82,8 +82,9 @@ struct partinfo *read_info(FILE *partfile, const char *fn, struct partinfo *ir)
   int c;
   struct stat stab;
   
-  if (fread(magicbuf,1,sizeof(PARTMAGIC)-1,partfile) != sizeof(PARTMAGIC)-1)
+  if (fread(magicbuf,1,sizeof(PARTMAGIC)-1,partfile) != sizeof(PARTMAGIC)-1) {
     if (ferror(partfile)) rerr(fn); else return 0;
+  }
   if (memcmp(magicbuf,PARTMAGIC,sizeof(magicbuf))) return 0;
   if (fseek(partfile,-sizeof(arh.ar_name),SEEK_CUR))
     ohshite(_("unable to seek back"));