1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6eval {
7    require Module::Build;
8} or do {
9    die "error: Missing Module::Build module, cannot proceed.\n";
10};
11
12if (-e 'Build.PL.in') {
13    die "error: This is an in-tree build, not a proper perl distribution.\n" .
14        "To create one please configure normally and then run 'make dist'.\n";
15}
16
17my $class = Module::Build->subclass(
18    class => 'Module::Build::Dpkg',
19    code => q{
20        sub subst {
21            my ($self, $file) = @_;
22            my $path = $self->install_path();
23            my $version = $self->dist_version();
24
25            unlink "blib/$file"
26                or die "error: cannot remove blib/$file: $!\n";
27            open my $fhin, '<', $file
28                or die "error: cannot open $file: $!\n";
29            open my $fhout, '>', "blib/$file"
30                or die "error: cannot create blib/$file: $!\n";
31            while (<$fhin>) {
32                s{our \$PROGVERSION = .*;}{our \$PROGVERSION = '$version';};
33                s{our \$CONFDIR = .*;}{our \$CONFDIR = '$path->{conf}';};
34                s{our \$DATADIR = .*;}{our \$DATADIR = '$path->{data}';};
35                s{our \$ADMINDIR = .*;}{our \$ADMINDIR = '$path->{admin}';};
36                s{our \$LIBDIR = .*;}{our \$LIBDIR = '$path->{libexec}';};
37                print { $fhout } $_;
38            }
39            close $fhout or die "error: cannot write blib/$file: $!\n";
40            close $fhin;
41        }
42
43        sub ACTION_build {
44            my $self = shift;
45
46            $self->SUPER::ACTION_build;
47            $self->subst('lib/Dpkg.pm');
48        }
49        sub ACTION_test {
50            my $self = shift;
51
52            local $ENV{LANG} = 'C';
53            local $ENV{LC_ALL} = 'C';
54            local $ENV{DPKG_TEST_MODE} = 'cpan';
55            local $ENV{DPKG_DATADIR} = 'data';
56            local $ENV{DPKG_ORIGINS_DIR} = 't/origins';
57            $self->SUPER::ACTION_test;
58        }
59    },
60);
61
62my $build = $class->new(
63    dist_name       => '@PACKAGE_CPAN_NAME@',
64    dist_abstract   => 'Debian Package Manager Perl modules',
65    dist_version    => '@PACKAGE_VERSION@',
66    dist_author     => '@PACKAGE_COPYRIGHT_HOLDER@ <@PACKAGE_BUGREPORT@>',
67    license         => 'GPL_2',
68
69    release_status  => @PACKAGE_DIST_IS_RELEASE@ ? 'stable' : 'testing',
70
71    # Set only to avoid warnings.
72    module_name     => '@PACKAGE_CPAN_NAME@',
73
74    meta_merge => {
75        'meta-spec' => {
76            version => 2,
77        },
78        prereqs => {
79            test => {
80                recommends => {
81                    'Test::Pod'             => 0,
82                    'Test::Strict'          => 0,
83                },
84            },
85            develop => {
86                recommends => {
87                    'Test::MinimumVersion'  => 0,
88                    'Test::Perl::Critic'    => 0,
89                    'Test::Pod::Coverage'   => 0,
90                    'Test::Spelling'        => 0,
91                    'Test::Synopsis'        => 0,
92                },
93            },
94        },
95        resources => {
96            homepage => '@PACKAGE_URL@',
97            repository => {
98                type => '@PACKAGE_VCS_TYPE@',
99                url => '@PACKAGE_VCS_URL@',
100                web => '@PACKAGE_VCS_WEB@',
101            },
102            bugtracker => {
103                web => '@PACKAGE_BUG_WEB@',
104            },
105        },
106        keywords => [ qw(dpkg debian perl) ],
107    },
108
109    sign            => @PACKAGE_DIST_IS_RELEASE@,
110    dynamic_config  => 0,
111
112    configure_requires => {
113        'Module::Build'         => '0.4004',
114    },
115    test_requires => {
116        'TAP::Harness'          => 0,
117        'Test::More'            => 0,
118    },
119    recommends => {
120        'Algorithm::Merge'      => 0,
121        'File::FcntlLock'       => 0,
122        'Locale::gettext'       => 0,
123
124    },
125    requires => {
126        'perl'                  => '@PERL_MIN_VERSION@',
127    },
128
129    data_files => {
130        map { $_ => $_ } glob 'data/*'
131    },
132    install_path => {
133        conf => '/etc/dpkg',
134        data => '/usr/share/dpkg',
135        admin => '/var/lib/dpkg',
136        libexec => '/usr/lib/dpkg',
137    },
138);
139
140$build->add_build_element('data');
141$build->create_build_script();
142
1431;
144