Rex-Apache-Deploy
view release on metacpan or search on metacpan
lib/Rex/Apache/Build/deb.pm view on Meta::CPAN
$name ||= $self->{name};
my $version = $self->version;
my $old_dir = getcwd;
mkdir "temp-deb-build";
mkdir "temp-deb-build/control";
mkdir "temp-deb-build/tree";
$self->copy_files_to_tmp;
file "temp-deb-build/debian-binary",
content => "2.0\n";
file "temp-deb-build/control/control",
content => template('@control.file', pkg => $self);
file "temp-deb-build/control/md5sums",
content => $self->get_md5sums;
$self->create_config_files;
$self->create_scripts;
$self->package_data;
$self->package_control;
rmdir "temp-deb-build/tree";
rmdir "temp-deb-build/control";
chdir "temp-deb-build";
my $arch = $self->{arch};
my $package_name = "${name}_${version}_${arch}.deb";
run "ar -qc ../$package_name debian-binary control.tar.gz data.tar.gz";
chdir "..";
rmdir "temp-deb-build";
Rex::Logger::info("Your build is now available: $package_name");
return $package_name;
}
sub create_config_files {
my ($self) = @_;
if($self->{config_files}) {
file "temp-deb-build/control/conffiles",
content => join("\n", @{ $self->{config_files} });
}
}
sub create_scripts {
my ($self) = @_;
if($self->{post_install}) {
my $post_install = $self->{post_install};
if($post_install !~ m/\n/sim && -f $post_install) {
$post_install = eval { local(@ARGV, $/) = ($post_install); <>; };
}
file "temp-deb-build/control/postinst",
content => $post_install,
mode => 755;
}
if($self->{pre_install}) {
my $pre_install = $self->{pre_install};
if($pre_install !~ m/\n/sim && -f $pre_install) {
$pre_install = eval { local(@ARGV, $/) = ($pre_install); <>; };
}
file "temp-deb-build/control/preinst",
content => $pre_install,
mode => 755;
}
if($self->{post_uninstall}) {
my $post_uninstall = $self->{post_uninstall};
if($post_uninstall !~ m/\n/sim && -f $post_uninstall) {
$post_uninstall = eval { local(@ARGV, $/) = ($post_uninstall); <>; };
}
file "temp-deb-build/control/postrm",
content => $post_uninstall,
mode => 755;
}
if($self->{pre_uninstall}) {
my $pre_uninstall = $self->{pre_uninstall};
if($pre_uninstall !~ m/\n/sim && -f $pre_uninstall) {
$pre_uninstall = eval { local(@ARGV, $/) = ($pre_uninstall); <>; };
}
file "temp-deb-build/control/prerm",
content => $pre_uninstall,
mode => 755;
}
}
sub package_data {
my ($self) = @_;
chdir "temp-deb-build/tree";
run "tar czf ../data.tar.gz .";
chdir "../../";
}
sub package_control {
my ($self) = @_;
chdir "temp-deb-build/control";
run "tar czf ../control.tar.gz .";
chdir "../../";
}
sub copy_files_to_tmp {
my ($self) = @_;
my $prefix = $self->prefix || ".";
mkdir "temp-deb-build/tree/$prefix";
my @dirs = ($self->{source});
for my $dir (@dirs) {
opendir(my $dh, $dir) or die($!);
DIR_ENTRY: while(my $entry = readdir($dh)) {
next if ($entry eq "." or $entry eq ".." or $entry eq "temp-deb-build");
for my $ex (@{ $self->exclude }) {
if($entry =~ m/$ex/) {
next DIR_ENTRY;
}
}
my $new_dir = "$dir/$entry";
$new_dir =~ s/^$dirs[0]//;
$new_dir =~ s/^\///;
if(-d "$dir/$entry") {
mkdir "temp-deb-build/tree$prefix/$new_dir";
push(@dirs, "$dir/$entry");
next DIR_ENTRY;
}
cp "$dir/$entry", "temp-deb-build/tree$prefix/$new_dir";
} # DIR_ENTRY
( run in 0.912 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )