Skip to content

Commit 874e7ce

Browse files
committed
documentation update
1 parent f0a44ff commit 874e7ce

File tree

4 files changed

+92
-87
lines changed

4 files changed

+92
-87
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ The following compile-time variable can tighten further the security of PEB.
155155
PEB can also use any Perl on PATH.
156156

157157
## Preparing a Perl Distribution for PEB
158-
Sometimes it is important to minimize the size of the relocatable (or portable) Perl distribution used for a PEB-based application. ``{PEB_binary_directory}/sdk/compactor.pl`` script is one solution to this problem. It finds all dependencies of the Perl scripts in the ``{PEB_binary_directory}/resources/app`` directory and copies them in a new ``{PEB_binary_directory}/perl/lib`` folder; a new ``{PEB_binary_directory}/perl/bin`` is also created. The original ``bin`` and ``lib`` folders are saved as ``{PEB_binary_directory}/perl/bin-original`` and ``{PEB_binary_directory}/perl/lib-original`` respectively. These directories should be manually archived or removed.
158+
Sometimes it is important to minimize the size of the relocatable (or portable) Perl distribution used by a PEB-based application. ``{PEB_binary_directory}/sdk/compactor.pl`` script is one solution to this problem. It finds all dependencies of all Perl scripts in the ``{PEB_binary_directory}/resources/app`` directory and copies them in a new ``{PEB_binary_directory}/perl/lib`` folder; a new ``{PEB_binary_directory}/perl/bin`` is also created. The original ``bin`` and ``lib`` folders are saved as ``{PEB_binary_directory}/perl/bin-original`` and ``{PEB_binary_directory}/perl/lib-original`` respectively. These directories should be manually archived for future use or removed.
159159

160-
``compactor.pl`` should be started using ``{PEB_binary_directory}/compactor.sh`` on a Linux and Mac machines and ``{PEB_binary_directory}/compactor.cmd`` on a Windows machine to ensure that only the Perl distribution used by PEB is going to start ``compactor.pl``. This is necessary to avoid dependency mismatches with any other Perl on PATH.
160+
``compactor.pl`` should be started using ``{PEB_binary_directory}/compactor.sh`` on a Linux or a Mac machine and ``{PEB_binary_directory}/compactor.cmd`` on a Windows machine to ensure that only the Perl distribution used by PEB is going to start ``compactor.pl``. This is necessary to avoid dependency mismatches with any other Perl on PATH.
161161

162162
``compactor.pl`` relies on ``Module::ScanDeps`` and ``File::Copy::Recursive`` CPAN modules, which are located in the ``{PEB_binary_directory}/sdk/lib`` folder.
163163

sdk/lib/File/Copy/Recursive.pm

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/perl
2+
13
package File::Copy::Recursive;
24

35
use strict;
@@ -8,12 +10,12 @@ BEGIN {
810
use warnings;
911

1012
use Carp;
11-
use File::Copy;
13+
use File::Copy;
1214
use File::Spec; #not really needed because File::Copy already gets it, but for good measure :)
1315

14-
use vars qw(
15-
@ISA @EXPORT_OK $VERSION $MaxDepth $KeepMode $CPRFComp $CopyLink
16-
$PFSCheck $RemvBase $NoFtlPth $ForcePth $CopyLoop $RMTrgFil $RMTrgDir
16+
use vars qw(
17+
@ISA @EXPORT_OK $VERSION $MaxDepth $KeepMode $CPRFComp $CopyLink
18+
$PFSCheck $RemvBase $NoFtlPth $ForcePth $CopyLoop $RMTrgFil $RMTrgDir
1719
$CondCopy $BdTrgWrn $SkipFlop $DirPerms
1820
);
1921

@@ -24,7 +26,7 @@ $VERSION = '0.38';
2426

2527
$MaxDepth = 0;
2628
$KeepMode = 1;
27-
$CPRFComp = 0;
29+
$CPRFComp = 0;
2830
$CopyLink = eval { local $SIG{'__DIE__'};symlink '',''; 1 } || 0;
2931
$PFSCheck = 1;
3032
$RemvBase = 0;
@@ -36,7 +38,7 @@ $RMTrgDir = 0;
3638
$CondCopy = {};
3739
$BdTrgWrn = 0;
3840
$SkipFlop = 0;
39-
$DirPerms = 0777;
41+
$DirPerms = 0777;
4042

4143
my $samecheck = sub {
4244
return 1 if $^O eq 'MSWin32'; # need better way to check for this on winders...
@@ -66,7 +68,7 @@ my $samecheck = sub {
6668
carp "Caught Deep Recursion Condition: $_[0] contains $_[1]";
6769
return;
6870
}
69-
71+
7072
pop @pth;
7173
}
7274
}
@@ -76,15 +78,15 @@ my $samecheck = sub {
7678

7779
my $glob = sub {
7880
my ($do, $src_glob, @args) = @_;
79-
81+
8082
local $CPRFComp = 1;
81-
83+
8284
my @rt;
8385
for my $path ( glob($src_glob) ) {
8486
my @call = [$do->($path, @args)] or return;
8587
push @rt, \@call;
8688
}
87-
89+
8890
return @rt;
8991
};
9092

@@ -124,7 +126,7 @@ my $ok_todo_asper_condcopy = sub {
124126
return $copy;
125127
};
126128

127-
sub fcopy {
129+
sub fcopy {
128130
$samecheck->(@_) or return;
129131
if($RMTrgFil && (-d $_[1] || -e $_[1]) ) {
130132
my $trg = $_[1];
@@ -146,10 +148,10 @@ sub fcopy {
146148
pathmk(File::Spec->catpath($volm,$path,''), $NoFtlPth);
147149
}
148150
if( -l $_[0] && $CopyLink ) {
149-
carp "Copying a symlink ($_[0]) whose target does not exist"
151+
carp "Copying a symlink ($_[0]) whose target does not exist"
150152
if !-e readlink($_[0]) && $BdTrgWrn;
151153
symlink readlink(shift()), shift() or return;
152-
} else {
154+
} else {
153155
copy(@_) or return;
154156

155157
my @base_file = File::Spec->splitpath($_[0]);
@@ -160,11 +162,11 @@ sub fcopy {
160162
return wantarray ? (1,0,0) : 1; # use 0's incase they do math on them and in case rcopy() is called in list context = no uninit val warnings
161163
}
162164

163-
sub rcopy {
165+
sub rcopy {
164166
if (-l $_[0] && $CopyLink) {
165-
goto &fcopy;
167+
goto &fcopy;
166168
}
167-
169+
168170
goto &dircopy if -d $_[0] || substr( $_[0], ( 1 * -1), 1) eq '*';
169171
goto &fcopy;
170172
}
@@ -191,9 +193,9 @@ sub dircopy {
191193

192194
$samecheck->( $_zero, $_[1] ) or return;
193195
if ( !-d $_zero || ( -e $_[1] && !-d $_[1] ) ) {
194-
$! = 20;
196+
$! = 20;
195197
return;
196-
}
198+
}
197199

198200
if(!-d $_[1]) {
199201
pathmk($_[1], $NoFtlPth) or return;
@@ -212,9 +214,9 @@ sub dircopy {
212214
my $recurs; #must be my()ed before sub {} since it calls itself
213215
$recurs = sub {
214216
my ($str,$end,$buf) = @_;
215-
$filen++ if $end eq $baseend;
217+
$filen++ if $end eq $baseend;
216218
$dirn++ if $end eq $baseend;
217-
219+
218220
$DirPerms = oct($DirPerms) if substr($DirPerms,0,1) eq '0';
219221
mkdir($end,$DirPerms) or return if !-d $end;
220222
chmod scalar((stat($str))[2]), $end if $KeepMode;
@@ -224,7 +226,7 @@ sub dircopy {
224226
}
225227
$level++;
226228

227-
229+
228230
my @files;
229231
if ( $] < 5.006 ) {
230232
opendir(STR_DH, $str) or return;
@@ -242,21 +244,21 @@ sub dircopy {
242244
my $org = File::Spec->catfile($str, $file_ut);
243245
my $new = File::Spec->catfile($end, $file_ut);
244246
if( -l $org && $CopyLink ) {
245-
carp "Copying a symlink ($org) whose target does not exist"
247+
carp "Copying a symlink ($org) whose target does not exist"
246248
if !-e readlink($org) && $BdTrgWrn;
247249
symlink readlink($org), $new or return;
248-
}
250+
}
249251
elsif(-d $org) {
250252
$recurs->($org,$new,$buf) if defined $buf;
251253
$recurs->($org,$new) if !defined $buf;
252254
$filen++;
253255
$dirn++;
254-
}
256+
}
255257
else {
256258
if($ok_todo_asper_condcopy->($org)) {
257259
if($SkipFlop) {
258260
fcopy($org,$new,$buf) or next if defined $buf;
259-
fcopy($org,$new) or next if !defined $buf;
261+
fcopy($org,$new) or next if !defined $buf;
260262
}
261263
else {
262264
fcopy($org,$new,$buf) or return if defined $buf;
@@ -274,13 +276,13 @@ sub dircopy {
274276
return wantarray ? ($filen,$dirn,$level) : $filen;
275277
}
276278

277-
sub fmove { $move->(1, @_) }
279+
sub fmove { $move->(1, @_) }
278280

279-
sub rmove {
281+
sub rmove {
280282
if (-l $_[0] && $CopyLink) {
281-
goto &fmove;
283+
goto &fmove;
282284
}
283-
285+
284286
goto &dirmove if -d $_[0] || substr( $_[0], ( 1 * -1), 1) eq '*';
285287
goto &fmove;
286288
}
@@ -307,10 +309,10 @@ sub pathmk {
307309
$pth = File::Spec->catdir($pth, $parts[$_ + 1]) unless $_ == $#parts;
308310
}
309311
1;
310-
}
312+
}
311313

312314
sub pathempty {
313-
my $pth = shift;
315+
my $pth = shift;
314316

315317
return 2 if !-d $pth;
316318

@@ -322,19 +324,19 @@ sub pathempty {
322324
}
323325
else {
324326
opendir($pth_dh, $pth) or return;
325-
@names = grep !/^\.+$/, readdir($pth_dh);
327+
@names = grep !/^\.+$/, readdir($pth_dh);
326328
}
327-
329+
328330
for my $name (@names) {
329331
my ($name_ut) = $name =~ m{ (.*) }xms;
330332
my $flpth = File::Spec->catdir($pth, $name_ut);
331333

332334
if( -l $flpth ) {
333-
unlink $flpth or return;
335+
unlink $flpth or return;
334336
}
335337
elsif(-d $flpth) {
336338
pathrmdir($flpth) or return;
337-
}
339+
}
338340
else {
339341
unlink $flpth or return;
340342
}
@@ -346,7 +348,7 @@ sub pathempty {
346348
else {
347349
closedir $pth_dh;
348350
}
349-
351+
350352
1;
351353
}
352354

@@ -356,13 +358,13 @@ sub pathrm {
356358
my @pth = File::Spec->splitdir( $path );
357359
my $force = shift;
358360

359-
while(@pth) {
361+
while(@pth) {
360362
my $cur = File::Spec->catdir(@pth);
361-
last if !$cur; # necessary ???
363+
last if !$cur; # necessary ???
362364
if(!shift()) {
363365
pathempty($cur) or return if $force;
364366
rmdir $cur or return;
365-
}
367+
}
366368
else {
367369
pathempty($cur) if $force;
368370
rmdir $cur;
@@ -382,7 +384,7 @@ sub pathrmdir {
382384
}
383385

384386
pathempty($dir) or return;
385-
387+
386388
rmdir $dir or return;
387389
}
388390

@@ -405,7 +407,7 @@ File::Copy::Recursive - Perl extension for recursively copying files and directo
405407
fmove($orig,$new[,$buf]) or die $!;
406408
rmove($orig,$new[,$buf]) or die $!;
407409
dirmove($orig,$new[,$buf]) or die $!;
408-
410+
409411
rcopy_glob("orig/stuff-*", $trg [, $buf]) or die $!;
410412
rmove_glob("orig/stuff-*", $trg [,$buf]) or die $!;
411413
@@ -428,7 +430,7 @@ returns the same as File::Copy::copy() in scalar context and 1,0,0 in list conte
428430
429431
This function recursively traverses the $orig directory's structure and recursively copies it to the $new directory.
430432
$new is created if necessary (multiple non existant directories is ok (IE foo/bar/baz). The script logically and portably creates all of them if necessary).
431-
It attempts to preserve the mode (see Preserving Mode below) and
433+
It attempts to preserve the mode (see Preserving Mode below) and
432434
by default it copies all the way down into the directory, (see Managing Depth) below.
433435
If a directory is not specified it croaks just like fcopy croaks if its not a file that is specified.
434436
@@ -437,7 +439,7 @@ In list context it returns the number of files and directories, number of direct
437439
438440
my $num_of_files_and_dirs = dircopy($orig,$new);
439441
my($num_of_files_and_dirs,$num_of_dirs,$depth_traversed) = dircopy($orig,$new);
440-
442+
441443
Normally it stops and return's if a copy fails, to continue on regardless set $File::Copy::Recursive::SkipFlop to true.
442444
443445
local $File::Copy::Recursive::SkipFlop = 1;
@@ -447,7 +449,7 @@ That way it will copy everythgingit can ina directory and won't stop because of
447449
=head2 rcopy()
448450
449451
This function will allow you to specify a file *or* directory. It calls fcopy() if its a file and dircopy() if its a directory.
450-
If you call rcopy() (or fcopy() for that matter) on a file in list context, the values will be 1,0,0 since no directories and no depth are used.
452+
If you call rcopy() (or fcopy() for that matter) on a file in list context, the values will be 1,0,0 since no directories and no depth are used.
451453
This is important becasue if its a directory in list context and there is only the initial directory the return value is 1,1,1.
452454
453455
=head2 rcopy_glob()
@@ -482,7 +484,7 @@ So if you:
482484
483485
rmove('foo/bar/baz', '/etc/');
484486
# "baz" is removed from foo/bar after it is successfully copied to /etc/
485-
487+
486488
local $File::Copy::Recursive::Remvbase = 1;
487489
rmove('foo/bar/baz','/etc/');
488490
# if baz is successfully copied to /etc/ :
@@ -572,7 +574,7 @@ to false;
572574
=head2 Managing Depth
573575
574576
You can set the maximum depth a directory structure is recursed by setting:
575-
$File::Copy::Recursive::MaxDepth
577+
$File::Copy::Recursive::MaxDepth
576578
to a whole number greater than 0.
577579
578580
=head2 SymLinks
@@ -614,7 +616,7 @@ This should be unnecessary most of the time but its there if you need it :)
614616
615617
=head2 Turning off stat() check
616618
617-
By default the files or directories are checked to see if they are the same (IE linked, or two paths (absolute/relative or different relative paths) to the same file) by comparing the file's stat() info.
619+
By default the files or directories are checked to see if they are the same (IE linked, or two paths (absolute/relative or different relative paths) to the same file) by comparing the file's stat() info.
618620
It's a very efficient check that croaks if they are and shouldn't be turned off but if you must for some weird reason just set $File::Copy::Recursive::PFSCheck to a false value. ("PFS" stands for "Physical File System")
619621
620622
=head2 Emulating cp -rf dir1/ dir2/
@@ -665,7 +667,7 @@ This is false by default so that a check is done to see if the source directory
665667
666668
If you ever find a situation where $CopyLoop = 1 is desirable let me know (IE its a bad bad idea but is there if you want it)
667669
668-
(Note: On Windows this was necessary since it uses stat() to detemine samedness and stat() is essencially useless for this on Windows.
670+
(Note: On Windows this was necessary since it uses stat() to detemine samedness and stat() is essencially useless for this on Windows.
669671
The test is now simply skipped on Windows but I'd rather have an actual reliable check if anyone in Microsoft land would care to share)
670672
671673
=head1 SEE ALSO
@@ -691,6 +693,6 @@ Daniel Muey, L<http://drmuey.com/cpan_contact.pl>
691693
Copyright 2004 by Daniel Muey
692694
693695
This library is free software; you can redistribute it and/or modify
694-
it under the same terms as Perl itself.
696+
it under the same terms as Perl itself.
695697
696698
=cut

0 commit comments

Comments
 (0)