summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteffen Hansen <steffen@kdab.com>2005-06-08 12:44:35 (GMT)
committerSteffen Hansen <steffen@kdab.com>2005-06-08 12:44:35 (GMT)
commit7ca6b355417e0699eaf0a72990844da52f636b16 (patch)
tree8ce425f1bc0b66fc3a1417a5604c70460e94448a
parent2887879731722d8761714e1c80d13f093e5cd8d6 (diff)
downloadperl-Kolab-7ca6b355417e0699eaf0a72990844da52f636b16.tar.gz
autoperlized perl-kolab. Last non-autoperl version is tagged pre_autoperl
-rw-r--r--Kolab-Conf/Conf.pm167
-rw-r--r--Kolab-Conf/Makefile.am1
-rw-r--r--Kolab-Cyrus/Cyrus.pm4
-rw-r--r--Kolab-Cyrus/Makefile.am1
-rw-r--r--Kolab-DirServ/DirServ.pm3
-rw-r--r--Kolab-DirServ/Makefile.am1
-rw-r--r--Kolab-LDAP-Backend-ad/Makefile.am1
-rw-r--r--Kolab-LDAP-Backend-ad/ad.pm4
-rw-r--r--Kolab-LDAP-Backend-dirservd/Makefile.am1
-rw-r--r--Kolab-LDAP-Backend-dirservd/dirservd.pm4
-rw-r--r--Kolab-LDAP-Backend-slurpd/Makefile.am1
-rw-r--r--Kolab-LDAP-Backend-slurpd/slurpd.pm3
-rw-r--r--Kolab-LDAP-Backend/Makefile.am1
-rw-r--r--Kolab-LDAP/LDAP.pm7
-rw-r--r--Kolab-LDAP/Makefile.am1
-rw-r--r--Kolab-Mailer/Mailer.pm9
-rw-r--r--Kolab-Mailer/Makefile.am1
-rw-r--r--Kolab-Util/Makefile.am1
-rw-r--r--Kolab/Kolab.pm29
-rw-r--r--Kolab/Makefile.am1
-rw-r--r--Makefile26
-rw-r--r--Makefile.am31
-rw-r--r--Makefile.cvs24
-rwxr-xr-xconfigure3032
-rw-r--r--dist_conf/kolab57
-rw-r--r--perl-kolab.spec125
-rw-r--r--perl-kolab.spec.in79
27 files changed, 3370 insertions, 245 deletions
diff --git a/Kolab-Conf/Conf.pm b/Kolab-Conf/Conf.pm
index 251225b..6f0b091 100644
--- a/Kolab-Conf/Conf.pm
+++ b/Kolab-Conf/Conf.pm
@@ -1,10 +1,10 @@
package Kolab::Conf;
##
-## Copyright (c) 2004 Klaralvdalens Datakonsult AB
+## Copyright (c) 2004 Klaraelvdalens Datakonsult AB
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bing?<s.binge@codefusion.co.za>
+## Writen by Stuart Bingë <s.binge@codefusion.co.za>
## Portions based on work by the following people:
##
## (c) 2003 Tassilo Erlewein <tassilo.erlewein@erfrakon.de>
@@ -38,6 +38,7 @@ use Kolab::Util;
use Kolab::LDAP;
require Exporter;
+require "config.h";
our @ISA = qw(Exporter);
@@ -106,7 +107,7 @@ sub build {
}
my $config;
if (!($config = new File::Temp( TEMPLATE => 'tmpXXXXX',
- DIR => $prefix.'/etc/kolab/',
+ DIR => $prefix.$ap::config->{sysconfdir}/kolab/,
SUFFIX => '.kolabtmp',
UNLINK => 0 ))) {
Kolab::log('T', "Unable to open configuration file `$cfg'", KOLAB_ERROR);
@@ -231,14 +232,14 @@ sub buildPostfixMap
Kolab::log('T', "Building Postfix $map map", KOLAB_DEBUG);
my $prefix = $Kolab::config{'prefix'};
- my $cfg = "$prefix/etc/postfix/$map";
+ my $cfg = "$ap::config->{sysconfdir}/postfix/$map";
my $oldcfg = $cfg . '.old';
my $oldmask = umask 077;
copy($cfg, $oldcfg);
chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $oldcfg);
umask $oldmask;
- copy("$prefix/etc/kolab/templates/$map.template", $cfg);
+ copy("$ap::config->{sysconfdir}/kolab/templates/$map.template", $cfg);
my $transport;
if (!($transport = IO::File->new($cfg, 'a'))) {
@@ -281,8 +282,8 @@ sub buildPostfixMap
$transport->close;
# FIXME: bad way of doing things...
- #system("chown root:root $prefix/etc/postfix/*");
- system("$prefix/sbin/postmap $prefix/etc/postfix/$map");
+ #system("chown root:root $ap::config->{sysconfdir}/postfix/*");
+ system("$ap::config->{sbindir}/postmap $ap::config->{sysconfdir}/etc/postfix/$map");
if (-f $oldcfg) {
my $rc = `diff -q $cfg $oldcfg`;
@@ -304,12 +305,12 @@ sub buildCyrusConfig
my $prefix = $Kolab::config{'prefix'};
my $cyrustemplate;
- if (!($cyrustemplate = IO::File->new("$prefix/etc/kolab/templates/cyrus.conf.template", 'r'))) {
+ if (!($cyrustemplate = IO::File->new("$ap::config->{sysconfdir}/kolab/templates/cyrus.conf.template", 'r'))) {
Kolab::log('T', "Unable to open template file `cyrus.conf.template'", KOLAB_ERROR);
exit(1);
}
- my $cfg = "$prefix/etc/imapd/cyrus.conf";
+ my $cfg = "$ap::config->{sysconfdir}/imapd/cyrus.conf";
my $oldcfg = $cfg . '.old';
my $oldmask = umask 077;
copy($cfg, $oldcfg);
@@ -324,23 +325,23 @@ sub buildCyrusConfig
while (<$cyrustemplate>) {
if (/\@{3}cyrus-imap\@{3}/ && ($Kolab::config{"cyrus-imap"} =~ /true/i)) {
- $_ = "imap cmd=\"imapd -C $prefix/etc/imapd/imapd.conf\" listen=\"143\" prefork=0\n";
+ $_ = "imap cmd=\"imapd -C $ap::config->{sysconfdir}/imapd/imapd.conf\" listen=\"143\" prefork=0\n";
}
elsif (/\@{3}cyrus-imap\@{3}/ && ($Kolab::config{"cyrus-imap"} =~ /false/i)) {
# Even if imapd is disabled, enable it for localhost -- resource handlers depend on it
- $_ = "imap cmd=\"imapd -C $prefix/etc/imapd/imapd.conf\" listen=\"127.0.0.1:143\" prefork=0\n";
+ $_ = "imap cmd=\"imapd -C $ap::config->{sysconfdir}/imapd/imapd.conf\" listen=\"127.0.0.1:143\" prefork=0\n";
}
elsif (/\@{3}cyrus-pop3\@{3}/ && ($Kolab::config{"cyrus-pop3"} =~ /true/i)) {
- $_ = "pop3 cmd=\"pop3d -C $prefix/etc/imapd/imapd.conf\" listen=\"110\" prefork=0\n";
+ $_ = "pop3 cmd=\"pop3d -C $ap::config->{sysconfdir}/imapd/imapd.conf\" listen=\"110\" prefork=0\n";
}
elsif (/\@{3}cyrus-imaps\@{3}/ && ($Kolab::config{"cyrus-imaps"} =~ /true/i)) {
- $_ = "imaps cmd=\"imapd -s -C $prefix/etc/imapd/imapd.conf\" listen=\"993\" prefork=0\n";
+ $_ = "imaps cmd=\"imapd -s -C $ap::config->{sysconfdir}/imapd/imapd.conf\" listen=\"993\" prefork=0\n";
}
elsif (/\@{3}cyrus-pop3s\@{3}/ && ($Kolab::config{"cyrus-pop3s"} =~ /true/i)) {
- $_ = "pop3s cmd=\"pop3d -s -C $prefix/etc/imapd/imapd.conf\" listen=\"995\" prefork=0\n";
+ $_ = "pop3s cmd=\"pop3d -s -C $ap::config->{sysconfdir}/imapd/imapd.conf\" listen=\"995\" prefork=0\n";
}
elsif (/\@{3}cyrus-sieve\@{3}/ && ($Kolab::config{"cyrus-sieve"} =~ /true/i)) {
- $_ = "sieve cmd=\"timsieved -C $prefix/etc/imapd/imapd.conf\" listen=\"2000\" prefork=0\n";
+ $_ = "sieve cmd=\"timsieved -C $ap::config->{sysconfdir}/imapd/imapd.conf\" listen=\"2000\" prefork=0\n";
}
$_ =~ s/\@{3}.*\@{3}//;
print $cyrusconf $_;
@@ -370,14 +371,14 @@ sub buildCyrusGroups
Kolab::log('T', 'Building Cyrus groups', KOLAB_DEBUG);
my $prefix = $Kolab::config{'prefix'};
- my $cfg = "$prefix/etc/imapd/imapd.group";
+ my $cfg = "$ap::config->{sysconfdir}/imapd/imapd.group";
my $oldcfg = $cfg . '.old';
my $oldmask = umask 077;
copy($cfg, $oldcfg);
chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $oldcfg);
umask $oldmask;
- copy("$prefix/etc/kolab/templates/imapd.group.template", $cfg);
+ copy("$ap::config->{sysconfdir}/kolab/templates/imapd.group.template", $cfg);
my $groupconf;
if (!($groupconf = IO::File->new($cfg, 'a'))) {
Kolab::log('T', "Unable to open configuration file `$cfg'", KOLAB_ERROR);
@@ -446,13 +447,13 @@ sub buildLDAPReplicas
Kolab::log('T', 'Building LDAP replicas', KOLAB_DEBUG);
my $prefix = $Kolab::config{'prefix'};
- my $cfg = "$prefix/etc/openldap/slapd.replicas";
+ my $cfg = "$ap::config->{sysconfdir}/openldap/slapd.replicas";
my $oldcfg = $cfg . '.old';
my $oldmask = umask 077;
copy($cfg, $oldcfg);
chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $oldcfg);
- copy("$prefix/etc/kolab/templates/slapd.replicas.template", $cfg);
+ copy("$ap::config->{sysconfdir}/kolab/templates/slapd.replicas.template", $cfg);
my $repl;
if (!($repl = IO::File->new($cfg, 'a'))) {
Kolab::log('T', "Unable to open configuration file `$cfg'", KOLAB_ERROR);
@@ -556,77 +557,79 @@ sub loadMetaTemplates
}
my $prefix = $Kolab::config{'prefix'};
-my $templatedir = "$prefix/etc/kolab/templates";
+my $templatedir = "$ap::config->{sysconfdir}/kolab/templates";
my %templates = (
- "$templatedir/rc.conf.template" => "$prefix/etc/rc.conf",
- "$templatedir/session_vars.php.template" => "$prefix/var/kolab/php/admin/include/session_vars.php",
- "$templatedir/clamd.conf.template" => "$prefix/etc/clamav/clamd.conf",
- "$templatedir/freshclam.conf.template" => "$prefix/etc/clamav/freshclam.conf",
- "$templatedir/amavisd.conf.template" => "$prefix/etc/amavisd/amavisd.conf",
- "$templatedir/main.cf.template" => "$prefix/etc/postfix/main.cf",
- "$templatedir/master.cf.template" => "$prefix/etc/postfix/master.cf",
- "$templatedir/saslauthd.conf.template" => "$prefix/etc/sasl/saslauthd.conf",
- "$templatedir/imapd.conf.template" => "$prefix/etc/imapd/imapd.conf",
- "$templatedir/httpd.conf.template" => "$prefix/etc/apache/apache.conf",
- "$templatedir/httpd.local.template" => "$prefix/etc/apache/apache.local",
- "$templatedir/php.ini.template" => "$prefix/etc/apache/php.ini",
- "$templatedir/proftpd.conf.template" => "$prefix/etc/proftpd/proftpd.conf",
- "$templatedir/ldap.conf.template" => "$prefix/etc/openldap/ldap.conf",
- "$templatedir/slapd.conf.template" => "$prefix/etc/openldap/slapd.conf",
+ "$templatedir/rc.conf.template" => "$ap::config->{sysconfdir}/rc.conf",
+ "$templatedir/session_vars.php.template" => "$ap::config->{webadmindir}/php/admin/include/session_vars.php",
+ "$templatedir/clamd.conf.template" => "$ap::config->{sysconfdir}/clamav/clamd.conf",
+ "$templatedir/freshclam.conf.template" => "$ap::config->{sysconfdir}/clamav/freshclam.conf",
+ "$templatedir/amavisd.conf.template" => "$ap::config->{sysconfdir}/amavisd/amavisd.conf",
+ "$templatedir/main.cf.template" => "$ap::config->{sysconfdir}/postfix/main.cf",
+ "$templatedir/master.cf.template" => "$ap::config->{sysconfdir}/postfix/master.cf",
+ "$templatedir/saslauthd.conf.template" => "$ap::config->{sysconfdir}/sasl/saslauthd.conf",
+ "$templatedir/imapd.conf.template" => "$ap::config->{sysconfdir}/imapd/imapd.conf",
+ "$templatedir/httpd.conf.template" => "$ap::config->{webserver_confdir}/apache.conf",
+ "$templatedir/httpd.local.template" => "$ap::config->{webserver_confdir}/apache.local",
+ "$templatedir/php.ini.template" => "$ap::config->{webserver_confdir}/php.ini",
+ "$templatedir/proftpd.conf.template" => "$ap::config->{ftpserver_confdir}/proftpd.conf",
+ "$templatedir/ldap.conf.template" => "$ap::config->{sysconfdir}/openldap/ldap.conf",
+ "$templatedir/slapd.conf.template" => "$ap::config->{sysconfdir}/openldap/slapd.conf",
"$templatedir/DB_CONFIG.slapd.template" => "$prefix/var/openldap/openldap-data/DB_CONFIG",
- "$templatedir/freebusy.conf.template" => "$prefix/etc/resmgr/freebusy.conf",
- "$templatedir/fbview.conf.template" => "$prefix/etc/resmgr/fbview.conf",
- "$templatedir/resmgr.conf.template" => "$prefix/etc/resmgr/resmgr.conf"
+ "$templatedir/freebusy.conf.template" => "$ap::config->{sysconfdir}/resmgr/freebusy.conf",
+ "$templatedir/fbview.conf.template" => "$ap::config->{sysconfdir}/resmgr/fbview.conf",
+ "$templatedir/resmgr.conf.template" => "$ap::config->{sysconfdir}/resmgr/resmgr.conf"
);
my %permissions = (
- "$prefix/etc/rc.conf" => 0644,
- "$prefix/var/kolab/php/admin/include/session_vars.php" => 0640,
- "$prefix/etc/resmgr/freebusy.conf" => 0640,
- "$prefix/etc/resmgr/fbview.conf" => 0640,
- "$prefix/etc/resmgr/resmgr.conf" => 0640,
- "$prefix/etc/postfix/main.cf" => 0640,
- "$prefix/etc/postfix/master.cf" => 0640,
- "$prefix/etc/clamav/clamd.conf" => 0640,
- "$prefix/etc/clamav/freshclam.conf" => 0640,
- "$prefix/etc/amavisd/amavisd.conf" => 0640,
- "$prefix/etc/sasl/saslauthd.conf" => 0600,
- "$prefix/etc/imapd/imapd.conf" => 0640,
- "$prefix/etc/apache/apache.conf" => 0640,
- "$prefix/etc/apache/apache.local" => 0640,
- "$prefix/etc/apache/php.ini" => 0640,
- "$prefix/etc/proftpd/proftpd.conf" => 0640,
- "$prefix/etc/openldap/slapd.conf" => 0640,
+ "$ap::config->{sysconfdir}/rc.conf" => 0644,
+ "$ap::config->{webadmindir}/php/admin/include/session_vars.php" => 0640,
+ "$ap::config->{sysconfdir}/resmgr/freebusy.conf" => 0640,
+ "$ap::config->{sysconfdir}/resmgr/fbview.conf" => 0640,
+ "$ap::config->{sysconfdir}/resmgr/resmgr.conf" => 0640,
+ "$ap::config->{sysconfdir}/postfix/main.cf" => 0640,
+ "$ap::config->{sysconfdir}/postfix/master.cf" => 0640,
+ "$ap::config->{sysconfdir}/clamav/clamd.conf" => 0640,
+ "$ap::config->{sysconfdir}/clamav/freshclam.conf" => 0640,
+ "$ap::config->{sysconfdir}/amavisd/amavisd.conf" => 0640,
+ "$ap::config->{sysconfdir}/sasl/saslauthd.conf" => 0600,
+ "$ap::config->{sysconfdir}/imapd/imapd.conf" => 0640,
+ "$ap::config->{webserver_confdir}/apache.conf" => 0640,
+ "$ap::config->{webserver_confdir}/apache.local" => 0640,
+ "$ap::config->{webserver_confdir}/php.ini" => 0640,
+ "$ap::config->{ftpserver_confdir}/proftpd.conf" => 0640,
+ "$ap::config->{sysconfdir}/openldap/slapd.conf" => 0640,
"$prefix/var/openldap/openldap-data/DB_CONFIG" => 0640,
- "$prefix/etc/openldap/ldap.conf" => 0644,
- "$prefix/etc/postfix/transport" => 0640,
- "$prefix/etc/imapd/cyrus.conf" => 0640,
- "$prefix/etc/imapd/imapd.group" => 0640);
+ "$ap::config->{sysconfdir}/openldap/ldap.conf" => 0644,
+ "$ap::config->{sysconfdir}/postfix/transport" => 0640,
+ "$ap::config->{sysconfdir}/postfix/virtual" => 0640,
+ "$ap::config->{sysconfdir}/imapd/cyrus.conf" => 0640,
+ "$ap::config->{sysconfdir}/imapd/imapd.group" => 0640);
my %ownership = (
- "$prefix/etc/rc.conf" => "kolab:kolab",
- "$prefix/var/kolab/php/admin/include/session_vars.php" => "kolab:kolab-n",
- "$prefix/etc/resmgr/freebusy.conf" => "kolab:kolab-n",
- "$prefix/etc/resmgr/fbview.conf" => "kolab:kolab-n",
- "$prefix/etc/resmgr/resmgr.conf" => "kolab:kolab-n",
- "$prefix/etc/postfix/main.cf" => "kolab:kolab-r",
- "$prefix/etc/postfix/master.cf" => "kolab:kolab-r",
- "$prefix/etc/clamav/clamd.conf" => "kolab:kolab-r",
- "$prefix/etc/clamav/freshclam.conf" => "kolab:kolab-r",
- "$prefix/etc/amavisd/amavisd.conf" => "kolab:kolab-r",
- "$prefix/etc/sasl/saslauthd.conf" => "kolab:kolab",
- "$prefix/etc/imapd/imapd.conf" => "kolab:kolab-r",
- "$prefix/etc/apache/apache.conf" => "kolab:kolab-n",
- "$prefix/etc/apache/apache.local" => "kolab:kolab-n",
- "$prefix/etc/apache/php.ini" => "kolab:kolab-n",
- "$prefix/etc/proftpd/proftpd.conf" => "kolab:kolab-n",
- "$prefix/etc/openldap/ldap.conf" => "kolab:kolab",
- "$prefix/etc/openldap/slapd.conf" => "kolab:kolab",
- "$prefix/var/openldap/openldap-data/DB_CONFIG" => "kolab:kolab",
- "$prefix/etc/postfix/transport" => "root:kolab",
- "$prefix/etc/imapd/cyrus.conf" => "kolab:kolab",
- "$prefix/etc/imapd/imapd.group" => "kolab:kolab-r");
+ "$ap::config->{sysconfdir}/rc.conf" => "kolab:kolab",
+ "$ap::config->{webadmindir}/php/admin/include/session_vars.php" => "kolab:kolab-n",
+ "$ap::config->{sysconfdir}/resmgr/freebusy.conf" => "kolab:kolab-n",
+ "$ap::config->{sysconfdir}/resmgr/fbview.conf" => "kolab:kolab-n",
+ "$ap::config->{sysconfdir}/resmgr/resmgr.conf" => "kolab:kolab-n",
+ "$ap::config->{sysconfdir}/postfix/main.cf" => "kolab:kolab-r",
+ "$ap::config->{sysconfdir}/postfix/master.cf" => "kolab:kolab-r",
+ "$ap::config->{sysconfdir}/clamav/clamd.conf" => "kolab:kolab-r",
+ "$ap::config->{sysconfdir}/clamav/freshclam.conf" => "kolab:kolab-r",
+ "$ap::config->{sysconfdir}/amavisd/amavisd.conf" => "kolab:kolab-r",
+ "$ap::config->{sysconfdir}/sasl/saslauthd.conf" => "kolab:kolab",
+ "$ap::config->{sysconfdir}/imapd/imapd.conf" => "kolab:kolab-r",
+ "$ap::config->{webserver_confdir}/apache.conf" => "kolab:kolab-n",
+ "$ap::config->{webserver_confdir}/apache.local" => "kolab:kolab-n",
+ "$ap::config->{webserver_confdir}/php.ini" => "kolab:kolab-n",
+ "$ap::config->{ftpserver_confdir}/proftpd.conf" => "kolab:kolab-n",
+ "$ap::config->{sysconfdir}/openldap/ldap.conf" => "kolab:kolab",
+ "$ap::config->{sysconfdir}/openldap/slapd.conf" => "kolab:kolab",
+ "$prefix/var/openldap/openldap-data/DB_CONFIG" => "kolab:kolab",
+ "$ap::config->{sysconfdir}/postfix/transport" => "root:kolab",
+ "$ap::config->{sysconfdir}/postfix/virtual" => "root:kolab",
+ "$ap::config->{sysconfdir}/imapd/cyrus.conf" => "kolab:kolab",
+ "$ap::config->{sysconfdir}/imapd/imapd.group" => "kolab:kolab-r");
sub rebuildTemplates
@@ -696,7 +699,7 @@ Kolab::Conf - Perl extension for Kolab template generation
=head1 AUTHOR
-Stuart Bing묠E<lt>s.binge@codefusion.co.zaE<gt>
+Stuart Bingë <lt>s.binge@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab-Conf/Makefile.am b/Kolab-Conf/Makefile.am
new file mode 100644
index 0000000..215596b
--- /dev/null
+++ b/Kolab-Conf/Makefile.am
@@ -0,0 +1 @@
+include_HEADERS = Conf.pm
diff --git a/Kolab-Cyrus/Cyrus.pm b/Kolab-Cyrus/Cyrus.pm
index 275d9f3..2f024a0 100644
--- a/Kolab-Cyrus/Cyrus.pm
+++ b/Kolab-Cyrus/Cyrus.pm
@@ -3,7 +3,7 @@ package Kolab::Cyrus;
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bing <s.binge@codefusion.co.za>
+## Writen by Stuart Bing� <s.binge@codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
@@ -199,7 +199,7 @@ admin module.
=head1 AUTHOR
-Stuart Bing, E<lt>s.binge@codefusion.co.zaE<gt>
+Stuart Bing� E<lt>s.binge@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab-Cyrus/Makefile.am b/Kolab-Cyrus/Makefile.am
new file mode 100644
index 0000000..b4cec24
--- /dev/null
+++ b/Kolab-Cyrus/Makefile.am
@@ -0,0 +1 @@
+include_HEADERS = Cyrus.pm
diff --git a/Kolab-DirServ/DirServ.pm b/Kolab-DirServ/DirServ.pm
index ce5037a..9675cf7 100644
--- a/Kolab-DirServ/DirServ.pm
+++ b/Kolab-DirServ/DirServ.pm
@@ -38,6 +38,7 @@ use POSIX qw(tmpnam);
use vars qw(@peers);
require Exporter;
+require "config.h";
our @ISA = qw(Exporter);
@@ -62,7 +63,7 @@ our $VERSION = '0.9';
sub reloadPeers
{
- @peers = readList($Kolab::config{'prefix'} . "/etc/kolab/addressbook.peers");
+ @peers = readList($Kolab::config{"$ap::config->{prefix}"} . "$ap::config->{sysconfdir}/kolab/addressbook.peers");
foreach my $peer (@peers) {
Kolab::log('DS', "Using peer $peer", KOLAB_DEBUG);
diff --git a/Kolab-DirServ/Makefile.am b/Kolab-DirServ/Makefile.am
new file mode 100644
index 0000000..2643507
--- /dev/null
+++ b/Kolab-DirServ/Makefile.am
@@ -0,0 +1 @@
+include_HEADERS = DirServ.pm
diff --git a/Kolab-LDAP-Backend-ad/Makefile.am b/Kolab-LDAP-Backend-ad/Makefile.am
new file mode 100644
index 0000000..1626067
--- /dev/null
+++ b/Kolab-LDAP-Backend-ad/Makefile.am
@@ -0,0 +1 @@
+include_HEADERS = ad.pm
diff --git a/Kolab-LDAP-Backend-ad/ad.pm b/Kolab-LDAP-Backend-ad/ad.pm
index 0c97fd8..cebc752 100644
--- a/Kolab-LDAP-Backend-ad/ad.pm
+++ b/Kolab-LDAP-Backend-ad/ad.pm
@@ -3,7 +3,7 @@ package Kolab::LDAP::Backend::ad;
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bing <s.binge@codefusion.co.za>
+## Writen by Stuart Bing� <s.binge@codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
@@ -225,7 +225,7 @@ Kolab::LDAP::Backend::ad - Perl extension for an Active Directory backend
=head1 AUTHOR
-Stuart Bing, E<lt>s.binge@codefusion.co.zaE<gt>
+Stuart Bing� E<lt>s.binge@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab-LDAP-Backend-dirservd/Makefile.am b/Kolab-LDAP-Backend-dirservd/Makefile.am
new file mode 100644
index 0000000..96c9804
--- /dev/null
+++ b/Kolab-LDAP-Backend-dirservd/Makefile.am
@@ -0,0 +1 @@
+include_HEADERS = dirservd.pm
diff --git a/Kolab-LDAP-Backend-dirservd/dirservd.pm b/Kolab-LDAP-Backend-dirservd/dirservd.pm
index 9585ad1..85640b6 100644
--- a/Kolab-LDAP-Backend-dirservd/dirservd.pm
+++ b/Kolab-LDAP-Backend-dirservd/dirservd.pm
@@ -3,7 +3,7 @@ package Kolab::LDAP::Backend::dirservd;
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bing <s.binge@codefusion.co.za>
+## Writen by Stuart Bing� <s.binge@codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
@@ -111,7 +111,7 @@ Services updater.
=head1 AUTHOR
-Stuart Bing, E<lt>s.buys@codefusion.co.zaE<gt>
+Stuart Bing� E<lt>s.buys@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab-LDAP-Backend-slurpd/Makefile.am b/Kolab-LDAP-Backend-slurpd/Makefile.am
new file mode 100644
index 0000000..d2383fa
--- /dev/null
+++ b/Kolab-LDAP-Backend-slurpd/Makefile.am
@@ -0,0 +1 @@
+include_HEADERS = slurpd.pm
diff --git a/Kolab-LDAP-Backend-slurpd/slurpd.pm b/Kolab-LDAP-Backend-slurpd/slurpd.pm
index e625d71..75acb21 100644
--- a/Kolab-LDAP-Backend-slurpd/slurpd.pm
+++ b/Kolab-LDAP-Backend-slurpd/slurpd.pm
@@ -40,6 +40,7 @@ use Kolab::LDAP;
use vars qw($conn $server);
require Exporter;
+require "config.h";
our @ISA = qw(Exporter);
@@ -277,7 +278,7 @@ sub run
$changes = 0;
Kolab::log('SD', 'Change detected w/ no pending LDAP messages; reloading services if needed');
Kolab::LDAP::sync;
- system($Kolab::config{'prefix'} . '/sbin/kolabconf');
+ system($Kolab::config{'prefix'} . $ap::config->{sbindir}/kolabconf);
}
Kolab::log('SD', 'Waiting for LDAP updates');
diff --git a/Kolab-LDAP-Backend/Makefile.am b/Kolab-LDAP-Backend/Makefile.am
new file mode 100644
index 0000000..bfbd3dc
--- /dev/null
+++ b/Kolab-LDAP-Backend/Makefile.am
@@ -0,0 +1 @@
+include_HEADERS = Backend.pm
diff --git a/Kolab-LDAP/LDAP.pm b/Kolab-LDAP/LDAP.pm
index e71dd7b..632738a 100644
--- a/Kolab-LDAP/LDAP.pm
+++ b/Kolab-LDAP/LDAP.pm
@@ -35,6 +35,7 @@ use Kolab::DirServ;
use vars qw(%uid_db %gyard_db %newuid_db %gyard_ts_db);
require Exporter;
+require "config.h";
our @ISA = qw(Exporter);
@@ -67,19 +68,19 @@ sub startup
Kolab::log('L', 'Opening mailbox uid cache DB');
- if (!dbmopen(%uid_db, $Kolab::config{'prefix'} . '/var/kolab/mailbox-uidcache.db', 0666)) {
+ if (!dbmopen(%uid_db, $Kolab::config{'prefix'} . $ap::config->{localstatedir}/kolab/mailbox-uidcache.db, 0666)) {
Kolab::log('L', 'Unable to open mailbox uid cache DB', KOLAB_ERROR);
exit(1);
}
Kolab::log('L', 'Opening graveyard uid/timestamp cache DB');
- if (!dbmopen(%gyard_db, $Kolab::config{'prefix'} . '/var/kolab/graveyard-uidcache.db', 0666)) {
+ if (!dbmopen(%gyard_db, $Kolab::config{'prefix'} . $ap::config->{localstatedir}/kolab/graveyard-uidcache.db, 0666)) {
Kolab::log('L', 'Unable to open graveyard uid cache DB', KOLAB_ERROR);
exit(1);
}
- if (!dbmopen(%gyard_ts_db, $Kolab::config{'prefix'} . '/var/kolab/graveyard-tscache.db', 0666)) {
+ if (!dbmopen(%gyard_ts_db, $Kolab::config{'prefix'} . $ap::config->{localstatedir}/kolab/graveyard-tscache.db, 0666)) {
Kolab::log('L', 'Unable to open graveyard timestamp cache DB', KOLAB_ERROR);
exit(1);
}
diff --git a/Kolab-LDAP/Makefile.am b/Kolab-LDAP/Makefile.am
new file mode 100644
index 0000000..c06bf6b
--- /dev/null
+++ b/Kolab-LDAP/Makefile.am
@@ -0,0 +1 @@
+include_HEADERS = LDAP.pm
diff --git a/Kolab-Mailer/Mailer.pm b/Kolab-Mailer/Mailer.pm
index 25554f0..04ba2fb 100644
--- a/Kolab-Mailer/Mailer.pm
+++ b/Kolab-Mailer/Mailer.pm
@@ -3,7 +3,7 @@ package Kolab::Mailer;
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bing <s.binge@codefusion.co.za>
+## Writen by Stuart Bing� <s.binge@codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
@@ -27,6 +27,7 @@ use MIME::Entity;
use MIME::Body;
require Exporter;
+require "config.h";
our @ISA = qw(Exporter);
@@ -67,7 +68,7 @@ sub sendMultipart
$mesg->attach(Data => $data);
}
- open(SENDMAIL, '|' . $Kolab::config{'prefix'} . '/sbin/sendmail -oi -t -odq');
+ open(SENDMAIL, '|' . $Kolab::config{'prefix'} . $ap::config->{sbindir}/sendmail -oi -t -odq);
$mesg->print(\*SENDMAIL);
close(SENDMAIL);
}
@@ -86,7 +87,7 @@ sub sendText
Data => $text,
);
- open(SENDMAIL, '|' . $Kolab::config{'prefix'} . '/sbin/sendmail -oi -t -odq');
+ open(SENDMAIL, '|' . $Kolab::config{'prefix'} . $ap::config->{sbindir}/sendmail -oi -t -odq);
$mesg->print(\*SENDMAIL);
close(SENDMAIL);
}
@@ -106,7 +107,7 @@ Kolab::Mailer - Perl extension for sending out email
=head1 AUTHOR
-Stuart Bing, E<lt>s.binge@codefusion.co.zaE<gt>
+Stuart Bing� E<lt>s.binge@codefusion.co.zaE<gt>
=head1 COPYRIGHT AND LICENSE
diff --git a/Kolab-Mailer/Makefile.am b/Kolab-Mailer/Makefile.am
new file mode 100644
index 0000000..96be348
--- /dev/null
+++ b/Kolab-Mailer/Makefile.am
@@ -0,0 +1 @@
+include_HEADERS = Mailer.pm
diff --git a/Kolab-Util/Makefile.am b/Kolab-Util/Makefile.am
new file mode 100644
index 0000000..6205657
--- /dev/null
+++ b/Kolab-Util/Makefile.am
@@ -0,0 +1 @@
+include_HEADERS = Util.pm
diff --git a/Kolab/Kolab.pm b/Kolab/Kolab.pm
index b291ac3..c4ca912 100644
--- a/Kolab/Kolab.pm
+++ b/Kolab/Kolab.pm
@@ -3,7 +3,7 @@ package Kolab;
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Bing?<s.binge@codefusion.co.za>
+## Writen by Stuart Bingë <s.binge@codefusion.co.za>
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
@@ -30,6 +30,7 @@ use Kolab::Util;
use vars qw(%config %haschanged $reloadOk);
require Exporter;
+require "config.h"
our @ISA = qw(Exporter);
@@ -82,12 +83,12 @@ sub reloadConfig
&log('C', 'Unable to determine the kolab root directory', KOLAB_ERROR);
$error = 1;
} else {
- %config = readConfig(%config, "$tempval/etc/kolab/kolab.globals");
+ %config = readConfig(%config, "$tempval$ap::config->{sysconfdir}/kolab/kolab.globals");
$config{'prefix'} = $tempval;
}
# Now read `kolab.conf', overwriting values read from `kolab.globals'
- %config = readConfig(\%config, "$tempval/etc/kolab/kolab.conf");
+ %config = readConfig(\%config, "$tempval$ap::config->{sysconfdir}/kolab/kolab.conf");
# $config{'log_level'} = KOLAB_WARN if (!exists $config{'log_level'});
&log('C', 'Reloading configuration');
@@ -126,7 +127,7 @@ sub reloadConfig
# Make a hash of the bind password available too
if( !exists $config{'bind_pw_hash'} ) {
- my $hashcmd = $config{'prefix'}."/sbin/slappasswd -s '".$config{'bind_pw'}."'";
+ my $hashcmd = $config{'prefix'}."$ap::config->{sbindir}/slappasswd -s '".$config{'bind_pw'}."'";
$config{'bind_pw_hash'} = `$hashcmd`;
chomp($config{'bind_pw_hash'});
}
@@ -350,49 +351,49 @@ sub reload
if ($haschanged{'slapd'}) {
&log('K', 'Restarting OpenLDAP...');
- system("$prefix/bin/openpkg rc openldap restart &");
+ system("$ap::config->{sbindir}/slurpd restart &");
}
if ($haschanged{'saslauthd'}) {
&log('K', 'Restarting SASLAuthd...');
- system("$prefix/bin/openpkg rc sasl stop; sleep 1; $prefix/sbin/saslauthd -a ldap -n 5");
+ system("$ap::config->{sbindir}/rcsaslauthd stop; sleep 1; $ap::config->{sbindir}/rcsaslauthd -a ldap -n 5");
}
if ($haschanged{'apache'}) {
&log('K', 'Reloading Apache...');
- system("$prefix/sbin/apachectl graceful");
+ system("$ap::config->{sbindir}/apache2ctl graceful");
}
if ($haschanged{'postfix'}) {
&log('K', 'Reloading Postfix...');
- system("$prefix/sbin/postfix reload");
+ system("$ap::config->{sbindir}/rcpostfix reload");
}
if ($haschanged{'imapd'}) {
&log('K', 'Restarting imapd...');
- system("$prefix/bin/openpkg rc imapd restart");
+ system("$ap::config->{sbindir}/rccyrus restart");
}
if ($haschanged{'amavisd'}) {
&log('K', 'Restarting amavisd...');
- system("$prefix/bin/openpkg rc amavisd restart");
+ system("$ap::config->{sbindir}/rcamavisd restart");
}
if ($haschanged{'clamav'}) {
&log('K', 'Restarting clamav...');
- system("$prefix/bin/openpkg rc clamav restart");
+ system("$ap::config->{sbindir}/clamd restart");
}
if ($config{'proftpd-ftp'} =~ /true/i) {
Kolab::log('K', 'Starting ProFTPd if not running');
- system("$prefix/bin/openpkg rc proftpd start");
+ system("$ap::config->{bindir}/openpkg rc proftpd start");
if ($haschanged{'proftpd'}) {
&log('K', 'Reloading ProFTPd...');
- kill('SIGHUP', `cat $prefix/var/proftpd/proftpd.pid`);
+ kill('SIGHUP', `cat $ap::config->{localstatedir}/proftpd/proftpd.pid`);
}
} else {
&log('K', 'Stopping ProFTPd, if running...');
- system("$prefix/bin/openpkg rc proftpd stop");
+ system("$ap::config->{bindir}/openpkg rc proftpd stop");
}
%Kolab::Conf::haschanged = ();
diff --git a/Kolab/Makefile.am b/Kolab/Makefile.am
new file mode 100644
index 0000000..f4cc4b7
--- /dev/null
+++ b/Kolab/Makefile.am
@@ -0,0 +1 @@
+include_HEADERS = Kolab.pm
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 6310a8d..0000000
--- a/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-RPM = /kolab/bin/openpkg rpm
-VERSION = 0.9.2
-
-ifeq "x$(KOLABRPMSRC)" "x"
- KOLABRPMSRC = /kolab/RPM/SRC
-endif
-
-SRCDIR=$(KOLABRPMSRC)/perl-kolab
-
-all:
- test -d $(SRCDIR) || mkdir $(SRCDIR)
- tar cvzf $(SRCDIR)/Kolab-$(VERSION).tar.gz Kolab
- tar cvzf $(SRCDIR)/Kolab-Util-$(VERSION).tar.gz Kolab-Util
- tar cvzf $(SRCDIR)/Kolab-Conf-$(VERSION).tar.gz Kolab-Conf
- tar cvzf $(SRCDIR)/Kolab-Cyrus-$(VERSION).tar.gz Kolab-Cyrus
- tar cvzf $(SRCDIR)/Kolab-DirServ-$(VERSION).tar.gz Kolab-DirServ
- tar cvzf $(SRCDIR)/Kolab-LDAP-$(VERSION).tar.gz Kolab-LDAP
- tar cvzf $(SRCDIR)/Kolab-LDAP-Backend-$(VERSION).tar.gz Kolab-LDAP-Backend
- tar cvzf $(SRCDIR)/Kolab-LDAP-Backend-ad-$(VERSION).tar.gz Kolab-LDAP-Backend-ad
- tar cvzf $(SRCDIR)/Kolab-LDAP-Backend-dirservd-$(VERSION).tar.gz Kolab-LDAP-Backend-dirservd
- tar cvzf $(SRCDIR)/Kolab-LDAP-Backend-slurpd-$(VERSION).tar.gz Kolab-LDAP-Backend-slurpd
- tar cvzf $(SRCDIR)/Kolab-Mailer-$(VERSION).tar.gz Kolab-Mailer
- cp perl-kolab.spec $(SRCDIR)
- cd $(SRCDIR) && $(RPM) -ba perl-kolab.spec
-binary:
- $(RPM) -bB perl-kolab.spec
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..cf7bd60
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,31 @@
+PROGRAM = perl-kolab
+VERSION = 0.9.2
+
+SUBDIRS = \
+ Kolab \
+ Kolab-Conf \
+ Kolab-Cyrus \
+ Kolab-DirServ \
+ Kolab-LDAP \
+ Kolab-LDAP-Backend \
+ Kolab-LDAP-Backend-ad \
+ Kolab-LDAP-Backend-dirservd \
+ Kolab-LDAP-Backend-slurpd \
+ Kolab-Mailer \
+ Kolab-Util
+
+
+EXTRA_DIST = perl-kolab.spec.in dist_conf/kolab
+
+AC_CONFIG_FILES = perl-kolab.spec
+
+# own Variables and default values:
+
+localstatedir_ARG = ${prefix}/var
+localstatedir_ARG_HELP = localstatedir default:
+
+# for including the ../dist_conf/kolab file
+
+{
+ `cat ./dist_conf/kolab`
+}
diff --git a/Makefile.cvs b/Makefile.cvs
new file mode 100644
index 0000000..5b01041
--- /dev/null
+++ b/Makefile.cvs
@@ -0,0 +1,24 @@
+RPM = /kolab/bin/openpkg rpm
+RPMNAME=perl-kolab
+
+
+PATH:=/kolab/bin:$(PATH)
+
+ifeq "x$(KOLABRPMSRC)" "x"
+ KOLABRPMSRC = /kolab/RPM/SRC
+endif
+
+VERSION:=`grep 'VERSION' $(PWD)/Makefile.am|sed 's/VERSION *= *\(.*\)/\1/'`
+
+all:
+ test -d $(KOLABRPMSRC)/$(RPMNAME) || mkdir $(KOLABRPMSRC)/$(RPMNAME)
+ ./configure --prefix=/kolab \
+ && make dist && mv $(RPMNAME)-$(VERSION).tar.gz $(KOLABRPMSRC)/$(RPMNAME)
+ cp $(RPMNAME).spec $(KOLABRPMSRC)/$(RPMNAME)/
+ cd $(KOLABRPMSRC)/$(RPMNAME) && $(RPM) -ba $(RPMNAME).spec --define 'kolab_version CVS'
+binary:
+ $(RPM) -bB $(RPMNAME).spec
+
+release:
+ tar cvzf $(RPMNAME)-$(VERSION).tar.gz $(RPMNAME)
+ $(RPM) -ba $(RPMNAME).spec
diff --git a/configure b/configure
new file mode 100755
index 0000000..8c79fd4
--- /dev/null
+++ b/configure
@@ -0,0 +1,3032 @@
+#!/usr/bin/env perl
+
+# -*-CPerl-*-
+#
+# Autoperl - a portable build system for Perl applications
+#
+# Copyright 2003-2004 by Mark Heily <devel@heily.com>
+#
+# This library is free software; you can redistribute it and/or modify it
+# under the same terms as Perl itself.
+
+#
+# logger.pm
+#
+# An object that can process logging, trace, and debugging output
+#
+package Autoperl::Logger;
+
+use constant LOG_DEBUG => 0;
+use constant LOG_INFO => 1;
+use constant LOG_WARNING => 2;
+use constant LOG_NOTICE => 3;
+use constant LOG_CRITICAL => 4;
+
+BEGIN {
+our @ISA = 'Exporter';
+our @EXPORT = qw(debug info warning notice critical LOG_INFO LOG_WARNING LOG_NOTICE LOG_DEBUG LOG_CRITICAL);
+}
+
+our $open = 0;
+our $LOG_LEVEL = LOG_WARNING;
+1;
+
+#######################################################################
+
+
+sub new
+{
+my $class = shift;
+my $logfile = shift || 'config.log';
+
+
+my $self = +{
+ logfile => $logfile,
+ fh => undef,
+ };
+bless $self, $class;
+$self->open($logfile);
+return $self;
+}
+
+sub open($$)
+{
+ my ($self,$fn) = @_;
+
+ die 'cannot re-open logfile' if $open;
+ $open = 1;
+
+ open (FH, ">" . $fn) or die "$fn: $!";
+ print FH "Logfile opened at " . scalar localtime() . "\n";
+
+}
+
+
+sub set_log_level
+{
+ my $lvl = shift;
+ print FH "Setting log level to '$lvl'\n";
+ if ($lvl eq 'debug') { $LOG_LEVEL = LOG_DEBUG }
+ elsif ($lvl eq 'info') { $LOG_LEVEL = LOG_INFO }
+ elsif ($lvl eq 'warning') { $LOG_LEVEL = LOG_WARNING }
+ elsif ($lvl eq 'notice') { $LOG_LEVEL = LOG_NOTICE }
+ else { die "invalid log level: $lvl" }
+}
+
+sub AUTOLOAD
+{
+ my $sub = our $AUTOLOAD;
+ my $msg = join("\n",@_);
+ $msg .= "\n" unless $msg =~ /\n$/;
+ if ( $sub =~ /^Autoperl::Logger::(debug|info|warning|notice|critical)$/ ) {
+ my $lvl = $1;
+ if ($lvl eq 'debug') { $lvl = LOG_DEBUG }
+ elsif ($lvl eq 'info') { $lvl = LOG_INFO }
+ elsif ($lvl eq 'warning') { $lvl = LOG_WARNING }
+ elsif ($lvl eq 'notice') { $lvl = LOG_NOTICE }
+ elsif ($lvl eq 'critical') { $lvl = LOG_CRITICAL }
+ else { die "invalid logger method" }
+ if ( $lvl >= $LOG_LEVEL ) {
+ print FH $msg;
+ print STDERR $msg;
+ }
+ } else {
+ die "Autoloaded method not found: \&$sub";
+ }
+}
+
+sub DESTROY
+{
+ print FH "Logfile closed at " . scalar localtime() . "\n";
+ close(FH);
+}
+
+1;
+#!/usr/bin/perl -I/usr/local/lib/autoperl
+
+# -*-CPerl-*-
+#
+# Autoperl - a portable build system for Perl applications
+#
+# Copyright 2003-2004 by Mark Heily <devel@heily.com>
+#
+# This library is free software; you can redistribute it and/or modify it
+# under the same terms as Perl itself.
+
+use English;
+use Data::Dumper;
+use File::Copy;
+use strict;
+use warnings;
+
+use subs qw( vprint );
+
+# Generated by autoperl
+unless (defined $ap::CONFIG_H) {
+
+$ap::CONFIG_H = 1;
+%ap::config = (
+ 'docdir' => '/usr/local/share/doc/autoperl',
+ 'mandir' => '/usr/local/man',
+ 'pkgdatadir' => '/usr/local/share/autoperl',
+ 'PERL' => '/usr/bin/perl',
+ 'author' => 'Mark Heily <devel@heily.com>',
+ 'program' => 'autoperl',
+ 'infodir' => '/usr/local/info',
+ 'TEST_MULTILINE_DEFINITION' => 'one two three',
+ 'sysconfdir' => '/etc',
+ 'htmldir' => 'var/www',
+ 'bindir' => '/usr/local/bin',
+ 'confdir' => '/etc/autoperl',
+ 'libexecdir' => '/usr/local/libexec',
+ 'localedir' => '/usr/local/locale',
+ 'version' => '1.10',
+ 'cgidir' => 'usr/lib/cgi-bin',
+ 'includedir' => '/usr/local/lib/site_perl',
+ 'statedir' => '/var/lib/autoperl',
+ 'datadir' => '/usr/local/share',
+ 'sbindir' => '/usr/local/sbin',
+ 'libdir' => '/usr/local/lib/autoperl',
+ 'srcdir' => undef,
+ 'prefix' => '/usr/local'
+ );
+
+
+# Inconvenience hashref
+$ap::config = \%ap::config;
+}
+
+
+BEGIN { import Autoperl; }
+BEGIN { import Autoperl::Parser; }
+BEGIN { import Autoperl::Generator; }
+BEGIN { import Autoperl::Installer; }
+BEGIN { import Autoperl::Linker; }
+BEGIN { import Autoperl::Logger; }
+BEGIN { import Autoperl::Packager; }
+
+
+# Parse ARGV
+my $original_action = shift @ARGV;
+my $action = $original_action;
+$action = '' unless defined $action;
+$action =~ s/^--//;
+
+if ($action eq 'autoperl') {
+ $action = shift @ARGV;
+ $action = '' unless defined $action;
+ if ($action eq 'init') {
+ Autoperl::Generator::generate_configure_in();
+ } elsif ($action eq 'link') {
+ my $ld = Autoperl::Linker::new(join(' ',@ARGV));
+ $ld->run_linker();
+ } elsif ($action eq 'package') {
+ Autoperl::Packager::make_package();
+ } elsif ($action eq 'install') {
+ Autoperl::Installer::main();
+ } else {
+ die 'unsupported autoperl action';
+ }
+
+# The default action is to run as ./configure
+} else {
+ # Initialize globals
+ our $log = new Autoperl::Logger;
+ our $ap = new Autoperl();
+
+ # Parse Makefile.am
+ $ap->{mk}->parse_all();
+
+ # Parse command line options
+ unshift @ARGV, $original_action if defined $original_action;
+ $ap->get_options();
+
+ # FIXME-WORKAROUND for $ap->{program}
+ # this is ugly
+ $ap->{program} = $ap->{mk}->{program};
+ $ap->{author} = $ap->{mk}->{author};
+ $ap->{version} = $ap->{mk}->{version};
+ $ap->configure();
+ $log->info(Dumper($ap->{mk}));
+}
+# -*-CPerl-*-
+#
+# Autoperl - a portable build system for Perl applications
+#
+# Copyright 2003-2004 by Mark Heily <devel@heily.com>
+#
+# This library is free software; you can redistribute it and/or modify it
+# under the same terms as Perl itself.
+#
+
+package Autoperl;
+
+use strict;
+use warnings;
+use Carp;
+use POSIX;
+use Data::Dumper;
+use English;
+use Sys::Hostname;
+use Cwd 'abs_path'; # aka realpath()
+use File::Copy;
+
+BEGIN { import Autoperl::Logger; }
+
+# GLOBAL VARIABLE
+our $AP; # FIXME-hackish reference to current $ap variable
+
+
+#################################################################
+#
+# System Tests
+#
+#################################################################
+
+
+#
+# check_host()
+#
+# Determine the host operating system and architecture
+#
+sub check_host($)
+ {
+ my $self = shift;
+
+ return if $self->{sys}->{uname};
+ print "Determining operating system type... ";
+ my $uname_bin = '/bin/uname';
+ $uname_bin = '/usr/bin/uname' unless ( -e $uname_bin );
+ die unless ( -e $uname_bin );
+
+ chomp ( my $uname = `$uname_bin` );
+ chomp ( my $arch = `$uname_bin -m` );
+
+ my $host = "$arch-$uname";
+
+ $self->{sys}->{hostname} = hostname;
+ $self->{sys}->{hostname} =~ s/\..*//;
+
+ $self->{sys}->{uname} = $uname;
+ chomp ( $self->{sys}->{release} = `$uname_bin -r` );
+ $self->{sys}->{arch} = $arch;
+ $self->{sys}->{host} = $host;
+
+ #fixme - not GNU compatible
+ my $hoststr = "$arch-$uname-" . $self->{sys}->{release};
+ $hoststr =~ tr/[A-Z]/[a-z]/;
+ print "$hoststr\n";
+ return $host;
+ }
+
+
+#
+# check_bin()
+#
+# Check for the availability of an executable by searching the $PATH
+#
+sub check_bin
+ {
+ my $ap = shift;
+
+# Macro: AC_CHECK_PROG (VARIABLE, PROG-TO-CHECK-FOR, VALUE-IF-FOUND,
+# [VALUE-IF-NOT-FOUND], [PATH], [REJECT])
+
+ my ($var,$bin,$if_found) = @_;
+
+ local $ENV{PATH} .= ":/sbin:/usr/sbin:/usr/local/sbin";
+
+ $bin =~ s/[^A-Za-z0-9.\-]//g;
+ print "checking for $bin.. ";
+ chomp ( my $result = `/usr/bin/which $bin` ) ;
+ print $result ? "yes" : "no", "\n";
+ $ap->{mk}->{custom_arg}->{$var} = $result ? 1 : 0;
+
+ }
+
+
+#
+# check_lib() - Determine the availability of a Perl library
+#
+sub check_lib($$$)
+ {
+ my ($self,$lib,$flags) = @_;
+ my $result = 0;
+ my $silent = 1;
+ my ($answer, $pathname);
+
+ # Return a cached result
+ return $self->{_depends}->{$lib}
+ if defined $self->{_depends}->{$lib};
+
+ # Get the path name (Foo::Bar becomes Foo/Bar.pm)
+ $pathname = $lib;
+ $pathname =~ s/::/\//g;
+ $pathname .= '.pm';
+
+ # Only print messages for non-pragmas
+ if ( $lib =~ /^[A-Z]/ ) { $silent = 0; }
+
+ if ( not $silent ) {
+ print "checking for $lib" . ($flags->{version} ? " ".$flags->{version} : "" ) . ".. ";
+ }
+
+ # Try to load the library
+ eval "use $lib qw()";
+ my $errmsg = $@;
+
+ # Check the error message
+ if ( $errmsg =~ /^Can\'t locate / ) {
+ $answer = "no";
+ } elsif ($errmsg) {
+ $errmsg =~ s/\n.*//s;
+ $answer = "error, see below:\n" .
+ "-"x78 . "\n$errmsg\n" . "-"x78 . "\n";
+ } else {
+ $answer = "yes";
+ }
+ $result = ! $errmsg;
+
+ ## Perform version checking
+ if ( $flags->{version} ) {
+ eval "\$result &&= ( \$".$lib."::VERSION $flags->{version} )";
+ }
+
+ ## Build a static library, if available
+ my $static;
+ $static = `find ./lib 2>/dev/null | grep $pathname` if -e './lib';
+ if ( $static and ( not $result or $self->{static} ) ) {
+ chomp $static;
+ $static =~ m|./lib/.*?/|;
+ my $libpath = $&;
+ $answer = "yes (in $libpath)";
+
+ push @{ $self->{_static_libs}},$libpath
+ unless grep /^$libpath$/, @{ $self->{_static_libs}};
+ $result = 1;
+ }
+
+ print "$answer\n" unless $silent;
+
+ $self->{_depends}->{$lib} = $result;
+ return $result;
+ }
+
+##########################################################
+#
+# BUILD UTILITIES
+#
+#########################################################
+
+# &get_options()
+#
+# Read ./configure options from the command line
+#
+sub get_options($@)
+ {
+ my $ap = shift;
+ # Process overrides
+ while (@_) {
+ my $key = shift;
+ my $val = shift;
+ $key =~ s/^-//;
+ $ap->{$key} = $val;
+ }
+
+ $ap->check_argv();
+
+ }
+
+
+# &show_help()
+#
+# Print the ./configure usage message
+#
+sub show_help($)
+ {
+ my $ap = shift;
+ my $program = $ap->{program} || "the program";
+ my $mk = $ap->{mk};
+
+ print <<__HELP__
+Usage: ./configure [OPTIONS]...
+
+Configuration:
+ -h, --help display this help and exit
+ -v, --verbose be more verbose
+ -vv, --very-verbose be very verbose
+
+Installation directories:
+ --prefix=DIR use this prefix for installing $program [/usr/local]
+ --bindir=DIR use this prefix for installing $program binary
+ [PREFIX/bin]
+ --confdir=DIR use this prefix for installing configuration files
+ [PREFIX/etc/$program]
+ --sysconfdir=DIR use this prefix for installing system configuration
+ files [PREFIX/etc]
+ --datadir=DIR use this prefix for installing machine independent
+ data files [PREFIX/share]
+ --includedir=DIR public Perl header files [PREFIX/include]
+ --libdir=DIR use this prefix for private libraries [PREFIX/lib]
+ --mandir=DIR use this prefix for installing manpages [PREFIX/man]
+ --pkgdatadir=DIR use this for package-specific machine independent
+ data files [DATADIR/program-name]
+
+Compilation options:
+ --static do not use any shared system libraries [no]
+
+Optional Features:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+
+Custom options:
+__HELP__
+ ;
+
+ # Display custom options
+ foreach my $name ( keys %{$mk->{help_string}} ) {
+ my $val = $mk->{custom_arg}->{$name};
+ my $desc = $mk->{help_string}->{$name};
+ if ( defined $val and $val =~ /^[01]$/ ) {
+ $val = ( $val eq '1' ) ? 'yes' : 'no';
+ }
+ print " --$name" . ' 'x(21-length($name)) . $desc;
+ print ' [' . $val . "]" if defined $val;
+ print "\n";
+ }
+ print "\n";
+
+ exit 0;
+ }
+
+
+# Scan the Makefile parse tree and check dependencies
+sub check_all_depends
+{
+ my $ap = shift;
+ my $top = $ap->{mk};
+
+ # Build a queue of Parser objects to process (depth=1)
+ my @q = ( $top );
+
+ while (@q) {
+ my $mk = shift @q;
+ my $curdir = $mk->{curdir};
+
+ # Parse all sources and headers
+ foreach my $src ( mk_get_all_sources($mk),
+ @{$mk->{headers}} ) {
+# $log->info("Marking $_ for dependency checking");
+ $ap->check_depends("$curdir/$src");
+ }
+
+ # If the binaries exist, check them too
+ # (Special case)
+ foreach ( @{$mk->{bin_programs}}, @{$mk->{sbin_programs}}) {
+ next unless -e $_;
+ #$log->info("Marking $_ for dependency checking");
+ $ap->check_depends("$curdir/$_");
+ }
+
+ # Add any children to the queue
+ foreach my $child (keys %{$mk->{child}}) {
+ push @q, $mk->{child}->{$child};
+ }
+ }
+}
+
+sub write_all_makefiles
+{
+ my ($ap) = @_;
+ my $top = $ap->{mk};
+
+ # Build a queue of Parser objects to process (depth=1)
+ my @q = ( $top );
+
+ while (@q) {
+ my $mk = shift @q;
+
+
+ # Process additional files in AC_CONFIG_FILES
+ if ($mk->{vars}->{AC_CONFIG_FILES}) {
+ my @ac_files = split / /, $mk->{vars}->{AC_CONFIG_FILES};
+ foreach my $output (@ac_files) {
+ $mk->ac_parse_file($mk->{curdir} . '/' . $output);
+ push @{$mk->{extra_dist}}, "$output.in";
+ }
+ }
+
+ # Write the Makefile and config.h
+ $ap->write_makefile($mk);
+ Autoperl::Generator::write_config_h($ap,$mk);
+
+ # Add any children to the queue
+ foreach my $child (keys %{$mk->{child}}) {
+ push @q, $mk->{child}->{$child};
+ }
+ }
+}
+
+# WORKAROUND: copied from parser.pm
+sub mk_get_all_sources
+{
+ my $mk = shift ||die;
+ my @s;
+
+ foreach my $x ( keys %{$mk->{sources}} ) {
+ foreach my $y ( @{$mk->{sources}->{$x}} ) {
+ push @s, $y;
+ }
+ }
+
+ return @s;
+}
+
+# &check_recursive_depends(target)
+#
+# Scans all files within a directory for library dependencies
+#
+sub check_recursive_depends($$)
+{
+ my ($ap,$target) = @_;
+
+ die "$target: not a directory" unless -d $target;
+ opendir (my $dh, $target) or die "$target: error opening directory";
+ while (my $dirent = readdir ($dh)) {
+ my $abspath = "$target/$dirent";
+
+
+ next if $dirent eq '.' or $dirent eq '..'
+ or $dirent =~ m|/\.$| or $dirent =~ m|/\.\.|;
+
+ $ap->check_recursive_depends($abspath) if -d $abspath;
+ $ap->check_depends($abspath) if $abspath =~ /\.p[lm]/;
+ }
+ closedir ($dh);
+}
+
+# &check_depends(target)
+#
+# Parse a Perl source file, and check it's dependencies
+#
+# OR: if given a directory, scan all files within the directory
+#
+# Returns : True, if all deps found, FALSE if not
+#
+sub check_depends($$) {
+ my ($ap,$target) = @_;
+ my $success = 1;
+ my $lineno = 0;
+ chomp $target; #workaround
+
+ our %_dep_cache;
+
+ return $_dep_cache{$target} if exists $_dep_cache{$target};
+ return 1 unless $ap->{dependency_tracking};
+ return $ap->check_recursive_depends($target) if -d $target;
+
+ $ap->vprint("scanning $target for library dependencies");
+ open (TARGET, "<$target") or $ap->fatal("$target: $!");
+ while (<TARGET>) {
+ chomp;
+ my $line = $_;
+ $lineno++;
+ last if $line eq '__END__';
+
+ # Trim leading & trailing whitespace
+ $line =~ s/^\s*//;
+ $line =~ s/\s*$//;
+ $line =~ s/#.*//;
+ $line =~ s/;.*//;
+ $line .= ' ';
+ next unless $line =~ /^\s*use [A-Za-z0-9\:\-\_]+/;
+ my ($use,$lib,$flags) = split / +/, $line, 3;
+
+
+ #XXX-WORKAROUND -FIX PARSER!
+ next if $lib eq 'use'; ##XXX workaround for parser error
+ next unless $lib =~ /^[A-Za-z0-9\-\_\:]+$/;
+
+ $ap->vprint("${target}:${lineno}: checking dependency for $lib");
+
+ # Don't run duplicate tests
+ next if defined $ap->{_depends}->{$lib};
+
+ # Don't test for it if the project provides it
+ next if grep /^$lib$/, @{$ap->{mk}->{PROVIDES}};
+
+ # Test it!
+ $success = 0 unless $ap->check_lib($lib, {});
+ }
+ $_dep_cache{$target} = $success;
+ return $success;
+}
+
+
+# &check_argv()
+#
+# Process the arguments to a ./configure script
+#
+sub check_argv($)
+ {
+ my $ap = shift;
+ my $mk = $ap->{mk};
+
+ # Translation table
+ my %trans = (
+ '-h' => '--help',
+ '-v' => '--verbose',
+ '-vv' => '--very-verbose',
+ );
+
+ foreach my $arg ( @ARGV ) {
+ $arg = $trans{$arg} if exists $trans{$arg};
+
+ die "invalid argument '$arg'" unless $arg =~ /^--/;
+ $arg =~ s/^--//;
+ my ($option, $value);
+ if ( $arg =~ /=/ ) {
+ ($option,$value) = split /=/, $arg;
+ } else {
+ $option = $arg;
+ $value = 1;
+ }
+
+ if ( $option =~ /^(without|disable)-(.*)/ ) {
+ $option = $2;
+ $value = 0;
+ }
+ if ( $option =~ /^(with|enable)-(.*)/ ) {
+ $option = $2;
+ $value = 1;
+ }
+
+ #FIXME-workaround
+ if ( $option =~ /^disable_dependency_tracking/ ) {
+ $ap->{dependency_tracking} = 0;
+ }
+ elsif ( $option eq 'help' ) {
+ $ap->{mk}->parse_all(); # Parse custom_arg
+ $ap->show_help();
+ }
+ elsif ( $option eq 'verbose' ) {
+ Autoperl::Logger::set_log_level('info');
+ }
+ elsif ( $option eq 'very-verbose' ) {
+ Autoperl::Logger::set_log_level('debug');
+ }
+ elsif ( grep /^$option$/, keys %{$ap} ) {
+ $ap->{$option} = $value;
+ } else {
+ $mk->{top}->{custom_arg}->{$option} = $value;
+ }
+ }
+ 1;
+ }
+
+
+# &finalize()
+#
+# Combine prefix and installation path to create the final destination
+# for various paths.
+#
+sub finalize($) {
+ return; #XXX-THIS IS NOW DEADWOOD
+ my $ap = shift;
+
+ $ap->{pkgdatadir} = $ap->{datadir};
+
+ # Some paths don't have a prefix, but have a suffix
+ foreach my $path (qw(pkgdatadir confdir statedir)) {
+ $ap->{$path} = '/' . $ap->{$path} . '/' . $ap->{program} . '/';
+ }
+
+ # Combine the prefix with the path
+ foreach my $path (qw(bindir
+ sbindir
+ libexecdir
+ datadir
+ pkgdatadir
+ mandir
+ infodir
+ localedir
+ )
+ ) {
+ $ap->{$path} = $ap->prefix . '/' . $ap->{$path} . '/';
+ }
+
+ # Certain paths contain the name of the program (e.g. /etc/myprogram)
+ foreach my $path (qw(libdir
+ docdir
+ )
+ ) {
+ $ap->{$path} = $ap->prefix . '/' . $ap->{$path} . '/' . $ap->{program} . '/';
+ }
+
+ # Remove any double slashes (//) and trailing slashes in the paths
+ foreach my $key (keys %{$ap}) {
+ next unless $key =~ /dir$/ or $key =~ /^(prefix)$/;
+ $ap->{$key} =~ s|/+|/|g;
+ $ap->{$key} =~ s|/$||;
+ }
+
+}
+
+# &write_makefile()
+#
+# Write the Make and Perl header files
+#
+
+sub write_makefile($$) {
+ my ($ap,$mk) = @_;
+ my $target = $mk->{curdir} . '/Makefile';
+ my ($basename,$topdir) = ("","");
+
+ # Get basename and topdir
+ $target =~ /.*\//;
+ $basename = $&;
+ $basename = "" unless defined $basename;
+ $basename = "" if $basename =~ m|^\./?$|;
+ if ($basename) {
+ $topdir = $basename;
+ $topdir =~ s/[a-zA-Z0-9\-\_\.]+/\.\./g;
+ }
+
+ print "writing $target..\n";
+ open ( MKFILE, ">$target" ) or die $!;
+
+ print MKFILE "# Generated by\n#\n# ./configure --" . join("\n#" . ' 'x16 . '--' ,@ARGV) . "\n#\n";
+
+ foreach my $id ( keys %{ $ap } ) {
+ next if ref($ap->{$id});
+ next if $id =~ /^_/; # don't print internal structures
+
+ my $uc_id = $id;
+ $uc_id =~ tr/a-z/A-Z/;
+ my $val = $ap->{$id};
+
+ $val = '$$DESTDIR' . $val if $id =~ /dir$/;
+ die "null values for $id not permitted" unless defined $val;
+ print MKFILE $uc_id . " = $val\n";
+ }
+
+print MKFILE "TOPDIR = " . $ap->{topdir}. "\n";
+print MKFILE "DISTDIR = ${topdir}\$(PROGRAM)-\$(VERSION)/${basename}\n";
+
+ Autoperl::Generator::write_makefile($mk,*MKFILE);
+ close(MKFILE);
+
+ }
+
+# &errors()
+#
+# Return true if threre are unresolved dependencies
+#
+sub errors {
+ my $self = shift;
+ return ($self->{_errors} > 0) ? 1 : 0;
+}
+
+
+
+# &new
+#
+# Create a new Autoperl object
+#
+sub new
+ {
+ my $class = shift;
+ my $ap = bless {
+
+ # Permanent properties (TODO-Make project file i.e. metaconf)
+ program => 'undefined-program',
+ author => 'Undefined-author',
+ version => 0.01,
+
+ # Installation paths
+ destdir => '',
+ prefix => '${destdir}/usr/local',
+ bindir => '${prefix}/bin',
+ sbindir => '${prefix}/sbin',
+ libexecdir => '${prefix}/libexec',
+ datadir => '${prefix}/share',
+ pkgdatadir => '${datadir}/${program}',
+ mandir => '${prefix}/man',
+ includedir => '/usr/local/lib/site_perl',
+ infodir => '${prefix}/info',
+ confdir => '/etc/${program}',
+ sysconfdir => '/etc',
+ libdir => '${prefix}/lib',
+ docdir => '${prefix}/share/doc',
+ localedir => '${prefix}/locale',
+ statedir => '/var/lib',
+
+ # Build flags
+ static => 0,
+ verbose => 0,
+ dependency_tracking => 1,
+
+ # Internal structures
+ mk => new Autoperl::Parser(),
+ custom_arg => +{},
+ topdir => abs_path(getcwd),
+ sys => +{},
+ _sources => [],
+ _dirs => [],
+ _errors => 0,
+ _depends => +{ Autoperl => 1, },
+ _static_libs => [],
+ _ignore_libs => [],
+ }, $class;
+
+ # KLUDGE
+ die 'Cannot instantiate multiple Autoperl objects' if defined $AP;
+ $AP = $ap;
+
+ return $ap;
+ }
+
+sub DESTROY {1;}
+
+# &finished()
+#
+# Signal the end of the autoperl configure script and write the
+# output, if successful.
+#
+sub configure($) {
+ my $self = shift;
+
+ $self->check_host();
+ $self->check_all_depends();
+
+ # Missing dependencies?
+ my @missing;
+ foreach my $lib ( keys %{$self->{_depends}} ) {
+ next if grep /^$lib$/, @{$self->{_ignore_libs}};
+ my $valid = $self->{_depends}->{$lib};
+ push @missing, $lib unless $valid;
+ }
+ if ( @missing and $self->{dependency_tracking}) {
+ print "\nThe following libraries were not found:\n\t" .
+ join ("\n\t", @missing) . "\n\n";
+ $self->quit('aborting due to missing or broken dependencies.');
+ }
+
+ $self->fatal() if $self->errors;
+ unlink "build-stamp";
+
+ $self->finalize();
+
+ $self->write_all_makefiles();
+}
+
+# quit(msg)
+#
+# Abort processing due to a normal error
+#
+sub quit($$) {
+ my ($self,$msg) = @_;
+ critical("./configure: $msg\n");
+ debug(Dumper($self));
+ POSIX::_exit(1);
+}
+
+# fatal(msg)
+#
+# Throw a fatal exception with stack backtrace
+#
+sub fatal($$) {
+ print "./configure: caught fatal exception: $_[1]\n";
+ open (CORE, ">configure.core") or die $!;
+ print CORE $_[1] . "\n\n" . Dumper($_[0]) . Carp::longmess;
+ close CORE;
+ POSIX::_exit(255);
+}
+
+# vprint(msg)
+# vvprint(msg)
+#
+# Print a verbose message
+# Print a very verbose message
+#
+sub vprint($$) { print $_[1] . "\n" if $_[0]->verbose; }
+sub vvprint($$) { print $_[1] . "\n" if $_[0]->very_verbose; }
+
+# AUTOLOAD()
+#
+# Allow %ap keys to be accessed via accessor methods
+#
+sub AUTOLOAD {
+ use vars qw($AUTOLOAD);
+ my $ap = shift;
+ my $key = $AUTOLOAD;
+ $key =~ s/.*:://;
+ if ( defined $ap->{$key} ) { return $ap->{$key} }
+ confess "unknown method or attribute '$key'";
+}
+
+1;
+# parser.pm
+#
+# Functions that parse configuration files
+#
+package Autoperl::Parser;
+use strict;
+use warnings;
+use Carp;
+use Data::Dumper;
+BEGIN { import Autoperl::Logger; }
+
+use subs qw(raise);
+
+sub parse_all
+{
+ my $mk = shift || confess;
+
+ $mk->parse_makefile_am('Makefile');
+ $mk->parse_package_in();
+}
+
+sub raise {
+ critical("autoperl: ERROR: " . join("\n",@_));
+ debug(Carp::longmess);
+ exit(255);
+ }
+
+
+sub init_manifest
+{
+ my $project = +{
+ compat => 1,
+ name => undef,
+ version => undef,
+ author => undef,
+ title => undef,
+ synopsis => undef,
+ description => undef,
+ category => undef,
+ license => undef,
+ project_uri => undef,
+ source_uri => undef,
+ vuxml_uri => undef,
+ build_depends => [],
+ build_optional => [],
+ build_architectures => [],
+ runtime_depends => [],
+ library_depends => [],
+ depends => [],
+ suggests => [],
+ replaces => [],
+ };
+ return $project;
+}
+
+sub new
+{
+ my $class = shift;
+ my $parent = shift;
+
+ # Variables defined in Makefile.am
+ my $self = +{
+
+ # Global variables from configure.in
+ # TODO- reorganize this crap
+ program => 'mtest-comment-parsery-program',
+ version => '0.1',
+ author => 'Anonymous <nobody@nowhere.com>',
+
+ # The current directory, relative to the project root
+ curdir => '.',
+
+ # Pointer to the parent and the top-level parser object
+ # Pointer to child Makefile.am's defined in SUBDIRS
+ parent => undef,
+ top => undef,
+ child => +{},
+
+ # A list of Perl package names and/or binaries that this
+ # program provides.
+ # Indexed by packagename -> filename
+ provides => +{},
+
+ # Program files to be compiled, and their sources
+ bin_programs => [],
+ sbin_programs => [],
+ sources => +{},
+
+ # Headers to install publicly in $(includedir)
+ headers => [],
+
+ subdirs => [],
+ extra_dist => [],
+ manpages => +{},
+ pkgdata => [],
+ pkgdocs => [],
+ makefiles => [],
+
+ # All user-defined Makefile targets
+ targets => +{},
+
+ # Most system and user-defined variables
+ vars => +{
+ AUTOPERL => '$(TOPDIR)/configure --autoperl',
+ INSTALL => '$(AUTOPERL) install -p',
+ MAKE => '/usr/bin/make',
+ PERL => '/usr/bin/perl',
+ CC => '/usr/bin/perl -c',
+ LD => '$(AUTOPERL) link',
+ },
+
+ # User-defined ./configure --help strings
+ custom_arg => +{},
+ help_string => +{},
+
+ # User-defined hooks
+ hooks => [],
+
+ # Package manifest
+ manifest => undef,
+ };
+
+ if (defined $parent) {
+ $self->{parent} = $parent;
+ $self->{top} = $parent->{top};
+ $self->{manifest} = $parent->{top}->{manifest};
+ } else {
+ $self->{top} = $self;
+
+ # Top-level objects have special concatenated variables
+ # so code does not have to be recursive
+ $self->{PROVIDES} = [];
+ }
+
+ bless $self, $class;
+ return $self;
+}
+
+sub parse_makefile_am($$)
+{
+my ($mk,$input) = @_;
+$input .= '.am';
+
+raise "$input not found" unless -e $input;
+
+# Get the current directory
+$input =~ /(.*)\//;
+my $curdir = $1;;
+$curdir = '.' unless defined $curdir;
+$curdir =~ s|^\./||;
+$mk->{curdir} = $curdir;
+debug("curdir = $curdir");
+
+# Parse the 'aplocal.inc' file, if it exists
+# XXX-TODO-REMOVE THIS AND USE THE INLINE-PERL FACILITY INSTEAD
+#
+$mk->parse_aplocal_inc("$curdir/aplocal.inc");
+
+# Slurp the entire file into @lines
+open ( my $infile, "<./$input") or raise "$input: $!";
+my @lines = <$infile>;
+close ($infile);
+
+# Preprocess for Autoconf-style substitutions (@VARIABLE@)
+@lines = $mk->ac_parse(@lines);
+
+# Parse each line
+for (my $lineno = 0; $lineno <= $#lines; $lineno++) {
+ my $s = $lines[$lineno];
+ debug("stage1, $lineno: $s");
+
+ #====================================================
+ # Parser for inline perl code
+ my $left_curly = '{';
+ my $right_curly = '}';
+ if ($s =~ /^$left_curly/) {
+ my @inline_perl = ( $s );
+ my $start = $lineno;
+ while ($lineno++ <= $#lines) {
+ my $s = $lines[$lineno];
+ push @inline_perl, $s;
+ my $lookahead = ($lineno < $#lines) ? $lines[$lineno + 1] : "";
+ last if ($s =~ /^$right_curly/ and not $lookahead =~ /^$right_curly/);
+ }
+ my $OUT;
+ my @result = ( eval join('',@inline_perl) );
+ $OUT .= join('',@result);
+ splice @lines,
+ $start,
+ ($lineno - $start + 1),
+ map { "$_\n" } split /\n/, $OUT;
+ $lineno = $start + 1;
+ next;
+ }
+}
+push @lines, "\n"; # This is a kludge because $lineno <= $#lines doesn't work.. ??
+
+#====================================================
+# Stage 2: Parse all Makefile targets
+#
+for (my $lineno = 0; $lineno <= $#lines; $lineno++) {
+ my $raw_line = $lines[$lineno];
+ debug("stage2 raw line $lineno: $raw_line");
+
+ # Strip comments
+ $raw_line =~ s/(?!\\)(#.*?)(\\?)$//;
+ $raw_line .= "\\" if $2;
+
+
+ # Import Make-style targets
+ if ($raw_line =~ /^([a-zA-Z0-9\-\_]+?)\:\s*(.*)/) {
+ my $cur_target = $1;
+ my $depends = $2;
+ debug(" makefile target: $cur_target");
+ $mk->{targets}->{$cur_target} = +{
+ depends => defined $depends ? $depends : '',
+ lines => [],
+ };
+
+ $lineno++;
+ while ($lineno <= $#lines and $lines[$lineno] =~ /^\t/) {
+ chomp ( my $s = $lines[$lineno]);
+ # Strip comments
+ $s =~ s/(?!\\)(#.*?)(\\?)$//;
+ $s .= "\\" if $2;
+
+ debug(" >> $s");
+ push @{$mk->{targets}->{$cur_target}->{lines}}, $s;
+ $lineno++;
+ }
+ $lineno--;
+ next;
+
+ # Parse variable definitions in the form of 'FOO = BAR'
+ } elsif ($raw_line =~ /^(.*?)=(.*)$/) {
+ chomp (my $line = $raw_line);
+
+ # Lines ending with a backslash are continued on the next line
+ while ($line =~ /\\$/) {
+ chop $line;
+ $lineno++;
+ raise("unexpected end of file") if $lineno > $#lines;
+
+ chomp ( my $next_line = $lines[$lineno] );
+ $next_line =~ s/^\s*//;
+ $line .= $next_line;
+ }
+
+ debug(" get_variable($line)");
+
+ # Split the definition into a token and a value (TOKEN=VALUE)
+ my ($token, $value);
+ if ($line =~ /^\s*([A-Za-z0-9\-\_]+)\s*=\s*(.*)\s*$/) {
+ ($token, $value) = ($1,$2);
+ } else {
+ raise "Malformed variable definition";
+ }
+
+ # Remove trailing whitespace
+ $value =~ s/\s*$//;
+
+ # Parse internal Autoperl variables
+ if (grep /^$token$/, qw( PROGRAM VERSION AUTHOR )) {
+ $mk->{top}->{lc $token} = $value;
+ } elsif ($token =~ /_ARG$/) {
+ my $arg = $`;
+ $arg =~ tr/_/-/;
+ $mk->{top}->{custom_arg}->{$arg} = $value;
+ } elsif ($token =~ /_ARG_HELP$/) {
+ my $arg = $`;
+ $arg =~ tr/_/-/;
+ $mk->{top}->{help_string}->{$arg} = $value;
+ } elsif ($token =~ /(.*)_SOURCES/) {
+ my $binary = "$1.pl";
+ my @src = split /\s+/, $value;
+ @{$mk->{sources}->{$binary}} = @src;
+ foreach my $srcfile (@src) {
+ next unless $srcfile =~ /\.pm$/;
+ my $pkgname = $mk->get_package_from_source($srcfile);
+ next unless $pkgname;
+ $mk->{provides}->{$pkgname} = $srcfile;
+ push @{$mk->{top}->{PROVIDES}}, $pkgname;
+ }
+ } elsif ($token eq 'SUBDIRS') {
+ $mk->{subdirs} = [ split /\s+/, $value ];
+
+ # FIXME-
+ #
+ # Each SUBDIR should have it's Makefile generated
+ # This doesn't play nice with non-Autoperl makefiles :(
+ # We should really fix the autoperl --init generation
+ # the AC_CONFIG_FILES macro. That would introduce another
+ # problem: what happens when you add a directory after running
+ # --init; the user would need to edit configure.in.
+ #
+ # For now this is OK.
+ #
+ foreach my $subdir (@{$mk->{subdirs}}) {
+ my $input = $curdir . '/' . $subdir . '/Makefile';
+ push @{$mk->{top}->{makefiles}}, $input;
+
+ # RECURSION:
+ #
+ # Create a new Parser object and parse each Makefile.am
+ # under SUBDIRS, storing in $child
+ my $submk = new Autoperl::Parser($mk);
+ $submk->parse_makefile_am($input);
+ $mk->{child}->{$input} = $submk;
+ }
+
+
+ } elsif ($token =~ /(dist_)?(man[0-9])_MANS/) {
+ my ($section,$files) = ( $2, $value);
+ @{$mk->{manpages}->{$section}} = split /\s+/, $files;
+ } elsif ($token =~ /(dist_)?man_MANS/) {
+ my ($section,$files) = ( $2, $value);
+ foreach my $file ( split /\s+/, $files ) {
+ $file =~ /.*\.([0-8])(\.gz)?$/;
+ my $section = $1;
+ die 'unable to determine manpage section for '.$file
+ unless defined $section;
+ push @{$mk->{manpages}->{$section}}, $file;
+
+ }
+ } elsif ($token =~ /(dist_)?pkgdata_DOCS/) {
+ $mk->{pkgdocs} = [ split /\s+/, $value ];
+ } elsif ($token =~ /(dist_)?pkgdata_DATA/) {
+ push @{$mk->{pkgdata}}, split /\s+/, $value;
+ } elsif ($token =~ /EXTRA_DIST/) {
+ push @{$mk->{extra_dist}}, split /\s+/, $value;
+ } elsif ($token =~ /s?bin_(PROGRAMS|SCRIPTS)/) {
+ $mk->{lc $token} = [ split /\s+/, $value ];
+ } elsif ($token =~ /include_HEADERS/) {
+ my @hdr = split /\s+/, $value;
+ @{$mk->{headers}} = @hdr;
+ foreach my $srcfile (@hdr) {
+ my $pkgname = $mk->get_package_from_source($srcfile);
+ next unless $pkgname;
+ $mk->{provides}->{$pkgname} = $srcfile;
+ push @{$mk->{top}->{PROVIDES}}, $pkgname;
+ }
+
+ # Non-Autoperl variables are stored in the $mk->{vars} hash
+ } elsif (defined $token and defined $value) {
+ $mk->{vars}->{$token} = $value;
+
+ # Trap parser errors like an incomplete definition (`FOO=')
+ } else {
+ warn "line:\n`$line'\ntoken = `$token'\nvalue = `$value'";
+ for (my $i = 0; $i<=$lineno; $i++) {
+ my $s = $lines[$i];
+ chop $s;
+ print "$i: |$s|\n";
+ }
+ raise "Makefile.am:$lineno: parse error";
+ }
+ $line = "";
+
+ # Ignore blank lines
+ } elsif ($raw_line =~ /^\s*$/) {
+ next;
+
+ } else {
+ raise "Makefile.am:$lineno: parse error";
+ }
+ }
+}
+
+
+# ac_parse_file($self, $filename)
+#
+# Parse an arbitrary file using the same conventions as the Autoconf
+# AC_CONFIG_FILES macro
+#
+# - Variables are surrounded by at-signs (e.g. @VARIABLE@)
+# - Files with a '.in' extension are parsed
+#
+# No return value
+#
+sub ac_parse_file($$)
+{
+ my ($self, $output) = @_;
+ my $ap = $Autoperl::AP;
+ my $input = $output . ".in";
+
+ # Read input
+ open (my $inf, "<$input") or die "$input: $!";
+ my @lines = <$inf>;
+ close ($inf);
+
+ # Write to output file
+ open (my $outf, ">$output") or die "$output: $!";
+ print $outf $self->ac_parse(@lines);
+ close($outf);
+}
+
+
+sub ac_parse
+{
+ my ($self, @input) = @_;
+ my $ap = $Autoperl::AP;
+
+ for (my $i = 0; $i<=$#input; $i++) {
+ my $line = $input[$i];
+
+ my @token = $line =~ m/\@([A-Z0-9\_\-]+?)\@/g;
+ foreach my $id (@token) {
+ my $saved = $id;
+ if (defined $ap->{lc $id}) {
+ $id = lc $id;
+ $line =~ s/\@$saved\@/$ap->{$id}/g;
+ } elsif (defined $self->{vars}->{$id}) {
+ $line =~ s/\@$saved\@/$ap->{$id}/g;
+ }
+ }
+ $input[$i] = $line;
+ }
+ return @input;
+}
+
+sub parse_aplocal_inc
+{
+ my ($mk,$input) = @_;
+ return unless -e $input;
+
+ debug("parse_aplocal_inc($input)");
+
+ # Read the entire file
+ open( my $infile, "<$input") or die "$input: $!";
+ my @lines = <$infile>;
+ close($infile);
+
+ # Find the 'hook' functions
+ my @valid_hooks = qw( configure make_all make_install
+ make_dist make_uninstall make_package
+ make_clean
+ );
+ foreach (grep( /^\s*sub /, @lines )) {
+ /sub ([A-Za-z0-9_]+)/;
+ my $sub = $1;
+ next unless $sub =~ /^(pre|post)_(.*?)_hook/;
+ my $hook = $2;
+ die 'invalid hook: ' . $sub
+ unless grep /^$hook$/, @valid_hooks;
+ push @{$mk->{hooks}}, "$1_$hook";
+ }
+ debug(" found: " . join(", ",@{$mk->{hooks}}) );
+}
+
+
+# Parse package information file
+#
+sub parse_package_in
+{
+ my $self = shift;
+ my %r;
+
+ return unless -e 'package.in';
+
+ # Define the grammar
+ my @multiline = qw( Description
+ );
+ my @array = qw( Requires
+ );
+
+ my @scalar = qw( Package Title License
+ Project-URI Source-URI VuXML-URI
+ );
+
+ # Grab the whole file
+ open(my $infile, "<package.in") or die "package.in: $!";
+ my @lines = <$infile>;
+ close($infile);
+
+ # Parse it
+ my $pkg = "";
+ my $key = "";
+ my $value = "";
+ for (my $i = 0; $i <= $#lines; $i++) {
+ my $line = $lines[$i];
+ $line =~ s/\#.*//;
+ next unless $line =~ /\w/ or
+ (defined $key and grep /^$key$/, @multiline);
+
+ if ($line =~ /^([A-Za-z\-\_]+)\:\s*(.*)$/) {
+ $key = $1;
+ $value = $2;
+ $pkg = $value if $key eq 'Package';
+ $pkg =~ s/^\s*//;
+ $value =~ s/\s*$//;
+ } else {
+ $value = $line;
+ }
+
+ die 'package.in: must declare "Package" before other variables'
+ if $key and not $pkg;
+
+ die 'package.in: '.$i.': parser error' unless $key;
+
+ $r{$pkg} = +{} unless defined $r{$pkg};
+
+ if (grep /^$key$/, @multiline) {
+ $r{$pkg}->{$key} = "" unless defined $r{$pkg}->{$key};
+ $r{$pkg}->{$key} .= $value;
+ } elsif (grep /^$key$/, @scalar) {
+ $value =~ s/^\s*//;
+ $value =~ s/\s*$//;
+ die 'package.in: '.$i.': '.$key.' cannot be redefined'
+ if exists $r{$pkg}->{$key};
+ $r{$pkg}->{$key} = $value;
+ } elsif (grep /^$key$/, @array) {
+ $value =~ s/^\s*//;
+ $value =~ s/\s*$//;
+ my @subvalues = split /\s+/, $value;
+ $r{$pkg}->{$key} = [] unless defined $r{$pkg}->{$key};
+ push @{$r{$pkg}->{$key}}, @subvalues;
+ } else {
+ die 'package.in: '.$i.': unknown variable "'.$key.'"';
+ }
+ }
+ $self->{packager} = \%r;
+ bless $self->{packager}, "Autoperl::Packager";
+ return \%r;
+}
+
+
+# get_package_from_source(src)
+#
+# Parse a source code file and return the package name
+# based first occurance of 'package <foo>'
+#
+# NOTE: This cant handle multiple packages inside the same file.
+#
+sub get_package_from_source($$)
+{
+ my ($self,$src) = @_;
+ my $result = "";
+
+ confess "$src is required" unless $src;
+ die "$src is not a perl module" unless ($src =~ /\.pm$/);
+
+ $src = $self->{curdir} . '/' . $src;
+
+ open( my $infile, "<$src") or die "get_package_from_source(): $src: $!";
+ while (<$infile>) {
+ s/#.*//;
+ next unless /^\s*package ([A-Za-z0-9\:\_]+)\s*.*\;/;
+ my $match = $1;
+ $result = $match;
+ last;
+ }
+ close($infile);
+ debug("get_package_from_source($src) = $result");
+ die "$src: package name not found"
+ unless $result;
+ return $result;
+}
+
+
+############ Flattening routines
+
+sub get_all_vars($)
+{
+ my $self = shift;
+
+ my $s = "";
+
+ foreach my $key (keys %{$self->{vars}}) {
+ $s .= $key . ' := ' . $self->{vars}->{$key} . "\n";
+ }
+ return $s;
+}
+
+# KLUDGE - flatten the $mk->{'sources'} key
+# into a list of all source code files
+#
+sub get_all_sources
+{
+ my $mk = shift ||die;
+ my @s;
+
+ foreach my $x ( keys %{$mk->{sources}} ) {
+ foreach my $y ( @{$mk->{sources}->{$x}} ) {
+ push @s, $y;
+ }
+ }
+
+ return @s;
+}
+
+sub get_all_binaries
+{
+ my $mk = shift ||die;
+ my @s;
+
+ foreach (@{$mk->{bin_programs}}) { push @s, $_ }
+ foreach (@{$mk->{sbin_programs}}) { push @s, $_ }
+ foreach (@{$mk->{bin_scripts}}) { push @s, $_ }
+ foreach (@{$mk->{sbin_scripts}}) { push @s, $_ }
+
+ return join(' ',@s);
+}
+
+sub get_all_manpages
+{
+ my $mk = shift||die;
+
+ my @m;
+
+foreach my $section (keys %{$mk->{manpages}}) {
+ foreach my $manpage (@{$mk->{manpages}->{$section}}) {
+ push @m, $manpage;
+ }
+ }
+return @m;
+}
+
+sub get_all_makefiles($)
+{
+ my $mk = shift;
+
+ return ( unique(@{$mk->{makefiles}}) );
+}
+
+sub dump($)
+{
+ return "\n\nAutoperl::Parser dump follows:\n" . Dumper($_[0]);
+}
+
+#------------------ Utility Functions -------------------------
+
+# unique(@foo)
+#
+# Given a list @foo, make a copy, remove any duplicate elements,
+# and return a list containing unique items.
+#
+sub unique
+{
+ my %saw;
+ my @out = grep(!$saw{$_}++, @_);
+
+ return ( @out );
+}
+
+
+# file_exists(@in)
+#
+# Give a list of files (@in), check if each file exists.
+# die()s if not.
+#
+sub check_file_exists
+{
+ foreach my $fn (@_) {
+ die "$fn: no such file or directory" unless -e $fn;
+ }
+ 1;
+}
+
+
+1;
+package Autoperl::Packager;
+
+use Cwd;
+use strict;
+use warnings;
+use Data::Dumper;
+
+our %manifest;
+
+# make_package()
+#
+# Build a native binary package
+#
+sub make_package
+{
+ my $mk = shift;
+ my $pkg_in = Autoperl::Parser::parse_package_in();
+ undef %ap::config;
+ undef $ap::CONFIG_H;
+ eval 'require ' . '"config.h"';
+
+# Stat the local OS
+ my $uname = $^O;
+ foreach my $package (keys %{$pkg_in}) {
+ my $manifest_ref = $pkg_in->{$package};
+ %manifest = %{$manifest_ref};
+ if ($uname eq 'openbsd') {
+ make_openbsd_package();
+ } elsif ($^O eq 'linux' and -e '/etc/debian_version') {
+ make_deb_package();
+ } elsif ($^O eq 'linux' and -e '/etc/redhat-release') {
+ make_rpm_package();
+ } else {
+ die "Autoperl does not support building binary packages on this operating system ($^O)"
+ }
+ }
+}
+
+# '''''''''''''''''''''''' DEBIAN
+
+sub make_deb_package
+ {
+ my $program = $ap::config{program};
+ my $version = $ap::config{version};
+
+ die "Cannot find dpkg-buildpackage; please install the debhelper package"
+ unless `which dpkg-buildpackage`;
+
+ die "Cannot find fakeroot; please install the fakeroot package"
+ unless `which fakeroot`;
+
+ die "A subdirectory named 'debian/' already exists, cannot continue"
+ if -d 'debian/';
+ mkdir 'debian' or die "mkdir: $!";
+
+ my $cwd = getcwd;
+
+ my $version_str = "$program ($version) unstable; urgency=low";
+ open (CHANGELOG, ">debian/changelog") || die "$!";
+ print CHANGELOG $version_str . "\n\n";
+ print CHANGELOG " * Automatically generated by autoperl\n\n";
+ print CHANGELOG " -- $ap::config{author} " . `date -R` . "\n\n";
+ close (CHANGELOG);
+
+ my $depends = "";
+ my $arch = 'any'; #TODO: $spec->{'architecture'}
+
+ # TODO: calculate dependencies
+ # map { $depends .= "," . $self->getCanonicalName($_); } @{$spec->{depends}};
+
+ # reformat the description to satisfy debian quirkyness
+ # remove blank lines, [FIXME-TODO] shift each paragraph beginning right 1 space.
+
+ my $synopsis = $manifest{Title};
+ my $original = $manifest{Description};
+ my $description;
+ my $para_marker = 0;
+ foreach my $line ( split /\n/, $manifest{Description} ) {
+ unless ( $line =~ /\w/ ) { $para_marker = 1; next; }
+ if ( $para_marker ) {
+ $line = ".\n $line";
+ $para_marker = 0;
+ }
+ $description .= " $line\n";
+ }
+
+ open ( CONTROL, ">debian/control" ) or die "$!";
+ print CONTROL <<EOF
+Source: $ap::config{program}
+Section: unknown
+Priority: optional
+Maintainer: $ap::config{author}
+Build-Depends: debhelper (>> 3.0.0)
+Standards-Version: 3.5.2
+
+Package: $ap::config{program}
+Architecture: $arch
+Depends: \${shlibs:Depends} $depends
+Description: $synopsis
+$description
+EOF
+;
+ close ( CONTROL );
+
+ ## Create debian/rules Makefile
+
+
+ open ( RULES, ">debian/rules" ) or die "$!";
+ print RULES <<EOF
+#!/usr/bin/make -f
+# Automatically generated debian/rules by autoperl(1)
+
+config.status:
+ dh_testdir
+ touch config.status
+
+build: build-stamp
+
+build-stamp: config.status
+ dh_testdir
+ make
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp
+
+ # Add here commands to clean up after the build process.
+ #-\$(MAKE) distclean
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Copy all files to debian/[package-name]
+ install -d -m 700 debian/$program
+ make install DESTDIR=$cwd/debian/$program
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+
+# dh_installdocs
+# dh_installexamples
+ dh_install
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+# dh_installman
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+# dh_perl
+# dh_python
+# dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
+
+
+EOF
+;
+ close ( RULES );
+ chmod 0755, 'debian/rules';
+
+ #XXX-FIXME-this does wierd things
+# open ( DIRS, ">debian/dirs" ) or die "$!";
+# foreach ( @{$spec->{dirs}} ) {
+# print DIRS "$_\n";
+# }
+# close ( DIRS );
+
+ system "echo 4 > debian/compat";
+
+# $self->SUPER::create("post");
+ system "bash -c 'dpkg-buildpackage -b -us -uc -rfakeroot'";
+ if ( $? ) {
+ die "dpkg-buildpackage returned an error";
+ }
+ my $deb_file = Cwd::abs_path('..') . "/${program}_${version}_i386.deb"; #FIXME-hardcoded
+ if ( ! -e $deb_file ) { die "could not find deb package $deb_file, or error copying"; }
+
+ system "rm -rf debian/ ../${program}_*.changes";
+ die "cleanup of 'debian/' failed" if $?;
+
+ $deb_file =~ m|^.*/|;
+ rename $deb_file, $';
+ }
+
+
+sub make_rpm_package
+ {
+ my $program = $ap::config{program};
+ my $package = $program;
+ my $version = $ap::config{version};
+ my $title = $manifest{Title};
+ my $description = $manifest{Description};
+ my $author = $ap::config{author};
+ my $cwd = getcwd();
+ my $tmpdir = "$cwd/rpm-build";
+ my $specfile = "$tmpdir/rpm.spec";
+ my $rpm_base = $tmpdir;
+ my $buildroot = "$rpm_base/BUILD/$package-$version";
+
+ # Cross-compiling presents a problem for the find-requires script
+ my $cross_compiling = 0;
+
+ ## Create SOURCES, RPMS directories if needed
+ foreach ($tmpdir, "$rpm_base/BUILD", "$rpm_base/SOURCES",
+ "$rpm_base/RPMS", $buildroot)
+ {
+ print "mkdir $_\n";
+ mkdir $_ or die "*ERROR* $!"
+ }
+
+ # Install the package into $buildroot
+ my @files = install_all($buildroot);
+
+ ## Eliminate the RPM 'find-requires' script, since it is not portable (!)
+ if ($cross_compiling) {
+ open (FINDREQ, ">$rpm_base/find-requires" ) || die "$!";
+ print FINDREQ <<EOF
+#!/bin/sh
+xargs >/dev/null
+echo ""
+EOF
+ ;
+ close (FINDREQ);
+ chmod 0755, "$rpm_base/find-requires";
+ }
+
+ ## RPM '%files' requires leading slashes
+ for ( my $i; $i <= $#files; $i++ ) {
+ $files[$i] = "/" . $files[$i];
+ }
+
+ ## Generate the make(1) commands
+ open ("SPEC", ">$specfile") or die "$specfile: $!";
+
+print SPEC "# autoperl generated spec file " .
+ "for package $package (Version $version)\n\n";
+
+foreach (keys %ap::config) {
+ my $value = $ap::config{$_};
+ next unless defined $value and $_;
+ print SPEC "\%define _$_ $value\n";
+}
+
+print SPEC "\%define __find_requires $tmpdir/find-requires\n"
+ if $cross_compiling;
+
+die Dumper(%manifest);
+ print SPEC <<"__EOF__";
+%define _topdir $tmpdir
+Name: $package
+Summary: $title
+Version: $version
+License: $manifest{License}
+Vendor: $author
+Packager: $author
+Release: 1
+Group: Other
+BuildRoot: $buildroot
+
+\%description
+$manifest{Description}
+
+\%prep
+###%setup -q
+###echo %_target
+###echo %_target_alias
+###echo %_target_cpu
+###echo %_target_os
+###echo %_target_vendor
+
+\%build
+true
+
+\%install
+true
+
+\%clean
+true
+
+\%post
+true
+
+\%postun
+true
+
+\%files
+%defattr(-,root,root)
+__EOF__
+
+foreach (@files) {
+print SPEC "$_\n";
+}
+
+ close SPEC;
+
+ ## Compile the software
+ chdir $rpm_base or die "$!";
+ system "rpm -bb rpm.spec";
+ my $result = $?;
+ chdir '..';
+ if ( $result ) {
+ die "RPM failed to create the package (message: $?)";
+ }
+
+ map {
+ chomp;
+ my $src = $_;
+ $src =~ m|^.*/|;
+ my $dest = $';
+ rename $src, $dest or die "error moving $src to $dest: $!";
+ print "$dest\n";
+ } `find $rpm_base/RPMS -name '*.rpm'`;
+
+ system "rm -rf $tmpdir";
+ }
+
+
+sub make_openbsd_package
+{
+ my $tmpdir = './bsd-package';
+ my @files = install_all($tmpdir);
+
+ chomp(my $release = `/usr/bin/uname -r`);
+ $release =~ s/\.//g;
+ chomp(my $machine = `/usr/bin/uname -m`);
+ open (my $plist,">plist") or die "plist:$!";
+ print $plist join("\n",map { s|^usr/local/||; $_ } @files);
+ close ($plist);
+
+ my $output_fn = $ap::config{program} .
+ '-' .
+ $ap::config{version} .
+ ".tgz";
+
+
+ my $cmd = "pkg_create -f plist -B $tmpdir -p /usr/local " .
+ " -c '-package title' -d '-longdesc' " .
+ " $output_fn";
+ print "$cmd\n";
+ system $cmd;
+ die "pkg_create returned an error" if $?;
+
+#my @cmd = ( "pkg_create -f pkg/PLIST ",
+# "\t -p /usr/local",
+# "\t -c '" . $manifest->{synopsis} . "'",
+# "\t -d pkg/DESC",
+ #"\t -i pkg/INSTALL",
+ #"\t -k DEINSTALL",
+# $output_fn,
+# );
+ system "rm -rf $tmpdir";
+ unlink "plist";
+}
+
+sub install_all
+{
+
+ my $dest = shift || die;
+ my $cwd = getcwd;
+ die 'invalid install_all() target: '.$dest
+ unless $dest =~ m|^(\./\|/)|;
+ system "rm -rf $dest";
+ $dest =~ s|^\./|$cwd/|;
+ system "make install DESTDIR=$dest/";
+
+ # Get a list of all installed files
+ my @files = map { s|^$dest/||; chomp; $_; }
+ `find $dest -type f`;
+
+ return @files;
+}
+
+1;
+# generator.pm
+#
+# Functions that generate datafiles
+#
+package Autoperl::Generator;
+
+use strict;
+use warnings;
+use English;
+use Data::Dumper;
+BEGIN { import Autoperl::Logger; }
+
+use constant INSTALL_PATHS => qw( prefix
+ bindir
+ sbindir
+ libexecdir
+ datadir
+ includedir
+ pkgdatadir
+ mandir
+ infodir
+ confdir
+ libdir
+ docdir
+ localedir
+ statedir
+ sysconfdir
+ destdir
+ );
+
+
+sub write_config_h
+{
+ my ($ap,$mk) = @_;
+ my $outfile = $mk->{curdir} . '/config.h';
+
+ notice("writing $outfile..");
+
+ # Generate a 'cfg' object to be included in the binary
+ my $cfg;
+ foreach my $key (INSTALL_PATHS, qw(program author version)) {
+ $cfg->{$key} = $ap->{$key};
+ }
+
+ # Recursively add all custom arguments
+ # Arguments from all parent directories will be merged
+ # If an argument is defined in parent and child, child overrides
+ my $mk_saved = $mk;
+ do {
+ foreach my $key (keys %{$mk->{custom_arg}}) {
+ next if exists $cfg->{$key};
+ $cfg->{$key} = $mk->{custom_arg}->{$key};
+ $cfg->{$key} = 1 unless defined $cfg->{$key}
+ }
+ $mk = $mk->{parent};
+ } while ($mk);
+ $mk = $mk_saved;
+
+ # Copy all user-defined variables from Makefile.am to config.h
+ foreach my $key (keys %{$mk->{vars}}) {
+ my $value = $mk->{vars}->{$key};
+ next if grep /^$key$/, qw( CC LD INSTALL AUTOPERL MAKE );
+ if (defined $cfg->{$key}) {
+ warning("Variable collision detected: $key");
+ next;
+ }
+ $cfg->{$key} = $value;
+ }
+
+ # Recursively expand all variables
+ # Do this in multiple passes until there are no more candidates
+ my $found;
+ my $pass = 0;
+ do {
+ $found = 0;
+ foreach my $query (keys %{$cfg}) {
+ next unless defined $query;
+ my $replace = $cfg->{$query};
+ foreach my $x (keys %{$cfg}) {
+ my $s = $cfg->{$x};
+ #next unless defined $s and defined $x;
+ if ($s =~ /\$[\{\(]$query[\)\}]/) {
+ $cfg->{$x} =~ s/\$[\{\(]$query[\}\)]/$replace/g;
+ $found++;
+ }
+ }
+ }
+ $pass++;
+ } until $found == 0 or $pass > 200;
+
+ die 'infinite recursion detected' if $pass > 200;
+
+ # Save to disk
+ open (FH, ">$outfile") or die "$outfile: $!";
+ print FH "# Generated by autoperl\n";
+ print FH "unless (defined \$ap::CONFIG_H) {\n";
+ print FH "\n\$ap::CONFIG_H = 1;\n";
+ print FH Data::Dumper->Dump([$cfg],["*ap::config"]);
+
+ #FIXME: This creates problems when require()d multiple times
+ #print FH "\n# Accessor methods\n\n";
+ #print FH "eval {\n";
+ #foreach my $key (keys %{$cfg}) {
+ # my $val = $cfg->{$key};
+ # $val = '' unless defined $val;
+ # print FH "sub ap::$key { '$val' }\n";
+ #}
+ #print FH "};\n";
+ print FH "\n\n# Inconvenience hashref\n";
+ print FH '$ap::config = \%ap::config;' . "\n";
+
+ print FH "}\n";
+ print FH "\n1;\n";
+ close (FH);
+}
+
+
+# KLUDGE: Autoperl::write_makefile calls this with an open file descriptor
+# to the current Makefile
+#
+sub write_makefile
+{
+my $mk = shift;
+*MOUT = shift;
+my $curdir = $mk->{curdir};
+my $basename = $curdir;
+
+# Get the output name
+my $output = $curdir . '/Makefile.in';
+
+# Generate all variable definitions
+my $subdirs = join(' ',@{$mk->{subdirs}});
+print MOUT "SUBDIRS = $subdirs\n" if $subdirs;
+if ($mk->get_all_vars()) {
+ #print MOUT "\n\n#---- User defined variables ----\n\n";
+ print MOUT $mk->get_all_vars() . "\n";
+}
+print MOUT "APLOCAL = \$(PERL) -e 'do \"config.h\"; do \"aplocal.inc\";' -e \n";
+
+
+# ----------- BEGIN targets -------------
+
+my @recursive_targets = qw(all install dist clean test uninstall);
+
+print MOUT "\ndefault: all\n\n";
+
+# Declare 'phony' targets
+print MOUT "\n.PHONY : package ";
+print MOUT "\$(SUBDIRS) " if $subdirs;
+print MOUT join(' ', @recursive_targets);
+print MOUT "\n\n";
+
+# FIXME-fugly
+# Generate some recursive targets
+if ($subdirs) {
+foreach my $target (@recursive_targets) {
+print MOUT "recursive-$target:\n";
+foreach my $subdir (@{$mk->{subdirs}}) {
+ print MOUT "\tcd $subdir && \$(MAKE) $target && cd ..\n";
+ }
+print MOUT "\n";
+ }
+}
+
+# Generate the 'make all' target
+unless ( exists $mk->{targets}->{'all-local'} ) {
+print MOUT "all: ".($subdirs ? 'recursive-all' : '') . "\n";
+print MOUT "\t\$(APLOCAL) 'pre_make_all_hook()'\n"
+ if grep /pre_make_all/, @{$mk->{hooks}};
+
+# Emulate the compilation stage by validating syntax
+#
+# FIXME-XXX this fails when packages import symbols from
+# other parts of the project tree and don't qualify their use.
+#
+# MakeMaker builds a 'blib/' tree and runs compilation checks
+# from blib/ so that use() statements work.
+#
+# See the kolab-perl source tree for example of module interdepency
+#
+#my @sources = ( $mk->get_all_sources(), @{$mk->{headers}} );
+#foreach my $src (@sources) {
+# next unless $src;
+# print MOUT "\t\$(CC) $src\n"
+#}
+
+# Compress all manpages
+foreach my $manpage ($mk->get_all_manpages()) {
+ print MOUT "\tgzip -c $manpage > ${manpage}.gz\n"
+ unless $manpage =~ /\.gz$/;
+}
+
+# Emulate the linker stage by merging source code files
+foreach my $src ( keys %{$mk->{sources}} ) {
+ my @objs = @{$mk->{sources}->{$src}};
+ my $obj = ' ' . join(' ', @{$mk->{sources}->{$src}}) . ' ';
+ my $bin = $src;
+ $bin =~ s/\.pl$//;
+
+ # Basic support for C programs
+ if ( $obj =~ /\.c / ) {
+ $obj =~ s/ (.*?)\.h / /g;
+ print MOUT "\tgcc -o $bin";
+ foreach (@objs) { print MOUT " $_" if /\.c$/ }
+ print MOUT "\n";
+ } else {
+ print MOUT "\t\$(LD) -o $bin $obj\n";
+ }
+}
+print MOUT "\t\$(APLOCAL) 'post_make_all_hook()'\n"
+ if grep /post_make_all/, @{$mk->{hooks}};
+print MOUT "\n";
+}
+
+# Generate the targets for SUBDIRs
+foreach my $subdir (@{$mk->{subdirs}}) {
+ print MOUT "$subdir:\n";
+ print MOUT "\tcd $subdir && \$(MAKE) && cd ..\n";
+ print MOUT "\n";
+}
+
+# Generate the 'make install' target
+print MOUT "install: ".($subdirs ? 'recursive-install' : '') . "\n";
+print MOUT "\t\$(APLOCAL) 'pre_make_install_hook()'\n"
+ if grep /pre_make_install/, @{$mk->{hooks}};
+
+my $abspath = +{
+ '$(BINDIR)' => $mk->{bin_programs},
+ '$(SBINDIR)' => $mk->{sbin_programs},
+ };
+foreach my $base (keys %{$abspath}) {
+ foreach my $src ( @{$abspath->{$base}} ) {
+ my $dest = $src;
+ $dest =~ s/\.pl$//;
+ $dest = $base.'/' . $dest;
+ print MOUT "\t\$(INSTALL) -m 755 $src $dest\n";
+ }
+ }
+
+# Install all modules that the sources depend on
+foreach my $src ( keys %{$mk->{sources}} ) {
+ my @objs = @{$mk->{sources}->{$src}};
+ foreach my $obj (@objs) {
+ next unless $obj =~ /\.pm$/;
+ my $pkg_path = $mk->get_package_from_source($obj);
+ $pkg_path =~ s/::/\//g;
+ my $dest = "\$(LIBDIR)/$pkg_path.pm";
+ print MOUT "\t\$(INSTALL) -m 755 $obj $dest\n";
+ }
+}
+
+foreach my $script (@{$mk->{bin_scripts}}) {
+ print MOUT "\t\$(INSTALL) -m 755 $script \$(BINDIR)\n";
+}
+foreach my $script (@{$mk->{sbin_scripts}}) {
+ print MOUT "\t\$(INSTALL) -m 755 $script \$(SBINDIR)\n";
+}
+
+if (exists $mk->{targets}->{'install-exec-hook'}) {
+ print MOUT "\tmake install-exec-hook\n";
+}
+foreach my $manpage ($mk->get_all_manpages()) {
+ $manpage =~ /\.([0-9])(\.gz)?$/;
+ my $section = $1;
+ $manpage .= '.gz' unless defined $2;
+ print MOUT "\t\$(INSTALL) -m 644 ${manpage} " .
+ "\$(MANDIR)/man${section}/${manpage}\n"
+}
+foreach my $pkgdata (@{$mk->{pkgdata}}) {
+ print MOUT "\t\$(INSTALL) $pkgdata \$(PKGDATADIR)/$pkgdata\n";
+}
+foreach my $pkgdoc (@{$mk->{pkgdocs}}) {
+ print MOUT "\t\$(INSTALL) $pkgdoc \$(DOCDIR)/$pkgdoc\n";
+}
+if (exists $mk->{targets}->{'install-data-hook'}) {
+ print MOUT "\tmake install-data-hook\n";
+}
+
+# Install headers into $(includedir)
+print MOUT "\t\$(INSTALL) -d \$(INCLUDEDIR)\n" if (@{$mk->{headers}});
+foreach my $header (@{$mk->{headers}}) {
+ my $pkg_path = $mk->get_package_from_source($header)
+ or die 'error';
+ $pkg_path =~ s/::/\//g;
+ my $dest = "\$(INCLUDEDIR)/$pkg_path.pm";
+ print MOUT "\t\$(INSTALL) -m 644 $header $dest\n";
+}
+
+print MOUT "\t\$(APLOCAL) 'post_make_install_hook()'\n"
+ if grep /post_make_install/, @{$mk->{hooks}};
+
+print MOUT "\n";
+
+#-------------------------------------
+# Generate the 'make uninstall' target
+#-------------------------------------
+
+print MOUT "uninstall: ".($subdirs ? 'recursive-uninstall' : '') . "\n";
+print MOUT "\t\$(APLOCAL) 'pre_make_uninstall_hook()'\n"
+ if grep /pre_make_uninstall/, @{$mk->{hooks}};
+
+# Note: $abspath is defined in the 'install' target
+foreach my $base (keys %{$abspath}) {
+ foreach my $src ( @{$abspath->{$base}} ) {
+ my $dest = $src;
+ $dest =~ s/\.pl$//;
+ $dest = $base.'/' . $dest;
+ print MOUT "\trm $dest\n";
+ }
+ }
+
+# Uninstall all modules that the sources depend on
+foreach my $src ( keys %{$mk->{sources}} ) {
+ my @objs = @{$mk->{sources}->{$src}};
+ foreach my $obj (@objs) {
+ next unless $obj =~ /\.pm$/;
+ my $pkg_path = $mk->get_package_from_source($obj);
+ $pkg_path =~ s/::/\//g;
+ my $dest = "\$(LIBDIR)/$pkg_path.pm";
+ print MOUT "\trm $dest\n";
+ }
+}
+
+foreach my $script (@{$mk->{bin_scripts}}) {
+ print MOUT "\trm \$(BINDIR)/$script\n";
+}
+
+foreach my $script (@{$mk->{sbin_scripts}}) {
+ print MOUT "\trm \$(SBINDIR)/$script\n";
+}
+
+foreach my $manpage ($mk->get_all_manpages()) {
+ $manpage =~ /\.([0-9])(\.gz)?$/;
+ my $section = $1;
+ print MOUT "\trm \$(MANDIR)/man${section}/${manpage}.gz\n"
+ unless defined $2;
+}
+
+foreach my $pkgdata (@{$mk->{pkgdata}}) {
+ print MOUT "\trm \$(PKGDATADIR)/$pkgdata\n";
+}
+foreach my $pkgdoc (@{$mk->{pkgdocs}}) {
+ print MOUT "\trm \$(DOCDIR)/$pkgdoc\n";
+}
+
+# Uninstall headers from $(includedir)
+foreach my $header (@{$mk->{headers}}) {
+ my $pkg_path = $mk->get_package_from_source($header)
+ or die 'error';
+ $pkg_path =~ s/::/\//g;
+ my $dest = "\$(INCLUDEDIR)/$pkg_path.pm";
+ print MOUT "\trm $dest\n";
+}
+
+# Run the 'uninstall-hook' target
+if (exists $mk->{targets}->{'uninstall-hook'}) {
+ print MOUT "\tmake uninstall-hook\n";
+}
+
+print MOUT "\t\$(APLOCAL) 'post_make_uninstall_hook()'\n"
+ if grep /post_make_uninstall/, @{$mk->{hooks}};
+
+print MOUT "\n";
+#--------------------------------
+# Generate the 'make dist' target
+#
+print MOUT "dist: ".($subdirs ? 'recursive-dist' : '') . "\n";
+
+print MOUT "\t\$(APLOCAL) 'pre_make_dist_hook()'\n"
+ if grep /pre_make_dist/, @{$mk->{hooks}};
+
+# Initialize the buildd, if we are in TOPDIR
+my $buildd = '$(DISTDIR)';
+print MOUT "\tinstall -d -m 755 \$(DISTDIR)\n";
+
+# Install some optional files
+my @optional;
+foreach my $opt_fn (qw(configure package.in Makefile.am ChangeLog aplocal.inc
+ AUTHORS COPYING NEWS README BUGS THANKS)) {
+ push @optional, $opt_fn if -e "$curdir/$opt_fn";
+ }
+if (@optional) {
+ print MOUT "\t\$(INSTALL) " . join(" ",@optional) . " \$(DISTDIR)\n";
+}
+
+# Copy all extra dist, sources, headers, and manpages into buildd
+my @ifiles = ( $mk->get_all_sources(),
+ @{$mk->{headers}},
+ $mk->get_all_manpages(),
+ @{$mk->{extra_dist}},
+ @{$mk->{pkgdata}},
+ );
+foreach (@ifiles) {
+ print MOUT "\t\$(INSTALL) $_ $buildd/$_\n";
+}
+
+print MOUT "\t\$(APLOCAL) 'post_make_dist_hook()'\n"
+ if grep /post_make_dist/, @{$mk->{hooks}};
+
+# Create the tarball and clean up
+if ( $curdir eq '.' ) {
+ print MOUT "\ttar zcvf ".$mk->{top}->{program}."-".$mk->{version}.".tar.gz $buildd\n";
+ print MOUT "\trm -rf $buildd\n";
+}
+print MOUT "\n";
+
+#----- Generate the 'make package' target ------
+if ($mk eq $mk->{top}) {
+
+print MOUT "package: all\n";
+
+print MOUT "\t\$(APLOCAL) 'pre_make_package_hook()'\n"
+ if grep /pre_make_package/, @{$mk->{hooks}};
+
+print MOUT "\t\$(AUTOPERL) package\n";
+
+print MOUT "\t\$(APLOCAL) 'post_make_package_hook()'\n"
+ if grep /post_make_package/, @{$mk->{hooks}};
+
+print MOUT "\n";
+}
+
+#----- Generate the 'make clean' target ------
+if ( ! $mk->{targets}->{'clean-local'} ) {
+ print MOUT "clean: ".($subdirs ? 'recursive-clean' : '') . "\n";
+ print MOUT "\t\$(APLOCAL) 'pre_make_clean_hook()'\n"
+ if grep /pre_make_clean/, @{$mk->{hooks}};
+
+ my $derived = join(' ', @{$mk->{bin_programs}},
+ @{$mk->{sbin_programs}});
+ print MOUT "\trm -f $derived\n" if $derived;
+ print MOUT "\t\$(APLOCAL) 'post_make_clean_hook()'\n"
+ if grep /post_make_clean/, @{$mk->{hooks}};
+}
+print MOUT "\n";
+
+#----- Generate the 'make test' target -----
+print MOUT "test: ".($subdirs ? 'recursive-test' : '') . "\n";
+
+print MOUT "\t\$(APLOCAL) 'pre_make_test_hook()'\n"
+ if grep /pre_make_test/, @{$mk->{hooks}};
+
+# Try to compile all of the source code
+foreach my $src ( keys %{$mk->{sources}} ) {
+ my @objs = @{$mk->{sources}->{$src}};
+ foreach my $obj (@objs) {
+ next unless $obj =~ /\.pm$/;
+ my $pkg_path = $mk->get_package_from_source($obj);
+ print MOUT "\tperl -w -c $obj\n";
+ }
+}
+
+
+if ( -d "$curdir/t") {
+ print MOUT "\tcd t; \$(PERL) -e 'use Test::Harness; runtests(\@ARGV)' *.t\n";
+}
+
+print MOUT "\t\$(APLOCAL) 'post_make_test_hook()'\n"
+ if grep /post_make_test/, @{$mk->{hooks}};
+
+print MOUT "\n";
+
+#----- Append all user-defined targets --------
+my $user_defined = generate_synthetic_targets($mk);
+if ($user_defined) {
+ print MOUT "\n#--User defined targets--\n" . $user_defined;
+}
+
+}
+
+# Return a text string containing 'synthetic' targets
+sub generate_synthetic_targets($)
+{
+ my $mk = shift;
+ my $s;
+
+ foreach my $key (keys %{$mk->{targets}}) {
+ my $target = $key;
+ if ($target =~ /\-local$/) {
+ $target = $`;
+ }
+ $s .= "\n$target: " . $mk->{targets}->{$key}->{depends} . "\n" .
+ join("\n", @{$mk->{targets}->{$key}->{lines}}) . "\n";
+ }
+ return $s;
+}
+
+1;
+package Autoperl::Linker;
+
+use strict;
+use warnings;
+
+use Data::Dumper;
+BEGIN { import Autoperl::Logger; }
+
+sub new
+{
+ my $argv = shift;
+ my $self = +{
+ output => undef,
+ input => [],
+ };
+ bless $self, 'Autoperl::Linker';
+ $self->parse_argv($argv) if $argv;
+ return $self;
+}
+
+sub get_provides
+{
+ my $self = shift;
+ my $fake_mk = +{ curdir=>'.' }; #WORKAROUND
+
+ foreach my $srcfile (@{$self->{input}}) {
+ next unless $srcfile =~ /\.pm$/;
+ my $pkgname = Autoperl::Parser::get_package_from_source($fake_mk,$srcfile);
+ $self->{provides}->{$pkgname} = $srcfile;
+ }
+}
+
+sub parse_argv($$)
+{
+ my ($self,$s) = @_;
+
+ # Find the output file
+ my $output;
+ $s =~ /-o [A-za-z0-9\.]+/;
+ die 'output file required' unless $&;
+ $self->{output} = $&;
+ $s =~ s/$&//;
+ $self->{output} =~ s/^-o //;
+
+ # Get the input files
+ $s =~ s/^\s*//;
+ @{$self->{input}} = split / /, $s;
+}
+
+sub run_linker($)
+{
+ my $self = shift;
+ my @input = @{$self->{input}};
+ my $output = $self->{output} || die 'output undefined';
+ my $hr = '#' . '='x76 . "\n";
+
+ # Get the 'provides'
+ $self->get_provides();
+ my @provides = keys %{$self->{provides}};
+
+ # Determine the main module (it has a .pl extension)
+ my $main;
+ foreach (@input) {
+ if (/\.pl$/) {
+ die 'Cannot merge multiple .pl files' if $main;
+ $main = $_;
+ next;
+ }
+ }
+
+ # Read all input files and generate an ordered list of
+ # dependencies (@depends)
+ my %contents;
+ my @depends;
+ foreach my $fn (@input) {
+ open (my $infile, "<$fn") or die "$fn: $!";
+ my @buf = <$infile>;
+ close ($infile);
+ $contents{$fn} = \@buf;
+
+ # Special case: the main module is processed last
+ next if $fn eq $main;
+
+ # Scan for 'use()' statements for dependency ordering
+ foreach (@buf) {
+ /^\s*use ([A-Za-z0-9\_\-\:]+)/ or next;
+ grep /^$1$/, @provides or next;
+ my $dep_fn = $self->{provides}->{$1};
+ push @depends, $dep_fn unless grep /^$dep_fn$/, @depends;
+ }
+ }
+
+ # Paste each file into @lines
+ my @lines;
+ my @done;
+ debug("Combining inputs into a single buffer:");
+ foreach my $fn (@depends, @input, $main) {
+ next if grep /^$fn$/, @done;
+ die 'Internal error pasting '.$fn
+ unless exists $contents{$fn};
+ debug(" + $fn");
+ push @lines, @{$contents{$fn}};
+ push @done, $fn;
+ }
+ # Special case: header block from main goes at the top
+ my @header;
+ foreach my $line (@{$contents{$main}}) {
+ last unless $line =~ /^\s*#/ or $line =~ /^\s*$/;
+ push @header, $line;
+ }
+ unshift @lines, @header;
+
+ # Read config.h into $config_h
+ open (my $cfg,"<config.h") or die "config.h: $!";
+ my $config_h = join('', <$cfg>);
+ close ($cfg);
+
+ # Parse @lines, looking for 'use' or 'require' statements
+ for (my $x = 0; $x < $#lines; $x++) {
+ my $line = $lines[$x];
+
+ next unless $line =~ /^\s*(use|require) /;
+ $line =~ /^\s*(use|require) \"?([A-Za-z\.0-9\_\-\:]+)\"?( ?.*);/;
+ my ($method,$target,$imports) = ($1,$2,$3);
+ if (not $target) {
+ warn "parse error: \n$line";
+ next; #WORKAROUND
+ }
+ $imports = "" unless defined $imports;
+
+ # Substitute config.h
+ $lines[$x] = $config_h if $target eq 'config.h';
+
+ # Replace 'use <foo>' with 'import <foo>' for @provides
+ $lines[$x] = "BEGIN { import $target$imports; }\n"
+ if grep /$target/, @provides;
+ }
+
+ # Do sanity checks on the resulting buffer
+ warning("Bad executable; no shebang (#!) line detected")
+ unless $lines[0] =~ /^#!/;
+ $lines[0] = "#!/usr/bin/env perl\n" unless
+ $lines[0] =~ /env perl/;
+
+ for (my $x=0; $x<=$#lines; $x++) {
+ my $lineno = $output . ':' . ( $x + 1 ) . " ";
+ warning("$lineno Warning: __END__ marker detected")
+ if $lines[$x] =~ /^__END__/;
+ warning("$lineno Warning: __DATA__ marker detected")
+ if $lines[$x] =~ /^__DATA__/;
+ }
+
+ # Save the buffer to disk
+ open(my $outfile,">$output") or die "$output: $!";
+ print $outfile @lines;
+ close($outfile);
+ chmod 0755, $output or die "chmod $output: $!";
+
+}
+
+1;
+# exception.pm
+#
+# Exception handling
+#
+# NOTE: This module is intended to be require()d into any source file
+#
+
+package Autoperl::Exception;
+use Carp;
+use Exporter;
+
+our @ISA = 'Exporter';
+our @EXPORT = qw(assert raise apwarn);
+
+sub assert {
+ #TODO
+}
+
+sub raise {
+ print "autoperl: ERROR: " . join("\n",@_) . "\n";
+ confess();
+ exit(255);
+ }
+
+sub warn {
+ print "autoperl: WARNING: " . join("\n",@_) . "\n";
+ }
+
+1;
+# install.pl - Perl replacement for install(1)
+#
+# Adapted from Jon Ericson's BSD install(1) replacement at:
+#
+# http://backpan.cpan.org/authors/id/J/JE/JERICSON/install/install-1.31.pl
+#
+package Autoperl::Installer;
+
+# Generated by autoperl
+unless (defined $ap::CONFIG_H) {
+
+$ap::CONFIG_H = 1;
+%ap::config = (
+ '' => 1,
+ 'docdir' => '/usr/local/share/doc/autoperl',
+ 'mandir' => '/usr/local/man',
+ 'pkgdatadir' => '/usr/local/share/autoperl',
+ 'author' => 'Mark Heily <devel@heily.com>',
+ 'program' => 'autoperl',
+ 'infodir' => '/usr/local/info',
+ 'sysconfdir' => 'etc',
+ 'htmldir' => 'var/www',
+ 'bindir' => '/usr/local/bin',
+ 'confdir' => '/etc/autoperl',
+ 'libexecdir' => '/usr/local/libexec',
+ 'localedir' => '/usr/local/locale',
+ 'version' => '0.9.4',
+ 'cgidir' => 'usr/lib/cgi-bin',
+ 'includedir' => '/usr/local/lib/site_perl',
+ 'statedir' => '/var/lib/autoperl',
+ 'datadir' => '/usr/local/share',
+ 'sbindir' => '/usr/local/sbin',
+ 'libdir' => '/usr/local/lib/autoperl',
+ 'srcdir' => undef,
+ 'prefix' => '/usr/local'
+ );
+
+
+# Inconvenience hashref
+$ap::config = \%ap::config;
+}
+
+
+use strict;
+
+use Getopt::Long qw(:config bundling_override);
+use Pod::Usage;
+
+use File::Copy;
+use File::Basename;
+use File::Compare;
+use File::Spec::Functions ':ALL';
+
+sub makedirs;
+sub install;
+sub message;
+sub logaction;
+sub preaction;
+sub postaction;
+sub setmode;
+sub setgroup;
+sub setowner;
+
+
+my %opt = (
+ help =>0,
+ man => 0,
+ version => 0,
+ directory => 0,
+ backup => 0,
+ B => '.old',
+ force => 0,
+ compare => 0,
+ preserve => 0,
+ mode => undef,
+ owner => undef,
+ group => undef,
+ verbose => 0,
+ log => 'install.log',
+ pre => [],
+ post => [],
+);
+my $log;
+
+
+sub main {
+GetOptions (\%opt,
+ 'help|?',
+ 'man',
+ 'version',
+ 'directory|d',
+ 'backup|b',
+ 'B=s',
+ 'force|f',
+ 'compare|C',
+ 'preserve|p',
+ 'mode|m=s',
+ 'owner|o=s',
+ 'group|g=s',
+ 'verbose|v',
+ 'log=s',
+ 'pre=s',
+ 'post=s',
+ ) or pod2usage(1);
+pod2usage(1) if $opt{help};
+pod2usage(-exitstatus => 0, -verbose => 2) if $opt{man};
+
+
+if (defined $opt{log}) {
+ no strict 'refs';
+ open($log, ">> $opt{log}") or die "can't open $opt{log}: $!";
+};
+
+if (defined $opt{mode}){
+ my %likely = (
+ 777 => 1, 776 => 1, 775 => 1, 774 => 1, 766 => 1,
+ 755 => 1, 744 => 1, 700 => 1,
+ 666 => 1, 665 => 1, 664 => 1, 655 => 1, 644 => 1,
+ 600 => 1,
+ 555 => 1, 554 => 1, 544 => 1, 500 => 1,
+ 444 => 1, 400 => 1,
+ );
+
+ warn "$opt{mode} seems an unlikely mode"
+ unless $likely{sprintf "%d", $opt{mode}};
+};
+
+if ($opt{directory}) {
+ pod2usage("$0: not enough arguments") unless @ARGV > 0;
+
+ makedirs(@ARGV);
+} elsif (@ARGV == 2 && ! -d $ARGV[1]){
+ install $ARGV[0], $ARGV[1];
+} else {
+ pod2usage("$0: not enough arguments") unless @ARGV > 1;
+
+ my $dest = pop @ARGV;
+
+ pod2usage "$0: `$dest' is not a directory" unless -d $dest;
+
+ for (@ARGV){
+ my $base = basename($_);
+ my $target = catfile($dest, $base);
+
+ install $_, $target;
+ };
+};
+
+}
+
+sub makedirs{
+ # print "makedirs called with: @_\n";
+ for (@_) {
+
+ if(-d $_){
+ postaction($_);
+ next;
+ };
+
+ #print "trying $_\n";
+ if (-d dirname($_)) {
+ mkdir $_ or die "can't mkdir $_: $!";
+ message $_;
+ logaction "mkdir $_";
+ postaction $_;
+ }else {
+ makedirs(dirname($_), $_);
+ };
+ };
+};
+
+sub install{
+ my $source = shift;
+ my $target = shift;
+ my $base = basename($source);
+ my $target_dir = dirname($target);
+ my $old;
+
+# die "$source is not a file" unless -f $source;
+
+ preaction($source);
+
+ #FIXME - use makedirs
+ system "/usr/bin/install -d -m 755 $target_dir"
+ unless -d $target_dir;
+
+ if ($opt{compare} and compare($source, $target) == 0){
+ logaction "$source and $target are the same";
+ } else {
+ if ($opt{backup} && -f $target){
+ my $ext = $opt{B};
+ if ($ext eq 'numbered'){
+ $ext = 1;
+ while (-f "$target.$ext"){$ext++};
+ $ext = ".$ext";
+ };
+ $old = "$target$ext";
+
+ move $target => $old or die "can't move $target to $old: $!";
+ message $old;
+ logaction "$target => $old";
+ };
+
+ my ($dev, $ino) = (stat $source)[0,1];
+ if (-f $target && $dev == (stat $target)[0] && $ino == (stat _)[1]){
+ die "$source and $target are the same file";
+ };
+
+ my $copied = copy $source, $target;
+
+ unless ($copied){
+ if ($opt{force} && -f $target){
+ unlink $target or die "can't unlink $target:$!";
+ logaction "unlink $target";
+ $copied = copy $source, $target;
+ };
+ if ($opt{backup}) {
+ move $old => $target or die "can't move $old to $target: $!";
+ message "restoring $target from $old";
+ logaction "$old => $target";
+ }
+ };
+ die "can't copy $source to $target: $!" unless $copied;
+
+ message $target;
+ logaction "$source -> $target";
+
+ apsubst($target) if $source =~ /\.p[lm]$/;
+ };
+
+ # Code cribbed from
+ # <http://www.perl.com/language/ppt/src/cp/cp.schumacks>
+ if ($opt{preserve}){
+ my($mode, $uid, $gid, $atime, $mtime) = (stat $source)[2,4,5,8,9];
+ utime $atime, $mtime, $target or die "can't utime $target: $!";
+ my $oldmode = (07777 & $mode);
+ chmod $oldmode, $target or die "can't chmod $target: $!";
+ chown $uid, $gid, $target
+ or warn "can't chown $target to $mode: $!";
+ };
+
+ postaction($target);
+};
+
+sub preaction{
+ my $source = shift;
+ for my $pre (@{$opt{pre}}){
+ system "$pre $source" and die "--pre command `$pre' failed: $!";
+ logaction "$pre $source";
+ };
+};
+
+sub postaction{
+ my $target = shift;
+ setmode($opt{mode}, $target) if (defined $opt{mode});
+ setowner($opt{owner}, $target) if (defined $opt{owner});
+ setgroup($opt{group}, $target) if (defined $opt{group});
+
+ for my $post (@{$opt{post}}){
+ system "$post $target" and die "--post command `$post' failed: $!";
+ logaction "$post $target";
+ };
+
+};
+
+sub setmode{
+ my $mode = shift;
+ $mode = oct($mode);
+
+
+ for (@_){
+ chmod $mode, $_ or die "can't chmod $_ to $mode: $!";
+ logaction "chmod $mode, $_";
+ };
+
+};
+
+sub setowner{
+ my $owner = shift;
+ my $uid;
+
+ if ($owner =~ /^\d+$/) {
+ ($uid, $owner) = ($owner, getpwuid $owner);
+ die "can't getpwuid $uid: $!" unless defined $owner;
+ } else {
+ $uid = getpwnam $owner;
+ die "can't getpwnam $owner: $!" unless defined $uid;
+ }
+
+ for (@_){
+ chown $uid, -1, $_ or die "can't chown $_ to $owner: $!";
+ logaction "chown $uid, -1, $_";
+ };
+
+};
+
+sub setgroup{
+ my $group = shift;
+ my $gid;
+
+ if ($group =~ /^\d+$/) {
+ ($gid, $group) = ($group, getgrgid $group);
+ die "can't getgrnam $gid: $!" unless defined $group;
+ }else {
+ $gid = getgrnam $group;
+ die "can't getgrnam $group: $!" unless defined $gid;
+ }
+
+ for (@_){
+ chown -1, $gid, $_ or die "can't chown $_ to $group: $!";
+ logaction "chown -1, $gid, $_";
+ };
+
+};
+
+sub message{
+ print @_, "\n" if $opt{verbose};
+}
+
+sub logaction{
+ no strict 'refs';
+ print $log scalar gmtime, ': ', @_, "\n" if defined $opt{log};
+};
+
+sub apsubst{
+ my $target = shift;
+ my $found = 0;
+ my @src;
+
+ open(my $config_h, "<config.h") or die "config.h: $!";
+ my @config = <$config_h>;
+ close($config_h);
+
+ # The last line is '1;' which terminates processing. Don't include it.
+ pop @config;
+
+ my $repl = join('', @config);
+ open(my $input, "<$target") or die "open failed";
+ while (<$input>) {
+ if (/^\s*(require|do) \"config.h\";/) {
+ $_ = $repl;
+ $found++;
+ }
+ push @src, $_;
+ }
+ close ($input);
+ return unless $found;
+
+ # Rewrite the shebang line to point to $LIBDIR
+ if ($src[0] =~ /^\#\!(.*?)perl/ ) {
+ my $flags = $';
+ $flags = "" unless defined $flags;
+ chomp $src[0];
+ $src[0] = '#!' .
+ #FIXME- should be $ap::config->{perl} .
+ '/usr/bin/perl' .
+ ' -I'.$ap::config->{libdir} .
+ " $flags\n";
+ }
+
+ open(my $output, ">$target") or die "open failed";
+ print $output @src;
+ close ($output);
+}
+
+1;
diff --git a/dist_conf/kolab b/dist_conf/kolab
new file mode 100644
index 0000000..e50bff8
--- /dev/null
+++ b/dist_conf/kolab
@@ -0,0 +1,57 @@
+kolab_usr=kolab-n # @l_nusr@
+kolab_grp=kolab-n # @l_ngrp@
+kolab_uid=1002 # @l_nuid@
+kolab_gid=1002 # @l_ngid@
+restricted_kolab_usr=kolab-r # @l_rusr@
+restricted_kolab_grp=kolab-r # @l_rgrp@
+
+rcdir=${sysconfdir}/rc
+kolabd_usr=root
+
+clamav_socket=${localstatedir}/clamav/clamd.sock
+clamav_logfile=${localstatedir}/clamav/clamd.log
+clamav_pidfile=${localstatedir}/clamav/clamd.pid
+
+emailscan_usr=${restricted_kolab_usr}
+emailscan_grp=${restricted_kolab_grp}
+
+emailserver_socket=${localstatedir}/kolab/lmtp
+emailserver_localstatedir=${localstatedir}/postfix
+emailserver_imapdir=${localstatedir}/imapd
+emailserver_imapspooldir=${localstatedir}/imapd/spool
+emailserver_sievedir=${localstatedir}/imapd/sieve
+emailserver_sasl_conffile=${sysconfdir}/sasl/apps/smtpd.conf
+emailserver_usr=${kolab_usr}
+emailserver_grp=${restricted_kolab_grp}
+emailserver_mail_usr=kolab # = @l_musr@
+
+ftpserver_scoreboardfile=${localstatedir}/proftpd/score
+ftpserver_logfile=${localstatedir}/proftpd/proftpd.log
+ftpserver_confdir=${sysconfdir}/proftpd
+ftpserver_usr=${kolab_usr}
+ftpserver_grp=${kolab_grp}
+ftpserver_uid=19416
+ftpserver_gid=19416
+
+kolab_logdir=${localstatedir}/kolab/log
+kolab_pidfile=${localstatedir}/kolab/kolab.pid
+
+ldapserver_dir=${localstatedir}/openldap/openldap-data
+ldapserver_rundir=${localstatedir}/openldap/run
+ldapserver_schemadir=${sysconfdir}/openldap/schema
+ldapserver_replogfile=${localstatedir}/openldap/replog
+ldapserver_argsfile=${localstatedir}/openldap/slapd.args
+ldapserver_usr=
+ldapserver_grp=
+
+webserver_document_root=${localstatedir}/kolab/www
+webserver_logdir=${localstatedir}/apache/log
+webadmindir = ${webserver_document_root}/kolab
+webserver_confdir=${sysconfdir}/apache
+webserver_pidfile=${localstatedir}/apache/run/apache.pid
+webserver_mime_magicfile=${sysconfdir}/apache/mime.magic
+webserver_mime_typesfile=${sysconfdir}/apache/mime.types
+webserver_usr=${kolab_usr}
+webserver_grp=${kolab_grp}
+
+sysrundir = ${localstatedir}/run \ No newline at end of file
diff --git a/perl-kolab.spec b/perl-kolab.spec
index 37c8849..3661a7a 100644
--- a/perl-kolab.spec
+++ b/perl-kolab.spec
@@ -24,18 +24,7 @@
##
# versions of individual parts
-%define V_perl 5.8.5
-%define V_kolab 0.9.2
-%define V_kolab_util 0.9.2
-%define V_kolab_ldap 0.9.2
-%define V_kolab_ldap_backend 0.9.2
-%define V_kolab_ldap_backend_ad 0.9.2
-%define V_kolab_ldap_backend_slurpd 0.9.2
-%define V_kolab_ldap_backend_dirservd 0.9.2
-%define V_kolab_cyrus 0.9.2
-%define V_kolab_conf 0.9.2
-%define V_kolab_dirserv 0.9.2
-%define V_kolab_mailer 0.9.2
+
# package information
Name: perl-kolab
@@ -47,124 +36,44 @@ Distribution: OpenPKG
Class: PLUS
Group: Language
License: GPL/Artistic
-Version: %{V_perl}
-Release: 20050530
+Version: 0.9.2
+Release: 20050421
# list of sources
-Source0: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-%{V_kolab}.tar.gz
-Source1: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-Util-%{V_kolab_util}.tar.gz
-Source2: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-LDAP-%{V_kolab_ldap}.tar.gz
-Source3: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-LDAP-Backend-%{V_kolab_ldap_backend}.tar.gz
-Source4: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-LDAP-Backend-ad-%{V_kolab_ldap_backend_ad}.tar.gz
-Source5: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-LDAP-Backend-slurpd-%{V_kolab_ldap_backend_slurpd}.tar.gz
-Source6: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-LDAP-Backend-dirservd-%{V_kolab_ldap_backend_dirservd}.tar.gz
-Source7: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-Cyrus-%{V_kolab_cyrus}.tar.gz
-Source8: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-Conf-%{V_kolab_conf}.tar.gz
-Source9: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-DirServ-%{V_kolab_dirserv}.tar.gz
-Source10: http://www.cpan.org/authors/id/S/ST/STEPHANB/Kolab-Mailer-%{V_kolab_mailer}.tar.gz
+Source0: perl-kolab-0.9.2.tar.gz
# build information
Prefix: %{l_prefix}
BuildRoot: %{l_buildroot}
-BuildPreReq: OpenPKG, openpkg >= 2.0, perl >= %{V_perl}, perl-openpkg >= %{V_perl}
-PreReq: OpenPKG, openpkg >= 2.2.0, perl >= %{V_perl}, perl-openpkg >= %{V_perl}, perl-db, perl-mail, perl-ldap
+BuildPreReq: OpenPKG, openpkg >= 2.0, perl >= 0.9.2, perl-openpkg >= 0.9.2
+PreReq: OpenPKG, openpkg >= 2.2.0, perl >= 0.9.2, perl-openpkg >= 0.9.2, perl-db, perl-mail, perl-ldap
AutoReq: no
AutoReqProv: no
%description
Perl modules for use with the Kolab server
-%track
- prog perl-util:Kolab = {
- version = %{V_kolab}
- url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
- regex = Kolab-(__VER__)\.tar\.gz
- }
- prog perl-util:Kolab-Conf = {
- version = %{V_kolab_conf}
- url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
- regex = Kolab-Conf-(__VER__)\.tar\.gz
- }
- prog perl-util:Kolab-Cyrus = {
- version = %{V_kolab_cyrus}
- url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
- regex = Kolab-Cyrus-(__VER__)\.tar\.gz
- }
- prog perl-util:Kolab-DirServ = {
- version = %{V_kolab_dirserv}
- url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
- regex = Kolab-DirServ-(__VER__)\.tar\.gz
- }
- prog perl-util:Kolab-LDAP = {
- version = %{V_kolab_ldap}
- url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
- regex = Kolab-LDAP-(__VER__)\.tar\.gz
- }
- prog perl-util:Kolab-LDAP-Backend = {
- version = %{V_kolab_ldap_backend}
- url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
- regex = Kolab-LDAP-Backend-(__VER__)\.tar\.gz
- }
- prog perl-util:Kolab-LDAP-Backend-ad = {
- version = %{V_kolab_ldap_backend_ad}
- url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
- regex = Kolab-LDAP-Backend-ad-(__VER__)\.tar\.gz
- }
- prog perl-util:Kolab-LDAP-Backend-dirservd = {
- version = %{V_kolab_ldap_backend_dirservd}
- url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
- regex = Kolab-LDAP-Backend-dirservd-(__VER__)\.tar\.gz
- }
- prog perl-util:Kolab-LDAP-Backend-slurpd = {
- version = %{V_kolab_ldap_backend_slurpd}
- url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
- regex = Kolab-LDAP-Backend-slurpd-(__VER__)\.tar\.gz
- }
- prog perl-util:Kolab-Mailer = {
- version = %{V_kolab_mailer}
- url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
- regex = Kolab-Mailer-(__VER__)\.tar\.gz
- }
- prog perl-util:Kolab-Util = {
- version = %{V_kolab_util}
- url = http://www.cpan.org/authors/id/S/ST/STEPHANB/
- regex = Kolab-Util-(__VER__)\.tar\.gz
- }
-
%prep
- %setup -q -c
- %setup -q -T -D -a 1
- %setup -q -T -D -a 2
- %setup -q -T -D -a 3
- %setup -q -T -D -a 4
- %setup -q -T -D -a 5
- %setup -q -T -D -a 6
- %setup -q -T -D -a 7
- %setup -q -T -D -a 8
- %setup -q -T -D -a 9
- %setup -q -T -D -a 10
+
+%setup -n %{name}-%{version}
%build
+ %{configure} --prefix=/usr \
+ --includedir=%{perl_sitearch} \
+ --localstatedir=/var \
+ --sysconfdir=/etc \
+ --webadmindir=/srv/www/htdocs/kolab
+
+ make
%install
- %{l_prefix}/bin/perl-openpkg prepare
- %{l_prefix}/bin/perl-openpkg -d %{SOURCE0} configure build install
- %{l_prefix}/bin/perl-openpkg -d %{SOURCE1} configure build install
- %{l_prefix}/bin/perl-openpkg -d %{SOURCE2} configure build install
- %{l_prefix}/bin/perl-openpkg -d %{SOURCE3} configure build install
- %{l_prefix}/bin/perl-openpkg -d %{SOURCE4} configure build install
- %{l_prefix}/bin/perl-openpkg -d %{SOURCE5} configure build install
- %{l_prefix}/bin/perl-openpkg -d %{SOURCE6} configure build install
- %{l_prefix}/bin/perl-openpkg -d %{SOURCE7} configure build install
- %{l_prefix}/bin/perl-openpkg -d %{SOURCE8} configure build install
- %{l_prefix}/bin/perl-openpkg -d %{SOURCE9} configure build install
- %{l_prefix}/bin/perl-openpkg -d %{SOURCE10} configure build install
+ make DESTDIR=%{buildroot} install
%{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} `cat perl-openpkg-files`
%files -f files
%clean
- rm -rf $RPM_BUILD_ROOT
+ [ -d %{buildroot} -a "%{buildroot}" != "" ] && rm -rf %{buildroot}
diff --git a/perl-kolab.spec.in b/perl-kolab.spec.in
new file mode 100644
index 0000000..2cd10bf
--- /dev/null
+++ b/perl-kolab.spec.in
@@ -0,0 +1,79 @@
+##
+## perl-kolab.spec -- OpenPKG RPM Specification
+## Copyright (c) 2000-2004 The OpenPKG Project <http://www.openpkg.org/>
+## Copyright (c) 2000-2004 Ralf S. Engelschall <rse@engelschall.com>
+## Copyright (c) 2000-2004 Cable & Wireless <http://www.cw.com/>
+##
+## Permission to use, copy, modify, and distribute this software for
+## any purpose with or without fee is hereby granted, provided that
+## the above copyright notice and this permission notice appear in all
+## copies.
+##
+## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+## SUCH DAMAGE.
+##
+
+# versions of individual parts
+
+
+# package information
+Name: @PROGRAM@
+Summary: Perl Modules for use with the Kolab server
+URL: http://www.kolab.org
+Vendor: Code Fusion, Klaraelvdalens Datakonsult AB
+Packager: Klaraelvdalens Datakonsult AB
+Distribution: OpenPKG
+Class: PLUS
+Group: Language
+License: GPL/Artistic
+Version: @VERSION@
+Release: 20050421
+
+# list of sources
+Source0: perl-kolab-@VERSION@.tar.gz
+
+# build information
+Prefix: %{l_prefix}
+BuildRoot: %{l_buildroot}
+BuildPreReq: OpenPKG, openpkg >= 2.0, perl >= @VERSION@, perl-openpkg >= @VERSION@
+PreReq: OpenPKG, openpkg >= 2.2.0, perl >= @VERSION@, perl-openpkg >= @VERSION@, perl-db, perl-mail, perl-ldap
+AutoReq: no
+AutoReqProv: no
+
+%description
+ Perl modules for use with the Kolab server
+
+%prep
+
+%setup -n %{name}-%{version}
+
+
+%build
+ %{configure} --prefix=/usr \
+ --includedir=%{perl_sitearch} \
+ --localstatedir=/var \
+ --sysconfdir=/etc \
+ --webadmindir=/srv/www/htdocs/kolab
+
+ make
+
+%install
+ make DESTDIR=%{buildroot} install
+ %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
+ %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} `cat perl-openpkg-files`
+
+%files -f files
+
+%clean
+ [ -d %{buildroot} -a "%{buildroot}" != "" ] && rm -rf %{buildroot}
+