ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/App-Staticperl/staticperl.sh
Revision: 1.75
Committed: Tue Aug 1 03:48:59 2023 UTC (3 years, 1 month ago) by root
Content type: application/x-sh
Branch: MAIN
Changes since 1.74: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/bin/sh
2    
3     #############################################################################
4 root 1.45 # configuration to fill in (or to replace in your .staticperlrc)
5 root 1.1
6     STATICPERL=~/.staticperl
7 root 1.14 CPAN=http://mirror.netcologne.de/cpan # which mirror to use
8 root 1.1 EMAIL="read the documentation <rtfm@example.org>"
9 root 1.45 DLCACHE=
10 root 1.1
11     # perl build variables
12 root 1.21 MAKE=make
13 root 1.62 PERL_VERSION=http://stableperl.schmorp.de/dist/latest.tar.gz # 5.12.5 and 5.8.9 are good choices for small builds
14 root 1.19 PERL_CC=cc
15 root 1.4 PERL_CONFIGURE="" # additional Configure arguments
16 root 1.32 PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG"
17 root 1.51 PERL_OPTIMIZE="-Os" # -Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
18 root 1.1
19     ARCH="$(uname -m)"
20    
21 root 1.51 #case "$ARCH" in
22     # i*86 | x86_64 | amd64 )
23     # PERL_OPTIMIZE="$PERL_OPTIMIZE -mpush-args -mno-inline-stringops-dynamically -mno-align-stringops -mno-ieee-fp" # x86/amd64
24     # case "$ARCH" in
25     # i*86 )
26     # PERL_OPTIMIZE="$PERL_OPTIMIZE -fomit-frame-pointer -march=pentium3 -mtune=i386" # x86 only
27     # ;;
28     # esac
29     # ;;
30     #esac
31 root 1.1
32     # -Wl,--gc-sections makes it impossible to check for undefined references
33     # for some reason so we need to patch away the "-no" after Configure and before make :/
34 root 1.16 # --allow-multiple-definition exists to work around uclibc's pthread static linking bug
35 root 1.37 #PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition"
36     PERL_LDFLAGS=
37 root 1.1 PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself
38    
39     # some configuration options for modules
40 root 1.24 PERL_MM_USE_DEFAULT=1
41 root 1.39 PERL_MM_OPT="MAN1PODS= MAN3PODS="
42 root 1.24 #CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow
43 root 1.47 #EV_EXTRA_DEFS='-DEV_FEATURES=4+8+16+64 -DEV_USE_SELECT=0 -DEV_USE_POLL=1 -DEV_USE_EPOLL=1 -DEV_NO_LOOPS -DEV_COMPAT3=0'
44     export PERL_MM_USE_DEFAULT PERL_MM_OPT
45 root 1.1
46     # which extra modules to install by default from CPAN that are
47     # required by mkbundle
48 root 1.58 STATICPERL_MODULES="ExtUtils::MakeMaker ExtUtils::CBuilder common::sense Pod::Strip PPI PPI::XS Pod::Usage"
49 root 1.2
50     # which extra modules you might want to install
51     EXTRA_MODULES=""
52 root 1.1
53     # overridable functions
54 root 1.74 preconfigure() { : ; }
55     patchconfig() { : ; }
56     postconfigure() { : ; }
57     postbuild() { : ; }
58     postcpanconfig() { : ; }
59     postinstall() { : ; }
60 root 1.1
61     # now source user config, if any
62 root 1.14 if [ "$STATICPERLRC" ]; then
63     . "$STATICPERLRC"
64     else
65     [ -r /etc/staticperlrc ] && . /etc/staticperlrc
66     [ -r ~/.staticperlrc ] && . ~/.staticperlrc
67     [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc"
68     fi
69 root 1.1
70     #############################################################################
71     # support
72    
73 root 1.58 # work around ExtUtils::CBuilder and others
74     export CC="$PERL_CC"
75 root 1.66 export CFLAGS="$PERL_CFLAGS"
76 root 1.58 export LD="$PERL_CC"
77     export LDFLAGS="$PERL_LDFLAGS"
78     unset LIBS
79    
80 root 1.14 PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
81    
82 root 1.38 unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
83 root 1.39 unset PERL_MB_OPT
84 root 1.24 LC_ALL=C; export LC_ALL # just to be on the safe side
85 root 1.12
86 root 1.38 # prepend PATH - not required by staticperl itself, but might make
87     # life easier when working in e.g. "staticperl cpan / look"
88     PATH="$PERL_PREFIX/perl/bin:$PATH"
89    
90 root 1.1 # set version in a way that Makefile.PL can extract
91     VERSION=VERSION; eval \
92 root 1.72 $VERSION="1.46"
93 root 1.1
94     fatal() {
95     printf -- "\nFATAL: %s\n\n" "$*" >&2
96     exit 1
97     }
98    
99     verbose() {
100     printf -- "%s\n" "$*"
101     }
102    
103     verblock() {
104     verbose
105     verbose "***"
106     while read line; do
107     verbose "*** $line"
108     done
109     verbose "***"
110     verbose
111     }
112    
113     rcd() {
114     cd "$1" || fatal "$1: cannot enter"
115     }
116    
117     trace() {
118     prefix="$1"; shift
119     # "$@" 2>&1 | while read line; do
120     # echo "$prefix: $line"
121     # done
122     "$@"
123     }
124    
125     trap wait 0
126    
127     #############################################################################
128     # clean
129    
130     distclean() {
131     verblock <<EOF
132 root 1.14 deleting everything installed by this script (rm -rf $STATICPERL)
133 root 1.1 EOF
134    
135     rm -rf "$STATICPERL"
136     }
137    
138     #############################################################################
139     # download/configure/compile/install perl
140    
141     clean() {
142 root 1.48 rm -rf "$STATICPERL/src"
143 root 1.1 }
144    
145 root 1.23 realclean() {
146     rm -f "$PERL_PREFIX/staticstamp.postinstall"
147     rm -f "$PERL_PREFIX/staticstamp.install"
148 root 1.62 rm -f "$STATICPERL/src/perl/staticstamp.configure"
149 root 1.23 }
150    
151 root 1.1 fetch() {
152 root 1.65 (
153 root 1.1 rcd "$STATICPERL"
154    
155     mkdir -p src
156     rcd src
157    
158 root 1.62 if ! [ -d "perl" ]; then
159 root 1.63 rm -rf unpack
160     mkdir -p unpack
161    
162 root 1.62 case "$PERL_VERSION" in
163     *:* )
164 root 1.63 # url
165 root 1.62 PERLURL="$PERL_VERSION"
166     PERLTAR="$(basename "$PERL_VERSION")"
167     ;;
168 root 1.63 /* )
169     # directory
170     verbose "copying $PERL_VERSION"
171     cp -Rp "$PERL_VERSION/." unpack/.
172     chmod -R u+w unpack
173     mv unpack perl
174     return
175     ;;
176 root 1.62 * )
177     PERLURL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.bz2"
178     PERLTAR=perl-$PERL_VERSION.tar.bz2
179     ;;
180     esac
181 root 1.1
182 root 1.62 if ! [ -e "$PERLTAR" ]; then
183 root 1.1 verblock <<EOF
184     downloading perl
185 root 1.42
186 root 1.62 trying to download from $PERLURL
187 root 1.45
188     you can configure a download cache directory via DLCACHE
189     in your .staticperlrc to avoid repeated downloads.
190 root 1.62
191     to manually download perl yourself, place a suitable tarball in
192     $DLCACHE/$PERLTAR
193    
194     either curl or wget is required for automatic download.
195     curl is tried first, then wget.
196 root 1.1 EOF
197    
198 root 1.45 rm -f $PERLTAR~ # just to be on the safe side
199 root 1.48 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \
200 root 1.62 || wget -O $PERLTAR~ "$PERLURL" \
201     || curl -f >$PERLTAR~ "$PERLURL" \
202 root 1.5 || fatal "$URL: unable to download"
203 root 1.45 rm -f $PERLTAR
204     mv $PERLTAR~ $PERLTAR
205     if [ "$DLCACHE" ]; then
206     mkdir -p "$DLCACHE"
207 root 1.57 cp $PERLTAR "$DLCACHE"/$PERLTAR~$$~ && \
208     mv "$DLCACHE"/$PERLTAR~$$~ "$DLCACHE"/$PERLTAR
209 root 1.45 fi
210 root 1.1 fi
211    
212     verblock <<EOF
213     unpacking perl
214     EOF
215    
216 root 1.62 case "$PERLTAR" in
217     *.xz ) UNCOMPRESS="xz -d" ;;
218     *.lzma ) UNCOMPRESS="lzma -d" ;;
219     *.bz2 ) UNCOMPRESS="bzip2 -d" ;;
220     *.gz ) UNCOMPRESS="gzip -d" ;;
221     *.tar ) UNCOMPRESS="cat" ;;
222     * )
223 root 1.66 fatal "don't know hot to uncompress $PERLTAR,\nonly tar, tar.gz, tar.bz2, tar.lzma and tar.xz are supported."
224 root 1.62 exit 1
225     ;;
226     esac
227    
228     <"$PERLTAR" $UNCOMPRESS -d | ( cd unpack && tar xf - ) \
229 root 1.45 || fatal "$PERLTAR: error during unpacking"
230 root 1.62
231     if [ -d unpack/*/ ]; then
232     chmod -R u+w unpack/*/
233     mv unpack/*/ perl
234     rmdir -p unpack
235     else
236     fatal "unpacking $PERLTAR did not result in a single directory, don't know how to handle this"
237     fi
238    
239     rm "$PERLTAR"
240 root 1.1 fi
241 root 1.65 ) || exit
242 root 1.1 }
243    
244     # similar to GNU-sed -i or perl -pi
245     sedreplace() {
246     sed -e "$1" <"$2" > "$2~" || fatal "error while running sed"
247 root 1.20 rm -f "$2"
248 root 1.1 mv "$2~" "$2"
249     }
250    
251 root 1.22 configure_failure() {
252     cat <<EOF
253    
254    
255     ***
256     *** Configure failed - see above for the exact error message(s).
257     ***
258     *** Most commonly, this is because the default PERL_CCFLAGS or PERL_OPTIMIZE
259     *** flags are not supported by your compiler. Less often, this is because
260     *** PERL_LIBS either contains a library not available on your system (such as
261     *** -lcrypt), or because it lacks a required library (e.g. -lsocket or -lnsl).
262     ***
263     *** You can provide your own flags by creating a ~/.staticperlrc file with
264     *** variable assignments. For example (these are the actual values used):
265     ***
266    
267     PERL_CC="$PERL_CC"
268     PERL_CCFLAGS="$PERL_CCFLAGS"
269     PERL_OPTIMIZE="$PERL_OPTIMIZE"
270     PERL_LDFLAGS="$PERL_LDFLAGS"
271     PERL_LIBS="$PERL_LIBS"
272    
273     EOF
274     exit 1
275     }
276    
277 root 1.1 configure() {
278 root 1.65 (
279 root 1.1 fetch
280    
281 root 1.62 rcd "$STATICPERL/src/perl"
282 root 1.1
283     [ -e staticstamp.configure ] && return
284    
285     verblock <<EOF
286 root 1.62 configuring $STATICPERL/src/perl
287 root 1.1 EOF
288    
289 root 1.8 rm -f "$PERL_PREFIX/staticstamp.install"
290 root 1.1
291 root 1.21 "$MAKE" distclean >/dev/null 2>&1
292 root 1.1
293 root 1.23 sedreplace '/^#define SITELIB/d' config_h.SH
294    
295     # I hate them for this
296 root 1.1 grep -q -- -fstack-protector Configure && \
297     sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
298    
299 root 1.37 # what did that bloke think
300     grep -q -- usedl=.define hints/darwin.sh && \
301     sedreplace '/^usedl=.define.;$/d' hints/darwin.sh
302    
303     preconfigure || fatal "preconfigure hook failed"
304 root 1.7
305 root 1.1 # trace configure \
306     sh Configure -Duselargefiles \
307     -Uuse64bitint \
308     -Dusemymalloc=n \
309     -Uusedl \
310     -Uusethreads \
311     -Uuseithreads \
312     -Uusemultiplicity \
313     -Uusesfio \
314     -Uuseshrplib \
315 root 1.26 -Uinstallusrbinperl \
316 root 1.22 -A ccflags=" $PERL_CCFLAGS" \
317 root 1.19 -Dcc="$PERL_CC" \
318 root 1.1 -Doptimize="$PERL_OPTIMIZE" \
319     -Dldflags="$PERL_LDFLAGS" \
320     -Dlibs="$PERL_LIBS" \
321 root 1.6 -Dprefix="$PERL_PREFIX" \
322     -Dbin="$PERL_PREFIX/bin" \
323     -Dprivlib="$PERL_PREFIX/lib" \
324     -Darchlib="$PERL_PREFIX/lib" \
325 root 1.1 -Uusevendorprefix \
326 root 1.6 -Dsitelib="$PERL_PREFIX/lib" \
327     -Dsitearch="$PERL_PREFIX/lib" \
328 root 1.1 -Uman1dir \
329     -Uman3dir \
330     -Usiteman1dir \
331     -Usiteman3dir \
332     -Dpager=/usr/bin/less \
333     -Demail="$EMAIL" \
334     -Dcf_email="$EMAIL" \
335     -Dcf_by="$EMAIL" \
336 root 1.4 $PERL_CONFIGURE \
337 root 1.19 -Duseperlio \
338 root 1.64 -Uversiononly \
339 root 1.22 -dE || configure_failure
340 root 1.1
341     sedreplace '
342     s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
343     s/ *-fno-stack-protector */ /g
344     ' config.sh
345    
346 root 1.37 patchconfig || fatal "patchconfig hook failed"
347    
348 root 1.1 sh Configure -S || fatal "Configure -S failed"
349    
350     postconfigure || fatal "postconfigure hook failed"
351    
352 root 1.48 : > staticstamp.configure
353 root 1.65 ) || exit
354 root 1.1 }
355    
356 root 1.39 write_shellscript() {
357     {
358     echo "#!/bin/sh"
359     echo "STATICPERL=\"$STATICPERL\""
360     echo "PERL_PREFIX=\"$PERL_PREFIX\""
361     echo "MAKE=\"$MAKE\""
362     cat
363     } >"$PERL_PREFIX/bin/$1"
364     chmod 755 "$PERL_PREFIX/bin/$1"
365     }
366    
367 root 1.1 build() {
368 root 1.65 (
369 root 1.1 configure
370    
371 root 1.62 rcd "$STATICPERL/src/perl"
372 root 1.1
373     verblock <<EOF
374 root 1.62 building $STATICPERL/src/perl
375 root 1.1 EOF
376    
377 root 1.6 rm -f "$PERL_PREFIX/staticstamp.install"
378 root 1.1
379 root 1.21 "$MAKE" || fatal "make: error while building perl"
380 root 1.1
381     postbuild || fatal "postbuild hook failed"
382 root 1.65 ) || exit
383 root 1.1 }
384    
385 root 1.48 _postinstall() {
386     if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
387     NOCHECK_INSTALL=+
388     instcpan $STATICPERL_MODULES
389 root 1.56 [ "$EXTRA_MODULES" ] && instcpan $EXTRA_MODULES
390 root 1.48
391     postinstall || fatal "postinstall hook failed"
392    
393     : > "$PERL_PREFIX/staticstamp.postinstall"
394     fi
395     }
396    
397 root 1.1 install() {
398 root 1.65 (
399 root 1.9 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
400     build
401 root 1.1
402 root 1.9 verblock <<EOF
403 root 1.62 installing $STATICPERL/src/perl
404 root 1.6 to $PERL_PREFIX
405 root 1.1 EOF
406    
407 root 1.14 ln -sf "perl/bin/" "$STATICPERL/bin"
408     ln -sf "perl/lib/" "$STATICPERL/lib"
409    
410 root 1.39 mkdir "$STATICPERL/patched"
411    
412 root 1.14 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
413     rm -rf "$PERL_PREFIX" # by this rm -rf
414    
415 root 1.65 rcd "$STATICPERL/src/perl"
416    
417 root 1.21 "$MAKE" install || fatal "make install: error while installing"
418 root 1.1
419 root 1.9 rcd "$PERL_PREFIX"
420 root 1.2
421 root 1.9 # create a "make install" replacement for CPAN
422 root 1.65 write_shellscript SP-make-make <<'end_of_make'
423     #CAT make-make.sh
424     end_of_make
425    
426     # create a "make install" replacement for CPAN
427     write_shellscript SP-make-install-make <<'end_of_make_install_make'
428 root 1.39 #CAT make-install-make.sh
429 root 1.65 end_of_make_install_make
430 root 1.10
431 root 1.39 # create a "patch modules" helper
432 root 1.65 write_shellscript SP-patch-postinstall <<'end_of_patch_postinstall'
433 root 1.39 #CAT patch-postinstall.sh
434 root 1.65 end_of_patch_postinstall
435 root 1.10
436 root 1.58 # immediately use it
437 root 1.39 "$PERL_PREFIX/bin/SP-patch-postinstall"
438 root 1.9
439 root 1.39 # help to trick CPAN into avoiding ~/.cpan completely
440 root 1.9 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
441 root 1.1
442 root 1.39 # we call cpan with -MCPAN::MyConfig in this script, which
443 root 1.73 # is strictly unnecessary as we have to patch CPAN anyway,
444 root 1.39 # so consider it "for good measure".
445 root 1.36 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
446 root 1.9 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
447 root 1.75 CPAN::Shell->o (conf => pushy_https => "0");
448 root 1.9 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
449     CPAN::Shell->o (conf => q<init>);
450     CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
451     CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
452     CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
453     CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
454     CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
455 root 1.59 CPAN::Shell->o (conf => q<makepl_arg>, "MAP_TARGET=perl");
456 root 1.65 CPAN::Shell->o (conf => q<make>, "'"$PERL_PREFIX"'/bin/SP-make-make");
457 root 1.39 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make");
458 root 1.9 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
459 root 1.57 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>);
460 root 1.71 CPAN::Shell->o (conf => q<recommends_policy>, q<0>);
461     CPAN::Shell->o (conf => q<suggests_policy>, q<0>);
462 root 1.69 CPAN::Shell->o (conf => q<prefer_installer>, q<EUMM>);
463 root 1.9 CPAN::Shell->o (conf => q<commit>);
464     ' || fatal "error while initialising CPAN"
465 root 1.2
466 root 1.74 postcpanconfig
467    
468 root 1.48 : > "$PERL_PREFIX/staticstamp.install"
469 root 1.9 fi
470    
471 root 1.48 _postinstall
472 root 1.65 ) || exit
473 root 1.48 }
474    
475     import() {
476 root 1.65 (
477 root 1.48 IMPORT="$1"
478    
479     rcd "$STATICPERL"
480    
481     if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
482     verblock <<EOF
483     import perl from $IMPORT to $STATICPERL
484     EOF
485 root 1.1
486 root 1.48 rm -rf bin cpan lib patched perl src
487     mkdir -m 755 perl perl/bin
488     ln -s perl/bin/ bin
489     ln -s "$IMPORT" perl/bin/
490 root 1.1
491 root 1.51 echo "$IMPORT" > "$PERL_PREFIX/.import"
492    
493 root 1.48 : > "$PERL_PREFIX/staticstamp.install"
494 root 1.9 fi
495 root 1.48
496     _postinstall
497 root 1.65 ) || exit
498 root 1.1 }
499    
500     #############################################################################
501     # install a module from CPAN
502    
503     instcpan() {
504     [ $NOCHECK_INSTALL ] || install
505    
506     verblock <<EOF
507     installing modules from CPAN
508 root 1.67 $*
509 root 1.1 EOF
510    
511 root 1.51 MYCONFIG=
512     [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig
513    
514     "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
515 root 1.48
516     if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then
517 root 1.67 fatal "failure while installing modules from CPAN ($*)"
518 root 1.48 fi
519     rm -f "$STATICPERL/instcpan.log"
520 root 1.1 }
521    
522     #############################################################################
523     # install a module from unpacked sources
524    
525     instsrc() {
526     [ $NOCHECK_INSTALL ] || install
527    
528     verblock <<EOF
529     installing modules from source
530 root 1.67 $*
531 root 1.1 EOF
532    
533     for mod in "$@"; do
534     echo
535     echo $mod
536     (
537     rcd $mod
538 root 1.21 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
539     "$MAKE" distclean >/dev/null 2>&1
540 root 1.6 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
541 root 1.21 "$MAKE" || fatal "$mod: error building module"
542 root 1.39 "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module"
543 root 1.21 "$MAKE" distclean >/dev/null 2>&1
544 root 1.1 exit 0
545     ) || exit $?
546     done
547     }
548    
549     #############################################################################
550     # main
551    
552     podusage() {
553     echo
554 root 1.17
555 root 1.6 if [ -e "$PERL_PREFIX/bin/perl" ]; then
556     "$PERL_PREFIX/bin/perl" -MPod::Usage -e \
557 root 1.1 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
558     2>/dev/null && exit
559     fi
560 root 1.17
561 root 1.1 # try whatever perl we can find
562     perl -MPod::Usage -e \
563     'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
564     2>/dev/null && exit
565    
566 root 1.17 fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location"
567 root 1.1 }
568    
569     usage() {
570     podusage 0
571     }
572    
573     catmkbundle() {
574     {
575     read dummy
576 root 1.6 echo "#!$PERL_PREFIX/bin/perl"
577 root 1.1 cat
578 root 1.65 } <<'end_of_mkbundle'
579 root 1.1 #CAT mkbundle
580 root 1.65 end_of_mkbundle
581 root 1.1 }
582    
583     bundle() {
584 root 1.39 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
585 root 1.1 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
586     chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
587 root 1.12 CACHE="$STATICPERL/cache"
588     mkdir -p "$CACHE"
589     "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
590 root 1.1 }
591    
592     if [ $# -gt 0 ]; then
593     while [ $# -gt 0 ]; do
594     mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create"
595 root 1.6 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create"
596 root 1.1
597     command="${1#--}"; shift
598     case "$command" in
599 root 1.14 version )
600     echo "staticperl version $VERSION"
601     ;;
602 root 1.48 fetch | configure | build | install | clean | realclean | distclean )
603 root 1.22 ( "$command" ) || exit
604 root 1.1 ;;
605 root 1.48 import )
606     ( import "$1" ) || exit
607     shift
608     ;;
609 root 1.1 instsrc )
610 root 1.22 ( instsrc "$@" ) || exit
611 root 1.1 exit
612     ;;
613     instcpan )
614 root 1.22 ( instcpan "$@" ) || exit
615 root 1.1 exit
616     ;;
617 root 1.39 perl )
618     ( install ) || exit
619     exec "$PERL_PREFIX/bin/perl" "$@"
620     exit
621     ;;
622 root 1.1 cpan )
623 root 1.22 ( install ) || exit
624 root 1.48 PERL="$PERL_PREFIX/bin/perl"
625     export PERL
626 root 1.39 exec "$PERL_PREFIX/bin/cpan" "$@"
627 root 1.1 exit
628     ;;
629     mkbundle )
630 root 1.22 ( install ) || exit
631 root 1.40 bundle "$@"
632 root 1.1 exit
633     ;;
634     mkperl )
635 root 1.22 ( install ) || exit
636 root 1.40 bundle --perl "$@"
637 root 1.1 exit
638     ;;
639 root 1.11 mkapp )
640 root 1.22 ( install ) || exit
641 root 1.40 bundle --app "$@"
642 root 1.11 exit
643     ;;
644 root 1.1 help )
645     podusage 2
646     ;;
647     * )
648     exec 1>&2
649     echo
650     echo "Unknown command: $command"
651     podusage 0
652     ;;
653     esac
654     done
655     else
656     usage
657     fi
658    
659     exit 0
660    
661     #CAT staticperl.pod
662