ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/App-Staticperl/staticperl.sh
(Generate patch)

Comparing App-Staticperl/staticperl.sh (file contents):
Revision 1.11 by root, Wed Dec 8 22:27:35 2010 UTC vs.
Revision 1.38 by root, Fri Apr 1 05:58:22 2011 UTC

2 2
3############################################################################# 3#############################################################################
4# configuration to fill in 4# configuration to fill in
5 5
6STATICPERL=~/.staticperl 6STATICPERL=~/.staticperl
7CPAN=http://mirror.netcologne.de/cpan/ # which mirror to use 7CPAN=http://mirror.netcologne.de/cpan # which mirror to use
8EMAIL="read the documentation <rtfm@example.org>" 8EMAIL="read the documentation <rtfm@example.org>"
9 9
10MKBUNDLE="$STATICPERL/mkbundle"
11
12# perl build variables 10# perl build variables
13PERL_PREFIX="$STATICPERL/perl" # where the perl gets installed 11MAKE=make
14PERL_VERSION=5.12.2 # 5.8.9 is also a good choice 12PERL_VERSION=5.12.3 # 5.8.9 is also a good choice
13PERL_CC=cc
15PERL_CONFIGURE="" # additional Configure arguments 14PERL_CONFIGURE="" # additional Configure arguments
16PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" 15PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG"
17PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 16PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
18 17
19ARCH="$(uname -m)" 18ARCH="$(uname -m)"
20 19
21case "$ARCH" in 20case "$ARCH" in
29 ;; 28 ;;
30esac 29esac
31 30
32# -Wl,--gc-sections makes it impossible to check for undefined references 31# -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 :/ 32# for some reason so we need to patch away the "-no" after Configure and before make :/
34# -z muldefs is to work around uclibc's pthread static linking bug 33# --allow-multiple-definition exists to work around uclibc's pthread static linking bug
35PERL_LDFLAGS="-Wl,--no-gc-sections -z muldefs" 34#PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition"
35PERL_LDFLAGS=
36PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself 36PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself
37 37
38# some configuration options for modules 38# some configuration options for modules
39export PERL_MM_USE_DEFAULT=1 39PERL_MM_USE_DEFAULT=1
40#export CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow 40#CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow
41export 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' 41EV_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'
42export PERL_MM_USE_DEFAULT CORO_INTERFACE EV_EXTRA_DEFS
42 43
43# which extra modules to install by default from CPAN that are 44# which extra modules to install by default from CPAN that are
44# required by mkbundle 45# required by mkbundle
45STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" 46STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage"
46 47
47# which extra modules you might want to install 48# which extra modules you might want to install
48EXTRA_MODULES="" 49EXTRA_MODULES=""
49 50
50# overridable functions 51# overridable functions
51preconfigure() { : ; } 52preconfigure() { : ; }
53patchconfig() { : ; }
52postconfigure() { : ; } 54postconfigure() { : ; }
53postbuild() { : ; } 55postbuild() { : ; }
54postinstall() { : ; } 56postinstall() { : ; }
55 57
56# now source user config, if any 58# now source user config, if any
59if [ "$STATICPERLRC" ]; then
60 . "$STATICPERLRC"
61else
57[ -r /etc/staticperlrc ] && . /etc/staticperlrc 62 [ -r /etc/staticperlrc ] && . /etc/staticperlrc
58[ -r ~/.staticperlrc ] && . ~/.staticperlrc 63 [ -r ~/.staticperlrc ] && . ~/.staticperlrc
59[ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" 64 [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc"
65fi
60 66
61############################################################################# 67#############################################################################
62# support 68# support
69
70MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}"
71PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
72
73unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
74unset PERL_MM_OPT PERL_MB_OPT
75LC_ALL=C; export LC_ALL # just to be on the safe side
76
77# prepend PATH - not required by staticperl itself, but might make
78# life easier when working in e.g. "staticperl cpan / look"
79PATH="$PERL_PREFIX/perl/bin:$PATH"
63 80
64# set version in a way that Makefile.PL can extract 81# set version in a way that Makefile.PL can extract
65VERSION=VERSION; eval \ 82VERSION=VERSION; eval \
66$VERSION=0.9 83$VERSION="1.21"
67 84
68BZ2=bz2 85BZ2=bz2
69BZIP2=bzip2 86BZIP2=bzip2
70 87
71fatal() { 88fatal() {
104############################################################################# 121#############################################################################
105# clean 122# clean
106 123
107distclean() { 124distclean() {
108 verblock <<EOF 125 verblock <<EOF
109deleting everything installed by this script 126 deleting everything installed by this script (rm -rf $STATICPERL)
110EOF 127EOF
111 128
112 rm -rf "$STATICPERL" 129 rm -rf "$STATICPERL"
113} 130}
114 131
115############################################################################# 132#############################################################################
116# download/configure/compile/install perl 133# download/configure/compile/install perl
117 134
118clean() { 135clean() {
119 rm -rf "$STATICPERL/src/perl-$PERL_VERSION" 136 rm -rf "$STATICPERL/src/perl-$PERL_VERSION"
137}
138
139realclean() {
140 rm -f "$PERL_PREFIX/staticstamp.postinstall"
141 rm -f "$PERL_PREFIX/staticstamp.install"
142 rm -f "$STATICPERL/src/perl-"*"/staticstamp.configure"
120} 143}
121 144
122fetch() { 145fetch() {
123 rcd "$STATICPERL" 146 rcd "$STATICPERL"
124 147
136perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL 159perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL
137trying $URL 160trying $URL
138EOF 161EOF
139 162
140 rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side 163 rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side
164 curl -f >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \
141 wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 165 || wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \
142 || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \
143 || fatal "$URL: unable to download" 166 || fatal "$URL: unable to download"
167 rm -f perl-$PERL_VERSION.tar.$BZ2
144 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 168 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2
145 fi 169 fi
146 170
147 verblock <<EOF 171 verblock <<EOF
148unpacking perl 172unpacking perl
149EOF 173EOF
150 174
151 mkdir -p unpack 175 mkdir -p unpack
176 rm -rf unpack/perl-$PERL_VERSION
152 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xC unpack \ 177 $BZIP2 -d <perl-$PERL_VERSION.tar.$BZ2 | ( cd unpack && tar xf - ) \
153 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" 178 || fatal "perl-$PERL_VERSION.tar.$BZ2: error during unpacking"
154 chmod -R u+w unpack/perl-$PERL_VERSION 179 chmod -R u+w unpack/perl-$PERL_VERSION
155 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 180 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
156 rmdir -p unpack 181 rmdir -p unpack
157 fi 182 fi
158} 183}
159 184
160# similar to GNU-sed -i or perl -pi 185# similar to GNU-sed -i or perl -pi
161sedreplace() { 186sedreplace() {
162 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" 187 sed -e "$1" <"$2" > "$2~" || fatal "error while running sed"
188 rm -f "$2"
163 mv "$2~" "$2" 189 mv "$2~" "$2"
190}
191
192configure_failure() {
193 cat <<EOF
194
195
196***
197*** Configure failed - see above for the exact error message(s).
198***
199*** Most commonly, this is because the default PERL_CCFLAGS or PERL_OPTIMIZE
200*** flags are not supported by your compiler. Less often, this is because
201*** PERL_LIBS either contains a library not available on your system (such as
202*** -lcrypt), or because it lacks a required library (e.g. -lsocket or -lnsl).
203***
204*** You can provide your own flags by creating a ~/.staticperlrc file with
205*** variable assignments. For example (these are the actual values used):
206***
207
208PERL_CC="$PERL_CC"
209PERL_CCFLAGS="$PERL_CCFLAGS"
210PERL_OPTIMIZE="$PERL_OPTIMIZE"
211PERL_LDFLAGS="$PERL_LDFLAGS"
212PERL_LIBS="$PERL_LIBS"
213
214EOF
215 exit 1
164} 216}
165 217
166configure() { 218configure() {
167 fetch 219 fetch
168 220
174configuring $STATICPERL/src/perl-$PERL_VERSION 226configuring $STATICPERL/src/perl-$PERL_VERSION
175EOF 227EOF
176 228
177 rm -f "$PERL_PREFIX/staticstamp.install" 229 rm -f "$PERL_PREFIX/staticstamp.install"
178 230
179 make distclean >/dev/null 2>&1 231 "$MAKE" distclean >/dev/null 2>&1
180 232
233 sedreplace '/^#define SITELIB/d' config_h.SH
234
181 # I hate them 235 # I hate them for this
182 grep -q -- -fstack-protector Configure && \ 236 grep -q -- -fstack-protector Configure && \
183 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 237 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
184 238
185 preconfigure 239 # what did that bloke think
240 grep -q -- usedl=.define hints/darwin.sh && \
241 sedreplace '/^usedl=.define.;$/d' hints/darwin.sh
242
243 preconfigure || fatal "preconfigure hook failed"
186 244
187# trace configure \ 245# trace configure \
188 sh Configure -Duselargefiles \ 246 sh Configure -Duselargefiles \
189 -Uuse64bitint \ 247 -Uuse64bitint \
190 -Dusemymalloc=n \ 248 -Dusemymalloc=n \
191 -Uusedl \ 249 -Uusedl \
192 -Uusethreads \ 250 -Uusethreads \
193 -Uuseithreads \ 251 -Uuseithreads \
194 -Uusemultiplicity \ 252 -Uusemultiplicity \
195 -Duseperlio \
196 -Uusesfio \ 253 -Uusesfio \
197 -Uuseshrplib \ 254 -Uuseshrplib \
255 -Uinstallusrbinperl \
198 -Dcppflags="$PERL_CPPFLAGS" \ 256 -A ccflags=" $PERL_CCFLAGS" \
199 -Dccflags="-g2 -fno-strict-aliasing" \ 257 -Dcc="$PERL_CC" \
200 -Doptimize="$PERL_OPTIMIZE" \ 258 -Doptimize="$PERL_OPTIMIZE" \
201 -Dldflags="$PERL_LDFLAGS" \ 259 -Dldflags="$PERL_LDFLAGS" \
202 -Dlibs="$PERL_LIBS" \ 260 -Dlibs="$PERL_LIBS" \
203 -Dprefix="$PERL_PREFIX" \ 261 -Dprefix="$PERL_PREFIX" \
204 -Dbin="$PERL_PREFIX/bin" \ 262 -Dbin="$PERL_PREFIX/bin" \
205 -Dprivlib="$PERL_PREFIX/lib" \ 263 -Dprivlib="$PERL_PREFIX/lib" \
206 -Darchlib="$PERL_PREFIX/lib" \ 264 -Darchlib="$PERL_PREFIX/lib" \
207 -Uusevendorprefix \ 265 -Uusevendorprefix \
208 -Dsitelib="$PERL_PREFIX/lib" \ 266 -Dsitelib="$PERL_PREFIX/lib" \
209 -Dsitearch="$PERL_PREFIX/lib" \ 267 -Dsitearch="$PERL_PREFIX/lib" \
210 -Usitelibexp \
211 -Uman1dir \ 268 -Uman1dir \
212 -Uman3dir \ 269 -Uman3dir \
213 -Usiteman1dir \ 270 -Usiteman1dir \
214 -Usiteman3dir \ 271 -Usiteman3dir \
215 -Dpager=/usr/bin/less \ 272 -Dpager=/usr/bin/less \
216 -Demail="$EMAIL" \ 273 -Demail="$EMAIL" \
217 -Dcf_email="$EMAIL" \ 274 -Dcf_email="$EMAIL" \
218 -Dcf_by="$EMAIL" \ 275 -Dcf_by="$EMAIL" \
219 $PERL_CONFIGURE \ 276 $PERL_CONFIGURE \
277 -Duseperlio \
220 -dE || fatal "Configure failed" 278 -dE || configure_failure
221 279
222 sedreplace ' 280 sedreplace '
223 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 281 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
224 s/ *-fno-stack-protector */ /g 282 s/ *-fno-stack-protector */ /g
225 ' config.sh 283 ' config.sh
226 284
285 patchconfig || fatal "patchconfig hook failed"
286
227 sh Configure -S || fatal "Configure -S failed" 287 sh Configure -S || fatal "Configure -S failed"
228 288
229 postconfigure || fatal "postconfigure hook failed" 289 postconfigure || fatal "postconfigure hook failed"
230 290
231 touch staticstamp.configure 291 touch staticstamp.configure
240building $STATICPERL/src/perl-$PERL_VERSION 300building $STATICPERL/src/perl-$PERL_VERSION
241EOF 301EOF
242 302
243 rm -f "$PERL_PREFIX/staticstamp.install" 303 rm -f "$PERL_PREFIX/staticstamp.install"
244 304
245 make || fatal "make: error while building perl" 305 "$MAKE" || fatal "make: error while building perl"
246 306
247 postbuild || fatal "postbuild hook failed" 307 postbuild || fatal "postbuild hook failed"
248} 308}
249 309
250install() { 310install() {
254 verblock <<EOF 314 verblock <<EOF
255installing $STATICPERL/src/perl-$PERL_VERSION 315installing $STATICPERL/src/perl-$PERL_VERSION
256to $PERL_PREFIX 316to $PERL_PREFIX
257EOF 317EOF
258 318
259 rm -rf "$PERL_PREFIX" 319 ln -sf "perl/bin/" "$STATICPERL/bin"
260 320 ln -sf "perl/lib/" "$STATICPERL/lib"
321
322 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
323 rm -rf "$PERL_PREFIX" # by this rm -rf
324
261 make install || fatal "make install: error while installing" 325 "$MAKE" install || fatal "make install: error while installing"
262 326
263 rcd "$PERL_PREFIX" 327 rcd "$PERL_PREFIX"
264 328
265 # create a "make install" replacement for CPAN 329 # create a "make install" replacement for CPAN
266 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 330 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF
267make || exit 331"$MAKE" || exit
332
333# patch CPAN::HandleConfig.pm
334HCPM="$PERL_PREFIX"/lib/CPAN/HandleConfig.pm
335case "\$(head -n1 "\$HCPM")" in
336 *CPAN::MyConfig* )
337 ;;
338 * )
339 echo "patching \$HCPM for a safer tomorrow"
340 {
341 echo "use CPAN::MyConfig;"
342 cat "\$HCPM"
343 } >"\$HCPM~"
344 rm -f "\$HCPM"
345 mv "\$HCPM~" "\$HCPM"
346 ;;
347esac
268 348
269if find blib/arch/auto -type f | grep -q -v .exists; then 349if find blib/arch/auto -type f | grep -q -v .exists; then
270 echo Probably an XS module, rebuilding perl 350 echo Probably an XS module, rebuilding perl
271 if make perl; then 351 if "$MAKE" perl; then
272 mv perl "$PERL_PREFIX"/bin/perl 352 mv perl "$PERL_PREFIX"/bin/perl~ \
353 && rm -f "$PERL_PREFIX"/bin/perl \
354 && mv "$PERL_PREFIX"/bin/perl~ "$PERL_PREFIX"/bin/perl
273 make -f Makefile.aperl map_clean 355 "$MAKE" -f Makefile.aperl map_clean
274 else 356 else
275 make -f Makefile.aperl map_clean 357 "$MAKE" -f Makefile.aperl map_clean
276 exit 1 358 exit 1
277 fi 359 fi
278fi 360fi
279 361
280make install UNINST=1 362"$MAKE" install UNINST=1
281EOF 363EOF
282 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install 364 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
283 365
284 # trick CPAN into avoiding ~/.cpan completely 366 # trick CPAN into avoiding ~/.cpan completely
285 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 367 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
286 368
369 # we call cpan with -MCPAN::MyConfig in this script, but
370 # every make install will patch CPAN::HandleConfig.pm to
371 # protect the user.
372
287 "$PERL_PREFIX"/bin/perl -MCPAN -e ' 373 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
288 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 374 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
289 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 375 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
290 CPAN::Shell->o (conf => q<init>); 376 CPAN::Shell->o (conf => q<init>);
291 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 377 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
292 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 378 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
294 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 380 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
295 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 381 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
296 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); 382 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install");
297 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 383 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
298 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 384 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>);
385 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM");
299 CPAN::Shell->o (conf => q<commit>); 386 CPAN::Shell->o (conf => q<commit>);
300 ' || fatal "error while initialising CPAN" 387 ' || fatal "error while initialising CPAN"
301 388
302 touch "$PERL_PREFIX/staticstamp.install" 389 touch "$PERL_PREFIX/staticstamp.install"
303 fi 390 fi
323installing modules from CPAN 410installing modules from CPAN
324$@ 411$@
325EOF 412EOF
326 413
327 for mod in "$@"; do 414 for mod in "$@"; do
328 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ 415 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install => "'"$mod"'"' \
329 || fatal "$mod: unable to install from CPAN" 416 || fatal "$mod: unable to install from CPAN"
330 done 417 done
331 rm -rf "$STATICPERL/build" 418 rm -rf "$STATICPERL/build"
332} 419}
333 420
345 for mod in "$@"; do 432 for mod in "$@"; do
346 echo 433 echo
347 echo $mod 434 echo $mod
348 ( 435 (
349 rcd $mod 436 rcd $mod
350 make -f Makefile.aperl map_clean >/dev/null 2>&1 437 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
351 make distclean >/dev/null 2>&1 438 "$MAKE" distclean >/dev/null 2>&1
352 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" 439 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
353 make || fatal "$mod: error building module" 440 "$MAKE" || fatal "$mod: error building module"
354 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 441 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module"
355 make distclean >/dev/null 2>&1 442 "$MAKE" distclean >/dev/null 2>&1
356 exit 0 443 exit 0
357 ) || exit $? 444 ) || exit $?
358 done 445 done
359} 446}
360 447
361############################################################################# 448#############################################################################
362# main 449# main
363 450
364podusage() { 451podusage() {
365 echo 452 echo
453
366 if [ -e "$PERL_PREFIX/bin/perl" ]; then 454 if [ -e "$PERL_PREFIX/bin/perl" ]; then
367 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ 455 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \
368 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 456 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
369 2>/dev/null && exit 457 2>/dev/null && exit
370 fi 458 fi
459
371 # try whatever perl we can find 460 # try whatever perl we can find
372 perl -MPod::Usage -e \ 461 perl -MPod::Usage -e \
373 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 462 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
374 2>/dev/null && exit 463 2>/dev/null && exit
375 464
376 fatal "displaying documentation requires a working perl - try '$0 install' first" 465 fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location"
377} 466}
378 467
379usage() { 468usage() {
380 podusage 0 469 podusage 0
381} 470}
391} 480}
392 481
393bundle() { 482bundle() {
394 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 483 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
395 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 484 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
485 CACHE="$STATICPERL/cache"
486 mkdir -p "$CACHE"
396 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@" 487 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
397} 488}
398 489
399if [ $# -gt 0 ]; then 490if [ $# -gt 0 ]; then
400 while [ $# -gt 0 ]; do 491 while [ $# -gt 0 ]; do
401 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" 492 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create"
402 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" 493 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create"
403 494
404 command="${1#--}"; shift 495 command="${1#--}"; shift
405 case "$command" in 496 case "$command" in
497 version )
498 echo "staticperl version $VERSION"
499 ;;
406 fetch | configure | build | install | clean | distclean) 500 fetch | configure | build | install | clean | realclean | distclean)
407 verblock <<EOF
408$command
409EOF
410 ( "$command" ) 501 ( "$command" ) || exit
411 ;; 502 ;;
412 instsrc ) 503 instsrc )
413 ( instsrc "$@" ) 504 ( instsrc "$@" ) || exit
414 exit 505 exit
415 ;; 506 ;;
416 instcpan ) 507 instcpan )
417 ( instcpan "$@" ) 508 ( instcpan "$@" ) || exit
418 exit 509 exit
419 ;; 510 ;;
420 cpan ) 511 cpan )
421 ( install ) 512 ( install ) || exit
422 "$PERL_PREFIX/bin/cpan" "$@" 513 "$PERL_PREFIX/bin/cpan" "$@"
423 exit 514 exit
424 ;; 515 ;;
425 mkbundle ) 516 mkbundle )
426 ( install ) 517 ( install ) || exit
427 bundle "$@" 518 bundle "$@"
428 exit 519 exit
429 ;; 520 ;;
430 mkperl ) 521 mkperl )
431 ( install ) 522 ( install ) || exit
432 bundle --perl "$@" 523 bundle --perl "$@"
433 exit 524 exit
434 ;; 525 ;;
435 mkapp ) 526 mkapp )
436 ( install ) 527 ( install ) || exit
437 bundle --app "$@" 528 bundle --app "$@"
438 exit 529 exit
439 ;; 530 ;;
440 help ) 531 help )
441 podusage 2 532 podusage 2

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines