use inc::Module::Install;

name 'Epoll';
all_from 'lib/Epoll/DB.pm';

requires 'Catalyst' => '5.7015';
requires 'Catalyst::Plugin::ConfigLoader';
requires 'Catalyst::Plugin::Static::Simple';
requires 'Catalyst::Action::RenderView';
requires 'Catalyst::Plugin::Session::State::Cookie';
requires 'Catalyst::Plugin::Session::Store::DBI';
requires 'Catalyst::Plugin::Static::Simple';
requires 'Catalyst::Plugin::ConfigLoader';
requires 'Catalyst::Plugin::Prototype';
requires 'Catalyst::View::TT';

requires 'YAML'; # This should reflect the config file format you've chosen
                 # See Catalyst::Plugin::ConfigLoader for supported formats

# out of catalyst
requires 'XML::Simple';
requires 'Crypt::CBC';
requires 'Crypt::DES_EDE3';
requires 'Crypt::RSA';
requires 'DBI';
requires 'DBD::Pg';
requires 'MIME::Base64';
requires 'Mail::Mailer';
requires 'LaTeX::Driver';

catalyst;

install_script glob('script/*.pl');
auto_install;
WriteAll;

package MY;

sub distdir {
    my $dist = shift->SUPER::distdir(@_);
    $dist =~ s/^(create_distdir :.*)/$1 md5sum/m;
    $dist
}

sub dist_core {
    my $dist = shift->SUPER::dist_core(@_);
    $dist =~ s/^(\S.* :.*)/$1 md5sum/mg;
    $dist
}

sub postamble {
    return "

svnmanifest:
\tsvn ls -R| grep -v '/\$\$'  > MANIFEST

md5sum:
\tcat MANIFEST | sed 's/\\t.*//' | grep -v control/md5sum | xargs md5sum > control/md5sum

checkmd5:
\tmd5sum -c control/md5sum

.PHONY: md5sum checkmd5 svnmanifest

ChangeLog:
\tsvn log > ChangeLog

epoll.spec: epoll.spec.in Makefile
\tsed -e 's/\@VERSION@/\$(VERSION)/' < \$< > \$@

rpm: \$(DISTVNAME).tar.gz epoll.spec
\tmkdir ./noarch || :
\trpmbuild -ba --clean\\
\t --define \"_sourcedir `pwd`\" \\
\t --define \"_specdir `pwd`\" \\
\t --define \"_srcrpmdir `pwd`\" \\
\t --define \"_rpmdir `pwd`\" \\
\t epoll.spec
"
}
