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