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.41 by root, Sun May 1 09:29:47 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
78# life easier when working in e.g. "staticperl cpan / look" 79# life easier when working in e.g. "staticperl cpan / look"
79PATH="$PERL_PREFIX/perl/bin:$PATH" 80PATH="$PERL_PREFIX/perl/bin:$PATH"
80 81
81# set version in a way that Makefile.PL can extract 82# set version in a way that Makefile.PL can extract
82VERSION=VERSION; eval \ 83VERSION=VERSION; eval \
83$VERSION="1.22" 84$VERSION="1.31"
84 85
85BZ2=bz2 86BZ2=bz2
86BZIP2=bzip2 87BZIP2=bzip2
87 88
88fatal() { 89fatal() {
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
161EOF
162 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
163 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
164 curl -f >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 172 { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \
165 || wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ 173 || wget -O $PERLTAR~ "$URL" \
174 || curl -f >$PERLTAR~ "$URL" \
166 || fatal "$URL: unable to download" 175 || fatal "$URL: unable to download"
167 rm -f perl-$PERL_VERSION.tar.$BZ2 176 rm -f $PERLTAR
168 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
169 fi 183 fi
170 184
171 verblock <<EOF 185 verblock <<EOF
172unpacking perl 186unpacking perl
173EOF 187EOF
174 188
175 mkdir -p unpack 189 mkdir -p unpack
176 rm -rf unpack/perl-$PERL_VERSION 190 rm -rf unpack/perl-$PERL_VERSION
177 $BZIP2 -d <perl-$PERL_VERSION.tar.$BZ2 | ( cd unpack && tar xf - ) \ 191 $BZIP2 -d <$PERLTAR | ( cd unpack && tar xf - ) \
178 || fatal "perl-$PERL_VERSION.tar.$BZ2: error during unpacking" 192 || fatal "$PERLTAR: error during unpacking"
179 chmod -R u+w unpack/perl-$PERL_VERSION 193 chmod -R u+w unpack/perl-$PERL_VERSION
180 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION 194 mv unpack/perl-$PERL_VERSION perl-$PERL_VERSION
181 rmdir -p unpack 195 rmdir -p unpack
182 fi 196 fi
183} 197}
286 300
287 sh Configure -S || fatal "Configure -S failed" 301 sh Configure -S || fatal "Configure -S failed"
288 302
289 postconfigure || fatal "postconfigure hook failed" 303 postconfigure || fatal "postconfigure hook failed"
290 304
291 touch staticstamp.configure 305 : > staticstamp.configure
292} 306}
293 307
294write_shellscript() { 308write_shellscript() {
295 { 309 {
296 echo "#!/bin/sh" 310 echo "#!/bin/sh"
314 rm -f "$PERL_PREFIX/staticstamp.install" 328 rm -f "$PERL_PREFIX/staticstamp.install"
315 329
316 "$MAKE" || fatal "make: error while building perl" 330 "$MAKE" || fatal "make: error while building perl"
317 331
318 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
319} 345}
320 346
321install() { 347install() {
322 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then 348 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
323 build 349 build
371 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>); 397 CPAN::Shell->o (conf => q<build_requires_install_policy>, q<no>);
372 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM"); 398 CPAN::Shell->o (conf => q<prefer_installer>, "EUMM");
373 CPAN::Shell->o (conf => q<commit>); 399 CPAN::Shell->o (conf => q<commit>);
374 ' || fatal "error while initialising CPAN" 400 ' || fatal "error while initialising CPAN"
375 401
376 touch "$PERL_PREFIX/staticstamp.install" 402 : > "$PERL_PREFIX/staticstamp.install"
377 fi 403 fi
378 404
405 _postinstall
406}
407
408import() {
409 IMPORT="$1"
410
411 rcd "$STATICPERL"
412
379 if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then 413 if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
380 NOCHECK_INSTALL=+ 414 verblock <<EOF
381 instcpan $STATICPERL_MODULES 415import perl from $IMPORT to $STATICPERL
382 [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES 416EOF
383 417
384 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/
385 422
386 touch "$PERL_PREFIX/staticstamp.postinstall" 423 : > "$PERL_PREFIX/staticstamp.install"
387 fi 424 fi
425
426 _postinstall
388} 427}
389 428
390############################################################################# 429#############################################################################
391# install a module from CPAN 430# install a module from CPAN
392 431
396 verblock <<EOF 435 verblock <<EOF
397installing modules from CPAN 436installing modules from CPAN
398$@ 437$@
399EOF 438EOF
400 439
401 for mod in "$@"; do 440 #"$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"
402 "$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"
403 || fatal "$mod: unable to install from CPAN" 442
404 done 443 if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then
444 fatal "failure while installing modules from CPAN ($@)"
445 fi
405 rm -rf "$STATICPERL/build" 446 rm -f "$STATICPERL/instcpan.log"
406} 447}
407 448
408############################################################################# 449#############################################################################
409# install a module from unpacked sources 450# install a module from unpacked sources
410 451
483 command="${1#--}"; shift 524 command="${1#--}"; shift
484 case "$command" in 525 case "$command" in
485 version ) 526 version )
486 echo "staticperl version $VERSION" 527 echo "staticperl version $VERSION"
487 ;; 528 ;;
488 fetch | configure | build | install | clean | realclean | distclean) 529 fetch | configure | build | install | clean | realclean | distclean )
489 ( "$command" ) || exit 530 ( "$command" ) || exit
531 ;;
532 import )
533 ( import "$1" ) || exit
534 shift
490 ;; 535 ;;
491 instsrc ) 536 instsrc )
492 ( instsrc "$@" ) || exit 537 ( instsrc "$@" ) || exit
493 exit 538 exit
494 ;; 539 ;;
501 exec "$PERL_PREFIX/bin/perl" "$@" 546 exec "$PERL_PREFIX/bin/perl" "$@"
502 exit 547 exit
503 ;; 548 ;;
504 cpan ) 549 cpan )
505 ( install ) || exit 550 ( install ) || exit
551 PERL="$PERL_PREFIX/bin/perl"
552 export PERL
506 exec "$PERL_PREFIX/bin/cpan" "$@" 553 exec "$PERL_PREFIX/bin/cpan" "$@"
507 exit 554 exit
508 ;; 555 ;;
509 mkbundle ) 556 mkbundle )
510 ( install ) || exit 557 ( install ) || exit

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines