CPANPLUS-Dist-Slackware
view release on metacpan or search on metacpan
lib/CPANPLUS/Dist/Slackware.pm view on Meta::CPAN
if ( $installer_type eq 'CPANPLUS::Dist::MM' ) {
my $make = $param_ref->{make};
$cmd = [ $make, 'install', "DESTDIR=$destdir" ];
}
elsif ( $installer_type eq 'CPANPLUS::Dist::Build' ) {
my $perl = $param_ref->{perl};
$cmd = [
$perl, '-MCPANPLUS::Internals::Utils::Autoflush',
'Build', 'install', '--destdir', $destdir,
split( ' ', $dist->_perl_mb_opt )
];
}
else {
error( loc( q{Unknown type '%1'}, $installer_type ) );
return;
}
msg( loc( q{Staging distribution in '%1'}, $destdir ) );
return run( $cmd, { dir => $wrksrc, verbose => $verbose } );
}
sub _makepkg {
my ( $dist, $param_ref ) = @_;
my $status = $dist->status;
my $module = $dist->parent;
my $cb = $module->parent;
my $conf = $cb->configure_object;
my $pkgdesc = $status->_pkgdesc;
my $verbose = $param_ref->{verbose};
my $destdir = $pkgdesc->destdir;
my $outputname = $pkgdesc->outputname;
my $needs_chown = 0;
my $cmd = [ '/sbin/makepkg', '-l', 'y', '-c', 'y', $outputname ];
if ( $EFFECTIVE_USER_ID > 0 ) {
my $fakeroot = $status->_fakeroot_cmd;
if ($fakeroot) {
unshift @{$cmd}, $fakeroot;
}
else {
my $sudo = $conf->get_program('sudo');
if ($sudo) {
unshift @{$cmd}, $sudo;
$needs_chown = 1;
}
else {
error( loc($NONROOT_WARNING) );
return;
}
}
}
msg( loc( q{Creating package '%1'}, $outputname ) );
my $orig_uid = $UID;
my $orig_gid = ( split /\s+/, $GID )[0];
if ($needs_chown) {
my @stat = stat($destdir);
if ( !@stat ) {
error( loc( q{Could not stat '%1': %2}, $destdir, $OS_ERROR ) );
return;
}
$orig_uid = $stat[4];
$orig_gid = $stat[5];
$dist->_chown_recursively( 0, 0, $destdir ) or return;
}
my $fail = 0;
if ( !run( $cmd, { dir => $destdir, verbose => $verbose } ) ) {
++$fail;
}
if ($needs_chown) {
if ( -d $destdir ) {
if (!$dist->_chown_recursively( $orig_uid, $orig_gid, $destdir ) )
{
++$fail;
}
}
if ( -f $outputname ) {
if (!$dist->_chown_recursively(
$orig_uid, $orig_gid, $outputname
)
)
{
++$fail;
}
}
}
if ( !$param_ref->{keep_source} ) {
# Keep the staging directory if something failed.
if ( !$fail ) {
msg( loc( q{Removing '%1'}, $destdir ) );
if ( !$cb->_rmdir( dir => $destdir ) ) {
++$fail;
}
}
}
return ( $fail ? 0 : 1 );
}
sub _installpkg {
my ( $dist, $param_ref ) = @_;
my $status = $dist->status;
my $module = $dist->parent;
my $cb = $module->parent;
my $conf = $cb->configure_object;
my $pkgdesc = $status->_pkgdesc;
my $verbose = $param_ref->{verbose};
my $outputname = $pkgdesc->outputname;
my $cmd
lib/CPANPLUS/Dist/Slackware.pm view on Meta::CPAN
@keys = keys %{$old_pl};
}
if (@keys) {
my ($new_pl) = ExtUtils::Packlist->new();
for my $key (@keys) {
my $value = $old_pl->{$key};
$key =~ s{^\Q$destdir\E}{}xms;
# Add .gz to manual pages.
if ( $key =~ m{/man/man}xms ) {
if ( $key !~ m{\.gz$}xms ) {
$key .= '.gz';
}
if ( ref $value eq 'HASH' ) {
if ( defined $value->{type}
&& $value->{type} eq 'link'
&& defined $value->{from} )
{
my $from = $value->{from};
if ( $from =~ m{/man/man}xms ) {
if ( $from !~ m{\.gz$}xms ) {
$from .= '.gz';
$value->{from} = $from;
}
}
}
}
}
if ( -e "$destdir$key" ) {
$new_pl->{$key} = $value;
}
}
$new_pl->write($filename);
}
return 1;
}
sub _process_installed_files {
my ( $dist, $param_ref ) = @_;
my $status = $dist->status;
my $module = $dist->parent;
my $cb = $module->parent;
my $pkgdesc = $status->_pkgdesc;
my $destdir = $pkgdesc->destdir;
my $orig_dir = Cwd::cwd();
if ( !$cb->_chdir( dir => $destdir ) ) {
return;
}
my $fail = 0;
my @packlists;
my $wanted = sub {
my $filename = $_;
return if $filename eq q{.};
my @stat = lstat($filename);
if ( !@stat ) {
error( loc( q{Could not lstat '%1': %2}, $filename, $OS_ERROR ) );
return;
}
# Skip symbolic links.
return if -l _;
# Sanitize the file modes.
my $perm = ( $stat[2] & oct '0755' ) | oct '0200';
if ( !chmod $perm, $filename ) {
error( loc( q{Could not chmod '%1': %2}, $filename, $OS_ERROR ) );
++$fail;
}
if ( -d $filename ) {
# Remove empty directories.
rmdir $filename;
}
elsif ( -f $filename ) {
if ( $filename eq 'perllocal.pod'
|| ( $filename =~ /\.bs$/ && -z $filename ) )
{
if ( !unlink $filename ) {
error(
loc(q{Could not unlink '%1': %2}, $filename,
$OS_ERROR
)
);
++$fail;
}
}
elsif ( $filename eq '.packlist' ) {
push @packlists, $File::Find::name;
}
else {
my $type = filetype($filename);
if ( $type =~ /ELF.+(?:executable|shared object)/s ) {
if ( !strip($filename) ) {
++$fail;
}
}
}
}
};
File::Find::finddepth( $wanted, q{.} );
for my $packlist (@packlists) {
if ( !$dist->_process_packlist($packlist) ) {
++$fail;
}
}
if ( !$cb->_chdir( dir => $orig_dir ) ) {
++$fail;
}
return ( $fail ? 0 : 1 );
}
( run in 0.657 second using v1.01-cache-2.11-cpan-39bf76dae61 )