diff -urNad debian.orig/changelog debian/changelog
--- debian.orig/changelog	2012-04-24 13:55:41.000000000 +0100
+++ debian/changelog	2013-04-20 11:30:23.303722849 +0100
@@ -1,3 +1,9 @@
+xgraph (12.1+dfsg-17) unstable; urgency=low
+
+  * remove non-free routines by Paul Walker (closes: #705152)
+
+ -- Steven Ayre <steveayre@gmail.com>  Sat, 20 Apr 2013 11:30:23 +0100
+
 xgraph (12.1-16) unstable; urgency=low
 
   * bump to dh9
diff -urNad debian.orig/docs debian/docs
--- debian.orig/docs	2012-04-24 13:22:43.000000000 +0100
+++ debian/docs	2013-04-20 11:31:45.791720692 +0100
@@ -3,4 +3,3 @@
 README.GENERAL
 README.HARDCOPY
 README.INSTALL
-README.NEWFEATURES
diff -urNad debian.orig/patches/debian-changes debian/patches/debian-changes
--- debian.orig/patches/debian-changes	2012-04-24 13:55:56.000000000 +0100
+++ debian/patches/debian-changes	2013-04-20 11:45:07.371704354 +0100
@@ -32,66 +32,6 @@
 @@ -0,0 +1,2 @@
 +void DrawWindow(LocalWin *);
 +void EraseData(LocalWin *);
---- xgraph-12.1.orig/copyright.h
-+++ xgraph-12.1/copyright.h
-@@ -5,9 +5,6 @@
-  * University of California, Berkeley
-  * 1989
-  *
-- * Animation, Differentiation by Paul Walker
-- * NCSA and University of Illinois at Urbana Champaign Dept. of Physics
-- *
-  * Copyright (c) 1988, 1989, Regents of the University of California.
-  * All rights reserved.
-  *
-@@ -20,41 +17,6 @@
-  * Research Laboratory or the University of California make any
-  * warranty about the software, its performance or its conformity to
-  * any specification.
-- *
--
--Animation and differentiation routines were added by Paul Walker,
--NCSA and UIUC Dept of Physics.  The following copyright and disclaimer
--applies to these parts of the code only.
--
--UNIVERSITY OF ILLINOIS (UI), NATIONAL CENTER FOR SUPERCOMPUTING
--APPLICATIONS (NCSA), Software Distribution Policy for Copyrighted Software
--
--The above mentioned modifications to XGraph made with the authors consent are
--copyrighted, but  available without fee for education, academic research
--and non-commercial purposes.  The modifications are copyrighted in the name of
--the UI, and ownership of the modifications remains with the UI.  Users may
--distribute the binary and source code to third parties provided that the
--copyright notice and this statement appears on all copies and that no
--charge is made for such copies.  Any entity wishing to integrate all or
--part of the source code into a product for  commercial use or resale,
--should contact the University of Illinois, c/o NCSA, to negotiate an
--appropriate license for such commercial use.  
--
--UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR ANY
--PURPOSE.  IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.  THE
--UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE USER OF THIS
--SOFTWARE.  The software may have been developed under agreements between
--the UI and the Federal Government which entitle the Government to certain
--rights.
--
--By copying this program, you, the user, agree to abide by the copyright
--conditions and understandings with respect to any software which is marked
--with a copyright notice.
--
--Send all comments about the modifications to Paul Walker, 
--pwalker@ncsa.uiuc.edu
--
-- *
-  */
- 
- #ifndef _RIGHTS_
-@@ -62,4 +24,4 @@ pwalker@ncsa.uiuc.edu
- 
- static char copyright[] = "Copyright (c) 1989, Regents of the University of California.  All rights reserved.";
- 
--#endif				/* _RIGHTS_ */
-+#endif /* _RIGHTS_ */
 --- xgraph-12.1.orig/xgraph.c
 +++ xgraph-12.1/xgraph.c
 @@ -1,4 +1,4 @@
@@ -687,7 +627,7 @@
 -xgraph_c_sources = \
 -		xgraph.c xgX.c hard_devices.c dialog.c hpgl.c \
 -		  ps.c idraw.c xtb.c st.c params.c alloc.c draw.c \
--		  init.c read.c tgif.c derivative.c \
+-		  init.c read.c tgif.c \
 -		copyright.h \
 -		general.h \
 -		hard_devices.h \
@@ -701,7 +641,7 @@
 +
 +xgraph_SOURCES = xgraph.c xgX.c hard_devices.c dialog.c hpgl.c ps.c	\
 +	idraw.c xtb.c st.c params.c alloc.c draw.c init.c read.c	\
-+	tgif.c derivative.c copyright.h general.h hard_devices.h	\
++	tgif.c copyright.h general.h hard_devices.h	\
 +	params.h plotter.h st.h xgout.h xgraph.h xtb.h
  
  man_MANS = xgraph.man
diff -urNad debian.orig/README.source debian/README.source
--- debian.orig/README.source	1970-01-01 01:00:00.000000000 +0100
+++ debian/README.source	2013-04-20 11:29:31.971723503 +0100
@@ -0,0 +1,21 @@
+DFSG and repacking
+==================
+
+The upstream source tarball from contains source code contributed
+by Paul Walker that is under a non-free license - see #705152.
+
+We are currently using the mechanism that appears to be the closest
+thing to a Debian-wide DFSG-repacking mechanism - i.e. the scripts
+used by the Debian Perl Group. See #677270 for a request to make this
+(or something based upon it) a standard within Debian.
+
+To use this to download the current tarball (as indicated by debian/changelog)
+run 'fakeroot debian/rules get-orig-source' from within the top-level
+directory. If you are trying to build directly from the repository you
+will also need to unpack the tarball into the same top-level directory.
+
+Bugs: Beware of having upstream tarballs (with or without the
+non-DFSG material) in .. befrore running get-orig-source. It first downloads
+the unaltered file and then repacks to the new one. The process
+will stop if either file is present.
+
diff -urNad debian.orig/repack.local debian/repack.local
--- debian.orig/repack.local	1970-01-01 01:00:00.000000000 +0100
+++ debian/repack.local	2013-04-20 11:37:45.183714012 +0100
@@ -0,0 +1,3 @@
+patch -p1 < ../../../debian/repack.paulwalker.patch
+# Patch files cannot represent deletion of files
+rm README.NEWFEATURES derivative.c
diff -urNad debian.orig/repack.paulwalker.patch debian/repack.paulwalker.patch
--- debian.orig/repack.paulwalker.patch	1970-01-01 01:00:00.000000000 +0100
+++ debian/repack.paulwalker.patch	2013-04-20 11:35:48.151715773 +0100
@@ -0,0 +1,511 @@
+diff -urNad xgraph-12.1.orig/copyright.h xgraph-12.1/copyright.h
+--- xgraph-12.1.orig/copyright.h	2001-10-08 06:53:13.000000000 +0100
++++ xgraph-12.1/copyright.h	2013-04-20 11:34:29.903717420 +0100
+@@ -5,9 +5,6 @@
+  * University of California, Berkeley
+  * 1989
+  *
+- * Animation, Differentiation by Paul Walker
+- * NCSA and University of Illinois at Urbana Champaign Dept. of Physics
+- *
+  * Copyright (c) 1988, 1989, Regents of the University of California.
+  * All rights reserved.
+  *
+@@ -21,40 +18,6 @@
+  * warranty about the software, its performance or its conformity to
+  * any specification.
+  *
+-
+-Animation and differentiation routines were added by Paul Walker,
+-NCSA and UIUC Dept of Physics.  The following copyright and disclaimer
+-applies to these parts of the code only.
+-
+-UNIVERSITY OF ILLINOIS (UI), NATIONAL CENTER FOR SUPERCOMPUTING
+-APPLICATIONS (NCSA), Software Distribution Policy for Copyrighted Software
+-
+-The above mentioned modifications to XGraph made with the authors consent are
+-copyrighted, but  available without fee for education, academic research
+-and non-commercial purposes.  The modifications are copyrighted in the name of
+-the UI, and ownership of the modifications remains with the UI.  Users may
+-distribute the binary and source code to third parties provided that the
+-copyright notice and this statement appears on all copies and that no
+-charge is made for such copies.  Any entity wishing to integrate all or
+-part of the source code into a product for  commercial use or resale,
+-should contact the University of Illinois, c/o NCSA, to negotiate an
+-appropriate license for such commercial use.  
+-
+-UI MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR ANY
+-PURPOSE.  IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.  THE
+-UI SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY THE USER OF THIS
+-SOFTWARE.  The software may have been developed under agreements between
+-the UI and the Federal Government which entitle the Government to certain
+-rights.
+-
+-By copying this program, you, the user, agree to abide by the copyright
+-conditions and understandings with respect to any software which is marked
+-with a copyright notice.
+-
+-Send all comments about the modifications to Paul Walker, 
+-pwalker@ncsa.uiuc.edu
+-
+- *
+  */
+ 
+ #ifndef _RIGHTS_
+diff -urNad xgraph-12.1.orig/derivative.c xgraph-12.1/derivative.c
+--- xgraph-12.1.orig/derivative.c	2001-10-08 06:53:13.000000000 +0100
++++ xgraph-12.1/derivative.c	1970-01-01 01:00:00.000000000 +0100
+@@ -1,130 +0,0 @@
+-/* This entire routine written by PW. */
+-
+-#include <stdio.h>
+-#include <string.h>
+-#include "xgraph.h"
+-
+-void
+-Der1()
+-{
+-  PointList *theList, *D1List, *D2List;
+-  double m,b;
+-  int i;
+-
+-  
+-  for (i=0;i<MAXSETS;i++) {
+-    theList = PlotData[i].list;
+-    if (theList) {
+-      DataD1[i].list = (PointList *)malloc(sizeof(PointList));
+-      DataD2[i].list = (PointList *)malloc(sizeof(PointList));
+-      D1List = DataD1[i].list;
+-      D2List = DataD2[i].list;
+-    } else 
+-      DataD1[i].list = DataD2[i].list = NULL;
+-    DataD1[i].setName = 
+-      (char *)malloc(sizeof(char)*strlen(PlotData[i].setName));
+-    DataD2[i].setName = 
+-      (char *)malloc(sizeof(char)*strlen(PlotData[i].setName));
+-    strcpy(DataD1[i].setName,PlotData[i].setName);
+-    strcpy(DataD2[i].setName,PlotData[i].setName);
+-    while (theList) {
+-      int j;
+- 
+-      D1List->numPoints = D2List->numPoints = theList->numPoints;
+-      D1List->xvec = (double *)malloc(sizeof(double)*theList->numPoints);
+-      D1List->yvec = (double *)malloc(sizeof(double)*theList->numPoints);
+-      D1List->next = NULL;
+-      D2List->xvec = (double *)malloc(sizeof(double)*theList->numPoints);
+-      D2List->yvec = (double *)malloc(sizeof(double)*theList->numPoints);
+-      D2List->next = NULL;
+-
+-      for (j=1;j<theList->numPoints-1;j++) {
+-        D1List->xvec[j] = D2List->xvec[j] = theList->xvec[j];
+-        D1List->yvec[j] = (theList->yvec[j+1] - theList->yvec[j-1]) /
+-                (theList->xvec[j+1] - theList->xvec[j-1]);
+-        D2List->yvec[j] = (theList->yvec[j+1] + theList->yvec[j-1] -
+-                 2.0*theList->yvec[j]) /
+-                ((theList->xvec[j+1] - theList->xvec[j]) * 
+-                 (theList->xvec[j]-theList->xvec[j-1]));
+- 
+-      }
+-
+-      /* Extrapolate to get the endpoints ... */
+-      /* end near 0 */
+-      D1List->xvec[0] = theList->xvec[0];
+-      D1List->xvec[theList->numPoints-1] = 
+-       theList->xvec[theList->numPoints-1];
+-      m = (D1List->yvec[2]-D1List->yvec[1]) / 
+-          (theList->xvec[2]-theList->xvec[1]);
+-      b = D1List->yvec[1] - m*theList->xvec[1];
+-      D1List->yvec[0] = m*theList->xvec[0] + b;
+-      /* end near numPoints-1 */
+-      m = (D1List->yvec[theList->numPoints-2]-
+-           D1List->yvec[theList->numPoints-3]) / 
+-        (theList->xvec[theList->numPoints-2]-
+-         theList->xvec[theList->numPoints-3]);
+-      b = D1List->yvec [theList->numPoints-2] - 
+-          m*theList->xvec[theList->numPoints-2];
+-      D1List->yvec[theList->numPoints-1] = 
+-          m*theList->xvec[theList->numPoints-1] + b;
+-
+-      /* Extrapolate to get the endpoints ... */
+-      /* end near 0 */
+-      D2List->xvec[0] = theList->xvec[0];
+-      D2List->xvec[theList->numPoints-1] = 
+-       theList->xvec[theList->numPoints-1];
+-      m = (D2List->yvec[2]-D2List->yvec[1]) / 
+-          (theList->xvec[2]-theList->xvec[1]);
+-      b = D2List->yvec[1] - m*theList->xvec[1];
+-      D2List->yvec[0] = m*theList->xvec[0] + b;
+-      /* end near numPoints-1 */
+-      m = (D2List->yvec[theList->numPoints-2]-
+-           D2List->yvec[theList->numPoints-3]) / 
+-        (theList->xvec[theList->numPoints-2]-
+-         theList->xvec[theList->numPoints-3]);
+-      b = D2List->yvec[theList->numPoints-2] - 
+-          m*theList->xvec[theList->numPoints-2];
+-      D2List->yvec[theList->numPoints-1] = 
+-           m*theList->xvec[theList->numPoints-1] + b;
+-
+-      theList = theList->next;
+-      if (theList) {
+-        D1List->next = (PointList *)malloc(sizeof(PointList)); 
+-        D2List->next = (PointList *)malloc(sizeof(PointList)); 
+-        D1List = D1List->next;
+-        D2List = D2List->next;
+-      }
+-    }
+-  }
+-} 
+-
+-void
+-Bounds(loX, loY, hiX, hiY, Ord)
+-  double *loX, *loY, *hiX, *hiY;
+-  int Ord;
+-{
+-  int i;
+-  PointList *theList;
+-  if ((Ord<1) || (Ord>2)) {
+-    printf ("Internal Error - Cannot eval deriv > 2 in Bounds.\n");
+-    exit(1);
+-  }
+-  *loX = *loY = *hiX = *hiY = 0.0;
+-  for (i=0;i<MAXSETS;i++) {
+-    if (Ord == 1)
+-      theList = DataD1[i].list;
+-    else
+-      theList = DataD2[i].list;
+-    while (theList) {
+-      int j;
+- 
+-      for (j=0;j<theList->numPoints;j++) {
+-        *loX = (theList->xvec[j]<*loX?theList->xvec[j]:*loX);
+-        *loY = (theList->yvec[j]<*loY?theList->yvec[j]:*loY);
+-        *hiX = (theList->xvec[j]>*hiX?theList->xvec[j]:*hiX);
+-        *hiY = (theList->yvec[j]>*hiY?theList->yvec[j]:*hiY);
+-      }
+-      theList = theList->next;
+-    }
+-  }
+-}
+diff -urNad xgraph-12.1.orig/Makefile.am xgraph-12.1/Makefile.am
+--- xgraph-12.1.orig/Makefile.am	2001-10-08 06:53:01.000000000 +0100
++++ xgraph-12.1/Makefile.am	2013-04-20 11:33:09.111718940 +0100
+@@ -9,7 +9,7 @@
+ xgraph_c_sources = \
+ 		xgraph.c xgX.c hard_devices.c dialog.c hpgl.c \
+ 		  ps.c idraw.c xtb.c st.c params.c alloc.c draw.c \
+-		  init.c read.c tgif.c derivative.c \
++		  init.c read.c tgif.c \
+ 		copyright.h \
+ 		general.h \
+ 		hard_devices.h \
+@@ -29,7 +29,6 @@
+ 	README.GENERAL \
+ 	README.HARDCOPY \
+ 	README.INSTALL \
+-	README.NEWFEATURES \
+ 	bitmaps/dot.11 \
+ 	bitmaps/gray \
+ 	bitmaps/mark1.11 \
+diff -urNad xgraph-12.1.orig/Makefile.in xgraph-12.1/Makefile.in
+--- xgraph-12.1.orig/Makefile.in	2001-10-08 06:53:00.000000000 +0100
++++ xgraph-12.1/Makefile.in	2013-04-20 11:33:04.295720202 +0100
+@@ -69,13 +69,13 @@
+ AUTOMAKE_OPTIONS = 1.0 foreign
+ 
+ bin_PROGRAMS = xgraph
+-xgraph_c_sources =  		xgraph.c xgX.c hard_devices.c dialog.c hpgl.c 		  ps.c idraw.c xtb.c st.c params.c alloc.c draw.c 		  init.c read.c tgif.c derivative.c 		copyright.h 		general.h 		hard_devices.h 		params.h 		plotter.h 		st.h 		xgout.h 		xgraph.h 		xtb.h
++xgraph_c_sources =  		xgraph.c xgX.c hard_devices.c dialog.c hpgl.c 		  ps.c idraw.c xtb.c st.c params.c alloc.c draw.c 		  init.c read.c tgif.c 		copyright.h 		general.h 		hard_devices.h 		params.h 		plotter.h 		st.h 		xgout.h 		xgraph.h 		xtb.h
+ 
+ xgraph_SOURCES = $(xgraph_c_sources)
+ 
+ man_MANS = xgraph.man
+ 
+-EXTRA_DIST =  	$(man_MANS) 	README.ANNOUNCE 	README.GENERAL 	README.HARDCOPY 	README.INSTALL 	README.NEWFEATURES 	bitmaps/dot.11 	bitmaps/gray 	bitmaps/mark1.11 	bitmaps/mark2.11 	bitmaps/mark3.11 	bitmaps/mark4.11 	bitmaps/mark5.11 	bitmaps/mark6.11 	bitmaps/mark7.11 	bitmaps/mark8.11 	examples/Animation.xg 	examples/bar.xg 	examples/surface.xg 	examples/surface2.xg 	examples/surface3.xg 	examples/xgtest.xg
++EXTRA_DIST =  	$(man_MANS) 	README.ANNOUNCE 	README.GENERAL 	README.HARDCOPY 	README.INSTALL 	bitmaps/dot.11 	bitmaps/gray 	bitmaps/mark1.11 	bitmaps/mark2.11 	bitmaps/mark3.11 	bitmaps/mark4.11 	bitmaps/mark5.11 	bitmaps/mark6.11 	bitmaps/mark7.11 	bitmaps/mark8.11 	examples/Animation.xg 	examples/bar.xg 	examples/surface.xg 	examples/surface2.xg 	examples/surface3.xg 	examples/xgtest.xg
+ 
+ 
+ # C_WARNINGS = -Wall
+@@ -334,7 +334,7 @@
+ 	  fi; \
+ 	done
+ alloc.o: alloc.c
+-derivative.o: derivative.c xgraph.h autoconf.h xgout.h
++derivative.o: xgraph.h autoconf.h xgout.h
+ dialog.o: dialog.c copyright.h xgout.h xgraph.h autoconf.h \
+ 	hard_devices.h xtb.h params.h
+ draw.o: draw.c copyright.h xgraph.h autoconf.h xgout.h xtb.h \
+diff -urNad xgraph-12.1.orig/read.c xgraph-12.1/read.c
+--- xgraph-12.1.orig/read.c	2001-10-08 06:53:13.000000000 +0100
++++ xgraph-12.1/read.c	2013-04-20 11:33:28.355718694 +0100
+@@ -36,10 +36,6 @@
+ static int newGroup = 0;
+ static int redundant_set = 0;
+ 
+-#ifdef DO_DER
+-extern void Der1();
+-#endif
+-
+ static int
+ rdSet(fn)
+ char   *fn;			/* Reading from file `fn' */
+@@ -349,9 +345,6 @@
+ 	    break;
+ 	}
+     }
+-#ifdef DO_DER
+-    Der1();
+-#endif
+     if (errors)
+ 	return -1;
+     else
+diff -urNad xgraph-12.1.orig/README xgraph-12.1/README
+--- xgraph-12.1.orig/README	2001-10-08 06:53:00.000000000 +0100
++++ xgraph-12.1/README	2013-04-20 11:34:40.291717004 +0100
+@@ -10,7 +10,6 @@
+ Xgraph is an X-Windows application that includes:
+ 
+   - interactive plotting and graphing, by David Harrison of UC Berkeley
+-  - animation and deritives, added by Paul Walker of NCSA
+   - portability and bug fixes, by the VINT project
+ 
+ 
+diff -urNad xgraph-12.1.orig/README.NEWFEATURES xgraph-12.1/README.NEWFEATURES
+--- xgraph-12.1.orig/README.NEWFEATURES	2001-10-08 06:53:15.000000000 +0100
++++ xgraph-12.1/README.NEWFEATURES	1970-01-01 01:00:00.000000000 +0100
+@@ -1,43 +0,0 @@
+-This code is essentially XGraph release 11.4, with some modifications
+-which were made for use by the NCSA Relativity group.
+-These modifications were made by Paul Walker, and he should be
+-contacted at the below address if you have any problems/questions
+-regarding these features.
+-
+-1.	Animation.  XGraph will now do a *very* crude animation of
+-	your data sets.  It occasionally has problems with refreshes
+-	and will consequently run your animation three of four times.
+-	Consider this an undocumented feature!  You can adjust the
+-	speed of the animation with the -dl option.  I find "2" works
+-	well on a sparc displaying on MacX, "5" on a sparc on its
+-	own display, and "10" on an SGI or RS6K on its own display.
+-	Remeber, this animation is not being advertised as anything
+-	other than very crude, so if you are looking for production
+-	quality video, turn elsewhere.  We find it useful as it will
+-	quickly generate animation which shows time evolution. 
+-
+-2.	Differentation.  You can press the "Derivative" button to
+-	see the first and second derivatives of your data set.  The
+-	method is a standard centered difference.  You cannot display
+-	higher than second derivatives.  Animation, zooming, etc...
+-	work in each of the derivative windows.  Endpoints are found
+-	linearly interpolating inner values to ends, so pay them
+-	little heed!
+-
+-3.	New Color Map.  We couldn't differentiate the colors once we
+-	got past yellow, so we created a new color map.  If you don't
+-	like it, look in init.c for the variable "defColors" and 
+-	comment out the new one, replacing it with the commented
+-	old one.  Of course, you are free to insert your own choices
+-	here also ... Just use standard X color names. 
+-
+-
+-These modifications were made by Paul Walker, and distributed with the
+-Original author's consent.  See Copyright.h for information about
+-distribution and ownership of these changes.  Contact Paul Walker at
+-
+-Paul Walker
+-NCSA
+-605 E. Springfield Ave
+-Champaign IL 61820
+-pwalker@ncsa.uiuc.edu
+diff -urNad xgraph-12.1.orig/xgraph.c xgraph-12.1/xgraph.c
+--- xgraph-12.1.orig/xgraph.c	2001-10-08 06:53:05.000000000 +0100
++++ xgraph-12.1/xgraph.c	2013-04-20 11:35:05.827716952 +0100
+@@ -38,10 +38,6 @@
+ extern void init_X();
+ extern void do_error();
+ 
+-#ifdef DO_DER
+-extern void Bounds();
+-#endif /* DO_DER */
+-
+ static char *tildeExpand();
+ static void ReverseIt();
+ static void Traverse();
+@@ -561,13 +557,7 @@
+ Modification of code by David Harrison\n\
+ University of California, Berkeley\n\
+ (davidh@ic.Berkeley.EDU or \n\
+-...!ucbvax!ucbic!davidh)\n\
+-Animation, differentiation, and a few other\n\
+-new features added by Paul Walker,\n\
+-National Center for Supercomputer Applications\n\
+-and Univ. Illinois at U-C Dept of Physics.\n\
+-Send comments or suggestions to\n\
+-pwalker@ncsa.uiuc.edu\n";
++...!ucbvax!ucbic!davidh)\n";
+     static int active = 0;
+     char    msg_buf[1024];
+ 
+@@ -583,129 +573,6 @@
+ }
+ 
+ 
+-#ifdef DO_DER
+-static
+-/*ARGSUSED  PW*/
+-        xtb_hret
+-rew_func(win, bval, info)
+-Window  win;			/* Button window    */
+-int     bval;			/* Button value     */
+-char   *info;			/* User information */
+-{
+-    /* This routine added, Paul Walker, to rewind the animation and start
+-       it over.  The only even moderatly tricky part is erasing the last
+-       item, which still lives, and redrawing the axis.  I do it by just
+-       copying the "Expose" information from the main routine. */
+-    Window  the_win = (Window) info;
+-    LocalWin *win_info;
+-
+-    /* Set animation to True */
+-    param_set("Animate",BOOL,"on");
+-
+-    if (!XFindContext(disp, the_win, win_context, (caddr_t *) & win_info)) {
+-	  XWindowAttributes win_attr;
+-
+-	  XGetWindowAttributes(disp, the_win, &win_attr);
+-	  win_info->dev_info.area_w = win_attr.width;
+-	  win_info->dev_info.area_h = win_attr.height;
+-	  init_X(win_info->dev_info.user_state);
+-          EraseData (win_info);
+-	  DrawWindow(win_info);
+-    }
+-
+-    return XTB_HANDLED;
+-}
+-
+-static
+-/*ARGSUSED  PW*/
+-        xtb_hret
+-der_func(win, bval, info)
+-Window  win;			/* Button window    */
+-int     bval;			/* Button value     */
+-char   *info;			/* User information */
+-{
+-    /* This routine added, Paul Walker, to rewind the animation and start
+-       it over.  The only even moderatly tricky part is erasing the last
+-       item, which still lives, and redrawing the axis.  I do it by just
+-       copying the "Expose" information from the main routine. */
+-    Window  the_win = (Window) info;
+-    Window new_win;
+-    LocalWin *win_info;
+-    double loX,loY,hiX,hiY,asp;
+-    static char *msg_fmt =
+-    "Version %s\n\
+-Currently unable to display\n\
+-or calculate derivatives\n\
+-higher than 2nd order\n";
+-    static int active = 0;
+-    char    msg_buf[1024];
+-
+-    XFindContext(disp, the_win, win_context, (caddr_t *) & win_info);
+-    if (win_info->DOrder == 2) {
+-
+-      if (!active) {
+-	active = 1;
+-	xtb_bt_set(win, 1, (char *) 0, 0);
+-	(void) sprintf(msg_buf, msg_fmt, VERSION_STRING);
+-	msg_box("XGraph", msg_buf);
+-	xtb_bt_set(win, 0, (char *) 0, 0);
+-	active = 0;
+-      }
+-      return XTB_HANDLED;
+-    }
+-    Num_Windows += 1;
+-    asp = 1.0;
+-    Bounds(&loX,&loY,&hiX,&hiY,win_info->DOrder+1);
+-    new_win = NewWindow("Derivatives", loX, loY, hiX, hiY, asp, 
+-      win_info->DOrder+1);
+-
+-    if (!XFindContext(disp, new_win, win_context, (caddr_t *) & win_info)) {
+-	  XWindowAttributes win_attr;
+-
+-	  XGetWindowAttributes(disp, new_win, &win_attr);
+-	  win_info->dev_info.area_w = win_attr.width;
+-	  win_info->dev_info.area_h = win_attr.height;
+-	  init_X(win_info->dev_info.user_state);
+-          EraseData (win_info);
+-	  DrawWindow(win_info);
+-    }
+-
+-    return XTB_HANDLED;
+-}
+-
+-
+-static
+-/*ARGSUSED  PW*/
+-        xtb_hret
+-rpl_func(win, bval, info)
+-Window  win;			/* Button window    */
+-int     bval;			/* Button value     */
+-char   *info;			/* User information */
+-{
+-    /* Puts us back into static mode ... */
+-    Window  the_win = (Window) info;
+-    LocalWin *win_info;
+-
+-    /* Set animation to True */
+-    param_set("Animate",BOOL,"off");
+-
+-    if (!XFindContext(disp, the_win, win_context, (caddr_t *) & win_info)) {
+-	  XWindowAttributes win_attr;
+-
+-	  XGetWindowAttributes(disp, the_win, &win_attr);
+-	  win_info->dev_info.area_w = win_attr.width;
+-	  win_info->dev_info.area_h = win_attr.height;
+-	  init_X(win_info->dev_info.user_state);
+-          EraseData (win_info);
+-	  DrawWindow(win_info);
+-    }
+-
+-    return XTB_HANDLED;
+-}
+-/* End change PW */
+-
+-#endif /* DO_DER */
+-
+ #define NORMSIZE	600
+ #define MINDIM		100
+ 
+@@ -861,33 +728,6 @@
+ 		XMoveWindow(disp, new_info->about,
+ 			    (int) (BTNPAD + cl_frame.width + BTNINTER +
+ 				   hd_frame.width + BTNINTER), BTNPAD);
+-#ifdef DO_DER
+-                /* These buttons added PW */
+-		xtb_bt_new(new_window, "Anim", rew_func,
+-		   (xtb_data) new_window, &rw_frame);
+-		new_info->rewind = rw_frame.win;
+-		XMoveWindow(disp, new_info->rewind,
+-		    (int) (BTNPAD + cl_frame.width + BTNINTER +
+-			   hd_frame.width + BTNINTER +
+-                           ab_frame.width + BTNINTER), BTNPAD);
+-		xtb_bt_new(new_window, "Replot", rpl_func,
+-		   (xtb_data) new_window, &rp_frame);
+-		new_info->replot = rp_frame.win;
+-		XMoveWindow(disp, new_info->replot,
+-		    (int) (BTNPAD + cl_frame.width + BTNINTER +
+-			   hd_frame.width + BTNINTER +
+-                           ab_frame.width + BTNINTER +
+-			   rw_frame.width + BTNINTER), BTNPAD);
+-		xtb_bt_new(new_window, "Deriv", der_func,
+-		   (xtb_data) new_window, &dx_frame);
+-		new_info->deriv = dx_frame.win;
+-		XMoveWindow(disp, new_info->deriv,
+-		    (int) (BTNPAD + cl_frame.width + BTNINTER +
+-			   hd_frame.width + BTNINTER +
+-                           ab_frame.width + BTNINTER +
+-			   rw_frame.width + BTNINTER +
+-			   rp_frame.width + BTNINTER), BTNPAD); 
+-#endif /* DO_DER */
+ 
+ 		new_info->flags = 0;
+ 	    }
diff -urNad debian.orig/repack.sh debian/repack.sh
--- debian.orig/repack.sh	1970-01-01 01:00:00.000000000 +0100
+++ debian/repack.sh	2013-04-20 11:27:22.227725732 +0100
@@ -0,0 +1,161 @@
+#!/bin/sh
+
+# see the repack.stub for how to use
+
+# TODO: provide example watch files and repack.locals
+# TODO: test suite. problems fixed that need to be tested:
+# * globbing
+# * whitespace and then comments in the MANIFEST
+# TODO: does / in weird places work? test suite too.
+# TODO: I actually broke stuff with the MANIFEST change not thinking..
+# TODO: allow for a sepearate (and multiple) MANIFEST files, then
+# de-uglify libsyntax-highlight-engine-kate-perl.
+# TODO: have each mv and rm check that something actually changed, and
+# if not, die
+
+set -e
+set -u
+
+usage() {
+    echo "Usage: repack.sh --upstream-version <ver> <downloaded file>"
+    exit 1
+}
+
+if [ "$#" != "3" ]; then
+    usage
+fi
+if [ "$1" != "--upstream-version" ]; then
+    usage
+fi
+if [ ! -f "$3" ]; then
+    if [ -n "$3" ]; then
+        echo "$3 doesn't exist"
+    fi
+    usage
+fi
+VER="$2"
+FILE="$3"
+PKG=`dpkg-parsechangelog|grep ^Source:|sed 's/^Source: //'`
+
+SUFFIX="+dfsg"
+
+echo
+echo "Repackaging $FILE"
+echo
+
+DIR=`mktemp -d ./tmpRepackXXXXXX`
+DIR=$(readlink -f "$DIR")
+trap "/bin/rm -rf \"$DIR\"" QUIT INT EXIT
+
+# Create an extra directory to cope with rootless tarballs
+UP_BASE="$DIR/unpack"
+mkdir "$UP_BASE"
+tar xf "$FILE" -C "$UP_BASE" || unzip "$FILE" -d "$UP_BASE"
+
+if [ `ls -1 "$UP_BASE" | wc -l` -eq 1 ]; then
+	# Tarball does contain a root directory
+	UP_BASE="$UP_BASE/`ls -1 "$UP_BASE"`"
+fi
+
+RM_OPTS="-vrf"
+
+real_rm(){
+    /bin/rm "$@"
+}
+
+real_mv(){
+    /bin/mv "$@"
+}
+
+rm(){
+    set +f
+    MYOLDPWD=$(pwd)
+    cd "$UP_BASE"
+    if [ "$MANIFEST" = "1" ]; then
+        PERM=$(stat --format=%a "MANIFEST")
+        chmod u+w "MANIFEST"
+    fi
+    for i in $@; do
+        if [ "$MANIFEST" = "1" ]; then
+            PATTERN="^$i"
+            if [ -d "$i" ]; then
+                if ! { echo "$PATTERN" | grep -q "/$" ; }; then
+                    PATTERN="${PATTERN}/"
+                fi
+            else
+                PATTERN="${PATTERN}\s?"
+            fi
+            grep -Ev "$PATTERN" "MANIFEST" > "$DIR/MANIFEST"
+            real_mv "$DIR/MANIFEST" "MANIFEST"
+        fi
+        real_rm "$RM_OPTS" "$i"
+    done
+    if [ "$MANIFEST" = "1" ]; then
+        chmod $PERM "MANIFEST"
+    fi
+    cd $MYOLDPWD
+    set -f
+}
+
+mv(){
+    set +f
+    OLD=$(pwd)
+    cd $UP_BASE
+    real_mv "$@"
+    cd $OLD
+    if [ "$MANIFEST" = "1" ]; then
+        echo "MANIFEST cannot be manipulated with mv yet, patches welcome"
+        exit 1
+    fi
+    set -f
+}
+
+# bump with incompatible changes
+REPACK_VERSION=3
+
+requires_version(){
+    if [ $REPACK_VERSION -lt $1 ]; then
+        echo "repack.sh is not up to date enough for this package. you need at least version $1, while this script is only version $REPACK_VERSION"
+        exit 1
+    fi
+}
+
+MANIFEST=0
+## Remove stuff
+set -f
+MYORIGPWD=$(pwd)
+cd "$UP_BASE"
+. "$MYORIGPWD/debian/repack.local"
+cd $MYORIGPWD
+set +f
+## End
+
+REPACK_DIR="$PKG-${VER}${SUFFIX}.orig" # DevRef § 6.7.8.2
+DFSG_TAR="$(dirname $FILE)/${PKG}_${VER}${SUFFIX}.orig.tar"
+
+real_mv "$UP_BASE" "$DIR/$REPACK_DIR"
+
+# .gz or .bz2?
+FILETYPE=$(file --brief --mime-type --dereference "$FILE")
+case "$FILETYPE" in
+    application/x-gzip|application/zip)
+        C_PROGRAM="gzip"
+        C_SUFFIX="gz"
+        ;;
+    application/x-bzip2)
+        C_PROGRAM="bzip2"
+        C_SUFFIX="bz2"
+        ;;
+    *)
+        echo "E: Unknown filetye $FILETYPE"
+        exit 1
+        ;;
+esac
+    
+# Using a pipe hides tar errors!
+tar cfC "$DIR/repacked.tar" "$DIR" "$REPACK_DIR"
+$C_PROGRAM -9 < "$DIR/repacked.tar" > "$DIR/repacked.tar.$C_SUFFIX"
+
+real_mv "$DIR/repacked.tar.$C_SUFFIX" "$DFSG_TAR.$C_SUFFIX"
+
+echo "*** $DFSG_TAR.$C_SUFFIX ready"
diff -urNad debian.orig/rules debian/rules
--- debian.orig/rules	2012-04-24 13:22:43.000000000 +0100
+++ debian/rules	2013-04-20 11:30:42.067721719 +0100
@@ -7,3 +7,7 @@
 	dh_auto_install
 	rm    debian/xgraph/usr/share/man/manm/xgraph.man
 	rmdir debian/xgraph/usr/share/man/manm
+
+get-orig-source:
+	uscan --force-download --verbose --download-current-version
+
diff -urNad debian.orig/watch debian/watch
--- debian.orig/watch	2012-04-24 13:22:43.000000000 +0100
+++ debian/watch	2013-04-20 11:27:50.407726643 +0100
@@ -1,6 +1,11 @@
 # Watch control file.
 # Run uscan(1) to check for upstream updates and more.
 
+# See debian/README.source for more information about the DFSG repacking here.
+
 version=3
 
-http://www.isi.edu/nsnam/dist/ xgraph-([\d\.]*).tar.gz
+opts=dversionmangle=s/\+dfsg\d*$// \
+    http://www.isi.edu/nsnam/dist/ xgraph-([\d\.]*).tar.gz \
+    debian sh debian/repack.sh
+
diff -urNad debian.orig/watch2 debian/watch2
--- debian.orig/watch2	1970-01-01 01:00:00.000000000 +0100
+++ debian/watch2	2013-04-20 11:27:26.919725858 +0100
@@ -0,0 +1,8 @@
+# See debian/README.source for more information about the DFSG repacking here.
+version=3
+opts=dversionmangle=s/\+dfsg\d*$// \
+    http://mysql.linux.cz/Downloads/MySQL-5.5/mysql-([\d\.]+).tar.gz \
+    debian sh debian/repack.sh
+opts=dversionmangle=s/\+dfsg\d*$// \
+    http://ftp.gwdg.de/pub/misc/mysql/Downloads/MySQL-5.5/mysql-([\d\.]+).tar.gz \
+    debian sh debian/repack.sh
