CPANPLUS-Dist-Slackware
view release on metacpan or search on metacpan
lib/CPANPLUS/Dist/Slackware.pm view on Meta::CPAN
--installdirs $installdirs
--config install${installdirs}man1dir=$mandir{1}
--config install${installdirs}man3dir=$mandir{3}
END_PERL_MB_OPT
}
sub _fake_install {
my ( $dist, $param_ref ) = @_;
my $status = $dist->status;
my $module = $dist->parent;
my $pkgdesc = $status->_pkgdesc;
my $verbose = $param_ref->{verbose};
my $wrksrc = $module->status->extract;
if ( !$wrksrc ) {
error( loc(q{No dir found to operate on!}) );
return;
}
my $destdir = $pkgdesc->destdir;
my $cmd;
my $installer_type = $module->status->installer_type;
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
= [ '/sbin/upgradepkg', '--install-new', '--reinstall', $outputname ];
if ( $EFFECTIVE_USER_ID > 0 ) {
my $sudo = $conf->get_program('sudo');
if ($sudo) {
unshift @{$cmd}, $sudo;
}
else {
error( loc($NONROOT_WARNING) );
return;
}
}
msg( loc( q{Installing package '%1'}, $outputname ) );
return run( $cmd, { verbose => $verbose } );
}
sub _compress_manual_pages {
my ( $dist, $param_ref ) = @_;
my $status = $dist->status;
my $pkgdesc = $status->_pkgdesc;
my %mandir = $pkgdesc->mandirs;
lib/CPANPLUS/Dist/Slackware.pm view on Meta::CPAN
}
};
File::Find::find( { wanted => $wanted, no_chdir => 1 }, 'etc' );
if ( !$cb->_chdir( dir => $orig_dir ) ) {
++$fail;
}
return if $fail;
return 1 if !@conffiles;
@conffiles = sort { uc $a cmp uc $b } @conffiles;
# List the configuration files in README.SLACKWARE.
$dist->_append_config_files_to_readme_slackware(@conffiles) or return;
# Add a config function to doinst.sh.
my $script = $pkgdesc->config_function;
for my $conffile (@conffiles) {
$conffile =~ s/('+)/'"$1"'/g; # Quote single quotes.
$script .= "config '$conffile.new'\n";
}
my $installdir = catdir( $pkgdesc->destdir, 'install' );
my $doinstfile = catfile( $installdir, 'doinst.sh' );
return spurt( $doinstfile, { append => 1 }, $script );
}
sub _append_config_files_to_readme_slackware {
my ( $dist, @conffiles ) = @_;
my $status = $dist->status;
my $pkgdesc = $status->_pkgdesc;
my $readme
= "\n"
. "Configuration files\n"
. "-------------------\n\n"
. "This package provides the following configuration files:\n\n"
. join( "\n", map {"* /$_"} @conffiles ) . "\n";
my $docdir = catdir( $pkgdesc->destdir, $pkgdesc->docdir );
my $readmefile = catfile( $docdir, 'README.SLACKWARE' );
return spurt( $readmefile, { append => 1 }, $readme );
}
sub _write_slack_desc {
my ( $dist, $param_ref ) = @_;
my $status = $dist->status;
my $module = $dist->parent;
my $cb = $module->parent;
my $pkgdesc = $status->_pkgdesc;
my $installdir = catdir( $pkgdesc->destdir, 'install' );
my $descfile = catfile( $installdir, 'slack-desc' );
my $desc = $pkgdesc->slack_desc;
return spurt( $descfile, $desc );
}
sub _chown_recursively {
my ( $dist, $uid, $gid, @filenames ) = @_;
my $module = $dist->parent;
my $cb = $module->parent;
my $conf = $cb->configure_object;
my $cmd = [ '/bin/chown', '-R', "$uid:$gid", @filenames ];
if ( $EFFECTIVE_USER_ID > 0 ) {
my $sudo = $conf->get_program('sudo');
if ($sudo) {
unshift @{$cmd}, $sudo;
}
else {
error( loc($NONROOT_WARNING) );
return;
}
}
return run($cmd);
}
1;
__END__
=head1 NAME
CPANPLUS::Dist::Slackware - Install Perl distributions on Slackware Linux
=head1 VERSION
This document describes CPANPLUS::Dist::Slackware version 1.030.
=head1 SYNOPSIS
### from the cpanp interactive shell
$ cpanp
CPAN Terminal> i Some::Module --format=CPANPLUS::Dist::Slackware
### using the command-line tool
$ cpan2dist --format CPANPLUS::Dist::Slackware Some::Module
$ sudo /sbin/installpkg /tmp/perl-Some-Module-1.0-i586-1_CPANPLUS.tgz
=head1 DESCRIPTION
Do you prefer to manage all software in your operating system's native package
format?
This CPANPLUS plugin creates Slackware compatible packages from Perl
distributions. You can either install the created packages using the API
provided by CPANPLUS or manually with C<installpkg>.
=head2 Using CPANPLUS::Dist::Slackware
Start an interactive shell to edit the CPANPLUS settings:
$ cpanp
CPAN Terminal> s reconfigure
Once CPANPLUS is configured, modules can be installed. Example:
CPAN Terminal> i Mojolicious --format=CPANPLUS::Dist::Slackware
You can make CPANPLUS::Dist::Slackware your default format by setting the
C<dist_type> key:
CPAN Terminal> s conf dist_type CPANPLUS::Dist::Slackware
Some Perl distributions fail to show interactive prompts if the C<verbose>
lib/CPANPLUS/Dist/Slackware.pm view on Meta::CPAN
file.
=item B<< Unknown type 'CPANPLUS::Dist::WHATEVER' >>
CPANPLUS::Dist::Slackware supports CPANPLUS::Dist::MM and
CPANPLUS::Dist::Build.
=back
=head1 CONFIGURATION AND ENVIRONMENT
Similar to the build scripts provided by L<https://slackbuilds.org/>,
CPANPLUS::Dist::Slackware respects the following environment variables:
=over 4
=item B<TMP>
The staging directory where the Perl distributions are temporarily installed.
Defaults to F<$TMPDIR/CPANPLUS> or to F</tmp/CPANPLUS> if C<$ENV{TMPDIR}> is
not set.
=item B<OUTPUT>
The package output directory where all created packages are stored. Defaults
to F<$TMPDIR> or F</tmp>.
=item B<ARCH>
The package architecture. Defaults to "i586" on x86-based platforms, to "arm"
on ARM-based platforms and to the output of C<uname -m> on all other
platforms.
=item B<BUILD>
The build number that is added to the filename. Defaults to "1".
As packages may be built recursively, setting this variable is mainly useful
when all packages are rebuilt. For example, after Perl has been upgraded.
=item B<TAG>
This tag is added to the package filename. Defaults to "_CPANPLUS".
=item B<PKGTYPE>
The package extension. Defaults to "tgz". May be set to "tbz", "tlz" or
"txz". The respective compression utility needs to be installed on the
machine.
=item B<INSTALLDIRS>
The installation destination. Can be "vendor" or "site". Defaults to "vendor".
=back
=head1 DEPENDENCIES
Requires the Slackware Linux package management tools C<makepkg>,
C<installpkg>, C<updatepkg>, and C<removepkg>. Other required commands are
C<chown>, C<cp>, C<file>, C<make>, C<strip> and a C compiler.
In order to manage packages as a non-root user, which is highly recommended,
you must have C<sudo> and, optionally, C<fakeroot>. You can download a script
that builds C<fakeroot> from L<https://slackbuilds.org/>.
Requires the modules CPANPLUS and Module::Pluggable from CPAN.
The lowest supported Module::Build version is 0.36.
The required modules Cwd, ExtUtils::Packlist, File::Find, File::Spec,
File::Temp, IO::Compress::Gzip, IPC:Cmd, Locale::Maketext::Simple,
Module::CoreList 2.32, Params::Check, POSIX, Text::Wrap and version 0.77 are
distributed with Perl 5.12.3 and above.
If available, the modules Parse::CPAN::Meta, Pod::Find and Pod::Simple are used.
=head1 INCOMPATIBILITIES
Packages created with CPANPLUS::Dist::Slackware may provide the same files as
packages built with scripts from L<https://slackbuilds.org/> and packages created
with C<cpan2tgz>.
=head1 SEE ALSO
cpanp(1), cpan2dist(1), sudo(8), fakeroot(1), CPANPLUS::Dist::MM,
CPANPLUS::Dist::Build, CPANPLUS::Dist::Base
=head1 AUTHOR
Andreas Voegele E<lt>voegelas@cpan.orgE<gt>
=head1 BUGS AND LIMITATIONS
Some Perl distributions fail to show interactive prompts if the C<verbose> option
is not set. This problem has been reported as bug #47818 and bug #72095 at
L<https://rt.cpan.org/>.
Please report any bugs using the issue tracker at
L<https://github.com/graygnuorg/CPANPLUS-Dist-Slackware/issues>.
=head1 LICENSE AND COPYRIGHT
Copyright 2012-2020 Andreas Voegele
This library is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
See https://dev.perl.org/licenses/ for more information.
=cut
( run in 1.492 second using v1.01-cache-2.11-cpan-71847e10f99 )