[perl-App-cpanminus] Unbundle all modules

Petr Pisar ppisar at fedoraproject.org
Wed Sep 11 07:56:46 UTC 2013


commit 05a090766e3f6cf2f05e5e63cc12e9adc9e5e61f
Author: Petr Písař <ppisar at redhat.com>
Date:   Fri Aug 2 17:06:52 2013 +0200

    Unbundle all modules

 fatunpack               |  114 ++++++++++++++++++++++++++++++++++++++++++
 perl-App-cpanminus.spec |  126 +++++++++++++++++++++++++++++++++--------------
 2 files changed, 202 insertions(+), 38 deletions(-)
---
diff --git a/fatunpack b/fatunpack
new file mode 100755
index 0000000..f13b107
--- /dev/null
+++ b/fatunpack
@@ -0,0 +1,114 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use File::Path;
+use File::Spec;
+use Getopt::Long;
+
+my $libdir = 'lib';
+my $filter = '';
+
+GetOptions('libdir=s' => \$libdir, 'filter=s' => \$filter) or
+    die "Could not parse arguments\n";
+if ($filter eq '') {
+    # Empty pattern passes previous result by definition. Do not use it.
+    # Interpolared compilation is fixed in perl 5.18.0. RT#119095.
+    $filter = qr/(?:)/;
+}
+eval { $filter = qr{$filter}; 1} or
+    die "Could not compile filter as a regular expression: $@\n";
+
+my ($file, $filename, $delimiter);
+while (<>) {
+    if (/^\$fatpacked\{\s*"([^"]*)"\s*\}\s*=\s*<<\s*'([^']*)'\s*;/) {
+        # Packed module beginning found
+        $filename = $1;
+        $delimiter = $2;
+        if ($filename =~ $filter) {
+            print STDERR "Extracting `$filename'\n";
+            my $directory = (File::Spec->splitpath($filename))[1];
+            File::Path::make_path(File::Spec->catfile($libdir, $directory));
+            if ($file) {
+                die "Unballanced fat-packed module at line $.\n";
+            }
+            open($file, '>', File::Spec->catfile($libdir, $filename)) or
+                die "Could not create `",
+                    File::Spec->catfile($libdir, $filename), "': $!\n";
+        } else {
+            print STDERR "Removing `$filename'\n";
+        }
+    } elsif (defined $delimiter and /^\Q$delimiter\E$/) {
+        # Packed module end found
+        if (defined $file) {
+            close($file) or
+                die "Could not close `",
+                    File::Spec->catfile($libdir, $filename), "': $!\n";
+            $file = undef;
+        }
+        $filename = undef;
+        $delimiter = undef;
+    } elsif (defined $file) {
+        # Packed module to extract
+        s/^  //;    # de-escape recursive here-documents
+        print $file $_;
+    } elsif (! defined $delimiter) {
+        # Rest of code to output
+        print STDOUT $_;
+    }
+}
+
+__END__
+
+=encoding utf8
+
+=head1 NAME
+
+fatunpack - Unpacker for App::FatPacker packets
+
+=head1 SYNOPSYS
+
+fatunpack [OPTION…] [PACKED_SCRIPT…]
+
+=head1 DESCRIPTION
+
+This tool unpacks scripts packed with App::FatPacker.
+
+Packed script's file names are specified as positional arguments. If no
+argument is given, a script from standard intput will be processed.
+
+The content of packed script stripped of all bundled modules is written to
+standard output.
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<--libdir DIRECTORY>
+
+Directory to output unpacked modules to that where bundled into the input
+script. Default value is C<lib>.
+
+=item B<--filter REGULAR_EXPRESSION>
+
+Save only modules whose file name matches the B<REGULAR_EXPRESSION>. The file
+names are compared without B<--libdir> prefix. The expession is not anchored
+by default. Empty expression matches any file name. Default value is empty
+regular expression, i.e. to save all modules.
+
+=back
+
+=head1 VERSION
+
+This is version 1.
+
+=head1 COPYRIGHT
+
+Copyright © 2013  Petr Písař <ppisar at redhat.com>.
+
+=head1 LICENSE
+
+This is free software.  You may redistribute copies of it under the terms of
+the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>.
+There is NO WARRANTY, to the extent permitted by law.
+
+=cut
diff --git a/perl-App-cpanminus.spec b/perl-App-cpanminus.spec
index a0eb629..af4181a 100644
--- a/perl-App-cpanminus.spec
+++ b/perl-App-cpanminus.spec
@@ -1,72 +1,114 @@
 Name:           perl-App-cpanminus
 Version:        1.6927
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Get, unpack, build and install CPAN modules
 License:        GPL+ or Artistic
 Group:          Development/Libraries
 URL:            http://search.cpan.org/dist/App-cpanminus/
 Source0:        http://www.cpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-%{version}.tar.gz
+Source1:        fatunpack
 BuildArch:      noarch
+BuildRequires:  %{_bindir}/podselect
 BuildRequires:  perl
 BuildRequires:  perl(ExtUtils::MakeMaker) >= 6.30
-# Tests:
+BuildRequires:  perl(File::Path)
+BuildRequires:  perl(File::Spec)
+BuildRequires:  perl(Getopt::Long)
 BuildRequires:  perl(strict)
+BuildRequires:  perl(warnings)
+# Run-time:
+# Nothing special. The tests are very poor. But we run perl -c at built-time
+# to check for correct unpacking. So we need non-optional run-time
+# dependencies at build-time too:
+BuildRequires:  perl(aliased)
+BuildRequires:  perl(Config)
+BuildRequires:  perl(constant)
+# CPAN::DistnameInfo not needed for compilation
+# CPAN::Meta not needed for copmilation
+# CPAN::Meta::Check not needed for compilation
+# CPAN::Meta::Prereqs not needed for compilation
+BuildRequires:  perl(CPAN::Meta::Requirements)
+# CPAN::Meta::YAML not needed for compilation
+BuildRequires:  perl(Cwd)
+# Digest::SHA not needed for compilation
+BuildRequires:  perl(File::Basename)
+BuildRequires:  perl(File::Copy)
+BuildRequires:  perl(File::Find)
+# File::pushd not needed for compilation
+BuildRequires:  perl(File::Temp)
+# HTTP::Tiny not needed for compilation
+# local::lib not needed for compilation
+# JSON::PP not needed for compilation
+# Module::CPANfile not needed for compilation
+# Module::CoreList not needed for compilation
+# Module::Metadata not needed for compilation
+BuildRequires:  perl(Parse::CPAN::Meta)
+# Safe not needed for compilation
+BuildRequires:  perl(String::ShellQuote)
+BuildRequires:  perl(Symbol)
+BuildRequires:  perl(version)
+# version::vpp not needed for compilation
+BuildRequires:  perl(warnings::register)
+# YAML not needed for compilation
+# Tests:
 BuildRequires:  perl(Test::More)
 Requires:       perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
-# Required by bin/cpanm
-Requires:       perl(base)
-Requires:       perl(Carp)
+# Current dependency generator cannot parse compressed code. Use PPI to find
+# them, and list them manually:
+Requires:       perl(aliased)
+# Archive::Tar is optional
+# Archive::Zip is optional
+# Compress::Zlib is optional
+Requires:       perl(Config)
 Requires:       perl(constant)
-# CPAN::DistnameInfo bundled
-# CPAN::Meta not used
-# CPAN::Meta::Check bundled
-# CPAN::Meta::Converter bundled
-# CPAN::Meta::Feature bundled
-# CPAN::Meta::History bundled
-# CPAN::Meta::Prereqs bundled
-# CPAN::Meta::Requirements bundled
-# CPAN::Meta::Spec bundled
-# CPAN::Meta::Validator bundled
-# CPAN::Meta::YAML bundled
+Requires:       perl(CPAN::DistnameInfo)
+Requires:       perl(CPAN::Meta)
+Requires:       perl(CPAN::Meta::Check)
+Requires:       perl(CPAN::Meta::Prereqs)
+Requires:       perl(CPAN::Meta::Requirements)
+Requires:       perl(CPAN::Meta::YAML)
 Requires:       perl(Cwd)
 Requires:       perl(Digest::SHA)
-Requires:       perl(Encode)
-# Exporter bundled
-# Exporter::Heavy bundled
 Requires:       perl(ExtUtils::Install) >= 1.46
 Requires:       perl(ExtUtils::MakeMaker) >= 6.31
+Requires:       perl(File::Basename)
+Requires:       perl(File::Copy)
+Requires:       perl(File::Find)
+# File::HomeDir is optional
 Requires:       perl(File::Path)
-# File::pushd bundled
+Requires:       perl(File::pushd)
 Requires:       perl(File::Spec)
+Requires:       perl(File::Temp)
 Requires:       perl(Getopt::Long)
 # HTTP getter by LWP::UserAgent or wget or curl or HTTP::Tiny
-# HTTP::Tiny bundled
-Requires:       perl(IO::File)
-Requires:       perl(IO::Socket)
-# JSON::PP bundled
-# lib::core::only not used
-# local::lib bundled
-Requires:       perl(Math::BigFloat)
-Requires:       perl(Math::BigInt)
+Requires:       perl(HTTP::Tiny)
+Requires:       perl(JSON::PP)
+Requires:       perl(local::lib)
+# LWP::UserAgent is optional
+# LWP::Protocol::https is optional
 Requires:       perl(Module::Build)
+Requires:       perl(Module::CPANfile)
 Requires:       perl(Module::CoreList)
-# Module::CPANfile bundled
-# Module::Metadata bundled
-Requires:       perl(Module::Signature)
-# Parse::CPAN::Meta bundled
+Requires:       perl(Module::Metadata)
+# Module::Signature is optional
+Requires:       perl(Parse::CPAN::Meta)
 Requires:       perl(Safe)
-Requires:       perl(Scalar::Util)
-Requires:       perl(Time::Local)
-# version bundled
-# version::vpp bundled
+Requires:       perl(String::ShellQuote)
+Requires:       perl(Symbol)
+Requires:       perl(version)
+Requires:       perl(version::vpp)
+# Win32 not used
 Requires:       perl(YAML)
+Provides:       perl(App::cpanminus) = %{version}
 # XXX: Keep Provides: cpanminus to allow `yum install cpanminus' instead of
 # longer `yum install perl-App-cpanminus'.
 Provides:       cpanminus = %{version}-%{release}
 Obsoletes:      cpanminus <= 1.2002
 
-# Do not require/export in-place modules
-%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(App::cpanminus::script\\)$
+# Filter under-specified dependencies
+%global __provides_exclude %{?__provides_exclude:%__provides_exclude|}^perl\\(App::cpanminus\\)$
+# Filter private modules
+%global __provides_exclude %{__provides_exclude}|^perl\\(ModuleBuildSkipMan\\)
 
 %description
 Why? It's dependency free, requires zero configuration, and stands alone 
@@ -75,6 +117,11 @@ scripting. When running, it requires only 10 MB of RAM.
 
 %prep
 %setup -q -n App-cpanminus-%{version}
+# Unbundle fat-packed modules
+podselect lib/App/cpanminus.pm > lib/App/cpanminus.pod
+%{SOURCE1} --libdir lib --filter '^App/cpanminus' bin/cpanm >bin/cpanm.stripped
+perl -c -Ilib bin/cpanm.stripped
+mv bin/cpanm{.stripped,}
 
 %build
 perl Makefile.PL INSTALLDIRS=vendor
@@ -96,6 +143,9 @@ make test
 %{_bindir}/cpanm
 
 %changelog
+* Wed Sep 11 2013 Petr Pisar <ppisar at redhat.com> - 1.6927-3
+- Unbundle all modules (bug #907464)
+
 * Sat Aug 03 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.6927-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
 



More information about the perl-devel mailing list