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.9 by root, Tue Dec 7 20:03:15 2010 UTC vs.
Revision 1.17 by root, Sun Dec 12 00:38:36 2010 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
14PERL_VERSION=5.12.2 # 5.8.9 is also a good choice 11PERL_VERSION=5.12.2 # 5.8.9 is also a good choice
15PERL_CONFIGURE="" # additional Configure arguments 12PERL_CONFIGURE="" # additional Configure arguments
16PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" 13PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP"
17PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 14PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
18 15
29 ;; 26 ;;
30esac 27esac
31 28
32# -Wl,--gc-sections makes it impossible to check for undefined references 29# -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 :/ 30# 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 31# --allow-multiple-definition exists to work around uclibc's pthread static linking bug
35PERL_LDFLAGS="-Wl,--no-gc-sections -z muldefs" 32PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition"
36PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself 33PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself
37 34
38# some configuration options for modules 35# some configuration options for modules
39export PERL_MM_USE_DEFAULT=1 36export PERL_MM_USE_DEFAULT=1
40#export CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow 37#export CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow
52postconfigure() { : ; } 49postconfigure() { : ; }
53postbuild() { : ; } 50postbuild() { : ; }
54postinstall() { : ; } 51postinstall() { : ; }
55 52
56# now source user config, if any 53# now source user config, if any
54if [ "$STATICPERLRC" ]; then
55 . "$STATICPERLRC"
56else
57[ -r /etc/staticperlrc ] && . /etc/staticperlrc 57 [ -r /etc/staticperlrc ] && . /etc/staticperlrc
58[ -r ~/.staticperlrc ] && . ~/.staticperlrc 58 [ -r ~/.staticperlrc ] && . ~/.staticperlrc
59[ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" 59 [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc"
60fi
60 61
61############################################################################# 62#############################################################################
62# support 63# support
64
65MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}"
66PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed
67
68unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG
69export LC_ALL=C # just to be on the safe side
63 70
64# set version in a way that Makefile.PL can extract 71# set version in a way that Makefile.PL can extract
65VERSION=VERSION; eval \ 72VERSION=VERSION; eval \
66$VERSION=0.1 73$VERSION=0.911
67 74
68BZ2=bz2 75BZ2=bz2
69BZIP2=bzip2 76BZIP2=bzip2
70 77
71fatal() { 78fatal() {
104############################################################################# 111#############################################################################
105# clean 112# clean
106 113
107distclean() { 114distclean() {
108 verblock <<EOF 115 verblock <<EOF
109deleting everything installed by this script 116 deleting everything installed by this script (rm -rf $STATICPERL)
110EOF 117EOF
111 118
112 rm -rf "$STATICPERL" 119 rm -rf "$STATICPERL"
113} 120}
114 121
147 verblock <<EOF 154 verblock <<EOF
148unpacking perl 155unpacking perl
149EOF 156EOF
150 157
151 mkdir -p unpack 158 mkdir -p unpack
152 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xC unpack \ 159 $BZIP2 -d <perl-$PERL_VERSION.tar.bz2 | tar xfC - unpack \
153 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking" 160 || fatal "perl-$PERL_VERSION.tar.bz2: error during unpacking"
154 chmod -R u+w unpack/perl-$PERL_VERSION 161 chmod -R u+w unpack/perl-$PERL_VERSION
155 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 162 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
156 rmdir -p unpack 163 rmdir -p unpack
157 fi 164 fi
254 verblock <<EOF 261 verblock <<EOF
255installing $STATICPERL/src/perl-$PERL_VERSION 262installing $STATICPERL/src/perl-$PERL_VERSION
256to $PERL_PREFIX 263to $PERL_PREFIX
257EOF 264EOF
258 265
259 rm -rf "$PERL_PREFIX" 266 ln -sf "perl/bin/" "$STATICPERL/bin"
260 267 ln -sf "perl/lib/" "$STATICPERL/lib"
268
269 ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten
270 rm -rf "$PERL_PREFIX" # by this rm -rf
271
261 make install || fatal "make install: error while installing" 272 make install || fatal "make install: error while installing"
262 273
263 rcd "$PERL_PREFIX" 274 rcd "$PERL_PREFIX"
264 275
265 # create a "make install" replacement for CPAN 276 # create a "make install" replacement for CPAN
266 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF 277 cat >"$PERL_PREFIX"/bin/cpan-make-install <<EOF
267make install UNINST=1 278make || exit
279
268if find blib/arch/auto -type f | grep -q -v .exists; then 280if find blib/arch/auto -type f | grep -q -v .exists; then
269 echo Probably an XS module, rebuilding perl 281 echo Probably an XS module, rebuilding perl
270 make perl 282 if make perl; then
271 rm -f "$PERL_PREFIX"/bin/perl 283 mv perl "$PERL_PREFIX"/bin/perl
272 make -f Makefile.aperl inst_perl
273 make -f Makefile.aperl map_clean 284 make -f Makefile.aperl map_clean
285 else
286 make -f Makefile.aperl map_clean
287 exit 1
288 fi
274fi 289fi
290
291make install UNINST=1
275EOF 292EOF
276 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install 293 chmod 755 "$PERL_PREFIX"/bin/cpan-make-install
277 294
278 # trick CPAN into avoiding ~/.cpan completely 295 # trick CPAN into avoiding ~/.cpan completely
279 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" 296 echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"
294 ' || fatal "error while initialising CPAN" 311 ' || fatal "error while initialising CPAN"
295 312
296 touch "$PERL_PREFIX/staticstamp.install" 313 touch "$PERL_PREFIX/staticstamp.install"
297 fi 314 fi
298 315
299 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall"; then 316 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
300 NOCHECK_INSTALL=+ 317 NOCHECK_INSTALL=+
301 instcpan $STATICPERL_MODULES 318 instcpan $STATICPERL_MODULES
302 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES 319 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES
303 320
304 postinstall || fatal "postinstall hook failed" 321 postinstall || fatal "postinstall hook failed"
355############################################################################# 372#############################################################################
356# main 373# main
357 374
358podusage() { 375podusage() {
359 echo 376 echo
377
360 if [ -e "$PERL_PREFIX/bin/perl" ]; then 378 if [ -e "$PERL_PREFIX/bin/perl" ]; then
361 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ 379 "$PERL_PREFIX/bin/perl" -MPod::Usage -e \
362 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 380 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
363 2>/dev/null && exit 381 2>/dev/null && exit
364 fi 382 fi
383
365 # try whatever perl we can find 384 # try whatever perl we can find
366 perl -MPod::Usage -e \ 385 perl -MPod::Usage -e \
367 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 386 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \
368 2>/dev/null && exit 387 2>/dev/null && exit
369 388
370 fatal "displaying documentation requires a working perl - try '$0 install' first" 389 fatal "displaying documentation requires a working perl - try '$0 install' to build one in a safe location"
371} 390}
372 391
373usage() { 392usage() {
374 podusage 0 393 podusage 0
375} 394}
385} 404}
386 405
387bundle() { 406bundle() {
388 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" 407 catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create"
389 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" 408 chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE"
409 CACHE="$STATICPERL/cache"
410 mkdir -p "$CACHE"
390 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@" 411 "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@"
391} 412}
392 413
393if [ $# -gt 0 ]; then 414if [ $# -gt 0 ]; then
394 while [ $# -gt 0 ]; do 415 while [ $# -gt 0 ]; do
395 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" 416 mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create"
396 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" 417 mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create"
397 418
398 command="${1#--}"; shift 419 command="${1#--}"; shift
399 case "$command" in 420 case "$command" in
421 version )
422 echo "staticperl version $VERSION"
423 ;;
400 fetch | configure | build | install | clean | distclean) 424 fetch | configure | build | install | clean | distclean)
401 verblock <<EOF
402$command
403EOF
404 ( "$command" ) 425 ( "$command" )
405 ;; 426 ;;
406 instsrc ) 427 instsrc )
407 ( instsrc "$@" ) 428 ( instsrc "$@" )
408 exit 429 exit
422 exit 443 exit
423 ;; 444 ;;
424 mkperl ) 445 mkperl )
425 ( install ) 446 ( install )
426 bundle --perl "$@" 447 bundle --perl "$@"
448 exit
449 ;;
450 mkapp )
451 ( install )
452 bundle --app "$@"
427 exit 453 exit
428 ;; 454 ;;
429 help ) 455 help )
430 podusage 2 456 podusage 2
431 ;; 457 ;;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines