root/branches/new-install-process/Build.PL

Revision 1170, 4.5 kB (checked in by kake, 5 months ago)

Added missing prereq of Term::Prompt; removed some hardcoding.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1use File::Copy;
2use File::Spec;
3use Module::Build;
4use strict;
5
6# This magically subclasses Module::Build. We override the install action
7# to install the template files for us.
8my $class = Module::Build->subclass(
9  code => q{
10    sub ACTION_install {
11      my $self = shift;
12      my $ret = $self->SUPER::ACTION_install(@_);
13
14      # Slightly hacky. We require one of the modules that we just installed.
15      # then, we pull its path out of %INC, strip off the filename, and
16      # install the templates there. Well, they have to go _somewhere_, and
17      # perl doesn't have a good place for this stuff otherwise.
18
19      require OpenGuides or die;
20      my (undef, $path, undef) = File::Spec->splitpath($INC{'OpenGuides.pm'});
21
22      mkdir( File::Spec->catfile( $path, "OpenGuides" ) );
23      die "Can't make template install folder: $!\n" unless (-d File::Spec->catfile( $path, "OpenGuides" ) );
24
25      my $templ_dir = File::Spec->catfile( $path, "OpenGuides", "templates" );
26
27      mkdir( $templ_dir );
28      die "Can't make template install folder: $!\n" unless (-d $templ_dir );
29
30      print "Installing templates to $templ_dir\n";
31      opendir TEMPLATES, "templates"
32        or die "Can't open template source folder: $!\n";
33
34      for (grep { /\.(tt)$/ } readdir(TEMPLATES)) {
35        #print "  installing template $_\n";
36        File::Copy::copy(
37          File::Spec->catfile( "templates", $_ ),
38          File::Spec->catfile( $templ_dir, $_ )
39        ) or die "Error copying $_: $!\n";;
40      }
41      closedir(TEMPLATES);
42      print "Done!\n";
43
44      return $ret;
45    }
46  },
47);
48
49#####
50##### When updating the prereqs PLEASE REMEMBER to update PREREQUISITES.
51#####
52
53# Create the build object.
54my $build = $class->new(
55    sign => 1,
56    dist_name => "OpenGuides",
57    module_name => "OpenGuides",
58    dist_version_from => "lib/OpenGuides.pm",
59    license => "perl",
60    requires => {
61        'Algorithm::Diff'                     => '0.13'# for sdiff
62        'CGI'                                 => '2.92'# avoid escapeHTML bug
63        'CGI::Carp'                           => 0,
64        'CGI::Cookie'                         => 0,
65        'Wiki::Toolkit'                       => '0.74'# for dbport
66        'Wiki::Toolkit::Feed::Atom'           => 0,
67        'Wiki::Toolkit::Feed::RSS'            => 0,
68        'Wiki::Toolkit::Formatter::UseMod'    => 0,
69        'Wiki::Toolkit::Plugin::Categoriser'  => 0,
70        'Wiki::Toolkit::Plugin::Diff'         => 0,
71        'Wiki::Toolkit::Plugin::Locator::Grid'=> 0,
72        'Wiki::Toolkit::Plugin::RSS::Reader'  => 0,
73        'Class::Accessor'                     => 0,
74        'Config::Tiny'                        => 0,
75        'Data::Dumper'                        => 0,
76        'File::Spec::Functions'               => 0,
77        'File::Temp'                          => 0,
78        'Geo::Coordinates::UTM'               => 0,
79        'Geography::NationalGrid'             => 0,
80        'HTML::Entities'                      => 0,
81        'LWP::Simple'                         => 0,
82        'MIME::Lite'                          => 0,
83        'Parse::RecDescent'                   => 0,
84        'POSIX'                               => 0,
85        'Template'                            => '2.15', # for hash.delete and string.remove vmethods
86        'Term::Prompt'                        => 0,
87        'Time::Piece'                         => 0,
88        'URI::Escape'                         => 0,
89        'XML::RSS'                            => 0,
90        },
91    build_requires => {
92        'Module::Build' => '0.26', # API change for accessing config data
93        },
94    recommends => {
95        'DBD::SQLite'         => 0, # for testing
96        'Test::HTML::Content' => 0, # for testing, oddly enough
97        'Wiki::Toolkit::Plugin::Ping' => 0, # for pinging external services
98        'Geo::HelmertTransform'  => 0,      # for correct WGS84 lat/long
99                                            # when using grid systems
100        'Plucene'             => 0,
101
102    },
103    create_makefile_pl => "passthrough",
104    script_files => [
105                      "bin/openguides-install",
106                      "bin/openguides-newpage-script",
107                      "bin/openguides-preferences-script",
108                      "bin/openguides-search-script",
109                      "bin/openguides-wiki-script",
110                    ],
111);
112
113$build->add_to_cleanup( "t/indexes/" );
114$build->add_to_cleanup( "t/node.db" );
115$build->add_to_cleanup( "t/templates/tmp/" );
116
117# Finally write the build script.
118$build->create_build_script;
Note: See TracBrowser for help on using the browser.