App-CPANtoRPM
view release on metacpan or search on metacpan
lib/App/CPANtoRPM.pm view on Meta::CPAN
# t/readme => { t/README => 1,
# t/Readme => 1 }
# }
#
sub _get_filelist {
my($self,$dir) = @_;
$self->_log_message('INFO',"Listing package files");
my $succ = $self->_multiple_methods
( [ sub { 1; } ],
[ 'module','File::Find',['find'],
qq< find(sub { push(\@OUTPUT,\$File::Find::name) if (-f) },"$dir"); >
],
[ 'system','find',
"{find} '$dir' -type f" ]
);
my %files;
foreach my $file (@OUTPUT) {
$file =~ s,^$dir/,,;
next if (! $file);
$files{lc($file)}{$file} = 1;
}
return %files;
}
# This looks at the filelist determines which are pod files, which are
# .pm files, which are test files, etc.
#
sub _categorize_files {
my($self,$op,$dir,%files) = @_;
$self->_log_message('INFO',"Categorizing $op package files");
# First pass based on some simple tests.
my $in = new IO::File;
foreach my $file (keys %files) {
foreach my $f (keys %{ $files{$file} }) {
if ($op eq 'build') {
# Files in the blib directory:
#
# Ignored:
# */*.exists
#
# PM files:
# **/*.pm
#
# Bin files
# bin/*
# script/*
#
# man1 files:
# man1/*
# bindoc/*
#
# man3 files:
# man3/*
# libdoc/*
if ($f =~ /\.exists$/) {
next;
} elsif ($f =~ m,^lib/\Q$ARCH\E/.*\.pm$, ||
$f =~ m,^arch/auto/.*\.pm$,) {
$package{'instfiles'}{'pm'}{$f} = 1;
$package{'arch_inst'} = 1;
} elsif ($f =~ m,.*\.pm$,) {
$package{'instfiles'}{'pm'}{$f} = 1;
$package{'lib_inst'} = 1;
} elsif ($f =~ m,^lib/\Q$ARCH\E/.*\.so$, ||
$f =~ m,^arch/auto/.*\.so$,) {
$package{'instfiles'}{'lib'}{$f} = 1;
$package{'arch_inst'} = 1;
} elsif ($f =~ m,^(script|bin)/,) {
$package{'instfiles'}{'scripts'}{$f} = 1;
$package{'bin_inst'} = 1;
} elsif ($f =~ m,^man1/, ||
$f =~ m,^bindoc/,) {
$package{'instfiles'}{'man1'}{$f} = 1;
$package{'man1_inst'} = 1;
} elsif ($f =~ m,^man3/, ||
$f =~ m,^libdoc/,) {
$package{'instfiles'}{'man3'}{$f} = 1;
$package{'man3_inst'} = 1;
}
} else {
# Package files:
#
# Test files:
# t/*.t
# t/*.pl
# t/*.pm
#
# Build files:
# Makefile.PL
# Build.PL
# inc/*.pm
#
# POD files:
# *.pod
#
# PM files:
# *.pm
#
# XS files:
# *.c
# *.xs
#
# Scripts:
# *.pl
# Anything that starts with '#!'
if ($f =~ m,^t/.*\.(t|pl|pm)$,) {
$package{'files'}{'t'}{$f} = '';
} elsif ($f =~ m,^t/,) {
next;
} elsif ($f =~ m,^blib/, ||
$f =~ /pm_to_blib/) {
next;
} elsif ($f =~ m,^inc/.*\.pm$, ||
lc($f) eq 'makefile.pl' ||
lc($f) eq 'build.pl') {
$package{'files'}{'build'}{$f} = '';
} elsif ($f =~ m,^inc/,) {
next;
} elsif ($f =~ m,\.pod$,) {
$package{'files'}{'pod'}{$f} = '';
} elsif ($f =~ m,\.pm$,) {
$package{'files'}{'pm'}{$f} = '';
lib/App/CPANtoRPM.pm view on Meta::CPAN
}
@build_cmd = (qw(./Build));
@test_cmd = (qw(./Build test));
if ($package{'build_tiny'}) {
@install_cmd = (qw(./Build install --destdir=<_buildroot>
--create_packlist=0));
@clean_cmd = (qw(./Build realclean));
} else {
@install_cmd = (qw(./Build pure_install destdir=<_buildroot>
create_packlist=0));
@clean_cmd = (qw(./Build distclean));
}
} else {
if ($for_spec) {
@config_cmd = (qw(%{__perl} <make> OPTIMIZE="<_optimize>"));
@build_cmd = (qw(make %{?_smp_mflags}));
} else {
@config_cmd = ('perl',$package{make});
@build_cmd = ('make');
}
@test_cmd = (qw(make test));
@install_cmd = (qw(make pure_install PERL_INSTALL_ROOT=<_buildroot>));
@clean_cmd = (qw(make distclean));
}
# Handle directory arguments
#
# We have to record which directories things can get installed into.
my $t = $insttype;
my $T = uc($t);
DIR_ARGS:
{
# If we don't specify an installation directory or type,
# we don't have to add any arguments.
#
# Note: this will never be the information that goes in the SPEC
# file because the installation type will always be determined,
# so we don't have to record installation directories here.
if (! $dir && ! $insttype) {
last DIR_ARGS;
}
# If we know the installation type, but we're not using
# a special directory, it's a simple case.
if (! $dir && $insttype) {
if ($insttype eq 'perl') {
$package{'lib_dir'} = '%{perl_privlib}';
$package{'arch_dir'} = '%{perl_archlib}';
} elsif ($insttype eq 'site') {
$package{'lib_dir'} = '%{perl_sitelib}';
$package{'arch_dir'} = '%{perl_sitearch}';
} else {
$package{'lib_dir'} = '%{perl_vendorlib}';
$package{'arch_dir'} = '%{perl_vendorarch}';
}
$package{'bin_dir'} = '%{_bindir}';
$package{'man1_dir'} = '%{_mandir}/man1';
$package{'man3_dir'} = '%{_mandir}/man3';
if ($type eq 'build') {
if ($t eq 'perl') {
push(@config_cmd,
"--installdirs core");
} else {
push(@config_cmd,
"--installdirs $t");
}
push(@config_cmd,
"--install_path script=%{_bindir}",
"--install_path bin=%{_bindir}",
"--install_path libdoc=%{_mandir}/man3",
"--install_path bindoc=%{_mandir}/man1",
);
} else {
if ($t eq 'perl') {
push(@config_cmd,
"INSTALLDIRS=perl",
"INSTALLBIN=%{_bindir}",
"INSTALLSCRIPT=%{_bindir}",
"INSTALLMAN1DIR=%{_mandir}/man1",
"INSTALLMAN3DIR=%{_mandir}/man3",
);
} else {
push(@config_cmd,
"INSTALLDIRS=$t",
"INSTALL${T}BIN=%{_bindir}",
"INSTALL${T}SCRIPT=%{_bindir}",
"INSTALL${T}MAN1DIR=%{_mandir}/man1",
"INSTALL${T}MAN3DIR=%{_mandir}/man3",
"INSTALLSCRIPT=%{_bindir}", # necessary due to a bug
);
}
}
last DIR_ARGS;
}
# If we're installing in an alternate location, we have made
# sure to always pass in $insttype.
if ($dir) {
my $d = $dir;
if ($type eq 'build') {
if ($t eq 'perl') {
push(@config_cmd,
"--installdirs core",
"--install_path arch=$d/lib/perl5/$VERS/$ARCH",
"--install_path lib=$d/lib/perl5/$VERS",
"--install_path script=$d/bin",
"--install_path bin=$d/bin",
"--install_path libdoc=$d/$MAN/man3",
"--install_path bindoc=$d/$MAN/man1",
);
} else {
push(@config_cmd,
"--installdirs $t",
"--install_path arch=$d/lib/perl5/${t}_perl/$VERS/$ARCH",
"--install_path lib=$d/lib/perl5/${t}_perl/$VERS",
"--install_path script=$d/bin",
"--install_path bin=$d/bin",
"--install_path libdoc=$d/$MAN/man3",
"--install_path bindoc=$d/$MAN/man1",
);
}
} else {
if ($t eq 'perl') {
push(@config_cmd,
"INSTALLDIRS=perl",
"PERLPREFIX=$d",
"INSTALLARCHLIB=$d/lib/perl5/$VERS/$ARCH",
"INSTALLPRIVLIB=$d/lib/perl5/$VERS",
"INSTALLBIN=$d/bin",
"INSTALLSCRIPT=$d/bin",
"INSTALLMAN1DIR=$d/$MAN/man1",
"INSTALLMAN3DIR=$d/$MAN/man3",
);
} else {
push(@config_cmd,
"INSTALLDIRS=$t",
"${T}PREFIX=$d",
"INSTALL${T}ARCH=$d/lib/perl5/${t}_perl/$VERS/$ARCH",
"INSTALL${T}LIB=$d/lib/perl5/${t}_perl/$VERS",
"INSTALL${T}BIN=$d/bin",
"INSTALL${T}SCRIPT=$d/bin",
"INSTALL${T}MAN1DIR=$d/$MAN/man1",
"INSTALL${T}MAN3DIR=$d/$MAN/man3",
"INSTALLSCRIPT=$d/bin", # necessary due to a bug
);
}
}
$package{'bin_dir'} = "$d/bin";
$package{'man1_dir'} = "$d/$MAN/man1";
$package{'man3_dir'} = "$d/$MAN/man3";
if ($insttype eq 'perl') {
$package{'lib_dir'} = "$d/lib/perl5/$VERS";
} else {
$package{'lib_dir'} = "$d/lib/perl5/${t}_perl/$VERS"
}
$package{'arch_dir'} = "$package{lib_dir}/$ARCH";
}
}
#
# Now handle everything else.
#
push(@config_cmd,@{ $$self{'config'} });
push(@build_cmd,@{ $$self{'build'} });
$package{'config_cmd'} = join(' ',@config_cmd);
$package{'build_cmd'} = join(' ',@build_cmd);
$package{'test_cmd'} = join(' ',@test_cmd);
$package{'install_cmd'} = join(' ',@install_cmd);
$package{'clean_cmd'} = join(' ',@clean_cmd);
$package{'config_cmd_l'} = [@config_cmd];
$package{'build_cmd_l'} = [@build_cmd];
$package{'test_cmd_l'} = [@test_cmd];
$package{'install_cmd_l'} = [@install_cmd];
$package{'clean_cmd_l'} = [@clean_cmd];
( run in 0.695 second using v1.01-cache-2.11-cpan-2398b32b56e )