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 | |
6 | STATICPERL=~/.staticperl |
6 | STATICPERL=~/.staticperl |
7 | CPAN=http://mirror.netcologne.de/cpan # which mirror to use |
7 | CPAN=http://mirror.netcologne.de/cpan # which mirror to use |
8 | EMAIL="read the documentation <rtfm@example.org>" |
8 | EMAIL="read the documentation <rtfm@example.org>" |
|
|
9 | DLCACHE= |
9 | |
10 | |
10 | # perl build variables |
11 | # perl build variables |
11 | MAKE=make |
12 | MAKE=make |
12 | PERL_VERSION=5.12.3 # 5.8.9 is also a good choice |
13 | PERL_VERSION=5.12.4 # 5.8.9 is also a good choice |
13 | PERL_CC=cc |
14 | PERL_CC=cc |
14 | PERL_CONFIGURE="" # additional Configure arguments |
15 | PERL_CONFIGURE="" # additional Configure arguments |
15 | PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG" |
16 | PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG" |
16 | PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" |
17 | PERL_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 |
39 | PERL_MM_USE_DEFAULT=1 |
40 | PERL_MM_USE_DEFAULT=1 |
40 | PERL_MM_OPT="MAN1PODS= MAN3PODS=" |
41 | PERL_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 |
42 | 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' |
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' |
43 | export PERL_MM_USE_DEFAULT PERL_MM_OPT CORO_INTERFACE EV_EXTRA_DEFS |
44 | export 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 |
47 | STATICPERL_MODULES="common::sense Pod::Strip PPI::XS Pod::Usage" |
48 | STATICPERL_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 | |
135 | clean() { |
136 | clean() { |
136 | rm -rf "$STATICPERL/src/perl-$PERL_VERSION" |
137 | rm -rf "$STATICPERL/src" |
137 | } |
138 | } |
138 | |
139 | |
139 | realclean() { |
140 | realclean() { |
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 |
157 | downloading perl |
159 | downloading perl |
158 | to manually download perl yourself, place |
160 | to manually download perl yourself, place |
159 | perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
161 | perl-$PERL_VERSION.tar.$BZ2 in $STATICPERL |
160 | trying $URL |
162 | trying $URL |
161 | |
163 | |
162 | either curl or wget is required for automatic download. |
164 | either curl or wget is required for automatic download. |
163 | curl is tried first, then wget. |
165 | curl is tried first, then wget. |
164 | EOF |
|
|
165 | |
166 | |
|
|
167 | you can configure a download cache directory via DLCACHE |
|
|
168 | in your .staticperlrc to avoid repeated downloads. |
|
|
169 | EOF |
|
|
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 |
175 | unpacking perl |
186 | unpacking perl |
176 | EOF |
187 | EOF |
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 | |
297 | write_shellscript() { |
308 | write_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 | |
324 | install() { |
347 | install() { |
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 | |
|
|
408 | import() { |
|
|
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 |
415 | import perl from $IMPORT to $STATICPERL |
385 | [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES |
416 | EOF |
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 |
400 | installing modules from CPAN |
436 | installing modules from CPAN |
401 | $@ |
437 | $@ |
402 | EOF |
438 | EOF |
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 |