#! /bin/sh /usr/share/dpatch/dpatch-run
## 605-move-kuesvr-to-usrlib.dpatch by  <kmccarty@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Move kuesvr into /usr/lib/@MULTIARCH@/libpacklib1-gfortran in conformance
## DP: with Policy 8.1.

@DPATCH@
diff -urNad --exclude=CVS --exclude=.svn ./src/packlib/kuip/code_kuip/kedit.c /tmp/dpep-work.Ee7d3Y/cernlib-2005.05.09/src/packlib/kuip/code_kuip/kedit.c
--- ./src/packlib/kuip/code_kuip/kedit.c	2005-07-15 20:50:03.364033336 +0000
+++ cernlib-2005.05.09/src/packlib/kuip/code_kuip/kedit.c	2005-07-15 21:02:07.386883015 +0000
@@ -184,8 +184,12 @@
       }
     }
     close( fid );
-    
+
+#if defined(CERNLIB_DEBIAN)
+    line = strdup( "/usr/lib/@MULTIARCH@/libpacklib1-gfortran/kuesvr -p " );
+#else
     line = strdup( "kuesvr -p " );
+#endif
     line = mstricat( line, getpid() );
     line = mstr2cat( line, " -t ", editor_tmp );
     line = mstr4cat( line, " -c ", ku_path(), " -e '",
@@ -679,7 +683,11 @@
     if( strchr( kc_value.set_host_editor, '&' ) != NULL ) {
       /* must be a workstation and kuesvr in search path to use server */
       kc_flags.use_server =
+#if defined(CERNLIB_DEBIAN)
+	(getenv( "DISPLAY" ) != NULL); /* for Debian, kuesvr not in $PATH */
+#else
         (getenv( "DISPLAY" ) != NULL) && (ku_qexe( "kuesvr" ) != NULL);
+#endif
 
         /* vi must be wrapped into xterm */
       if( kc_flags.use_server
diff -urNad --exclude=CVS --exclude=.svn ./src/packlib/kuip/code_kuip/kiinit.F /tmp/dpep-work.Ee7d3Y/cernlib-2005.05.09/src/packlib/kuip/code_kuip/kiinit.F
--- ./src/packlib/kuip/code_kuip/kiinit.F	1997-10-23 16:53:58.000000000 +0000
+++ cernlib-2005.05.09/src/packlib/kuip/code_kuip/kiinit.F	2005-07-15 21:01:19.252193868 +0000
@@ -272,17 +272,29 @@
       IF (EDITOR(LE-1:LE) .EQ. 'vi') THEN
          IF (EDITOR(1:1) .EQ. '/' .OR. EDITOR(1:2) .EQ. 'vi') THEN
             SERVER = .FALSE.
+#if defined(CERNLIB_DEBIAN)
+C        For Debian, kuesvr is in /usr/lib/@MULTIARCH@/libpacklib1-gfortran/
+C        so don't test for it in PATH
+         ELSE
+            SERVER = .TRUE.
+#else
          ELSEIF (KUQEXE('kuesvr')) THEN
             SERVER = .TRUE.
          ELSE
             SERVER = .FALSE.
+#endif
          ENDIF
+#if defined(CERNLIB_DEBIAN)
+      ELSE
+         SERVER = .TRUE.
+#else
 #ifndef CERNLIB_WINNT
       ELSEIF (KUQEXE('kuesvr')) THEN
          SERVER = .TRUE.
 #endif
       ELSE
          SERVER = .FALSE.
+#endif
       ENDIF
 #endif
       NSVFIL = 0
diff -urNad --exclude=CVS --exclude=.svn ./src/packlib/kuip/code_kuip/kuipcdf.cdf /tmp/dpep-work.Ee7d3Y/cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuipcdf.cdf
--- ./src/packlib/kuip/code_kuip/kuipcdf.cdf	2005-07-15 20:50:03.365033123 +0000
+++ cernlib-2005.05.09/src/packlib/kuip/code_kuip/kuipcdf.cdf	2005-07-15 21:03:13.955630301 +0000
@@ -832,6 +832,8 @@
 can continue to receive commands.
 In order to do that the following conditions must be fulfilled:
  - The KUIP edit server 'kuesvr' must be found in the search path.
+   (This is not necessary in Debian, where it is installed into the
+   /usr/lib/@MULTIARCH@/libpacklib1-gfortran directory.)
  - The editor command set by HOST_EDITOR must end with an ampersand ('&').
  - The environment variable 'DISPLAY' must be set.
 .
