Index: main/trunk/package-kits/linux/distros/arch
===================================================================
--- main/trunk/package-kits/linux/distros/arch	(revision 29539)
+++ main/trunk/package-kits/linux/distros/arch	(revision 29546)
@@ -2,23 +2,42 @@
 
 SYSTEMLIB:              /usr/lib
+SYSTEMSHARE:            /usr/share
 SYSTEMBIN:              /usr/bin
 SYSTEMJAVA:             @SYSTEMLIB@/jvm/default
-GSSRV:                  /srv/gsdl
+GREENSTONE_HOME:        @SYSTEMSHARE@/greenstone
+WEB:                    @GREENSTONE_HOME@/web
 TOMCATLIB:              /usr/share/java/tomcat7
 TOMCATCONF:             /etc/tomcat7/Catalina/localhost
-GSTOOLS:                /opt/greenstone
-GLI:                    /opt/gli
+TOMCAT_USER:            tomcat7
+GSTOOLS:                @GREENSTONE_HOME@/tools
+GLI:                    @GREENSTONE_HOME@/gli
 
-PKG_SVN:                'svn'
-PKG_JAVA_JRE:           'java-runtime=7'
-PKG_TOMCAT:             'tomcat7' 'tomcat-native'
-PKG_JAVA_JDK:           'java-environment=7'
-PKG_ANT:                'apache-ant'
-PKG_PATCH:              'patch'
-PKG_AUTOCONF:           'autoconf'
-PKG_GCC:                'gcc'
-PKG_MAKE:               'make'
-PKG_WVWARE:             'wv'
-PKG_PERL:               'perl' 'perl-xml-parser' 'perl-text-iconv'
-PKG_IMAGEMAGICK:        'imagemagick'
-PKG_RSYNC:              'rsync'
+PKG_SVN:
+    svn
+PKG_JAVA_JRE:
+    java-runtime=7
+PKG_TOMCAT:
+    tomcat7
+    tomcat-native
+PKG_JAVA_JDK:
+    java-environment=7
+PKG_ANT:
+    apache-ant
+PKG_PATCH:
+    patch
+PKG_AUTOCONF:
+    autoconf
+PKG_GCC:
+    gcc
+PKG_MAKE:
+    make
+PKG_WVWARE:
+    wv
+PKG_PERL:
+    perl
+    perl-xml-parser
+    perl-text-iconv
+PKG_IMAGEMAGICK:
+    imagemagick
+PKG_RSYNC:
+    rsync
Index: main/trunk/package-kits/linux/distros/fedora
===================================================================
--- main/trunk/package-kits/linux/distros/fedora	(revision 29539)
+++ main/trunk/package-kits/linux/distros/fedora	(revision 29546)
@@ -2,23 +2,41 @@
 
 SYSTEMLIB:              /usr/lib
+SYSTEMSHARE:            /usr/share
 SYSTEMBIN:              /usr/bin
 SYSTEMJAVA:             /etc/alternatives/java_sdk
-GSSRV:                  /srv/gsdl
+GREENSTONE_HOME:        @SYSTEMSHARE@/greenstone
+WEB:                    @GREENSTONE_HOME@/web
 TOMCATLIB:              /usr/share/tomcat/lib
 TOMCATCONF:             /etc/tomcat/Catalina/localhost
-GSTOOLS:                /usr/share/greenstone
-GLI:                    /usr/share/gli
+TOMCAT_USER:            tomcat7
+GSTOOLS:                @GREENSTONE_HOME@/tools
+GLI:                    @GREENSTONE_HOME@/gli
 
-PKG_SVN:                svn,
-PKG_JAVA_JRE:           java >= 7,
-PKG_TOMCAT:             tomcat >= 7, tomcat-native,
-PKG_JAVA_JDK:           java-devel >= 7,
-PKG_ANT:                ant,
-PKG_PATCH:              patch,
-PKG_AUTOCONF:           autoconf,
-PKG_GCC:                gcc, gcc-c++,
-PKG_MAKE:               make,
-PKG_WVWARE:             wv,
-PKG_PERL:               perl,
-PKG_IMAGEMAGICK:        ImageMagick,
-PKG_RSYNC:              rsync,
+PKG_SVN:
+    svn
+PKG_JAVA_JRE:
+    java >= 7
+PKG_TOMCAT:
+    tomcat >= 7
+    tomcat-native
+PKG_JAVA_JDK:
+    java-devel >= 7
+PKG_ANT:
+    ant
+PKG_PATCH:
+    patch
+PKG_AUTOCONF:
+    autoconf
+PKG_GCC:
+    gcc
+    gcc-c++
+PKG_MAKE:
+    make
+PKG_WVWARE:
+    wv
+PKG_PERL:
+    perl
+PKG_IMAGEMAGICK:
+    ImageMagick
+PKG_RSYNC:
+    rsync
Index: main/trunk/package-kits/linux/distros/ubuntu
===================================================================
--- main/trunk/package-kits/linux/distros/ubuntu	(revision 29539)
+++ main/trunk/package-kits/linux/distros/ubuntu	(revision 29546)
@@ -2,23 +2,40 @@
 
 SYSTEMLIB:              /usr/lib
+SYSTEMSHARE:            /usr/share
 SYSTEMBIN:              /usr/bin
 SYSTEMJAVA:             @SYSTEMLIB@/jvm/default-java
-GSSRV:                  /srv/gsdl
+GREENSTONE_HOME:        @SYSTEMSHARE@/greenstone
+WEB:                    @GREENSTONE_HOME@/web
 TOMCATLIB:              /usr/share/tomcat7/lib
 TOMCATCONF:             /etc/tomcat7/Catalina/localhost
-GSTOOLS:                /opt/greenstone
-GLI:                    /opt/gli
+TOMCAT_USER:            tomcat7
+GSTOOLS:                @GREENSTONE_HOME@/tools
+GLI:                    @GREENSTONE_HOME@/gli
 
-PKG_SVN:                subversion,
-PKG_JAVA_JRE:           default-jre,
-PKG_TOMCAT:             tomcat7,
-PKG_JAVA_JDK:           default-jdk,
-PKG_ANT:                ant,
-PKG_PATCH:              patch,
-PKG_AUTOCONF:           autoconf,
-PKG_GCC:                gcc, g++,
-PKG_MAKE:               make,
-PKG_WVWARE:             wv,
-PKG_PERL:               perl,
-PKG_IMAGEMAGICK:        imagemagick,
-PKG_RSYNC:              rsync,
+PKG_SVN:
+    subversion
+PKG_JAVA_JRE:
+    default-jre
+PKG_TOMCAT:
+    tomcat7
+PKG_JAVA_JDK:
+    default-jdk
+PKG_ANT:
+    ant
+PKG_PATCH:
+    patch
+PKG_AUTOCONF:
+    autoconf
+PKG_GCC:
+    gcc
+    g++
+PKG_MAKE:
+    make
+PKG_WVWARE:
+    wv
+PKG_PERL:
+    perl
+PKG_IMAGEMAGICK:
+    imagemagick
+PKG_RSYNC:
+    rsync
Index: main/trunk/package-kits/linux/files/greenstone
===================================================================
--- main/trunk/package-kits/linux/files/greenstone	(revision 29539)
+++ main/trunk/package-kits/linux/files/greenstone	(revision 29546)
@@ -85,5 +85,5 @@
 if test -z "$GSDL3HOME" ; then
     echo "Setting collections location to the default" >&2
-    GSDL3HOME=@GSSRV@
+    GSDL3HOME=@WEB@
 fi
 export GSDL3HOME
Index: main/trunk/package-kits/linux/files/greenstone3.xml
===================================================================
--- main/trunk/package-kits/linux/files/greenstone3.xml	(revision 29539)
+++ main/trunk/package-kits/linux/files/greenstone3.xml	(revision 29546)
@@ -1,6 +1,6 @@
-<Context path="/greenstone3" docBase="/srv/gsdl/" reloadable="true">
+<Context path="/greenstone3" docBase="@WEB@" reloadable="true">
     <Realm className="org.apache.catalina.realm.JDBCRealm" 
         driverName="org.apache.derby.jdbc.EmbeddedDriver"
-        connectionURL="jdbc:derby:/srv/gsdl/etc/usersDB"
+        connectionURL="jdbc:derby:@WEB@/etc/usersDB"
         userTable="users" userNameCol="username" userCredCol="password"
         userRoleTable="roles" roleNameCol="role"
Index: main/trunk/package-kits/linux/global.conf
===================================================================
--- main/trunk/package-kits/linux/global.conf	(revision 29539)
+++ main/trunk/package-kits/linux/global.conf	(revision 29546)
@@ -1,4 +1,8 @@
-PKG_GREENSTONE:         'greenstone'
-PKG_GREENSTONE_TOOLS:   'greenstone-tools'
-PKG_GREENSTONE_DEMO:    'greenstone-demo'
-PKG_GLI:                'greenstone-gli'
+PKG_GREENSTONE:
+    greenstone
+PKG_GREENSTONE_TOOLS:
+    greenstone-tools
+PKG_GREENSTONE_DEMO:
+    greenstone-demo
+PKG_GLI:
+    greenstone-gli
Index: main/trunk/package-kits/linux/managers/pacman/PKGBUILD
===================================================================
--- main/trunk/package-kits/linux/managers/pacman/PKGBUILD	(revision 29539)
+++ main/trunk/package-kits/linux/managers/pacman/PKGBUILD	(revision 29546)
@@ -14,5 +14,5 @@
 # replaces=()
 # backup=()
-# install=''
+@INSTALL@
 source=(@SOURCES@
 )
Index: main/trunk/package-kits/linux/managers/rpm/@NAME@.spec
===================================================================
--- main/trunk/package-kits/linux/managers/rpm/@NAME@.spec	(revision 29539)
+++ main/trunk/package-kits/linux/managers/rpm/@NAME@.spec	(revision 29546)
@@ -25,4 +25,5 @@
 %make_install
 
+@INSTALL@
 %files
 %doc
Index: main/trunk/package-kits/linux/packages/demo
===================================================================
--- main/trunk/package-kits/linux/packages/demo	(revision 29539)
+++ main/trunk/package-kits/linux/packages/demo	(revision 29546)
@@ -23,5 +23,5 @@
 
 FILES:
-    @GSSRV@/sites/localsite/collect/*
+    @WEB@/sites/localsite/collect/*
 
 SOURCES:
Index: main/trunk/package-kits/linux/packages/main
===================================================================
--- main/trunk/package-kits/linux/packages/main	(revision 29539)
+++ main/trunk/package-kits/linux/packages/main	(revision 29546)
@@ -31,5 +31,5 @@
 
 FILES:
-    @GSSRV@
+    @WEB@
     @TOMCATCONF@/*
     @TOMCATLIB@/*
@@ -48,2 +48,8 @@
     build-core
     main
+
+POST_INSTALL:
+    chown -R @TOMCAT_USER@:@TOMCAT_USER@ @WEB@
+
+POST_REMOVE:
+    echo "To fully remove greenstone, delete /usr/share/greenstone/web"
Index: main/trunk/package-kits/linux/perllib/Greenstone/Config.pm
===================================================================
--- main/trunk/package-kits/linux/perllib/Greenstone/Config.pm	(revision 29539)
+++ main/trunk/package-kits/linux/perllib/Greenstone/Config.pm	(revision 29546)
@@ -4,4 +4,5 @@
 use warnings;
 use utf8; 
+use Greenstone::Helpers;
 
 # Formats an array
@@ -31,3 +32,33 @@
 }
 
+# Reads a config file into the config hashmap
+sub readconf {
+    my ($self, $conf) = @_;
+    $self->{config} = {} unless exists $self->{config};
+    open CONF, '<', $conf
+        or die "Failed to open '$conf' for reading: $!";
+    my $var;
+    while (my $line = <CONF>) {
+        if (empty $line or comment $line) {
+            $var = undef;
+        } elsif (defined $var and $line =~ /^\s/) {
+            trim $line;
+            $self->subst ($line);
+            escape $line;
+            push @{$self->{config}->{$var}}, $line;
+        } else {
+            ($var, my $val) = trim (split ":", $line, 2);
+            defined $var and defined $val or die "Invalid variable assignment: '$line'";
+            if (empty $val) {
+                $self->{config}->{$var} = [];
+            } else {
+                $self->subst ($val);
+                escape $val;
+                $self->{config}->{$var} = $val;
+            }
+        }
+    }
+    close CONF;
+}
+
 1;
Index: main/trunk/package-kits/linux/perllib/Greenstone/Config/Loader.pm
===================================================================
--- main/trunk/package-kits/linux/perllib/Greenstone/Config/Loader.pm	(revision 29539)
+++ 	(revision )
@@ -1,39 +1,0 @@
-package Greenstone::Config::Loader;
-
-use strict;
-use warnings;
-use utf8;
-use parent 'Greenstone::Config';
-use Greenstone::Helpers;
-
-# Reads a config file into the config hashmap
-sub readconf {
-    my ($self, $conf) = @_;
-    $self->{config} = {} unless exists $self->{config};
-    open CONF, '<', $conf
-        or die "Failed to open '$conf' for reading: $!";
-    my $var;
-    while (my $line = <CONF>) {
-        if (empty $line or comment $line) {
-            $var = undef;
-        } elsif (defined $var and $line =~ /^\s/) {
-            trim $line;
-            $self->subst ($line);
-            escape $line;
-            push @{$self->{config}->{$var}}, $line;
-        } else {
-            ($var, my $val) = trim (split ":", $line, 2);
-            defined $var and defined $val or die "Invalid variable assignment: '$line'";
-            if (empty $val) {
-                $self->{config}->{$var} = [];
-            } else {
-                $self->subst ($val);
-                escape $val;
-                $self->{config}->{$var} = $val;
-            }
-        }
-    }
-    close CONF;
-}
-
-1;
Index: main/trunk/package-kits/linux/perllib/Greenstone/Package.pm
===================================================================
--- main/trunk/package-kits/linux/perllib/Greenstone/Package.pm	(revision 29539)
+++ main/trunk/package-kits/linux/perllib/Greenstone/Package.pm	(revision 29546)
@@ -8,5 +8,4 @@
 use Greenstone::Helpers;
 use base 'Exporter';
-require Greenstone::Config::Loader;
 
 use parent 'Greenstone::Config';
@@ -53,18 +52,19 @@
 
     # Classify ourselves as config and load the config
-    my $self = bless({}, 'Greenstone::Config::Loader');
+    my $self = bless({}, 'Greenstone::Config');
 
     $self->readconf ("global.conf");
     $self->readconf ($distro_conf);
-    $self->readconf ($package_conf);
-
+    
     die "Distro '$args{distro}' is invalid (does not specify a manager)"
         unless (exists $self->{config}->{MANAGER});
 
     my $class = __PACKAGE__ . '::_' . lc $self->{config}->{MANAGER};
-    eval "require $class; 1" or die "Package manager '$self->{config}->{MANAGER}' does not exist";
+    eval "require $class; 1" or die "Package manager '$self->{config}->{MANAGER}' does not exist or did not compile";
 
     # Reclassify as our implementation
     bless $self, $class;
+
+    $self->readconf ($package_conf);
 
     $self->{package} = $args{package};
@@ -75,4 +75,5 @@
     $self->add_sources;
     $self->add_makefile;
+    $self->add_install;
     $self->add_package;
 }
Index: main/trunk/package-kits/linux/perllib/Greenstone/Package/_apt.pm
===================================================================
--- main/trunk/package-kits/linux/perllib/Greenstone/Package/_apt.pm	(revision 29539)
+++ main/trunk/package-kits/linux/perllib/Greenstone/Package/_apt.pm	(revision 29546)
@@ -12,3 +12,25 @@
 }
 
+sub write_function {
+    my ($self, $name, @lines) = @_;
+    open OUT, '>', "/tmp/$name";
+    for my $line (@lines) {
+        print OUT $line, "\n";
+    }
+    close OUT;
+    $self->add ("/tmp/$name", "$self->{output}/$name");
+}
+
+sub add_install {
+    my $self = shift;
+    exists $self->{config}->{PRE_INSTALL} and
+        $self->write_function ("preinst", @{$self->{config}->{PRE_INSTALL}});
+    exists $self->{config}->{POST_INSTALL} and
+        $self->write_function ("postinst", @{$self->{config}->{POST_INSTALL}});
+    exists $self->{config}->{PRE_REMOVE} and
+        $self->write_function ("prerm", @{$self->{config}->{PRE_REMOVE}});
+    exists $self->{config}->{POST_REMOVE} and
+        $self->write_function ("postrm", @{$self->{config}->{POST_REMOVE}});
+}
+
 1;
Index: main/trunk/package-kits/linux/perllib/Greenstone/Package/_pacman.pm
===================================================================
--- main/trunk/package-kits/linux/perllib/Greenstone/Package/_pacman.pm	(revision 29539)
+++ main/trunk/package-kits/linux/perllib/Greenstone/Package/_pacman.pm	(revision 29546)
@@ -38,3 +38,40 @@
 }
 
+sub write_function {
+    my ($name, $out, @lines) = @_;
+    print $out $name, "() {\n";
+    for my $line (@lines) {
+        print $out "\t", $line, "\n";
+    }
+    print $out "}\n\n";
+}
+
+sub add_install {
+    my $self = shift;
+    if (exists $self->{config}->{PRE_INSTALL} or
+        exists $self->{config}->{POST_INSTALL} or
+        exists $self->{config}->{PRE_REMOVE} or
+        exists $self->{config}->{POST_REMOVE}) {
+        my $name = "$self->{config}->{NAME}.install";
+        open my $INSTALL, '>', "/tmp/$name";
+        exists $self->{config}->{PRE_INSTALL} and do {
+            write_function "pre_install", $INSTALL, @{$self->{config}->{PRE_INSTALL}};
+            write_function "pre_upgrade", $INSTALL, @{$self->{config}->{PRE_INSTALL}};
+        };
+        exists $self->{config}->{POST_INSTALL} and do {
+            write_function "post_install", $INSTALL, @{$self->{config}->{POST_INSTALL}};
+            write_function "post_upgrade", $INSTALL, @{$self->{config}->{POST_INSTALL}};
+        };
+        exists $self->{config}->{PRE_REMOVE} and
+            write_function "pre_remove", $INSTALL, @{$self->{config}->{PRE_REMOVE}};
+        exists $self->{config}->{POST_REMOVE} and
+            write_function "post_remove", $INSTALL, @{$self->{config}->{POST_REMOVE}};
+        close $INSTALL;
+        $self->add ("/tmp/$name", "$self->{output}/$name");
+        $self->{config}->{INSTALL} = "install=$name";
+    } else {
+        $self->{config}->{INSTALL} = "";
+    }
+}
+
 1;
Index: main/trunk/package-kits/linux/perllib/Greenstone/Package/_rpm.pm
===================================================================
--- main/trunk/package-kits/linux/perllib/Greenstone/Package/_rpm.pm	(revision 29539)
+++ main/trunk/package-kits/linux/perllib/Greenstone/Package/_rpm.pm	(revision 29546)
@@ -12,3 +12,27 @@
 }
 
+sub write_function {
+    my ($name, @lines) = @_;
+    my $ret = "";
+    $ret .= "%" . $name . "\n";
+    for my $line (@lines) {
+        $ret .= $line . "\n";
+    }
+    $ret .= "\n";
+    return $ret;
+}
+
+sub add_install {
+    my $self = shift;
+    $self->{config}->{INSTALL} = "";
+    exists $self->{config}->{PRE_INSTALL} and
+        $self->{config}->{INSTALL} .= write_function "pre", @{$self->{config}->{PRE_INSTALL}};
+    exists $self->{config}->{POST_INSTALL} and
+        $self->{config}->{INSTALL} .= write_function "post", @{$self->{config}->{POST_INSTALL}};
+    exists $self->{config}->{PRE_REMOVE} and
+        $self->{config}->{INSTALL} .= write_function "preun", @{$self->{config}->{PRE_INSTALL}};
+    exists $self->{config}->{POST_REMOVE} and
+        $self->{config}->{INSTALL} .= write_function "postun", @{$self->{config}->{POST_INSTALL}};
+}
+
 1;
Index: main/trunk/package-kits/linux/segments/base
===================================================================
--- main/trunk/package-kits/linux/segments/base	(revision 29539)
+++ main/trunk/package-kits/linux/segments/base	(revision 29546)
@@ -2,5 +2,5 @@
 systembin  := @SYSTEMBIN@
 java       := @SYSTEMJAVA@
-gssrv      := @GSSRV@
+web        := @WEB@
 tomcatlib  := @TOMCATLIB@
 tomcatconf := @TOMCATCONF@
Index: main/trunk/package-kits/linux/segments/demo
===================================================================
--- main/trunk/package-kits/linux/segments/demo	(revision 29539)
+++ main/trunk/package-kits/linux/segments/demo	(revision 29546)
@@ -5,4 +5,4 @@
 
 install:
-	install -d $(DESTDIR)/$(gssrv)/sites/localsite
-	rsync -a --info=STATS --exclude .svn src/ $(DESTDIR)/$(gssrv)/sites/localsite/collect/
+	install -d $(DESTDIR)/$(web)/sites/localsite
+	rsync -a --info=STATS --exclude .svn src/ $(DESTDIR)/$(web)/sites/localsite/collect/
Index: main/trunk/package-kits/linux/segments/main
===================================================================
--- main/trunk/package-kits/linux/segments/main	(revision 29539)
+++ main/trunk/package-kits/linux/segments/main	(revision 29546)
@@ -1,7 +1,7 @@
 install:
-	install -d $(DESTDIR)/$(gssrv) $(DESTDIR)/$(systemlib) $(DESTDIR)/$(tomcatlib)
+	install -d $(DESTDIR)/$(web) $(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)/
+	rsync -a --info=STATS --exclude sites/localsite/collect/ --exclude .svn src/web/ $(DESTDIR)/$(web)/
 	install -Dm644 greenstone3.xml $(DESTDIR)/$(tomcatconf)/greenstone3.xml
-	mv $(DESTDIR)/$(gssrv)/WEB-INF/lib/derby.jar $(DESTDIR)/$(tomcatlib)
+	mv $(DESTDIR)/$(web)/WEB-INF/lib/derby.jar $(DESTDIR)/$(tomcatlib)
