Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packer v1.33 #570

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions README_PerlPowerTools.exe.pod
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
=pod

=encoding utf8

=head1 What is PerlPowerTools.exe ?

F<perlpowertools.exe> provides all PerlPowerTools packaged as a single standalone
Windows executable (no dependencies). Perl interpreter included.

As BusyBox, if the executable is renamed / hardlinked / symlinked as one of the
tools, it will behave as that tool automatically.

=head2 How to call the tools?

bin/cat # the standard way
bin/perlpowertools cat # with helper script
packed/perlpowertools.exe cat # from standalone executable
packed/cat.exe # perlpowertools.exe renamed as cat.exe

=head2 How to read the doc?

bin/perldoc cat # cat documentation
bin/perlpowertools perldoc cat # cat documentation
packed/perlpowertools.exe perldoc perlpowertools # PerlPowerTools documentation
packed/perlpowertools.exe perldoc perldoc # perldoc documentation

=head2 How to find the version?

bin/perlpowertools -V # PerlPowerTools module version
packed/perlpowertools.exe -V # PerlPowerTools module version

=head2 How does it work?

bin/perlpowertools # dispatcher/frontend (has same behaviour packed or not)
bin/perldoc # custom 'perldoc' (has same behaviour packed or not)
util/packer # bundles everything together with PAR::Packer

The build script F<util/packer> uses PAR::Packer to package the content of `bin`
and generate F<packed/perlpowertools.exe> (about 11MB). When executed, this file
unzip itself into a temporary directory (meaning fhe first run takes a few seconds).

PAR will execute the tool from `bin` with same name as the executable (without extension).
The executable MUST be called 'perlpowertools.exe' or 'one-of-the-tools.exe', otherwise
PAR won't know what to run.

=head2 Can I add my own scripts?

Yes, copy them into `bin` and run F<util/packer>.

=head2 Notes

=over

=item - The executable is detected by some antivirus software.

=item - Modulinos need a patch to work, please see F<PROGRAMMING_STYLE.md>.

=item - Feedbacks of any kind are very welcomed and encouraged.

=back

C<kaldor AT cpan.org>

=cut
30 changes: 21 additions & 9 deletions bin/perlpowertools
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
=begin metadata

Name: perlpowertools
Description: a program launcher for Perl Power Tools
Author: kal247, https://github.com/kal247
License: artistic2
Description: helper script for PerlPowerTools
Author: jul, [email protected]
License: Artistic License 2.0

=end metadata

Expand All @@ -18,11 +18,14 @@ use warnings;
use utf8;
use Getopt::Std;
use File::Basename;
use Cwd 'abs_path';
use Cwd qw (abs_path cwd);
my $ppt_dir;
BEGIN { $ppt_dir = dirname(abs_path($0)) . '/..' };
use lib $ppt_dir . '/lib';
use PerlPowerTools;

our $VERSION = qw( 1.024 );
our $VERSION = $PerlPowerTools::VERSION;
my $program = 'perlpowertools';
my @tools = qw( addbib apply ar arch arithmetic asa awk banner basename bc cal cat chgrp ching chmod chown clear cmp col colrm comm cp cut date dc deroff diff dirname du echo ed env expand expr factor false file find fish fmt fold fortune from glob grep hangman head id install join kill ln lock look ls mail man maze mimedecode mkdir mkfifo moo morse nl od par paste patch perldoc pig ping pom ppt pr primes printenv printf pwd rain random rev rm rmdir robots rot13 shar sleep sort spell split strings sum tac tail tar tee test time touch tr true tsort tty uname unexpand uniq units unpar unshar uudecode uuencode wc what which whois words wump xargs yes );
my $usage = <<EOF;

Usage: $program [-hVl]
Expand All @@ -44,17 +47,26 @@ my $list = $options{l} || 0;

die $usage if $help;
die $VERSION . "\n" if $version;
die join ("\n", @tools) . "\n" if $list;

my $tool = shift || '';

########
# MAIN #
########

my $tool = shift || '';
my $ppt_bin = defined $ENV{PAR_TEMP} ? "$ENV{PAR_TEMP}/inc/script" : dirname(abs_path($0));
my $cwd = cwd;
chdir $ppt_bin;
my @tools = glob("*");
chdir $cwd;
@tools = grep { $_ ne "$program" } @tools;

die join ("\n", @tools) . "\n" if $list;
die $usage if not grep { $tool eq $_ } @tools;

my $file = defined $ENV{PAR_TEMP} ? "$ENV{PAR_TEMP}/inc/script/$tool" : dirname(abs_path($0)) . "/$tool";
my $file = "$ppt_bin/$tool";
$0 = $tool; # for usage/warning/error messages
package PerlPowerTools::Packed; # change caller(0), for modulinos
my $return = do $file;
die $@ if $@;
die "$file: $!" unless defined $return;
Expand Down
Loading