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