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.44 by root, Tue Jun 14 07:04:43 2011 UTC vs.
Revision 1.49 by root, Sun Jul 10 01:37:56 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.4 # 5.8.9 is also a good choice
13PERL_CC=cc 14PERL_CC=cc
14PERL_CONFIGURE="" # additional Configure arguments 15PERL_CONFIGURE="" # additional Configure arguments
15PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG" 16PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG"
16PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" 17PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math"
17 18
37 38
38# some configuration options for modules 39# some configuration options for modules
39PERL_MM_USE_DEFAULT=1 40PERL_MM_USE_DEFAULT=1
40PERL_MM_OPT="MAN1PODS= MAN3PODS=" 41PERL_MM_OPT="MAN1PODS= MAN3PODS="
41#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
42EV_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' 43#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'
43export PERL_MM_USE_DEFAULT PERL_MM_OPT CORO_INTERFACE EV_EXTRA_DEFS 44export PERL_MM_USE_DEFAULT PERL_MM_OPT
44 45
45# which extra modules to install by default from CPAN that are 46# which extra modules to install by default from CPAN that are
46# required by mkbundle 47# required by mkbundle
47STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" 48STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage"
48 49
131 132
132############################################################################# 133#############################################################################
133# download/configure/compile/install perl 134# download/configure/compile/install perl
134 135
135clean() { 136clean() {
136 rm -rf "$STATICPERL/src/perl-$PERL_VERSION" 137 rm -rf "$STATICPERL/src"
137} 138}
138 139
139realclean() { 140realclean() {
140 rm -f "$PERL_PREFIX/staticstamp.postinstall" 141 rm -f "$PERL_PREFIX/staticstamp.postinstall"
141 rm -f "$PERL_PREFIX/staticstamp.install" 142 rm -f "$PERL_PREFIX/staticstamp.install"
147 148
148 mkdir -p src 149 mkdir -p src
149 rcd src 150 rcd src
150 151
151 if ! [ -d "perl-$PERL_VERSION" ]; then 152 if ! [ -d "perl-$PERL_VERSION" ]; then
152 if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then 153 PERLTAR=perl-$PERL_VERSION.tar.$BZ2
153 154
155 if ! [ -e $PERLTAR ]; then
154 URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" 156 URL="$CPAN/src/5.0/$PERLTAR"
155 157
156 verblock <<EOF 158 verblock <<EOF
157downloading perl 159downloading perl
158to manually download perl yourself, place 160to manually download perl yourself, place
159perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL 161perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL
160trying $URL 162trying $URL
161 163
162either curl or wget is required for automatic download. 164either curl or wget is required for automatic download.
163curl is tried first, then wget. 165curl is tried first, then wget.
164EOF
165 166
167you can configure a download cache directory via DLCACHE
168in your .staticperlrc to avoid repeated downloads.
169EOF
170
166 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
167 curl -f >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 172 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \
168 || wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 173 || wget -O $PERLTAR~ "$URL" \
174 || curl -f >$PERLTAR~ "$URL" \
169 || fatal "$URL: unable to download" 175 || fatal "$URL: unable to download"
170 rm -f perl-$PERL_VERSION.tar.$BZ2 176 rm -f $PERLTAR
171 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
172 fi 183 fi
173 184
174 verblock <<EOF 185 verblock <<EOF
175unpacking perl 186unpacking perl
176EOF 187EOF
177 188
178 mkdir -p unpack 189 mkdir -p unpack
179 rm -rf unpack/perl-$PERL_VERSION 190 rm -rf unpack/perl-$PERL_VERSION
180 $BZIP2 -d <perl-$PERL_VERSION.tar.$BZ2 | ( cd unpack && tar xf - ) \ 191 $BZIP2 -d <$PERLTAR | ( cd unpack && tar xf - ) \
181 || fatal "perl-$PERL_VERSION.tar.$BZ2: error during unpacking" 192 || fatal "$PERLTAR: error during unpacking"
182 chmod -R u+w unpack/perl-$PERL_VERSION 193 chmod -R u+w unpack/perl-$PERL_VERSION
183 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 194 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
184 rmdir -p unpack 195 rmdir -p unpack
185 fi 196 fi
186} 197}
289 300
290 sh Configure -S || fatal "Configure -S failed" 301 sh Configure -S || fatal "Configure -S failed"
291 302
292 postconfigure || fatal "postconfigure hook failed" 303 postconfigure || fatal "postconfigure hook failed"
293 304
294 touch staticstamp.configure 305 : > staticstamp.configure
295} 306}
296 307
297write_shellscript() { 308write_shellscript() {
298 { 309 {
299 echo "#!/bin/sh" 310 echo "#!/bin/sh"
317 rm -f "$PERL_PREFIX/staticstamp.install" 328 rm -f "$PERL_PREFIX/staticstamp.install"
318 329
319 "$MAKE" || fatal "make: error while building perl" 330 "$MAKE" || fatal "make: error while building perl"
320 331
321 postbuild || fatal "postbuild hook failed" 332 postbuild || fatal "postbuild hook failed"
333}
334
335_postinstall() {
336 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then
337 NOCHECK_INSTALL=+
338 instcpan $STATICPERL_MODULES
339 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES
340
341 postinstall || fatal "postinstall hook failed"
342
343 : > "$PERL_PREFIX/staticstamp.postinstall"
344 fi
322} 345}
323 346
324install() { 347install() {
325 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then 348 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
326 build 349 build
374 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 397 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>);
375 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM"); 398 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM");
376 CPAN::Shell->o (conf => q<commit>); 399 CPAN::Shell->o (conf => q<commit>);
377 ' || fatal "error while initialising CPAN" 400 ' || fatal "error while initialising CPAN"
378 401
379 touch "$PERL_PREFIX/staticstamp.install" 402 : > "$PERL_PREFIX/staticstamp.install"
380 fi 403 fi
381 404
405 _postinstall
406}
407
408import() {
409 IMPORT="$1"
410
411 rcd "$STATICPERL"
412
382 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then 413 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
383 NOCHECK_INSTALL=+ 414 verblock <<EOF
384 instcpan $STATICPERL_MODULES 415import perl from $IMPORT to $STATICPERL
385 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES 416EOF
386 417
387 postinstall || fatal "postinstall hook failed" 418 rm -rf bin cpan lib patched perl src
419 mkdir -m 755 perl perl/bin
420 ln -s perl/bin/ bin
421 ln -s "$IMPORT" perl/bin/
388 422
389 touch "$PERL_PREFIX/staticstamp.postinstall" 423 : > "$PERL_PREFIX/staticstamp.install"
390 fi 424 fi
425
426 _postinstall
391} 427}
392 428
393############################################################################# 429#############################################################################
394# install a module from CPAN 430# install a module from CPAN
395 431
399 verblock <<EOF 435 verblock <<EOF
400installing modules from CPAN 436installing modules from CPAN
401$@ 437$@
402EOF 438EOF
403 439
404 for mod in "$@"; do 440 #"$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
405 "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install => "'"$mod"'"' \ 441 "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
406 || fatal "$mod: unable to install from CPAN" 442
407 done 443 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then
444 fatal "failure while installing modules from CPAN ($@)"
445 fi
408 rm -rf "$STATICPERL/build" 446 rm -f "$STATICPERL/instcpan.log"
409} 447}
410 448
411############################################################################# 449#############################################################################
412# install a module from unpacked sources 450# install a module from unpacked sources
413 451
486 command="${1#--}"; shift 524 command="${1#--}"; shift
487 case "$command" in 525 case "$command" in
488 version ) 526 version )
489 echo "staticperl version $VERSION" 527 echo "staticperl version $VERSION"
490 ;; 528 ;;
491 fetch | configure | build | install | clean | realclean | distclean) 529 fetch | configure | build | install | clean | realclean | distclean )
492 ( "$command" ) || exit 530 ( "$command" ) || exit
531 ;;
532 import )
533 ( import "$1" ) || exit
534 shift
493 ;; 535 ;;
494 instsrc ) 536 instsrc )
495 ( instsrc "$@" ) || exit 537 ( instsrc "$@" ) || exit
496 exit 538 exit
497 ;; 539 ;;
504 exec "$PERL_PREFIX/bin/perl" "$@" 546 exec "$PERL_PREFIX/bin/perl" "$@"
505 exit 547 exit
506 ;; 548 ;;
507 cpan ) 549 cpan )
508 ( install ) || exit 550 ( install ) || exit
551 PERL="$PERL_PREFIX/bin/perl"
552 export PERL
509 exec "$PERL_PREFIX/bin/cpan" "$@" 553 exec "$PERL_PREFIX/bin/cpan" "$@"
510 exit 554 exit
511 ;; 555 ;;
512 mkbundle ) 556 mkbundle )
513 ( install ) || exit 557 ( install ) || exit

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines