… | |
… | |
40 | |
40 | |
41 | With F<uClibc> and F<upx> on x86, you can create a single 500kb binary |
41 | With F<uClibc> and F<upx> on x86, you can create a single 500kb binary |
42 | that contains perl and 100 modules such as POSIX, AnyEvent, EV, IO::AIO, |
42 | that contains perl and 100 modules such as POSIX, AnyEvent, EV, IO::AIO, |
43 | Coro and so on. Or any other choice of modules. |
43 | Coro and so on. Or any other choice of modules. |
44 | |
44 | |
|
|
45 | To see how this turns out, you can try out smallperl and bigperl, two |
|
|
46 | pre-built static and compressed perl binaries with many and even more |
|
|
47 | modules: just follow the links at L<http://staticperl.schmorp.de/>. |
|
|
48 | |
45 | The created files do not need write access to the file system (like PAR |
49 | The created files do not need write access to the file system (like PAR |
46 | does). In fact, since this script is in many ways similar to PAR::Packer, |
50 | does). In fact, since this script is in many ways similar to PAR::Packer, |
47 | here are the differences: |
51 | here are the differences: |
48 | |
52 | |
49 | =over 4 |
53 | =over 4 |
… | |
… | |
118 | often as necessary. |
122 | often as necessary. |
119 | |
123 | |
120 | =head1 THE F<STATICPERL> SCRIPT |
124 | =head1 THE F<STATICPERL> SCRIPT |
121 | |
125 | |
122 | This module installs a script called F<staticperl> into your perl |
126 | This module installs a script called F<staticperl> into your perl |
123 | binary directory. The script is fully self-contained, and can be used |
127 | binary directory. The script is fully self-contained, and can be |
124 | without perl (for example, in an uClibc chroot environment). In fact, |
128 | used without perl (for example, in an uClibc chroot environment). In |
125 | it can be extracted from the C<App::Staticperl> distribution tarball as |
129 | fact, it can be extracted from the C<App::Staticperl> distribution |
126 | F<bin/staticperl>, without any installation. |
130 | tarball as F<bin/staticperl>, without any installation. The |
|
|
131 | newest (possibly alpha) version can also be downloaded from |
|
|
132 | L<http://staticperl.schmorp.de/staticperl>. |
127 | |
133 | |
128 | F<staticperl> interprets the first argument as a command to execute, |
134 | F<staticperl> interprets the first argument as a command to execute, |
129 | optionally followed by any parameters. |
135 | optionally followed by any parameters. |
130 | |
136 | |
131 | There are two command categories: the "phase 1" commands which deal with |
137 | There are two command categories: the "phase 1" commands which deal with |
… | |
… | |
152 | |
158 | |
153 | To force recompilation or reinstallation, you need to run F<staticperl |
159 | To force recompilation or reinstallation, you need to run F<staticperl |
154 | distclean> first. |
160 | distclean> first. |
155 | |
161 | |
156 | =over 4 |
162 | =over 4 |
|
|
163 | |
|
|
164 | =item F<staticperl version> |
|
|
165 | |
|
|
166 | Prints some info about the version of the F<staticperl> script you are using. |
157 | |
167 | |
158 | =item F<staticperl fetch> |
168 | =item F<staticperl fetch> |
159 | |
169 | |
160 | Runs only the download and unpack phase, unless this has already happened. |
170 | Runs only the download and unpack phase, unless this has already happened. |
161 | |
171 | |
… | |
… | |
286 | |
296 | |
287 | All options that specify modules or files to be added are processed in the |
297 | All options that specify modules or files to be added are processed in the |
288 | order given on the command line (that affects the C<--use> and C<--eval> |
298 | order given on the command line (that affects the C<--use> and C<--eval> |
289 | options at the moment). |
299 | options at the moment). |
290 | |
300 | |
|
|
301 | =head3 PACKAGE SELECTION WORKFLOW |
|
|
302 | |
|
|
303 | F<staticperl mkbundle> has a number of options to control package |
|
|
304 | selection. This section describes how they interact with each other. Also, |
|
|
305 | since I am still a newbie w.r.t. these issues, maybe future versions of |
|
|
306 | F<staticperl> will change this, so watch out :) |
|
|
307 | |
|
|
308 | The idiom "in order" means "in order that they are specified on the |
|
|
309 | commandline". If you use a bundle specification file, then the options |
|
|
310 | will be processed as if they were given in place of the bundle file name. |
|
|
311 | |
|
|
312 | =over 4 |
|
|
313 | |
|
|
314 | =item 1. apply all C<--use>, C<--eval>, C<--add>, C<--addbin> and |
|
|
315 | C<--incglob> options, in order. |
|
|
316 | |
|
|
317 | In addition, C<--use> and C<--eval> dependencies will be added when the |
|
|
318 | options are processed. |
|
|
319 | |
|
|
320 | =item 2. apply all C<--include> and C<--exclude> options, in order. |
|
|
321 | |
|
|
322 | All this step does is potentially reduce the number of files already |
|
|
323 | selected or found in phase 1. |
|
|
324 | |
|
|
325 | =item 3. find all modules (== F<.pm> files), gather their static archives |
|
|
326 | (F<.a>) and AutoLoader splitfiles (F<.ix> and F<.al> files), find any |
|
|
327 | extra libraries they need for linking (F<extralibs.ld>) and optionally |
|
|
328 | evaluate any F<.packlist> files. |
|
|
329 | |
|
|
330 | This step is required to link against XS extensions and also adds files |
|
|
331 | required for L<AutoLoader> to do it's job. |
|
|
332 | |
|
|
333 | =back |
|
|
334 | |
|
|
335 | After this, all the files selected for bundling will be read and processed |
|
|
336 | (stripped), the bundle files will be written, and optionally a new F<perl> |
|
|
337 | or application binary will be linked. |
|
|
338 | |
291 | =head3 MKBUNDLE OPTIONS |
339 | =head3 MKBUNDLE OPTIONS |
292 | |
340 | |
293 | =over 4 |
341 | =over 4 |
294 | |
342 | |
295 | =item --verbose | -v |
343 | =item --verbose | -v |
… | |
… | |
416 | (using a C<require>) before anything else when the new perl is |
464 | (using a C<require>) before anything else when the new perl is |
417 | initialised. This can be used to modify C<@INC> or anything else before |
465 | initialised. This can be used to modify C<@INC> or anything else before |
418 | the perl interpreter executes scripts given on the command line (or via |
466 | the perl interpreter executes scripts given on the command line (or via |
419 | C<-e>). This works even in an embedded interpreter. |
467 | C<-e>). This works even in an embedded interpreter. |
420 | |
468 | |
|
|
469 | =item --usepacklist |
|
|
470 | |
|
|
471 | Read F<.packlist> files for each distribution that happens to match a |
|
|
472 | module name you specified. Sounds weird, and it is, so expect semantics to |
|
|
473 | change somehow in the future. |
|
|
474 | |
|
|
475 | The idea is that most CPAN distributions have a F<.pm> file that matches |
|
|
476 | the name of the distribution (which is rather reasonable after all). |
|
|
477 | |
|
|
478 | If this switch is enabled, then if any of the F<.pm> files that have been |
|
|
479 | selected match an install distribution, then all F<.pm>, F<.pl>, F<.al> |
|
|
480 | and F<.ix> files installed by this distribution are also included. |
|
|
481 | |
|
|
482 | For example, using this switch, when the L<URI> module is specified, then |
|
|
483 | all L<URI> submodules that have been installed via the CPAN distribution |
|
|
484 | are included as well, so you don't have to manually specify them. |
|
|
485 | |
421 | =item --incglob pattern |
486 | =item --incglob pattern |
422 | |
487 | |
423 | This goes through all library directories and tries to match any F<.pm> |
488 | This goes through all library directories and tries to match any F<.pm> |
424 | and F<.pl> files against the extended glob pattern (see below). If a file |
489 | and F<.pl> files against the extended glob pattern (see below). If a file |
425 | matches, it is added. This switch will automatically detect L<AutoLoader> |
490 | matches, it is added. This switch will automatically detect L<AutoLoader> |
… | |
… | |
552 | |
617 | |
553 | =back |
618 | =back |
554 | |
619 | |
555 | =head2 F<STATICPERL> CONFIGURATION AND HOOKS |
620 | =head2 F<STATICPERL> CONFIGURATION AND HOOKS |
556 | |
621 | |
557 | During (each) startup, F<staticperl> tries to source the following shell |
622 | During (each) startup, F<staticperl> tries to source some shell files to |
|
|
623 | allow you to fine-tune/override configuration settings. |
|
|
624 | |
|
|
625 | In them you can override shell variables, or define shell functions |
|
|
626 | ("hooks") to be called at specific phases during installation. For |
|
|
627 | example, you could define a C<postinstall> hook to install additional |
|
|
628 | modules from CPAN each time you start from scratch. |
|
|
629 | |
|
|
630 | If the env variable C<$STATICPERLRC> is set, then F<staticperl> will try |
|
|
631 | to source the file named with it only. Otherwise, it tries the following |
558 | files in order: |
632 | shell files in order: |
559 | |
633 | |
560 | /etc/staticperlrc |
634 | /etc/staticperlrc |
561 | ~/.staticperlrc |
635 | ~/.staticperlrc |
562 | $STATICPERL/rc |
636 | $STATICPERL/rc |
563 | |
|
|
564 | They can be used to override shell variables, or define functions to be |
|
|
565 | called at specific phases. |
|
|
566 | |
637 | |
567 | Note that the last file is erased during F<staticperl distclean>, so |
638 | Note that the last file is erased during F<staticperl distclean>, so |
568 | generally should not be used. |
639 | generally should not be used. |
569 | |
640 | |
570 | =head3 CONFIGURATION VARIABLES |
641 | =head3 CONFIGURATION VARIABLES |
… | |
… | |
632 | |
703 | |
633 | More commonly, you would either activate 64 bit integer support |
704 | More commonly, you would either activate 64 bit integer support |
634 | (C<-Duse64bitint>), or disable large files support (-Uuselargefiles), to |
705 | (C<-Duse64bitint>), or disable large files support (-Uuselargefiles), to |
635 | reduce filesize further. |
706 | reduce filesize further. |
636 | |
707 | |
637 | =item C<PERL_CPPFLAGS>, C<PERL_OPTIMIZE>, C<PERL_LDFLAGS>, C<PERL_LIBS> |
708 | =item C<PERL_CC>, C<PERL_CPPFLAGS>, C<PERL_OPTIMIZE>, C<PERL_LDFLAGS>, C<PERL_LIBS> |
638 | |
709 | |
639 | These flags are passed to perl's F<Configure> script, and are generally |
710 | These flags are passed to perl's F<Configure> script, and are generally |
640 | optimised for small size (at the cost of performance). Since they also |
711 | optimised for small size (at the cost of performance). Since they also |
641 | contain subtle workarounds around various build issues, changing these |
712 | contain subtle workarounds around various build issues, changing these |
642 | usually requires understanding their default values - best look at the top |
713 | usually requires understanding their default values - best look at the top |
… | |
… | |
645 | =back |
716 | =back |
646 | |
717 | |
647 | =head4 Variables you probably I<do not want> to override |
718 | =head4 Variables you probably I<do not want> to override |
648 | |
719 | |
649 | =over 4 |
720 | =over 4 |
|
|
721 | |
|
|
722 | =item C<MAKE> |
|
|
723 | |
|
|
724 | The make command to use - default is C<make>. |
650 | |
725 | |
651 | =item C<MKBUNDLE> |
726 | =item C<MKBUNDLE> |
652 | |
727 | |
653 | Where F<staticperl> writes the C<mkbundle> command to |
728 | Where F<staticperl> writes the C<mkbundle> command to |
654 | (default: F<$STATICPERL/mkbundle>). |
729 | (default: F<$STATICPERL/mkbundle>). |
… | |
… | |
916 | |
991 | |
917 | If you want to handle IRIs or IDNs (L<AnyEvent::Util> punycode and idn |
992 | If you want to handle IRIs or IDNs (L<AnyEvent::Util> punycode and idn |
918 | functions), you also need to include C<"AnyEvent/Util/idna.pl"> and |
993 | functions), you also need to include C<"AnyEvent/Util/idna.pl"> and |
919 | C<"AnyEvent/Util/uts46data.pl">. |
994 | C<"AnyEvent/Util/uts46data.pl">. |
920 | |
995 | |
|
|
996 | Or you can use C<--usepacklist> and specify C<-MAnyEvent> to include |
|
|
997 | everything. |
|
|
998 | |
921 | =item Carp |
999 | =item Carp |
922 | |
1000 | |
923 | Carp had (in older versions of perl) a dependency on L<Carp::Heavy>. As of |
1001 | Carp had (in older versions of perl) a dependency on L<Carp::Heavy>. As of |
924 | perl 5.12.2 (maybe earlier), this dependency no longer exists. |
1002 | perl 5.12.2 (maybe earlier), this dependency no longer exists. |
925 | |
1003 | |
… | |
… | |
929 | turn might need L<"Config_heavy.pl">. Including the latter gives you |
1007 | turn might need L<"Config_heavy.pl">. Including the latter gives you |
930 | both. |
1008 | both. |
931 | |
1009 | |
932 | =item Term::ReadLine::Perl |
1010 | =item Term::ReadLine::Perl |
933 | |
1011 | |
934 | Also needs L<Term::ReadLine::readline>. |
1012 | Also needs L<Term::ReadLine::readline>, or C<--usepacklist>. |
935 | |
1013 | |
936 | =item URI |
1014 | =item URI |
937 | |
1015 | |
938 | URI implements schemes as separate modules - the generic URL scheme is |
1016 | URI implements schemes as separate modules - the generic URL scheme is |
939 | implemented in L<URI::_generic>, HTTP is implemented in L<URI::http>. If |
1017 | implemented in L<URI::_generic>, HTTP is implemented in L<URI::http>. If |
940 | you need to use any of these schemes, you should include these manually. |
1018 | you need to use any of these schemes, you should include these manually, |
|
|
1019 | or use C<--usepacklist>. |
941 | |
1020 | |
942 | =back |
1021 | =back |
943 | |
1022 | |
944 | =head2 RECIPES |
1023 | =head2 RECIPES |
945 | |
1024 | |
… | |
… | |
978 | PERL_CONFIGURE="$PERL_CONFIGURE -U$sym" |
1057 | PERL_CONFIGURE="$PERL_CONFIGURE -U$sym" |
979 | done |
1058 | done |
980 | } |
1059 | } |
981 | |
1060 | |
982 | This mostly gains space when linking staticaly, as the functions will |
1061 | This mostly gains space when linking staticaly, as the functions will |
983 | liekly not be linked in. The gain for dynamically-linked binaries is |
1062 | likely not be linked in. The gain for dynamically-linked binaries is |
984 | smaller. |
1063 | smaller. |
985 | |
1064 | |
986 | Also, this leaves C<gethostbyname> in - not only is it actually used |
1065 | Also, this leaves C<gethostbyname> in - not only is it actually used |
987 | often, the L<Socket> module also exposes it, so leaving it out usually |
1066 | often, the L<Socket> module also exposes it, so leaving it out usually |
988 | gains little. Why Socket exposes a C function that is in the core already |
1067 | gains little. Why Socket exposes a C function that is in the core already |