diff -Nurd '-x*~' octave-@OCTVERSION@//octave-forge-comp octave-@OCTVERSION@.patched//octave-forge-comp
--- octave-@OCTVERSION@//octave-forge-comp	1969-12-31 19:00:00.000000000 -0500
+++ octave-@OCTVERSION@.patched//octave-forge-comp	2011-08-11 20:23:10.000000000 -0400
@@ -0,0 +1,4 @@
+#!@FINKPREFIX@/bin/octave-@OCTVERSION@ -V
+pkg prefix bld/share/octave/@OCTVERSION@/packages bld/lib/octave/@OCTVERSION@/packages
+pkg global_list bld/share/octave/@OCTVERSION@/octave_packages
+pkg install -verbose -nodeps ./@PKGNAME@/
diff -Nurd '-x*~' octave-@OCTVERSION@//octave-forge-compile.sh octave-@OCTVERSION@.patched//octave-forge-compile.sh
--- octave-@OCTVERSION@//octave-forge-compile.sh	1969-12-31 19:00:00.000000000 -0500
+++ octave-@OCTVERSION@.patched//octave-forge-compile.sh	2011-08-11 20:23:10.000000000 -0400
@@ -0,0 +1,7 @@
+#!/bin/sh -ev
+cd ..
+mkdir -p bld/share/octave/@OCTVERSION@/packages bld/lib/octave/@OCTVERSION@/packages
+cp @FINKPREFIX@/share/octave/@OCTVERSION@/scripts/octave-forge-comp @FINKPREFIX@/share/octave/@OCTVERSION@/scripts/octave-forge-inst bld
+chmod a+x bld/octave-forge*
+sed -i.bak -e "s/@PKGNAME@/$1/" bld/octave-forge*
+bld/octave-forge-comp
\ No newline at end of file
diff -Nurd '-x*~' octave-@OCTVERSION@//octave-forge-inst octave-@OCTVERSION@.patched//octave-forge-inst
--- octave-@OCTVERSION@//octave-forge-inst	1969-12-31 19:00:00.000000000 -0500
+++ octave-@OCTVERSION@.patched//octave-forge-inst	2011-08-11 20:23:10.000000000 -0400
@@ -0,0 +1,7 @@
+#!@FINKPREFIX@/bin/octave-@OCTVERSION@ -q
+load share/octave/@OCTVERSION@/octave_packages;
+apfx = global_packages {1}.archprefix;
+global_packages {1}.archprefix = regexprep(apfx,'.*bld','@FINKPREFIX@');
+dr = global_packages {1}.dir;
+global_packages {1}.dir = regexprep(dr,'.*bld','@FINKPREFIX@');
+save -text share/octave/@OCTVERSION@/octave_packages global_packages
diff -Nurd '-x*~' octave-@OCTVERSION@//octave-forge-install.sh octave-@OCTVERSION@.patched//octave-forge-install.sh
--- octave-@OCTVERSION@//octave-forge-install.sh	1969-12-31 19:00:00.000000000 -0500
+++ octave-@OCTVERSION@.patched//octave-forge-install.sh	2011-08-11 20:23:10.000000000 -0400
@@ -0,0 +1,5 @@
+#!/bin/sh -ev
+cd $2
+cp -r $3/../bld/{share,lib} .
+$3/../bld/octave-forge-inst
+mv share/octave/@OCTVERSION@/octave_packages share/octave/@OCTVERSION@/packages/$1/.
diff -Nurd '-x*~' octave-@OCTVERSION@//octave-forge-postinst octave-@OCTVERSION@.patched//octave-forge-postinst
--- octave-@OCTVERSION@//octave-forge-postinst	1969-12-31 19:00:00.000000000 -0500
+++ octave-@OCTVERSION@.patched//octave-forge-postinst	2011-08-11 20:23:10.000000000 -0400
@@ -0,0 +1,6 @@
+#!@FINKPREFIX@/bin/octave-@OCTVERSION@ -q
+load @FINKPREFIX@/share/octave/@OCTVERSION@/packages/@PKGNAME@/octave_packages
+newpackage = global_packages;
+load @FINKPREFIX@/var/octave/@OCTVERSION@/octave_packages
+global_packages = {global_packages{:},newpackage{:}};
+save -text @FINKPREFIX@/var/octave/@OCTVERSION@/octave_packages global_packages
diff -Nurd '-x*~' octave-@OCTVERSION@//octave-forge-prerm octave-@OCTVERSION@.patched//octave-forge-prerm
--- octave-@OCTVERSION@//octave-forge-prerm	1969-12-31 19:00:00.000000000 -0500
+++ octave-@OCTVERSION@.patched//octave-forge-prerm	2011-08-11 20:23:10.000000000 -0400
@@ -0,0 +1,9 @@
+#!@FINKPREFIX@/bin/octave-@OCTVERSION@ -q
+load @FINKPREFIX@/var/octave/@OCTVERSION@/octave_packages
+for i = 1:length(global_packages)
+  if strcmp(global_packages{i}.name,'@PKGNAME@')
+    global_packages(i) = [];
+    break
+  endif
+endfor
+save -text @FINKPREFIX@/var/octave/@OCTVERSION@/octave_packages global_packages
diff -Naur startup/octaverc.null startup/octaverc
--- startup/octaverc.null	2011-08-12 14:21:47.000000000 -0400
+++ startup/octaverc	2011-08-12 12:32:41.000000000 -0400
@@ -0,0 +1,24 @@
+## System-wide startup file for Octave.
+##
+## This file should contain any commands that should be executed each
+## time Octave starts for every user at this site.
+
+## Configure readline using the file inputrc in the Octave startup
+## directory.
+
+read_readline_init_file (sprintf ("%s%s%s",
+				  octave_config_info ("startupfiledir"),
+				  filesep, "inputrc"));
+
+if (strcmp (PAGER (), "less") && isempty (getenv ("LESS")))
+  PAGER_FLAGS ('-e -X -P"-- less ?pB(%pB\\%):--. (f)orward, (b)ack, (q)uit$"');
+endif
+
+## This appears here instead of in the pkg/PKG_ADD file so that --norc
+## will also skip automatic loading of packages.
+
+try 
+	pkg global_list @FINKPREFIX@/var/octave/@OCTVERSION@/octave_packages
+catch
+end_try_catch
+pkg ("load", "auto");
