~ubuntu-branches/ubuntu/oneiric/libcpandb-perl/oneiric

« back to all changes in this revision

Viewing changes to inc/Module/Install/Metadata.pm

  • Committer: Bazaar Package Importer
  • Author(s): Ansgar Burchardt
  • Date: 2010-05-11 21:15:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100511211552-5ejwob14u8ccv1jm
Tags: 0.14-1
* New upstream release.
* Bump (build-)dep on liborlite-mirror-perl to >= 1.20.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
use vars qw{$VERSION @ISA $ISCORE};
8
8
BEGIN {
9
 
        $VERSION = '0.95';
 
9
        $VERSION = '0.97';
10
10
        @ISA     = 'Module::Install::Base';
11
11
        $ISCORE  = 1;
12
12
}
178
178
        $self->{values}->{perl_version} = $version;
179
179
}
180
180
 
181
 
#Stolen from M::B
182
 
my %license_urls = (
183
 
    perl         => 'http://dev.perl.org/licenses/',
184
 
    apache       => 'http://apache.org/licenses/LICENSE-2.0',
185
 
    artistic     => 'http://opensource.org/licenses/artistic-license.php',
186
 
    artistic_2   => 'http://opensource.org/licenses/artistic-license-2.0.php',
187
 
    lgpl         => 'http://opensource.org/licenses/lgpl-license.php',
188
 
    lgpl2        => 'http://opensource.org/licenses/lgpl-2.1.php',
189
 
    lgpl3        => 'http://opensource.org/licenses/lgpl-3.0.html',
190
 
    bsd          => 'http://opensource.org/licenses/bsd-license.php',
191
 
    gpl          => 'http://opensource.org/licenses/gpl-license.php',
192
 
    gpl2         => 'http://opensource.org/licenses/gpl-2.0.php',
193
 
    gpl3         => 'http://opensource.org/licenses/gpl-3.0.html',
194
 
    mit          => 'http://opensource.org/licenses/mit-license.php',
195
 
    mozilla      => 'http://opensource.org/licenses/mozilla1.1.php',
196
 
    open_source  => undef,
197
 
    unrestricted => undef,
198
 
    restrictive  => undef,
199
 
    unknown      => undef,
200
 
);
201
 
 
202
 
sub license {
203
 
        my $self = shift;
204
 
        return $self->{values}->{license} unless @_;
205
 
        my $license = shift or die(
206
 
                'Did not provide a value to license()'
207
 
        );
208
 
        $self->{values}->{license} = $license;
209
 
 
210
 
        # Automatically fill in license URLs
211
 
        if ( $license_urls{$license} ) {
212
 
                $self->resources( license => $license_urls{$license} );
213
 
        }
214
 
 
215
 
        return 1;
216
 
}
217
 
 
218
181
sub all_from {
219
182
        my ( $self, $file ) = @_;
220
183
 
354
317
        require ExtUtils::MM_Unix;
355
318
        my ( $self, $file ) = @_;
356
319
        $self->version( ExtUtils::MM_Unix->parse_version($file) );
 
320
 
 
321
        # for version integrity check
 
322
        $self->makemaker_args( VERSION_FROM => $file );
357
323
}
358
324
 
359
325
sub abstract_from {
364
330
                        { DISTNAME => $self->name },
365
331
                        'ExtUtils::MM_Unix'
366
332
                )->parse_abstract($file)
367
 
         );
 
333
        );
368
334
}
369
335
 
370
336
# Add both distribution and module name
479
445
        }
480
446
}
481
447
 
 
448
#Stolen from M::B
 
449
my %license_urls = (
 
450
    perl         => 'http://dev.perl.org/licenses/',
 
451
    apache       => 'http://apache.org/licenses/LICENSE-2.0',
 
452
    apache_1_1   => 'http://apache.org/licenses/LICENSE-1.1',
 
453
    artistic     => 'http://opensource.org/licenses/artistic-license.php',
 
454
    artistic_2   => 'http://opensource.org/licenses/artistic-license-2.0.php',
 
455
    lgpl         => 'http://opensource.org/licenses/lgpl-license.php',
 
456
    lgpl2        => 'http://opensource.org/licenses/lgpl-2.1.php',
 
457
    lgpl3        => 'http://opensource.org/licenses/lgpl-3.0.html',
 
458
    bsd          => 'http://opensource.org/licenses/bsd-license.php',
 
459
    gpl          => 'http://opensource.org/licenses/gpl-license.php',
 
460
    gpl2         => 'http://opensource.org/licenses/gpl-2.0.php',
 
461
    gpl3         => 'http://opensource.org/licenses/gpl-3.0.html',
 
462
    mit          => 'http://opensource.org/licenses/mit-license.php',
 
463
    mozilla      => 'http://opensource.org/licenses/mozilla1.1.php',
 
464
    open_source  => undef,
 
465
    unrestricted => undef,
 
466
    restrictive  => undef,
 
467
    unknown      => undef,
 
468
);
 
469
 
 
470
sub license {
 
471
        my $self = shift;
 
472
        return $self->{values}->{license} unless @_;
 
473
        my $license = shift or die(
 
474
                'Did not provide a value to license()'
 
475
        );
 
476
        $license = __extract_license($license) || lc $license;
 
477
        $self->{values}->{license} = $license;
 
478
 
 
479
        # Automatically fill in license URLs
 
480
        if ( $license_urls{$license} ) {
 
481
                $self->resources( license => $license_urls{$license} );
 
482
        }
 
483
 
 
484
        return 1;
 
485
}
 
486
 
482
487
sub _extract_license {
483
488
        my $pod = shift;
484
489
        my $matched;
485
490
        return __extract_license(
486
491
                ($matched) = $pod =~ m/
487
 
                        (=head \d \s+ (?:licen[cs]e|licensing)\b.*?)
 
492
                        (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?)
488
493
                        (=head \d.*|=cut.*|)\z
489
 
                /ixms
 
494
                /xms
490
495
        ) || __extract_license(
491
496
                ($matched) = $pod =~ m/
492
 
                        (=head \d \s+ (?:copyrights?|legal)\b.*?)
 
497
                        (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?)
493
498
                        (=head \d.*|=cut.*|)\z
494
 
                /ixms
 
499
                /xms
495
500
        );
496
501
}
497
502
 
498
503
sub __extract_license {
499
504
        my $license_text = shift or return;
500
505
        my @phrases      = (
501
 
                'under the same (?:terms|license) as (?:perl|the perl programming language)' => 'perl', 1,
502
 
                'under the terms of (?:perl|the perl programming language) itself' => 'perl', 1,
503
 
                'Artistic and GPL'                   => 'perl',        1,
504
 
                'GNU general public license'         => 'gpl',         1,
505
 
                'GNU public license'                 => 'gpl',         1,
506
 
                'GNU lesser general public license'  => 'lgpl',        1,
507
 
                'GNU lesser public license'          => 'lgpl',        1,
508
 
                'GNU library general public license' => 'lgpl',        1,
509
 
                'GNU library public license'         => 'lgpl',        1,
510
 
                'BSD license'                        => 'bsd',         1,
511
 
                'Artistic license'                   => 'artistic',    1,
512
 
                'GPL'                                => 'gpl',         1,
513
 
                'LGPL'                               => 'lgpl',        1,
514
 
                'BSD'                                => 'bsd',         1,
515
 
                'Artistic'                           => 'artistic',    1,
516
 
                'MIT'                                => 'mit',         1,
517
 
                'proprietary'                        => 'proprietary', 0,
 
506
                '(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1,
 
507
                '(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1,
 
508
                'Artistic and GPL'                   => 'perl',         1,
 
509
                'GNU general public license'         => 'gpl',          1,
 
510
                'GNU public license'                 => 'gpl',          1,
 
511
                'GNU lesser general public license'  => 'lgpl',         1,
 
512
                'GNU lesser public license'          => 'lgpl',         1,
 
513
                'GNU library general public license' => 'lgpl',         1,
 
514
                'GNU library public license'         => 'lgpl',         1,
 
515
                'GNU Free Documentation license'     => 'unrestricted', 1,
 
516
                'GNU Affero General Public License'  => 'open_source',  1,
 
517
                '(?:Free)?BSD license'               => 'bsd',          1,
 
518
                'Artistic license'                   => 'artistic',     1,
 
519
                'Apache (?:Software )?license'       => 'apache',       1,
 
520
                'GPL'                                => 'gpl',          1,
 
521
                'LGPL'                               => 'lgpl',         1,
 
522
                'BSD'                                => 'bsd',          1,
 
523
                'Artistic'                           => 'artistic',     1,
 
524
                'MIT'                                => 'mit',          1,
 
525
                'Mozilla Public License'             => 'mozilla',      1,
 
526
                'Q Public License'                   => 'open_source',  1,
 
527
                'OpenSSL License'                    => 'unrestricted', 1,
 
528
                'SSLeay License'                     => 'unrestricted', 1,
 
529
                'zlib License'                       => 'open_source',  1,
 
530
                'proprietary'                        => 'proprietary',  0,
518
531
        );
519
532
        while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) {
520
533
                $pattern =~ s#\s+#\\s+#gs;
522
535
                        return $license;
523
536
                }
524
537
        }
 
538
        return '';
525
539
}
526
540
 
527
541
sub license_from {