Index: main/trunk/package-kits/linux/distros/fedora
===================================================================
--- main/trunk/package-kits/linux/distros/fedora	(revision 29516)
+++ main/trunk/package-kits/linux/distros/fedora	(revision 29526)
@@ -7,7 +7,7 @@
 GSSRV:                  /srv/gsdl
 TOMCATLIB:              /usr/share/tomcat7/lib
-TOMCATCONF:             /etc/tomcat7/Catalina/localhost
-GSTOOLS:                /opt/greenstone
-GLI:                    /opt/gli
+TOMCATCONF:             /etc/tomcat/Catalina/localhost
+GSTOOLS:                /usr/share/greenstone
+GLI:                    /usr/share/gli
 
 PKG_GREENSTONE:         greenstone,
@@ -17,5 +17,5 @@
 PKG_SVN:                svn,
 PKG_JAVA_JRE:           java >= 7,
-PKG_TOMCAT:             tomcat7,
+PKG_TOMCAT:             tomcat >= 7, tomcat-native,
 PKG_JAVA_JDK:           java-devel >= 7,
 PKG_ANT:                ant,
@@ -26,4 +26,4 @@
 PKG_WVWARE:             wv,
 PKG_PERL:               perl,
-PKG_IMAGEMAGICK:        imagemagick,
+PKG_IMAGEMAGICK:        ImageMagick,
 PKG_RSYNC:              rsync,
Index: main/trunk/package-kits/linux/files/greenstone
===================================================================
--- main/trunk/package-kits/linux/files/greenstone	(revision 29516)
+++ main/trunk/package-kits/linux/files/greenstone	(revision 29526)
@@ -34,5 +34,5 @@
 fi
 
-GSDLHOME=/opt/greenstone/gs2build
+GSDLHOME=@GSTOOLS@/gs2build
 export GSDLHOME
 
@@ -85,5 +85,5 @@
 if test -z "$GSDL3HOME" ; then
     echo "Setting collections location to the default" >&2
-    GSDL3HOME=/srv/gsdl
+    GSDL3HOME=@GSSRV@
 fi
 export GSDL3HOME
Index: main/trunk/package-kits/linux/generate
===================================================================
--- main/trunk/package-kits/linux/generate	(revision 29516)
+++ main/trunk/package-kits/linux/generate	(revision 29526)
@@ -35,9 +35,9 @@
 
 sub empty {
-    /^\s*$/ and return 1;
+    shift =~ /^\s*$/ and return 1;
 }
 
 sub comment {
-    /^\s*#/ and return 1;
+    shift =~ /^\s*#/ and return 1;
 }
 
@@ -49,24 +49,27 @@
 }
 
-sub copydir {
+sub add {
     my ($src, $dst, $subst) = @_;
-    mkdir $dst;
-    opendir my $DIRFH, $src or die "Could not open '$src': $!";
-    while (readdir $DIRFH) {
-        next if ($_ eq '.' or $_ eq '..');
-        print "    - $dst/$_\n";
-        if (-d "$src/$_") {
-            # copy folder
-            copydir ("$src/$_", "$dst/$_", $subst);
-        } elsif (-B "$src/$_") {
+    $dst =~ s/@([\w]+)@/$subst->{$1}/g;
+
+    if (-d $src) {
+        mkdir $dst;
+        opendir my $DIRFH, $src or die "Could not open '$src': $!";
+        while (readdir $DIRFH) {
+            next if ($_ eq '.' or $_ eq '..');
+            add ("$src/$_", "$dst/$_", $subst);
+        }
+        closedir $DIRFH;
+    } else {
+        print '    - ', $dst, "\n";
+        if (-B $src or $src =~ /\.patch$/i) {
             # copy binary file
-            cp "$src/$_", "$dst/$_" or die "Failed to copy '$_': $!";
+            cp $src, $dst or die "Failed to copy '$src': $!";
         } else {
             # copy normal file
-            my $newFile = "$dst/$_";
-            open OUT, '>', $newFile
-                or die "Failed to open '$_' for writing: $!";
-            open IN, '<', "$src/$_"
-                or die "Failed to open '$_' for reading: $!";
+            open IN, '<', $src
+                or die "Failed to open '$src' for reading: $!";
+            open OUT, '>', $dst
+                or die "Failed to open '$dst' for writing: $!";
             while (<IN>) {
                 s/@([\w]+)@/$subst->{$1}/g;
@@ -76,8 +79,7 @@
             close IN;
             close OUT;
-            chmod ($perms | 0600, $newFile);
+            chmod ($perms | 0600, $dst);
         }
     }
-    closedir $DIRFH;
 }
 
@@ -93,6 +95,6 @@
     defined $var and defined $val or die "Invalid variable assignment: '$line'";
     local $/ = '';
+    $val =~ s/@([\w]+)@/$vars->{$1}/g;
     $val =~ s/\\([ \\n]|$)/$escape{$1}/g;
-    $val =~ s/@([\w]+)@/$vars->{$1}/g;
     $vars->{$var} = $val;
 }
@@ -119,8 +121,8 @@
     open DISTRO, '<', $dconf;
     my %distro_vars;
-    while (<DISTRO>) {
-        chomp;
-        (comment or empty) and next;
-        readvar \%distro_vars, $_;
+    while (my $var = <DISTRO>) {
+        chomp $var;
+        (comment $var or empty $var) and next;
+        readvar \%distro_vars, $var;
     }
     close DISTRO;
@@ -134,9 +136,9 @@
         open PACKAGE, '<', $pconf;
         my %package_vars = %{dclone \%distro_vars};
-        while (<PACKAGE>) {
-            chomp;
-            empty and last;
-            comment and next;
-            readvar \%package_vars, $_;
+        while (my $var = <PACKAGE>) {
+            chomp $var;
+            empty $var and last;
+            comment $var and next;
+            readvar \%package_vars, $var;
         }
         for (keys %package_vars) {
@@ -145,10 +147,10 @@
         }
 
-        while (<PACKAGE>) {
-            chomp;
-            empty and last;
-            comment and next;
-            cp "files/$_", "$package_path/$_" or die "Failed to copy '$_': $!";
-            addsource \%package_vars, "$package_path/$_";
+        while (my $file = <PACKAGE>) {
+            chomp $file;
+            empty $file and last;
+            comment $file and next;
+            add ("files/$file", "$package_path/$file", \%package_vars);
+            addsource (\%package_vars, "$package_path/$file");
         }
 
@@ -158,10 +160,10 @@
         open MAKEFILE, '>', $outfile
             or die "Failed to open '$outfile' for writing: $!";
-        while (<PACKAGE>) {
-            chomp;
-            empty and last;
-            comment and next;
-            open IN, '<', "segments/$_"
-                or die "Failed to open '$_' for reading: $!";
+        while (my $segment = <PACKAGE>) {
+            chomp $segment;
+            empty $segment and last;
+            comment $segment and next;
+            open IN, '<', "segments/$segment"
+                or die "Failed to open 'segments/$segment' for reading: $!";
             while (<IN>) {
                 s/@([\w]+)@/$package_vars{$1}/g;
@@ -184,5 +186,5 @@
 
         # write the package manager files
-        copydir ("managers/$distro_vars{'MANAGER'}", $package_path, \%package_vars);
+        add ("managers/$distro_vars{'MANAGER'}", $package_path, \%package_vars);
     }
 }
Index: main/trunk/package-kits/linux/managers/rpm/@NAME@.spec
===================================================================
--- main/trunk/package-kits/linux/managers/rpm/@NAME@.spec	(revision 29526)
+++ main/trunk/package-kits/linux/managers/rpm/@NAME@.spec	(revision 29526)
@@ -0,0 +1,32 @@
+Name:       @NAME@
+Version:    @VERSION@
+Release:    @RELEASE@
+Summary:    @DESCRIPTION_SHORT@
+License:    @LICENSE_SHORT@
+URL:        @HOMEPAGE@
+Source0:    @NAME@
+
+AutoReqProv: no
+BuildRequires:  @MAKEDEPENDS@
+Requires:   @DEPENDS@
+
+%prep
+cp -pr %SOURCE0 .
+
+%description
+@DESCRIPTION@
+
+%build
+cd @NAME@
+make %{?_smp_mflags}
+
+%install
+cd @NAME@
+%make_install
+
+%files
+%doc
+@FILES@
+
+%changelog
+
Index: main/trunk/package-kits/linux/packages/demo
===================================================================
--- main/trunk/package-kits/linux/packages/demo	(revision 29516)
+++ main/trunk/package-kits/linux/packages/demo	(revision 29526)
@@ -13,4 +13,5 @@
 MAKEDEPENDS:            @PKG_GREENSTONE_TOOLS@ @PKG_SVN@ @PKG_RSYNC@
 PROVIDES:               
+FILES:                  @GSSRV@/sites/localsite/collect/*
 
 build-demo.sh
Index: main/trunk/package-kits/linux/packages/gli
===================================================================
--- main/trunk/package-kits/linux/packages/gli	(revision 29516)
+++ main/trunk/package-kits/linux/packages/gli	(revision 29526)
@@ -13,4 +13,5 @@
 MAKEDEPENDS:            @PKG_JAVA_JDK@ @PKG_SVN@ @PKG_RSYNC@
 PROVIDES:               
+FILES:                  @GLI@\n%{_bindir}/*
 
 gli
Index: main/trunk/package-kits/linux/packages/main
===================================================================
--- main/trunk/package-kits/linux/packages/main	(revision 29516)
+++ main/trunk/package-kits/linux/packages/main	(revision 29526)
@@ -13,11 +13,10 @@
 MAKEDEPENDS:            @PKG_JAVA_JDK@ @PKG_SVN@ @PKG_ANT@ @PKG_PATCH@ @PKG_AUTOCONF@ @PKG_GCC@ @PKG_MAKE@ @PKG_RSYNC@
 PROVIDES:               
+FILES:                  @GSSRV@\n@TOMCATCONF@/*\n@TOMCATLIB@/*\n%{_libdir}/*
 
 build.properties
-greenstone
 greenstone3.xml
 gs2build.patch
 perl-util.patch
-wvWare
 
 base
Index: main/trunk/package-kits/linux/packages/tools
===================================================================
--- main/trunk/package-kits/linux/packages/tools	(revision 29516)
+++ main/trunk/package-kits/linux/packages/tools	(revision 29526)
@@ -13,4 +13,5 @@
 MAKEDEPENDS:            @PKG_JAVA_JDK@ @PKG_SVN@ @PKG_ANT@ @PKG_PATCH@ @PKG_AUTOCONF@ @PKG_GCC@ @PKG_MAKE@ @PKG_RSYNC@
 PROVIDES:               
+FILES:                  @GSTOOLS@\n%{_bindir}/*
 
 build.properties
Index: main/trunk/package-kits/linux/segments/rpm
===================================================================
--- main/trunk/package-kits/linux/segments/rpm	(revision 29516)
+++ main/trunk/package-kits/linux/segments/rpm	(revision 29526)
@@ -1,3 +1,6 @@
 pkg: package
 package:
-	echo "TODO: RPM PACKAGES"
+	mkdir -p ~/rpmbuild/SPECS ~/rpmbuild/SOURCES/@NAME@
+	cp @NAME@.spec ~/rpmbuild/SPECS
+	rsync -a --info=STATS --exclude *.spec * ~/rpmbuild/SOURCES/@NAME@/
+	rpmbuild -ba @NAME@.spec
