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.33 by root, Thu Feb 24 07:10:03 2011 UTC vs.
Revision 1.46 by root, Sun Jun 26 17:27:18 2011 UTC

1#!/bin/sh 1#!/bin/sh
2 2
3############################################################################# 3#############################################################################
4# configuration to fill in 4# configuration to fill in (or to replace in your .staticperlrc)
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>"
9DLCACHE=
9 10
10# perl build variables 11# perl build variables
11MAKE=make 12MAKE=make
12PERL_VERSION=5.12.3 # 5.8.9 is also a good choice 13PERL_VERSION=5.12.3 # 5.8.9 is also a good choice
13PERL_CC=cc 14PERL_CC=cc
29esac 30esac
30 31
31# -Wl,--gc-sections makes it impossible to check for undefined references 32# -Wl,--gc-sections makes it impossible to check for undefined references
32# for some reason so we need to patch away the "-no" after Configure and before make :/ 33# for some reason so we need to patch away the "-no" after Configure and before make :/
33# --allow-multiple-definition exists to work around uclibc's pthread static linking bug 34# --allow-multiple-definition exists to work around uclibc's pthread static linking bug
34PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" 35#PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition"
36PERL_LDFLAGS=
35PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself 37PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself
36 38
37# some configuration options for modules 39# some configuration options for modules
38PERL_MM_USE_DEFAULT=1 40PERL_MM_USE_DEFAULT=1
41PERL_MM_OPT="MAN1PODS= MAN3PODS="
39#CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow 42#CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow
40EV_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' 43EV_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'
41export PERL_MM_USE_DEFAULT CORO_INTERFACE EV_EXTRA_DEFS 44export PERL_MM_USE_DEFAULT PERL_MM_OPT CORO_INTERFACE EV_EXTRA_DEFS
42 45
43# which extra modules to install by default from CPAN that are 46# which extra modules to install by default from CPAN that are
44# required by mkbundle 47# required by mkbundle
45STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" 48STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage"
46 49
47# which extra modules you might want to install 50# which extra modules you might want to install
48EXTRA_MODULES="" 51EXTRA_MODULES=""
49 52
50# overridable functions 53# overridable functions
51preconfigure() { : ; } 54preconfigure() { : ; }
55patchconfig() { : ; }
52postconfigure() { : ; } 56postconfigure() { : ; }
53postbuild() { : ; } 57postbuild() { : ; }
54postinstall() { : ; } 58postinstall() { : ; }
55 59
56# now source user config, if any 60# now source user config, if any
63fi 67fi
64 68
65############################################################################# 69#############################################################################
66# support 70# support
67 71
68MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}"
69PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed 72PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
70 73
71unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG 74unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
75unset PERL_MB_OPT
72LC_ALL=C; export LC_ALL # just to be on the safe side 76LC_ALL=C; export LC_ALL # just to be on the safe side
77
78# prepend PATH - not required by staticperl itself, but might make
79# life easier when working in e.g. "staticperl cpan / look"
80PATH="$PERL_PREFIX/perl/bin:$PATH"
73 81
74# set version in a way that Makefile.PL can extract 82# set version in a way that Makefile.PL can extract
75VERSION=VERSION; eval \ 83VERSION=VERSION; eval \
76$VERSION="1.1" 84$VERSION="1.31"
77 85
78BZ2=bz2 86BZ2=bz2
79BZIP2=bzip2 87BZIP2=bzip2
80 88
81fatal() { 89fatal() {
140 148
141 mkdir -p src 149 mkdir -p src
142 rcd src 150 rcd src
143 151
144 if ! [ -d "perl-$PERL_VERSION" ]; then 152 if ! [ -d "perl-$PERL_VERSION" ]; then
145 if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then 153 PERLTAR=perl-$PERL_VERSION.tar.$BZ2
146 154
155 if ! [ -e $PERLTAR ]; then
147 URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" 156 URL="$CPAN/src/5.0/$PERLTAR"
148 157
149 verblock <<EOF 158 verblock <<EOF
150downloading perl 159downloading perl
151to manually download perl yourself, place 160to manually download perl yourself, place
152perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL 161perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL
153trying $URL 162trying $URL
154EOF
155 163
164either curl or wget is required for automatic download.
165curl is tried first, then wget.
166
167you can configure a download cache directory via DLCACHE
168in your .staticperlrc to avoid repeated downloads.
169EOF
170
156 rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side 171 rm -f $PERLTAR~ # just to be on the safe side
157 curl -f >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 172 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~; } \
158 || wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 173 || wget -O $PERLTAR~ "$URL" \
174 || curl -f >$PERLTAR~ "$URL" \
159 || fatal "$URL: unable to download" 175 || fatal "$URL: unable to download"
160 rm -f perl-$PERL_VERSION.tar.$BZ2 176 rm -f $PERLTAR
161 mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 177 mv $PERLTAR~ $PERLTAR
178 if [ "$DLCACHE" ]; then
179 mkdir -p "$DLCACHE"
180 cp $PERLTAR "$DLCACHE"/$PERLTAR~ && \
181 mv "$DLCACHE"/$PERLTAR~ "$DLCACHE"/$PERLTAR
182 fi
162 fi 183 fi
163 184
164 verblock <<EOF 185 verblock <<EOF
165unpacking perl 186unpacking perl
166EOF 187EOF
167 188
168 mkdir -p unpack 189 mkdir -p unpack
169 rm -rf unpack/perl-$PERL_VERSION 190 rm -rf unpack/perl-$PERL_VERSION
170 $BZIP2 -d <perl-$PERL_VERSION.tar.$BZ2 | tar xfC - unpack \ 191 $BZIP2 -d <$PERLTAR | ( cd unpack && tar xf - ) \
171 || fatal "perl-$PERL_VERSION.tar.$BZ2: error during unpacking" 192 || fatal "$PERLTAR: error during unpacking"
172 chmod -R u+w unpack/perl-$PERL_VERSION 193 chmod -R u+w unpack/perl-$PERL_VERSION
173 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 194 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
174 rmdir -p unpack 195 rmdir -p unpack
175 fi 196 fi
176} 197}
227 248
228 # I hate them for this 249 # I hate them for this
229 grep -q -- -fstack-protector Configure && \ 250 grep -q -- -fstack-protector Configure && \
230 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure 251 sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure
231 252
232 preconfigure 253 # what did that bloke think
254 grep -q -- usedl=.define hints/darwin.sh && \
255 sedreplace '/^usedl=.define.;$/d' hints/darwin.sh
256
257 preconfigure || fatal "preconfigure hook failed"
233 258
234# trace configure \ 259# trace configure \
235 sh Configure -Duselargefiles \ 260 sh Configure -Duselargefiles \
236 -Uuse64bitint \ 261 -Uuse64bitint \
237 -Dusemymalloc=n \ 262 -Dusemymalloc=n \
269 sedreplace ' 294 sedreplace '
270 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g 295 s/-Wl,--no-gc-sections/-Wl,--gc-sections/g
271 s/ *-fno-stack-protector */ /g 296 s/ *-fno-stack-protector */ /g
272 ' config.sh 297 ' config.sh
273 298
299 patchconfig || fatal "patchconfig hook failed"
300
274 sh Configure -S || fatal "Configure -S failed" 301 sh Configure -S || fatal "Configure -S failed"
275 302
276 postconfigure || fatal "postconfigure hook failed" 303 postconfigure || fatal "postconfigure hook failed"
277 304
278 touch staticstamp.configure 305 touch staticstamp.configure
306}
307
308write_shellscript() {
309 {
310 echo "#!/bin/sh"
311 echo "STATICPERL=\"$STATICPERL\""
312 echo "PERL_PREFIX=\"$PERL_PREFIX\""
313 echo "MAKE=\"$MAKE\""
314 cat
315 } >"$PERL_PREFIX/bin/$1"
316 chmod 755 "$PERL_PREFIX/bin/$1"
279} 317}
280 318
281build() { 319build() {
282 configure 320 configure
283 321
304EOF 342EOF
305 343
306 ln -sf "perl/bin/" "$STATICPERL/bin" 344 ln -sf "perl/bin/" "$STATICPERL/bin"
307 ln -sf "perl/lib/" "$STATICPERL/lib" 345 ln -sf "perl/lib/" "$STATICPERL/lib"
308 346
347 mkdir "$STATICPERL/patched"
348
309 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten 349 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
310 rm -rf "$PERL_PREFIX" # by this rm -rf 350 rm -rf "$PERL_PREFIX" # by this rm -rf
311 351
312 "$MAKE" install || fatal "make install: error while installing" 352 "$MAKE" install || fatal "make install: error while installing"
313 353
314 rcd "$PERL_PREFIX" 354 rcd "$PERL_PREFIX"
315 355
316 # create a "make install" replacement for CPAN 356 # create a "make install" replacement for CPAN
317 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 357 write_shellscript SP-make-install-make <<'EOF'
318"$MAKE" || exit 358#CAT make-install-make.sh
319
320if find blib/arch/auto -type f | grep -q -v .exists; then
321 echo Probably an XS module, rebuilding perl
322 if "$MAKE" perl; then
323 mv perl "$PERL_PREFIX"/bin/perl~ \
324 && rm -f "$PERL_PREFIX"/bin/perl \
325 && mv "$PERL_PREFIX"/bin/perl~ "$PERL_PREFIX"/bin/perl
326 "$MAKE" -f Makefile.aperl map_clean
327 else
328 "$MAKE" -f Makefile.aperl map_clean
329 exit 1
330 fi
331fi
332
333"$MAKE" install UNINST=1
334EOF 359EOF
335 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
336 360
361 # create a "patch modules" helper
362 write_shellscript SP-patch-postinstall <<'EOF'
363#CAT patch-postinstall.sh
364EOF
365
366 "$PERL_PREFIX/bin/SP-patch-postinstall"
367
337 # trick CPAN into avoiding ~/.cpan completely 368 # help to trick CPAN into avoiding ~/.cpan completely
338 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 369 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
339 370
371 # we call cpan with -MCPAN::MyConfig in this script, which
372 # is strictly unnecssary as we have to patch CPAN anyway,
373 # so consider it "for good measure".
340 "$PERL_PREFIX"/bin/perl -MCPAN -e ' 374 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e '
341 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); 375 CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'");
342 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 376 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
343 CPAN::Shell->o (conf => q<init>); 377 CPAN::Shell->o (conf => q<init>);
344 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); 378 CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
345 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); 379 CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
346 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); 380 CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
347 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); 381 CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
348 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); 382 CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
349 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/cpan-make-install"); 383 CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make");
350 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); 384 CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
351 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 385 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>);
386 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM");
352 CPAN::Shell->o (conf => q<commit>); 387 CPAN::Shell->o (conf => q<commit>);
353 ' || fatal "error while initialising CPAN" 388 ' || fatal "error while initialising CPAN"
354 389
355 touch "$PERL_PREFIX/staticstamp.install" 390 touch "$PERL_PREFIX/staticstamp.install"
356 fi 391 fi
376installing modules from CPAN 411installing modules from CPAN
377$@ 412$@
378EOF 413EOF
379 414
380 for mod in "$@"; do 415 for mod in "$@"; do
381 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ 416 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install => "'"$mod"'"' \
382 || fatal "$mod: unable to install from CPAN" 417 || fatal "$mod: unable to install from CPAN"
383 done 418 done
384 rm -rf "$STATICPERL/build" 419 rm -rf "$STATICPERL/build"
385} 420}
386 421
402 rcd $mod 437 rcd $mod
403 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1 438 "$MAKE" -f Makefile.aperl map_clean >/dev/null 2>&1
404 "$MAKE" distclean >/dev/null 2>&1 439 "$MAKE" distclean >/dev/null 2>&1
405 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" 440 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL"
406 "$MAKE" || fatal "$mod: error building module" 441 "$MAKE" || fatal "$mod: error building module"
407 "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" 442 "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module"
408 "$MAKE" distclean >/dev/null 2>&1 443 "$MAKE" distclean >/dev/null 2>&1
409 exit 0 444 exit 0
410 ) || exit $? 445 ) || exit $?
411 done 446 done
412} 447}
444#CAT mkbundle 479#CAT mkbundle
445MKBUNDLE 480MKBUNDLE
446} 481}
447 482
448bundle() { 483bundle() {
484 MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}"
449 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 485 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
450 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 486 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
451 CACHE="$STATICPERL/cache" 487 CACHE="$STATICPERL/cache"
452 mkdir -p "$CACHE" 488 mkdir -p "$CACHE"
453 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" 489 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
472 ;; 508 ;;
473 instcpan ) 509 instcpan )
474 ( instcpan "$@" ) || exit 510 ( instcpan "$@" ) || exit
475 exit 511 exit
476 ;; 512 ;;
513 perl )
514 ( install ) || exit
515 exec "$PERL_PREFIX/bin/perl" "$@"
516 exit
517 ;;
477 cpan ) 518 cpan )
478 ( install ) || exit 519 ( install ) || exit
479 "$PERL_PREFIX/bin/cpan" "$@" 520 exec "$PERL_PREFIX/bin/cpan" "$@"
480 exit 521 exit
481 ;; 522 ;;
482 mkbundle ) 523 mkbundle )
483 ( install ) || exit 524 ( install ) || exit
484 bundle "$@" 525 bundle "$@"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines