Index: main/trunk/package-kits/linux/perllib/Greenstone/Package.pm
===================================================================
--- main/trunk/package-kits/linux/perllib/Greenstone/Package.pm	(revision 29598)
+++ main/trunk/package-kits/linux/perllib/Greenstone/Package.pm	(revision 29607)
@@ -59,5 +59,9 @@
     $self->readconf ("global.conf");
     $self->readconf ($distro_conf);
-    $self->{config}->{ARCH} = (uname)[4];
+
+    my $manager_conf = "managers/$self->{config}->{MANAGER}/conf";
+    -f $manager_conf or die "Manager config for '$self->{config}->{MANAGER}' does not exist";
+
+    $self->readconf ($manager_conf);
 
     die "Distro '$args{distro}' is invalid (does not specify a manager)"
@@ -79,5 +83,4 @@
     $self->add_sources;
     $self->add_makefile;
-    $self->add_install;
     $self->add_package;
 }
@@ -130,5 +133,6 @@
     
     # Add the (relatively) static files
-    $self->add ("managers/$self->{config}->{MANAGER}", $self->{output});
+    my $static = "managers/$self->{config}->{MANAGER}/files";
+    -d $static and $self->add ($static, $self->{output});
 
     if (exists $self->{config}->{SUB_PACKAGES}) {
Index: main/trunk/package-kits/linux/perllib/Greenstone/Package/_apt.pm
===================================================================
--- main/trunk/package-kits/linux/perllib/Greenstone/Package/_apt.pm	(revision 29598)
+++ main/trunk/package-kits/linux/perllib/Greenstone/Package/_apt.pm	(revision 29607)
@@ -6,4 +6,5 @@
 use parent 'Greenstone::Package';
 
+# Deb packages expect lists to be comma separated
 sub replacement_array {
     my $self = shift;
@@ -16,5 +17,6 @@
     my $file = "$self->{output}/debian/$name";
     print "    - $file\n";
-    open my $OUT, '>', $file;
+    open my $OUT, '>', $file
+        or die "Failed to open $file: $!";
     for my $line (@lines) {
         print $OUT $line, "\n";
@@ -24,16 +26,19 @@
 }
 
+# Add pre/post install/remove hooks
 sub add_install {
-    my $self = shift;
+    my ($self, $name) = @_;
+    my $prefix = (defined $name ? "$name." : "");
     exists $self->{config}->{PRE_INSTALL} and
-        $self->write_function ("preinst", @{$self->{config}->{PRE_INSTALL}});
+        $self->write_function ("${prefix}preinst", @{$self->{config}->{PRE_INSTALL}});
     exists $self->{config}->{POST_INSTALL} and
-        $self->write_function ("postinst", @{$self->{config}->{POST_INSTALL}});
+        $self->write_function ("${prefix}postinst", @{$self->{config}->{POST_INSTALL}});
     exists $self->{config}->{PRE_REMOVE} and
-        $self->write_function ("prerm", @{$self->{config}->{PRE_REMOVE}});
+        $self->write_function ("${prefix}prerm", @{$self->{config}->{PRE_REMOVE}});
     exists $self->{config}->{POST_REMOVE} and
-        $self->write_function ("postrm", @{$self->{config}->{POST_REMOVE}});
+        $self->write_function ("${prefix}postrm", @{$self->{config}->{POST_REMOVE}});
 }
 
+# Adds a definition for a package or subpackage
 sub add_package_section {
     my ($self, $out) = @_;
@@ -42,8 +47,8 @@
         'Architecture: %ARCHITECTURE%',
         'Homepage: %HOMEPAGE%',
-        'Depends:',
-        '  %DEPENDS%',
-        'Description: %DESCRIPTION_SHORT',
-        '  %DESCRIPTION'
+        'Depends: %DEPENDS%',
+        'Description: %DESCRIPTION_SHORT%',
+        '  %DESCRIPTION%',
+        ''
     ) {
         my $copy = $line;
@@ -53,10 +58,11 @@
 }
 
+# Handles the apt-specific package generation
 sub add_package_impl {
     my ($self, $packages) = @_;
-    $self->add_install;
     my $file = "$self->{output}/debian/control";
     print "    - $file\n";
-    open my $CONTROL, '>', $file;
+    open my $CONTROL, '>', $file
+        or die "Failed to open $file: $!";
     for my $line (
         'Source: %NAME%',
@@ -64,6 +70,6 @@
         'Priority: optional',
         'Maintainer: %MAINTAINER_NAME% <%MAINTAINER_EMAIL%>',
-        'Build-Depends:',
-        '  %MAKEDEPENDS%',
+        'Build-Depends: %MAKEDEPENDS%',
+        ''
     ) {
         my $copy = $line;
@@ -73,11 +79,29 @@
     if (defined $packages) {
         my $config = $self->{config};
+        my @names;
         for my $package (@{$packages}) {
+            push @names, $package->{NAME};
             $package->{HOMEPAGE} = $config->{HOMEPAGE};
             $self->{config} = $package;
+            $self->add_install ($package->{NAME});
             $self->add_package_section ($CONTROL);
+            my $install = "$self->{output}/debian/$self->{config}->{NAME}.install";
+            open my $INSTALL, '>', $install;
+            for my $line (@{$self->{config}->{FILES}}) {
+                print $INSTALL $line, "\n";
+            }
+            close $INSTALL;
         }
         $self->{config} = $config;
+        my $rules = "$self->{output}/debian/rules";
+        open my $RULES, '>>', $rules
+            or die "Failed to open $rules: $!";
+        print $RULES "\noverride_dh_gencontrol:\n";
+        for my $name (@names) {
+            print $RULES "\tdh_gencontrol -p$name\n";
+        }
+        close $RULES;
     } else {
+        $self->add_install;
         $self->add_package_section ($CONTROL);
     }
Index: main/trunk/package-kits/linux/perllib/Greenstone/Package/_pacman.pm
===================================================================
--- main/trunk/package-kits/linux/perllib/Greenstone/Package/_pacman.pm	(revision 29598)
+++ main/trunk/package-kits/linux/perllib/Greenstone/Package/_pacman.pm	(revision 29607)
@@ -94,5 +94,5 @@
         'url=%HOMEPAGE%',
         'license=%LICENSE_SHORT%',
-        'arch=(any)',
+        'arch=(' . (defined $self->{config}->{ARCH} ? '%ARCH%' : 'any') . ')',
         'makedepends=(',
         '%MAKEDEPENDS%',
Index: main/trunk/package-kits/linux/perllib/Greenstone/Package/_rpm.pm
===================================================================
--- main/trunk/package-kits/linux/perllib/Greenstone/Package/_rpm.pm	(revision 29598)
+++ main/trunk/package-kits/linux/perllib/Greenstone/Package/_rpm.pm	(revision 29607)
@@ -90,5 +90,7 @@
                 $self->add_install,
                 '%files',
-                '%FILES%'
+                '%FILES%',
+                '',
+                ''
             ) {
                 my $copy = $line;
