CPAN-Patches-Plugin-Debian
view release on metacpan or search on metacpan
lib/CPAN/Patches/Plugin/Debian.pm view on Meta::CPAN
package CPAN::Patches::Plugin::Debian;
use warnings;
use strict;
our $VERSION = '0.03';
use Moose::Role;
use Carp 'croak';
use IO::Any;
use Scalar::Util 'blessed';
use File::Path 'make_path';
use Storable 'dclone';
use Test::Deep::NoTest 'eq_deeply';
use File::Copy 'copy';
use Parse::Deb::Control '0.03';
use File::chdir;
use Debian::Dpkg::Version 'version_compare';
use CPAN::Patches 0.04;
use File::Basename 'basename';
sub update_debian {
my $self = shift;
my $path = shift || '.';
$self = $self->new()
if not blessed $self;
my $debian_path = File::Spec->catdir($path, 'debian');
my $debian_patches_path = File::Spec->catdir($debian_path, 'patches');
my $debian_control_filename = File::Spec->catdir($debian_path, 'control');
croak 'debian/ folder not found'
if not -d $debian_path;
my $meta = $self->read_meta($path);
my $name = $self->clean_meta_name($meta->{'name'}) or croak 'no name in meta';
my $debian_data = $self->read_debian_control($name);
my $deb_control = Parse::Deb::Control->new([$debian_control_filename]);
die $name.' has disabled auto build'
if $debian_data->{'No-Auto'};
my @series = $self->get_patch_series($name);
if (@series) {
# apply patches to the source (quilt 3.0 source format)
$self->patch($path);
make_path($debian_patches_path)
if not -d $debian_patches_path;
foreach my $patch_filename (@series) {
print 'copy ', $patch_filename,' to ', $debian_patches_path, "\n"
if $self->verbose;
copy($patch_filename, $debian_patches_path) or die $!;
}
IO::Any->spew(
[$debian_patches_path, 'series'],
join(
"\n",
map { basename($_) } @series
)."\n"
);
}
# write new debian/rules
IO::Any->spew(
[$debian_path, 'rules'],
"#!/usr/bin/make -f\n\n"
.($debian_data->{'X'} ? "override_dh_auto_test:\n xvfb-run -a dh_auto_test\n\n" : '')
."%:\n "
.'dh $@'
."\n"
);
# if there are patches set the format to quilt 3.0
if (@series) {
my $debian_source_folder = File::Spec->catdir($debian_path, 'source');
mkdir($debian_source_folder)
if (not -d $debian_source_folder);
IO::Any->spew(
[$debian_path, 'source', 'format'],
( run in 1.807 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )