Skip to content

Loading…

Remove Seco::Multipkg's dependency on File::FnMatch #17

Merged
merged 2 commits into from

2 participants

@cuzelac
ytoolshed member

Seco::Multipkg's dependency on File::FnMatch was making it very difficult to properly bootstrap.

I removed it by reimplementing the subset of functionality of File::FnMatch::fnmatch that we use.

My reimplementation passes all of the unit tests for File::FnMatch that apply to the way we use it. I have also tested by building lots of multipkg packages.

Please give this a once-over and make sure I haven't missed anything obvious.

Once this is merged, I can close out Issue 11.

@erikwb @nmeyerhans

@erikwb erikwb merged commit dcbe668 into master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 22 additions and 4 deletions.
  1. +0 −1 index.yaml
  2. +22 −3 source/lib/Seco/Multipkg.pm
View
1 index.yaml
@@ -9,7 +9,6 @@ default:
- perl-seco-class
- perl-seco-cpan
requires:
- - perl-File-FnMatch
- perl-YAML-Syck
- subversion-perl
- perl-Git
View
25 source/lib/Seco/Multipkg.pm
@@ -123,8 +123,6 @@ use IPC::Open3;
use FileHandle;
use Fcntl ':mode';
-use File::FnMatch ':fnmatch';
-
use constant MULTIPKG_VERSION => '__MULTIPKG_BUILD_VERSION__';
use base qw/Seco::Class/;
@@ -687,10 +685,31 @@ sub _find_match_attributes {
my $rules = shift;
# return the last shell pattern match
- my @found = ( grep { fnmatch( $_->{name}, $name, FNM_PATHNAME ) } (@$rules) );
+ my @found = ( grep { _fnmatch( $_->{name}, $name ) } (@$rules) );
return pop(@found);
}
+# pure-perl implementation of File::FnMatch::fnmatch with 'FNM_PATHNAME' argument
+sub _fnmatch {
+ my $pat = shift;
+ my $str = shift;
+
+ #dots are literal dots
+ $pat =~ s{\.}{\\\.}g;
+
+ #internal slashes must be escaped
+ $pat =~ s{/}{\\/}g;
+
+ #asterisks are everything but slash
+ $pat =~ s{\*}{[^\/]*}g;
+
+ #anchor it
+ $pat =~ s{^}{\^};
+ $pat =~ s{$}{\$};
+
+ return $str =~ m/$pat/;
+}
+
sub _find_parent_attributes {
my $name = shift;
my $rules = shift;
Something went wrong with that request. Please try again.