Index: main/trunk/package-kits/linux/ReadMe
===================================================================
--- main/trunk/package-kits/linux/ReadMe	(revision 29473)
+++ main/trunk/package-kits/linux/ReadMe	(revision 29474)
@@ -5,8 +5,8 @@
         patch -p0 -i package.patch
         where -p0 assumes the paths in the patch are valid in the current directory
+
     gs2build.patch
         Contains patches for the gs2build build process
         Disables building externals
-
     perl-util.patch
         Contains a patch to change the tmp folder for gs2build
@@ -28,3 +28,3 @@
 
 Issues:
-    -
+    Debian package has lots of warnings
Index: main/trunk/package-kits/linux/deb/demo/Makefile
===================================================================
--- main/trunk/package-kits/linux/deb/demo/Makefile	(revision 29474)
+++ main/trunk/package-kits/linux/deb/demo/Makefile	(revision 29474)
@@ -0,0 +1,43 @@
+gssrv       := /srv/gsdl
+DESTDIR     ?= /
+
+all: build
+
+deb:
+	dpkg-buildpackage -rfakeroot
+
+svn:
+	@echo "Getting latest source"
+	svn co http://svn.greenstone.org/main/trunk/greenstone3/web/sites/localsite/collect svn
+
+src: svn
+	$(eval svnver := $(shell cd svn && svnversion -c | grep -o '[[:digit:]:]*'))
+	$(eval srcver := $(shell if test -d src; then cd src && svnversion -c | grep -o '[[:digit:]:]*'; else echo "nope"; fi))
+	if test $(svnver) != $(srcver); then \
+	$(MAKE) clean ; \
+	echo "Making copy of source" ; \
+	cp -rT svn src ; \
+	fi
+
+clean:
+	@echo "Cleaning src directory"
+	rm -rf src
+	rm -f build
+
+cleanall: clean
+	@echo "Cleaning svn directory"
+	rm -rf svn
+
+build: src
+	rm -f $(wildcard src/*/index.zip)
+	./build.sh
+	touch build
+
+install: install-demo
+
+install-demo: build
+	@echo "Building demo collections"
+	install -d $(DESTDIR)/$(gssrv)/sites/localsite
+	rsync -a --info=STATS --exclude .svn src/ $(DESTDIR)/$(gssrv)/sites/localsite/collect/
+
+.PHONY: svn clean cleanall install install-demo
Index: main/trunk/package-kits/linux/deb/demo/build.sh
===================================================================
--- main/trunk/package-kits/linux/deb/demo/build.sh	(revision 29474)
+++ main/trunk/package-kits/linux/deb/demo/build.sh	(revision 29474)
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+GSDL3HOME=$(pwd)
+export GSDL3HOME
+. greenstone --no-interactive
+mv -T src sites/localsite/collect
+find sites/localsite/collect/ -mindepth 1 -maxdepth 1 -not -name ".*" -execdir bash -c 'col="$(basename $1)"; import.pl -removeold -site localsite "$col"; buildcol.pl -removeold -site localsite "$col"; mv "${col}/building" "${col}/index"' -- {} \;
+mv -T sites/localsite/collect src
+rm -rf sites
Index: main/trunk/package-kits/linux/deb/demo/debian/changelog
===================================================================
--- main/trunk/package-kits/linux/deb/demo/debian/changelog	(revision 29474)
+++ main/trunk/package-kits/linux/deb/demo/debian/changelog	(revision 29474)
@@ -0,0 +1,5 @@
+greenstone-demo (3.06) UNRELEASED; urgency=medium
+
+  * Initial release. (Closes: #XXXXXX)
+
+ -- Greenstone Team <greenstone_team@cs.waikato.ac.nz>  Tue, 25 Nov 2014 14:38:47 +1300
Index: main/trunk/package-kits/linux/deb/demo/debian/compat
===================================================================
--- main/trunk/package-kits/linux/deb/demo/debian/compat	(revision 29474)
+++ main/trunk/package-kits/linux/deb/demo/debian/compat	(revision 29474)
@@ -0,0 +1,1 @@
+9
Index: main/trunk/package-kits/linux/deb/demo/debian/control
===================================================================
--- main/trunk/package-kits/linux/deb/demo/debian/control	(revision 29474)
+++ main/trunk/package-kits/linux/deb/demo/debian/control	(revision 29474)
@@ -0,0 +1,15 @@
+Source: greenstone-demo
+Section: java
+Priority: optional
+Maintainer: Greenstone Team <greenstone_team@cs.waikato.ac.nz>
+Uploaders: Jeremy Symon <jtsymon@gmail.com>
+Build-Depends:
+    debhelper (>= 9),
+    greenstone-tools,
+    subversion
+
+Package: greenstone-demo
+Architecture: all
+Homepage: http://greenstone.org
+Depends: greenstone
+Description: Greenstone Digital Library Demo Collections
Index: main/trunk/package-kits/linux/deb/demo/debian/copyright
===================================================================
--- main/trunk/package-kits/linux/deb/demo/debian/copyright	(revision 29474)
+++ main/trunk/package-kits/linux/deb/demo/debian/copyright	(revision 29474)
@@ -0,0 +1,22 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: Greenstone Digital Library
+Upstream-Contact: greenstone_team@cs.waikato.ac.nz
+Source: http://greenstone.org
+
+Files: *
+License: GPL-2
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+On Debian GNU/Linux and Ubuntu systems, the complete text of the GPL-2 License
+can be found in '/usr/share/common-licenses/GPL-2'
Index: main/trunk/package-kits/linux/deb/demo/debian/rules
===================================================================
--- main/trunk/package-kits/linux/deb/demo/debian/rules	(revision 29474)
+++ main/trunk/package-kits/linux/deb/demo/debian/rules	(revision 29474)
@@ -0,0 +1,4 @@
+#!/usr/bin/make -f
+
+%:
+	dh $@ --with autotools_dev
Index: main/trunk/package-kits/linux/deb/gli/debian/changelog
===================================================================
--- main/trunk/package-kits/linux/deb/gli/debian/changelog	(revision 29473)
+++ main/trunk/package-kits/linux/deb/gli/debian/changelog	(revision 29474)
@@ -1,3 +1,3 @@
-gli (0.01) UNRELEASED; urgency=medium
+gli (3.06) UNRELEASED; urgency=medium
 
   * Initial release. (Closes: #XXXXXX)
Index: main/trunk/package-kits/linux/deb/gli/debian/control
===================================================================
--- main/trunk/package-kits/linux/deb/gli/debian/control	(revision 29473)
+++ main/trunk/package-kits/linux/deb/gli/debian/control	(revision 29474)
@@ -4,10 +4,15 @@
 Maintainer: Greenstone Team <greenstone_team@cs.waikato.ac.nz>
 Uploaders: Jeremy Symon <jtsymon@gmail.com>
-Build-Depends: debhelper (>= 9)
+Build-Depends:
+    debhelper (>= 9),
+    default-jdk,
+    subversion
 
 Package: gli
 Architecture: all
 Homepage: http://greenstone.org
-Depends: greenstone-tools
+Depends:
+    greenstone-tools,
+    default-jre
 Description: Greenstone Librarian Interface
  GUI frontend to greenstone-tools
Index: main/trunk/package-kits/linux/deb/gsdl/Makefile
===================================================================
--- main/trunk/package-kits/linux/deb/gsdl/Makefile	(revision 29473)
+++ main/trunk/package-kits/linux/deb/gsdl/Makefile	(revision 29474)
@@ -1,11 +1,23 @@
-systemlib	:= /usr/lib
-java		:= $(systemlib)/jvm/default-java
-systembin	:= /usr/bin
-gssrv		:= /srv/gsdl
-tomcatlib	:= /usr/share/java/tomcat7
-tomcatconf	:= /etc/tomcat7/Catalina/localhost
-gstools		:= /opt/greenstone
+systemlib   := /usr/lib
+java        := $(systemlib)/jvm/default-java
+systembin   := /usr/bin
+gssrv       := /srv/gsdl
+tomcatlib   := /usr/share/tomcat7/lib
+tomcatconf  := /etc/tomcat7/Catalina/localhost
+gstools     := /opt/greenstone
+DESTDIR     ?= /
 
-all: cleanpkg main tools demo
+all: build
+
+deb:
+	# generate .install files
+	rm -f debian/*.install
+	echo $(gssrv) >> debian/greenstone.install
+	echo $(tomcatlib) >> debian/greenstone.install
+	echo $(systemlib) >> debian/greenstone.install
+	echo $(tomcatconf) >> debian/greenstone.install
+	echo $(gstools) >> debian/greenstone-tools.install
+	echo $(systembin) >> debian/greenstone-tools.install
+	dpkg-buildpackage -rfakeroot
 
 svn:
@@ -17,16 +29,13 @@
 	$(eval srcver := $(shell if test -d src; then cd src && svnversion -c | grep -o '[[:digit:]:]*'; else echo "nope"; fi))
 	if test $(svnver) != $(srcver); then \
+	$(MAKE) clean ; \
 	echo "Making copy of source" ; \
-	rm -rf src ; \
 	cp -rT svn src ; \
 	fi
 
-cleanpkg:
-	@echo Cleaning pkg directory
-	rm -rf pkg
-
-clean: cleanpkg
+clean:
 	@echo "Cleaning src directory"
 	rm -rf src
+	rm -f prepare build
 
 cleanall: clean
@@ -45,9 +54,9 @@
 	rm -rf src/packages/axis/docs
 	rm -rf src/gs2build/build-src/packages
+	touch prepare
 
 build: prepare
 	cd src ; \
-	export JAVA_HOME=$(java) ; \
-	ant install
+	JAVA_HOME=$(java) ant install
 	mv src/lib/jni/*.jar src/web/WEB-INF/lib/
 	# patch for gs2build tempdir
@@ -56,27 +65,21 @@
 	find src/ -type d \( -iname "win32" -o -iname "windows" -o -iname "winutil" -o -iname "darwin" \) -exec rm -rf {} \; 2> /dev/null || :
 	find src/ \( -iname "*.dll" -o -iname "*.exe" \) -exec rm -rf {} \; || :
+	touch build
 
-main: build
-	$(eval pkgdir := pkg/main)
-	install -d $(pkgdir)/$(gssrv) $(pkgdir)/$(systemlib) $(pkgdir)/$(tomcatlib)
-	install -dm775 $(pkgdir)/$(tomcatlib)
-	install -Dm755 src/lib/jni/*.so $(pkgdir)/$(systemlib)
-	rsync -av --exclude sites/localsite/collect/ --exclude .svn src/web/ $(pkgdir)/$(gssrv)/
-	install -Dm644 greenstone3.xml $(pkgdir)/$(tomcatconf)/greenstone3.xml
-	mv $(pkgdir)/$(gssrv)/WEB-INF/lib/derby.jar $(pkgdir)/$(tomcatlib)
+install: install-main install-tools
 
-tools: build 
-	$(eval pkgdir := pkg/tools)
-	install -d $(pkgdir)/$(gstools)
-	rsync -av --exclude build-src --exclude common-src --exclude collect/demo --exclude .svn src/gs2build $(pkgdir)/$(gstools)/
-	rsync -av --exclude build-src --exclude common-src --exclude collect/demo --exclude .svn src/bin $(pkgdir)/$(gstools)/
-	install -Dm755 greenstone $(pkgdir)/$(systembin)/greenstone
+install-main: build
+	install -d $(DESTDIR)/$(gssrv) $(DESTDIR)/$(systemlib) $(DESTDIR)/$(tomcatlib)
+	install -dm775 $(DESTDIR)/$(tomcatlib)
+	install -Dm755 src/lib/jni/*.so $(DESTDIR)/$(systemlib)
+	rsync -a --info=STATS --exclude sites/localsite/collect/ --exclude .svn src/web/ $(DESTDIR)/$(gssrv)/
+	install -Dm644 greenstone3.xml $(DESTDIR)/$(tomcatconf)/greenstone3.xml
+	mv $(DESTDIR)/$(gssrv)/WEB-INF/lib/derby.jar $(DESTDIR)/$(tomcatlib)
 
-demo: build
-	$(eval pkgdir := pkg/demo)
-	@echo "Building demo collections"
-	$(shell find sites/localsite/collect/ -mindepth 1 -maxdepth 1 -not -name ".*" -execdir bash -c 'col="$(basename $1)"; import.pl -removeold -site localsite "$$col"; buildcol.pl -removeold -site localsite "$$col"; mv "$$col/building" "$$col/index"' -- {} \;)
-	install -d $(pkgdir)/$(gssrv)/sites/localsite
-	rsync -av --exclude .svn src/web/sites/localsite/collect $(pkgdir)/$(gssrv)/sites/localsite/
+install-tools: build 
+	install -d $(DESTDIR)/$(gstools)
+	rsync -a --info=STATS --exclude build-src --exclude common-src --exclude collect/demo --exclude .svn src/gs2build $(DESTDIR)/$(gstools)/
+	rsync -a --info=STATS --exclude build-src --exclude common-src --exclude collect/demo --exclude .svn src/bin $(DESTDIR)/$(gstools)/
+	install -Dm755 greenstone $(DESTDIR)/$(systembin)/greenstone
 
-.PHONY: svn cleanpkg clean cleanall prepare build main tools demo
+.PHONY: svn clean cleanall install install-main install-tools
Index: main/trunk/package-kits/linux/deb/gsdl/debian/changelog
===================================================================
--- main/trunk/package-kits/linux/deb/gsdl/debian/changelog	(revision 29473)
+++ main/trunk/package-kits/linux/deb/gsdl/debian/changelog	(revision 29474)
@@ -1,3 +1,3 @@
-greenstone (VERSION) UNRELEASED; urgency=medium
+greenstone (3.06) UNRELEASED; urgency=medium
 
   * Initial release. (Closes: #XXXXXX)
Index: main/trunk/package-kits/linux/deb/gsdl/debian/control
===================================================================
--- main/trunk/package-kits/linux/deb/gsdl/debian/control	(revision 29473)
+++ main/trunk/package-kits/linux/deb/gsdl/debian/control	(revision 29474)
@@ -4,5 +4,14 @@
 Maintainer: Greenstone Team <greenstone_team@cs.waikato.ac.nz>
 Uploaders: Jeremy Symon <jtsymon@gmail.com>
-Build-Depends: debhelper (>= 9)
+Build-Depends:
+    debhelper (>= 9),
+    subversion,
+    default-jdk,
+    ant,
+    patch,
+    autoconf,
+    gcc,
+    make,
+    perl
 
 Package: greenstone
@@ -10,4 +19,6 @@
 Homepage: http://greenstone.org
 Depends:
+    default-jre,
+    tomcat7
 Description: Greenstone Digital Library
  Greenstone is a suite of software for building and distributing digital library collections.
@@ -17,9 +28,7 @@
 Homepage: http://greenstone.org
 Depends:
+    default-jre,
+    wv,
+    perl,
+    imagemagick
 Description: Greenstone Digital Library Tools
-
-Package: greenstone-demo
-Architecture: all
-Homepage: http://greenstone.org
-Depends:
-Description: Greenstone Digital Library Demo Collections
Index: main/trunk/package-kits/linux/deb/gsdl/debian/greenstone-tools.install
===================================================================
--- main/trunk/package-kits/linux/deb/gsdl/debian/greenstone-tools.install	(revision 29474)
+++ main/trunk/package-kits/linux/deb/gsdl/debian/greenstone-tools.install	(revision 29474)
@@ -0,0 +1,2 @@
+/opt/greenstone
+/usr/bin
Index: main/trunk/package-kits/linux/deb/gsdl/debian/greenstone.install
===================================================================
--- main/trunk/package-kits/linux/deb/gsdl/debian/greenstone.install	(revision 29474)
+++ main/trunk/package-kits/linux/deb/gsdl/debian/greenstone.install	(revision 29474)
@@ -0,0 +1,4 @@
+/srv/gsdl
+/usr/share/tomcat7/lib
+/usr/lib
+/etc/tomcat7/Catalina/localhost
Index: main/trunk/package-kits/linux/deb/gsdl/debian/rules
===================================================================
--- main/trunk/package-kits/linux/deb/gsdl/debian/rules	(revision 29473)
+++ main/trunk/package-kits/linux/deb/gsdl/debian/rules	(revision 29474)
@@ -1,3 +1,8 @@
- #!/usr/bin/make -f
+#!/usr/bin/make -f
 
+%:
+	dh $@ --with autotools_dev
 
+override_dh_gencontrol:
+	dh_gencontrol -pgreenstone
+	dh_gencontrol -pgreenstone-tools
Index: main/trunk/package-kits/linux/gli
===================================================================
--- main/trunk/package-kits/linux/gli	(revision 29473)
+++ main/trunk/package-kits/linux/gli	(revision 29474)
@@ -1,5 +1,18 @@
-#!/bin/sh
+#!/bin/bash
 
-export JAVA_HOME=/usr/lib/jvm/default
+if test -z "$JAVA_HOME"; then
+    for dir in /usr/lib/jvm/default/ /usr/lib/jvm/default-java/; do
+        if test -d $dir; then
+            JAVA_HOME=$dir
+            break
+        fi
+    done
+fi
+if test -z "$JAVA_HOME"; then
+    echo -e "Could not find JAVA_HOME.\nPlease export JAVA_HOME=<jre_location>" >&2
+    exit 1
+fi
+
+export JAVA_HOME
 
 . greenstone --no-interactive
Index: main/trunk/package-kits/linux/greenstone
===================================================================
--- main/trunk/package-kits/linux/greenstone	(revision 29473)
+++ main/trunk/package-kits/linux/greenstone	(revision 29474)
@@ -16,5 +16,5 @@
 
 # make sure we are sourced, and not run
-if test "`basename $0`" == "greenstone" ; then
+if test "`basename $0`" = "greenstone" ; then
 # if $0 is "greenstone" we've been run... $0 is shellname if sourced.
 # One exception is zsh has an option to set it temporarily to the script name
