Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial

  • Loading branch information...
commit 1787418924ea2b876a4e0599fb618a7fc753a815 0 parents
@jozef authored
14 .gitignore
@@ -0,0 +1,14 @@
+/Makefile
+/blib
+/pm_to_blib
+/META.yml
+/MYMETA.yml
+/Makefile.PL
+/Build
+/_build
+/*.tar.gz
+/MANIFEST.bak
+/cover_db
+/tmp/*
+/CPAN-Patches-*
+/sharedstate/cpan-patches/*
57 Build.PL
@@ -0,0 +1,57 @@
+use strict;
+use warnings;
+use Module::Build::SysPath;
+
+use 5.010;
+
+my $builder = Module::Build::SysPath->new(
+ module_name => 'CPAN::Patches::Plugin::Debian',
+ license => 'perl',
+ dist_author => 'Jozef Kutej <jkutej@cpan.org>',
+ dist_version_from => 'lib/CPAN/Patches/Plugin/Debian.pm',
+
+ configure_requires => {
+ 'Module::Build::SysPath' => 0.13,
+ },
+ build_requires => {
+ 'Module::Build::SysPath' => 0.13,
+ 'Test::More' => 0,
+ },
+ requires => {
+ 'Moose::Role' => 0,
+ 'IO::Any' => 0,
+ 'Parse::Deb::Control' => 0.03,
+ 'Carp' => 0,
+ 'Getopt::Long' => 0,
+ 'Pod::Usage' => 0,
+ 'File::Path' => 2.01,
+ 'Storable' => 0,
+ 'File::Copy' => 0,
+ 'File::chdir' => 0,
+ 'Scalar::Util' => 0,
+ 'Storable' => 0,
+ 'Test::Deep::NoTest' => 0,
+ 'Dpkg::Version' => 0,
+ 'CPAN::Patches' => 0,
+ 'File::Basename' => 0,
+ 'Path::Class' => 0,
+ 'List::MoreUtils' => 0,
+ 'File::is' => 0,
+ 'File::Spec' => 0,
+ },
+ script_files => [
+ 'script/cpan-patches-update-from-debian',
+ ],
+ add_to_cleanup => [ 'CPAN-Patches-Plugin-Debian-*' ],
+ create_readme => 1,
+ sign => 1,
+ meta_merge => {
+ resources => {
+ repository => 'git://github.com/jozef/CPAN-Patches-Plugin-Debian.git',
+ bugtracker => 'http://github.com/jozef/CPAN-Patches-Plugin-Debian/issues',
+ },
+ keywords => [ qw/ cpan patch debian / ],
+ },
+);
+
+$builder->create_build_script();
5 Changes
@@ -0,0 +1,5 @@
+Revision history for CPAN-Patches
+
+0.01 1 Mar 2010
+ * created via removing Debian specific code from CPAN::Patches
+
16 MANIFEST
@@ -0,0 +1,16 @@
+Build.PL
+Changes
+lib/CPAN/Patches/Plugin/Debian.pm
+lib/CPAN/Patches/Plugin/Debian/SPc.pm
+MANIFEST This list of files
+META.yml
+README
+script/cpan-patches-update-from-debian
+sharedstate/cpan-patches/debian-set/.exists
+sharedstate/cpan-patches/pkg-perl-trunk/.exists
+t/00_compile.t
+t/distribution.t
+t/fixme.t
+t/pod-coverage.t
+t/pod-spell.t
+t/pod.t
38 MANIFEST.SKIP
@@ -0,0 +1,38 @@
+# Avoid version control files.
+\bRCS\b
+\bCVS\b
+,v$
+\B\.svn\b
+^\.git
+\.cvsignore
+\.svnignore
+
+# Avoid Makemaker generated and utility files.
+^Makefile$
+\bblib
+\bMakeMaker-\d
+\bpm_to_blib$
+\bblibdirs$
+^MANIFEST\.(SKIP|bak)$
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\b_build
+\bcover_db
+
+# Avoid temp and backup files.
+~$
+\.tmp$
+\.old$
+\.bak$
+\#$
+\b\.#
+
+^tmp/
+.*\.tar\.gz
+^MYMETA.yml$
+^CPAN-Patches-
+sharedstate/cpan-patches/set/[^.]
+sharedstate/cpan-patches/debian-set/[^.]
+sharedstate/cpan-patches/pkg-perl-trunk/[^.]
+
86 README
@@ -0,0 +1,86 @@
+NAME
+ CPAN::Patches::Plugin::Debian - patch CPAN distributions Debian package
+
+SYNOPSIS
+ cd Some-Distribution
+ dh-make-perl
+ cpan-patches list
+ cpan-patches update-debian
+ cpan-patches --patch-set $HOME/cpan-patches-set list
+ cpan-patches --patch-set $HOME/cpan-patches-set update-debian
+
+DESCRIPTION
+ This module allows to apply custom patches to the CPAN distributions
+ Debian package.
+
+ See http://github.com/jozef/CPAN-Patches-Debian-Set for example
+ generated Debian patches set folder.
+
+METHODS
+ update_debian
+ Copy all patches and series file from .../module-name/patches/ to
+ debian/patches folder. If there are any patches add `quilt' as
+ `Build-Depends-Indep' and runs adds `--with quilt' to debian/rules. Adds
+ dependencies from .../module-name/debian, adds usage of `xvfb-run' if
+ the modules requires X and renames `s/lib(.*)-perl/$1/' if the
+ distribution is an application.
+
+cpan-patches CMD
+ cmd_update_debian
+ See update_debian.
+
+INTERNAL METHODS
+ merge_debian_versions($v1, $v2)
+ Merges dependecies from `$v1' and `$v2' by keeping the ones that has
+ higher version (if the same).
+
+ get_deb_package_names($control, $key)
+ Return hash with package name as key and version string as value for
+ given `$key' in Debian `$control' file.
+
+ read_debian($name)
+ Read .../module-name/debian for given `$name'.
+
+ decode_debian($src)
+ Parses .../module-name/debian into a hash. Returns hash reference.
+
+ encode_debian($data)
+ Return .../module-name/debian content string generated from `$data'.
+
+AUTHOR
+ jozef@kutej.net, `<jkutej at cpan.org>'
+
+BUGS
+ Please report any bugs or feature requests to `bug-cpan-patches at
+ rt.cpan.org', or through the web interface at
+ http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPAN-Patches. I will be
+ notified, and then you'll automatically be notified of progress on your
+ bug as I make changes.
+
+SUPPORT
+ You can find documentation for this module with the perldoc command.
+
+ perldoc CPAN::Patches
+
+ You can also look for information at:
+
+ * RT: CPAN's request tracker
+ http://rt.cpan.org/NoAuth/Bugs.html?Dist=CPAN-Patches
+
+ * AnnoCPAN: Annotated CPAN documentation
+ http://annocpan.org/dist/CPAN-Patches
+
+ * CPAN Ratings
+ http://cpanratings.perl.org/d/CPAN-Patches
+
+ * Search CPAN
+ http://search.cpan.org/dist/CPAN-Patches/
+
+ACKNOWLEDGEMENTS
+LICENSE AND COPYRIGHT
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of either: the GNU General Public License as published
+ by the Free Software Foundation; or the Artistic License.
+
+ See http://dev.perl.org/licenses/ for more information.
+
386 lib/CPAN/Patches/Plugin/Debian.pm
@@ -0,0 +1,386 @@
+package CPAN::Patches::Plugin::Debian;
+
+=head1 NAME
+
+CPAN::Patches::Plugin::Debian - patch CPAN distributions Debian package
+
+=head1 SYNOPSIS
+
+ cd Some-Distribution
+ dh-make-perl
+ cpan-patches list
+ cpan-patches update-debian
+ cpan-patches --patch-set $HOME/cpan-patches-set list
+ cpan-patches --patch-set $HOME/cpan-patches-set update-debian
+
+=head1 DESCRIPTION
+
+This module allows to apply custom patches to the CPAN distributions
+Debian package.
+
+See L<http://github.com/jozef/CPAN-Patches-Debian-Set> for example generated
+Debian patches set folder.
+
+=cut
+
+use warnings;
+use strict;
+
+our $VERSION = '0.01';
+
+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 Dpkg::Version 'version_compare';
+
+=head1 METHODS
+
+=head2 update_debian
+
+Copy all patches and F<series> file from F<.../module-name/patches/> to
+F<debian/patches> folder. If there are any patches add C<quilt> as
+C<Build-Depends-Indep> and runs adds C<--with quilt> to F<debian/rules>.
+Adds dependencies from F<.../module-name/debian>, adds usage of C<xvfb-run>
+if the modules requires X and renames C<s/lib(.*)-perl/$1/> if the distribution
+is an application.
+
+=cut
+
+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($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) {
+ 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);
+ }
+ IO::Any->spew([$debian_patches_path, 'series'], join("\n", @series));
+ }
+
+ # write new debian/rules
+ IO::Any->spew(
+ [$debian_path, 'rules'],
+ "#!/usr/bin/make -f\n\n%:\n "
+ .($debian_data->{'X'} ? 'xvfb-run -a ' : '')
+ .'dh '.(@series ? '--with quilt ': '').'$@'
+ ."\n"
+ );
+
+ # update dependencies
+ foreach my $dep_type ('Depends', 'Build-Depends', 'Build-Depends-Indep') {
+ my $dep = {CPAN::Patches->get_deb_package_names($deb_control, $dep_type)};
+ my $new_dep = CPAN::Patches->merge_debian_versions($dep, $debian_data->{$dep_type} || {});
+
+ if ($debian_data->{'X'} and ($dep_type eq 'Build-Depends-Indep')) {
+ $new_dep->{'xauth'} = '';
+ $new_dep->{'xvfb'} = '';
+ }
+ if (@series and ($dep_type eq 'Build-Depends-Indep')) {
+ $new_dep->{'quilt'} = '';
+ }
+
+ # update if dependencies if needed
+ if (not eq_deeply($dep, $new_dep)) {
+ my ($control_key) = $deb_control->get_keys($dep_type =~ m/Build/ ? 'Source' : 'Package');
+ next if not $control_key;
+
+ my $new_value =
+ ' '.(
+ join ', ',
+ map { $_.($new_dep->{$_} ? ' '.$new_dep->{$_} : '') }
+ sort
+ keys %{$new_dep}
+ )."\n"
+ ;
+ $control_key->{'para'}->{$dep_type} = $new_value;
+ }
+ }
+ IO::Any->spew([$debian_control_filename], $deb_control->control);
+
+ if (my $app_name = $debian_data->{'App'}) {
+ local $CWD = $debian_path;
+ my $lib_name = 'lib'.$name.'-perl';
+ system(q{perl -lane 's/}.$lib_name.q{/}.$app_name.q{/;print' -i *});
+ foreach my $filename (glob($lib_name.'*')) {
+ rename($filename, $app_name.substr($filename, 0-length($lib_name)));
+ }
+ }
+
+
+ return;
+}
+
+=head1 cpan-patches CMD
+
+=head2 cmd_update_debian
+
+See L</update_debian>.
+
+=cut
+
+sub cmd_update_debian {
+ shift->update_debian();
+}
+
+
+=head1 INTERNAL METHODS
+
+=head2 merge_debian_versions($v1, $v2)
+
+Merges dependecies from C<$v1> and C<$v2> by keeping the ones that has
+higher version (if the same).
+
+=cut
+
+sub merge_debian_versions {
+ my $self = shift;
+ my $versions1_orig = shift or die;
+ my $versions2 = shift or die;
+
+ my $versions1 = dclone $versions1_orig;
+
+ while (my ($p, $v2) = each %{$versions2}) {
+ if (exists $versions1->{$p}) {
+ next if not $v2;
+ my $v1 = $versions1->{$p} || '(>= 0)';
+ if ($v1 !~ m/\(\s* >= \s* ([^\)]+?) \s*\)/xms) {
+ warn 'invalid version '.$v1.' in conflic resolution';
+ die;
+ next;
+ }
+ my $v1n = $1;
+ if ($v2 !~ m/\(\s* >= \s* ([^\)]+?) \s*\)/xms) {
+ warn 'invalid version '.$v2.' in conflic resolution';
+ die;
+ next;
+ }
+ my $v2n = $1;
+
+ # only when newer version is needed
+ $versions1->{$p} = $v2
+ if version_compare($v2n, $v1n) == 1;
+ }
+ else {
+ $versions1->{$p} = $v2;
+ }
+ }
+
+ return $versions1;
+}
+
+=head2 get_deb_package_names($control, $key)
+
+Return hash with package name as key and version string as value for
+given C<$key> in Debian C<$control> file.
+
+=cut
+
+sub get_deb_package_names {
+ my $self = shift;
+ my $control = shift or croak 'pass control object';
+ my $key = shift or croak 'pass key name';
+
+ return
+ map {
+ my ($p, $v) = split('\s+', $_, 2);
+ $v ||= '';
+ ($p => $v)
+ }
+ grep { $_ }
+ map { s/^\s*//;$_; }
+ map { s/\s*$//;$_; }
+ map { split(',', $_) }
+ map { ${$_->{'value'}} }
+ $control->get_keys($key)
+ ;
+}
+
+=head2 read_debian($name)
+
+Read F<.../module-name/debian> for given C<$name>.
+
+=cut
+
+sub read_debian {
+ my $self = shift;
+ my $name = shift or croak 'pass name param';
+
+ my $debian_filename = File::Spec->catfile($self->patch_set_location, $name, 'debian');
+ return {}
+ if not -r $debian_filename;
+
+ return $self->decode_debian([$debian_filename]);
+}
+
+=head2 decode_debian($src)
+
+Parses F<.../module-name/debian> into a hash. Returns hash reference.
+
+=cut
+
+sub decode_debian {
+ my $self = shift;
+ my $src = shift or die 'pass source';
+
+ my $deb_control = Parse::Deb::Control->new($src);
+ my %depends = CPAN::Patches->get_deb_package_names($deb_control, 'Depends');
+ my %build_depends = CPAN::Patches->get_deb_package_names($deb_control, 'Build-Depends');
+ my %build_depends_indep = CPAN::Patches->get_deb_package_names($deb_control, 'Build-Depends-Indep');
+ my ($app) =
+ map { s/^\s*//;$_; }
+ map { s/\s*$//;$_; }
+ map { ${$_->{'value'}} }
+ $deb_control->get_keys('App')
+ ;
+ my ($x_for_testing) =
+ map { s/^\s*//;$_; }
+ map { s/\s*$//;$_; }
+ map { ${$_->{'value'}} }
+ $deb_control->get_keys('X')
+ ;
+ my ($no_auto) =
+ map { s/^\s*//;$_; }
+ map { s/\s*$//;$_; }
+ map { ${$_->{'value'}} }
+ $deb_control->get_keys('No-Auto')
+ ;
+
+
+ return {
+ 'Depends' => \%depends,
+ 'Build-Depends' => \%build_depends,
+ 'Build-Depends-Indep' => \%build_depends_indep,
+ (defined $app ? ('App' => $app) : ()),
+ (defined $x_for_testing ? ('X' => $x_for_testing) : ()),
+ (defined $no_auto ? ('No-Auto' => $no_auto) : ()),
+ };
+}
+
+=head2 encode_debian($data)
+
+Return F<.../module-name/debian> content string generated from C<$data>.
+
+=cut
+
+sub encode_debian {
+ my $self = shift;
+ my $data = shift;
+
+ my $content = '';
+ $content .= 'App: '.$data->{'App'}."\n"
+ if exists $data->{'App'};
+
+ foreach my $dep_type ('Build-Depends', 'Build-Depends-Indep', 'Depends') {
+ next if (not $data->{$dep_type}) or (not keys %{$data->{$dep_type}});
+
+ my $new_value = (
+ join ', ',
+ map { $_.($data->{$dep_type}->{$_} ? ' '.$data->{$dep_type}->{$_} : '') }
+ sort
+ keys %{$data->{$dep_type}}
+ );
+ $content .= $dep_type.': '.$new_value."\n";
+ }
+
+ $content .= 'No-Auto: '.$data->{'No-Auto'}."\n"
+ if exists $data->{'No-Auto'};
+ $content .= 'X: '.$data->{'X'}."\n"
+ if exists $data->{'X'};
+
+ return $content;
+}
+
+1;
+
+
+__END__
+
+=head1 AUTHOR
+
+jozef@kutej.net, C<< <jkutej at cpan.org> >>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to C<bug-cpan-patches at rt.cpan.org>, or through
+the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPAN-Patches>. I will be notified, and then you'll
+automatically be notified of progress on your bug as I make changes.
+
+
+
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+ perldoc CPAN::Patches
+
+
+You can also look for information at:
+
+=over 4
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CPAN-Patches>
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/CPAN-Patches>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/CPAN-Patches>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/CPAN-Patches/>
+
+=back
+
+
+=head1 ACKNOWLEDGEMENTS
+
+
+=head1 LICENSE AND COPYRIGHT
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of either: the GNU General Public License as published
+by the Free Software Foundation; or the Artistic License.
+
+See http://dev.perl.org/licenses/ for more information.
+
+
+=cut
+
+1; # End of CPAN::Patches
33 lib/CPAN/Patches/Plugin/Debian/SPc.pm
@@ -0,0 +1,33 @@
+package CPAN::Patches::Plugin::Debian::SPc;
+
+=head1 NAME
+
+CPAN::Patches::Plugin::Debian::SPc - Debian specific folders
+
+=cut
+
+use warnings;
+use strict;
+
+our $VERSION = '0.01';
+
+use File::Spec;
+
+sub _path_types {qw(
+ sharedstatedir
+)};
+
+=head1 PATHS
+
+=head2 prefix
+
+=head2 sharedstatedir
+
+Used to store Debian patch set and svn trunk
+
+=cut
+
+sub prefix { use Sys::Path; Sys::Path->find_distribution_root(__PACKAGE__); };
+sub sharedstatedir { File::Spec->catdir(__PACKAGE__->prefix, 'sharedstate') };
+
+1;
196 script/cpan-patches-update-from-debian
@@ -0,0 +1,196 @@
+#!/usr/bin/perl
+
+=head1 NAME
+
+cpan-patches-update-from-debian - update patch set based on content of Debian pkg-perl repository
+
+=head1 SYNOPSIS
+
+ cpan-patches-update-from-debian
+
+ --pkg-perl=/path/to
+ default is /var/lib/cpan-patches/pkg-perl-trunk
+ --cpan-patches=/path/to2
+ default is /var/log/cpan-patches/debian-set
+
+=head1 DESCRIPTION
+
+Extracts Debian dependencies from an pkg-perl checkout and updates an
+cpan-patches set.
+
+=cut
+
+
+use strict;
+use warnings;
+
+use Getopt::Long;
+use Pod::Usage;
+use File::Basename 'dirname';
+use Path::Class 'file', 'dir';
+use IO::Any;
+use File::Path 'make_path';
+use List::MoreUtils 'none', 'any';
+use File::Copy 'copy';
+use File::is;
+use Parse::Deb::Control 0.03;
+use CPAN::Patches;
+use CPAN::Patches::SPc;
+use File::Spec;
+
+exit main();
+
+sub main {
+ my $help;
+ my $pkg_perl_folder
+ = File::Spec->catdir(CPAN::Patches::SPc->sharedstatedir, 'cpan-patches', 'pkg-perl-trunk');
+ my $cpan_patches_folder
+ = File::Spec->catdir(CPAN::Patches::SPc->sharedstatedir, 'cpan-patches', 'debian-set');
+ GetOptions(
+ 'help|h' => \$help,
+ 'pkg-perl=s' => \$pkg_perl_folder,
+ 'cpan-patches=s' => \$cpan_patches_folder,
+ ) or pod2usage;
+ pod2usage if $help;
+ pod2usage if not $pkg_perl_folder;
+ pod2usage if not $cpan_patches_folder;
+
+ die $pkg_perl_folder.' no such folder'
+ if not -d $pkg_perl_folder;
+ die $cpan_patches_folder.' no such folder'
+ if not -d $cpan_patches_folder;
+
+ update_patches($pkg_perl_folder, $cpan_patches_folder);
+ update_debian($pkg_perl_folder, $cpan_patches_folder);
+
+ return 0;
+}
+
+sub update_debian {
+ my $pkg_perl_folder = shift or die;
+ my $cpan_patches_folder = shift or die;
+
+ my %metas =
+ map { %{$_} }
+ grep { (%{$_})[1] } # only with parsable meta
+ map {
+ { $_ => eval { CPAN::Patches->read_meta($_) } || 0 }
+ } # parse meta
+ glob($pkg_perl_folder.'/*');
+ die 'no */debian/META.* found in '.$pkg_perl_folder
+ if not %metas;
+
+ while (my ($dist_folder, $meta) = each %metas) {
+ my $cpan_name = CPAN::Patches->clean_meta_name($meta->{'name'}) || die 'missing name in meta - '.$dist_folder;
+
+ my $cpan_patch_folder = dir($cpan_patches_folder, $cpan_name)->stringify;
+ my $cpan_patch_debian_filename = file($cpan_patch_folder, 'debian')->stringify;
+ my $debian_control_filename = file($dist_folder, 'debian', 'control')->stringify;
+
+ if (not -f $cpan_patch_debian_filename or File::is->older($cpan_patch_debian_filename, $debian_control_filename)) {
+ #print 'updating ', $cpan_patch_debian_filename, "\n";
+ make_path($cpan_patch_folder) or die 'make_path '.$cpan_patch_folder.' fail - '.$!
+ if not -d $cpan_patch_folder;
+ my %debian_data = eval { %{ CPAN::Patches->decode_debian([$cpan_patch_debian_filename]) } };
+ my $deb_control = Parse::Deb::Control->new([$debian_control_filename]);
+
+ my %depends = CPAN::Patches->get_deb_package_names($deb_control, 'Depends');
+ my %build_depends = CPAN::Patches->get_deb_package_names($deb_control, 'Build-Depends');
+ my %build_depends_indep = CPAN::Patches->get_deb_package_names($deb_control, 'Build-Depends-Indep');
+
+ $debian_data{'Depends'} =
+ CPAN::Patches->merge_debian_versions(\%depends, $debian_data{'Depends'} || {});
+ $debian_data{'Build-Depends'} =
+ CPAN::Patches->merge_debian_versions(\%build_depends, $debian_data{'Build-Depends'} || {});
+ $debian_data{'Build-Depends-Indep'} =
+ CPAN::Patches->merge_debian_versions(\%build_depends_indep, $debian_data{'Build-Depends-Indep'} || {});
+
+ if (not exists $debian_data{'X'}) {
+ $debian_data{'X'} = (
+ (any { $_ eq 'xvfb' } keys %build_depends, keys %build_depends_indep)
+ ? 1
+ : 0
+ );
+ }
+
+ if (not exists $debian_data{'App'}) {
+ my @package_names = (
+ sort { length($a) <=> length($b) }
+ map { s/^\s*//;$_; }
+ map { s/\s*$//;$_; }
+ map { ${$_->{'value'}} }
+ $deb_control->get_keys('Package')
+ );
+ $debian_data{'App'} = (
+ (
+ any { $_ !~ /^lib .+ -perl (:? -doc)? $/xms } # if any of the packages that will be created doesn't have lib.+-perl name than it is an app
+ @package_names
+ )
+ ? $package_names[0]
+ : 0
+ );
+ }
+
+ IO::Any->spew([$cpan_patch_debian_filename], CPAN::Patches->encode_debian(\%debian_data));
+ }
+ }
+}
+
+sub update_patches {
+ my $pkg_perl_folder = shift or die;
+ my $cpan_patches_folder = shift or die;
+
+ my %series =
+ map { %{$_} }
+ grep { (%{$_})[1] } # only with parsable meta
+ map { { $_ => eval { CPAN::Patches->read_meta($_) } || 0 } } # parse meta
+ map { $_->stringify }
+ map { $_->parent->parent }
+ map { file($_) }
+ map { dirname($_) }
+ glob($pkg_perl_folder.'/*/debian/patches/series');
+ die 'no */debian/patches/series found in '.$pkg_perl_folder
+ if not %series;
+
+ while (my ($dist_folder, $meta) = each %series) {
+ my $cpan_name = CPAN::Patches->clean_meta_name($meta->{'name'}) || die 'missing name in meta - '.$dist_folder;
+ my @deb_series =
+ grep { not m/^#/ } # skip commented out
+ map { s/\s*$//;$_; }
+ map { s/^\s*//;$_; }
+ split "\n",
+ IO::Any->slurp([$dist_folder, 'debian', 'patches', 'series'])
+ ;
+
+ my $cpan_patch_series_folder = dir($cpan_patches_folder, $cpan_name, 'patches')->stringify;
+ my $cpan_patch_series_filename = file($cpan_patch_series_folder, 'series')->stringify;
+ if (not -f $cpan_patch_series_filename) {
+ make_path($cpan_patch_series_folder) || die $!
+ if not -d $cpan_patch_series_folder;
+ IO::Any->spew($cpan_patch_series_filename, '');
+ }
+ my @cpan_patch_series =
+ map { s/\s*$//;$_; }
+ map { s/^\s*//;$_; }
+ split "\n",
+ IO::Any->slurp($cpan_patch_series_filename);
+
+ @deb_series =
+ grep {
+ my $d = $_;
+ none { $_ eq $d } @cpan_patch_series
+ } @deb_series
+ ;
+
+ foreach my $patch_name (@deb_series) {
+ #print 'copy ', file($dist_folder, 'debian', 'patches', $patch_name), ' to ', $cpan_patch_series_folder, "\n";
+ copy(
+ file($dist_folder, 'debian', 'patches', $patch_name),
+ $cpan_patch_series_folder,
+ ) or die $!;
+ push @cpan_patch_series, $patch_name;
+ }
+
+ IO::Any->spew($cpan_patch_series_filename, join("\n", @cpan_patch_series));
+ }
+}
0  sharedstate/cpan-patches/debian-set/.exists
No changes.
0  sharedstate/cpan-patches/pkg-perl-trunk/.exists
No changes.
9 t/00_compile.t
@@ -0,0 +1,9 @@
+use strict;
+use Test::More;
+
+eval "use Test::Compile 0.08";
+plan skip_all => "Test::Compile 0.08 required for testing compilation"
+ if $@;
+
+my @pmdirs = qw(lib blib sbin bin);
+all_pm_files_ok(all_pm_files(@pmdirs));
4 t/distribution.t
@@ -0,0 +1,4 @@
+use Test::More;
+
+eval 'use Test::Distribution not => "sig"';
+plan( skip_all => 'Test::Distribution not installed') if $@;
9 t/fixme.t
@@ -0,0 +1,9 @@
+use strict;
+use warnings;
+use Test::More;
+
+eval "use Test::Fixme";
+plan skip_all => "requires Test::Fixme to run"
+ if $@;
+
+run_tests();
18 t/pod-coverage.t
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod::Coverage
+my $min_tpc = 1.08;
+eval "use Test::Pod::Coverage $min_tpc";
+plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
+ if $@;
+
+# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
+# but older versions don't recognize some common documentation styles
+my $min_pc = 0.18;
+eval "use Pod::Coverage $min_pc";
+plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
+ if $@;
+
+all_pod_coverage_ok();
25 t/pod-spell.t
@@ -0,0 +1,25 @@
+use Test::More;
+
+if (!$ENV{TEST_SPELLING}) {
+ plan skip_all =>
+ "Set the environment variable TEST_SPELLING to enable this test.";
+}
+
+eval 'use Test::Spelling;';
+
+plan skip_all => "Test::Spelling required for testing POD spelling"
+ if $@;
+
+add_stopwords(qw(
+ Jozef Kutej
+ OFC
+ API
+ JSON
+ TBD
+ html
+ RT
+ CPAN
+ AnnoCPAN
+ http
+));
+all_pod_files_spelling_ok();
12 t/pod.t
@@ -0,0 +1,12 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod
+my $min_tp = 1.22;
+eval "use Test::Pod $min_tp";
+plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
+
+all_pod_files_ok();
Please sign in to comment.
Something went wrong with that request. Please try again.