… | |
… | |
49 | |
49 | |
50 | # which extra modules you might want to install |
50 | # which extra modules you might want to install |
51 | EXTRA_MODULES="" |
51 | EXTRA_MODULES="" |
52 | |
52 | |
53 | # overridable functions |
53 | # overridable functions |
54 | preconfigure() { : ; } |
54 | preconfigure() { : ; } |
55 | patchconfig() { : ; } |
55 | patchconfig() { : ; } |
56 | postconfigure() { : ; } |
56 | postconfigure() { : ; } |
57 | postbuild() { : ; } |
57 | postbuild() { : ; } |
|
|
58 | postcpanconfig() { : ; } |
58 | postinstall() { : ; } |
59 | postinstall() { : ; } |
59 | |
60 | |
60 | # now source user config, if any |
61 | # now source user config, if any |
61 | if [ "$STATICPERLRC" ]; then |
62 | if [ "$STATICPERLRC" ]; then |
62 | . "$STATICPERLRC" |
63 | . "$STATICPERLRC" |
63 | else |
64 | else |
… | |
… | |
69 | ############################################################################# |
70 | ############################################################################# |
70 | # support |
71 | # support |
71 | |
72 | |
72 | # work around ExtUtils::CBuilder and others |
73 | # work around ExtUtils::CBuilder and others |
73 | export CC="$PERL_CC" |
74 | export CC="$PERL_CC" |
74 | export CFLAGS="$PERL_CFLASGS" |
75 | export CFLAGS="$PERL_CFLAGS" |
75 | export LD="$PERL_CC" |
76 | export LD="$PERL_CC" |
76 | export LDFLAGS="$PERL_LDFLAGS" |
77 | export LDFLAGS="$PERL_LDFLAGS" |
77 | unset LIBS |
78 | unset LIBS |
78 | |
79 | |
79 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
80 | PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed |
… | |
… | |
86 | # life easier when working in e.g. "staticperl cpan / look" |
87 | # life easier when working in e.g. "staticperl cpan / look" |
87 | PATH="$PERL_PREFIX/perl/bin:$PATH" |
88 | PATH="$PERL_PREFIX/perl/bin:$PATH" |
88 | |
89 | |
89 | # set version in a way that Makefile.PL can extract |
90 | # set version in a way that Makefile.PL can extract |
90 | VERSION=VERSION; eval \ |
91 | VERSION=VERSION; eval \ |
91 | $VERSION="1.44" |
92 | $VERSION="1.46" |
92 | |
93 | |
93 | fatal() { |
94 | fatal() { |
94 | printf -- "\nFATAL: %s\n\n" "$*" >&2 |
95 | printf -- "\nFATAL: %s\n\n" "$*" >&2 |
95 | exit 1 |
96 | exit 1 |
96 | } |
97 | } |
… | |
… | |
146 | rm -f "$PERL_PREFIX/staticstamp.install" |
147 | rm -f "$PERL_PREFIX/staticstamp.install" |
147 | rm -f "$STATICPERL/src/perl/staticstamp.configure" |
148 | rm -f "$STATICPERL/src/perl/staticstamp.configure" |
148 | } |
149 | } |
149 | |
150 | |
150 | fetch() { |
151 | fetch() { |
|
|
152 | ( |
151 | rcd "$STATICPERL" |
153 | rcd "$STATICPERL" |
152 | |
154 | |
153 | mkdir -p src |
155 | mkdir -p src |
154 | rcd src |
156 | rcd src |
155 | |
157 | |
… | |
… | |
216 | *.lzma ) UNCOMPRESS="lzma -d" ;; |
218 | *.lzma ) UNCOMPRESS="lzma -d" ;; |
217 | *.bz2 ) UNCOMPRESS="bzip2 -d" ;; |
219 | *.bz2 ) UNCOMPRESS="bzip2 -d" ;; |
218 | *.gz ) UNCOMPRESS="gzip -d" ;; |
220 | *.gz ) UNCOMPRESS="gzip -d" ;; |
219 | *.tar ) UNCOMPRESS="cat" ;; |
221 | *.tar ) UNCOMPRESS="cat" ;; |
220 | * ) |
222 | * ) |
221 | fatal "don't know hot to uncompress $PERL_TAR,\nonly tar, tar.gz, tar.bz2, tar.lzma and tar.xz are supported." |
223 | fatal "don't know hot to uncompress $PERLTAR,\nonly tar, tar.gz, tar.bz2, tar.lzma and tar.xz are supported." |
222 | exit 1 |
224 | exit 1 |
223 | ;; |
225 | ;; |
224 | esac |
226 | esac |
225 | |
227 | |
226 | <"$PERLTAR" $UNCOMPRESS -d | ( cd unpack && tar xf - ) \ |
228 | <"$PERLTAR" $UNCOMPRESS -d | ( cd unpack && tar xf - ) \ |
… | |
… | |
234 | fatal "unpacking $PERLTAR did not result in a single directory, don't know how to handle this" |
236 | fatal "unpacking $PERLTAR did not result in a single directory, don't know how to handle this" |
235 | fi |
237 | fi |
236 | |
238 | |
237 | rm "$PERLTAR" |
239 | rm "$PERLTAR" |
238 | fi |
240 | fi |
|
|
241 | ) || exit |
239 | } |
242 | } |
240 | |
243 | |
241 | # similar to GNU-sed -i or perl -pi |
244 | # similar to GNU-sed -i or perl -pi |
242 | sedreplace() { |
245 | sedreplace() { |
243 | sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
246 | sed -e "$1" <"$2" > "$2~" || fatal "error while running sed" |
… | |
… | |
270 | EOF |
273 | EOF |
271 | exit 1 |
274 | exit 1 |
272 | } |
275 | } |
273 | |
276 | |
274 | configure() { |
277 | configure() { |
|
|
278 | ( |
275 | fetch |
279 | fetch |
276 | |
280 | |
277 | rcd "$STATICPERL/src/perl" |
281 | rcd "$STATICPERL/src/perl" |
278 | |
282 | |
279 | [ -e staticstamp.configure ] && return |
283 | [ -e staticstamp.configure ] && return |
… | |
… | |
344 | sh Configure -S || fatal "Configure -S failed" |
348 | sh Configure -S || fatal "Configure -S failed" |
345 | |
349 | |
346 | postconfigure || fatal "postconfigure hook failed" |
350 | postconfigure || fatal "postconfigure hook failed" |
347 | |
351 | |
348 | : > staticstamp.configure |
352 | : > staticstamp.configure |
|
|
353 | ) || exit |
349 | } |
354 | } |
350 | |
355 | |
351 | write_shellscript() { |
356 | write_shellscript() { |
352 | { |
357 | { |
353 | echo "#!/bin/sh" |
358 | echo "#!/bin/sh" |
… | |
… | |
358 | } >"$PERL_PREFIX/bin/$1" |
363 | } >"$PERL_PREFIX/bin/$1" |
359 | chmod 755 "$PERL_PREFIX/bin/$1" |
364 | chmod 755 "$PERL_PREFIX/bin/$1" |
360 | } |
365 | } |
361 | |
366 | |
362 | build() { |
367 | build() { |
|
|
368 | ( |
363 | configure |
369 | configure |
364 | |
370 | |
365 | rcd "$STATICPERL/src/perl" |
371 | rcd "$STATICPERL/src/perl" |
366 | |
372 | |
367 | verblock <<EOF |
373 | verblock <<EOF |
… | |
… | |
371 | rm -f "$PERL_PREFIX/staticstamp.install" |
377 | rm -f "$PERL_PREFIX/staticstamp.install" |
372 | |
378 | |
373 | "$MAKE" || fatal "make: error while building perl" |
379 | "$MAKE" || fatal "make: error while building perl" |
374 | |
380 | |
375 | postbuild || fatal "postbuild hook failed" |
381 | postbuild || fatal "postbuild hook failed" |
|
|
382 | ) || exit |
376 | } |
383 | } |
377 | |
384 | |
378 | _postinstall() { |
385 | _postinstall() { |
379 | if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
386 | if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then |
380 | NOCHECK_INSTALL=+ |
387 | NOCHECK_INSTALL=+ |
… | |
… | |
386 | : > "$PERL_PREFIX/staticstamp.postinstall" |
393 | : > "$PERL_PREFIX/staticstamp.postinstall" |
387 | fi |
394 | fi |
388 | } |
395 | } |
389 | |
396 | |
390 | install() { |
397 | install() { |
|
|
398 | ( |
391 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
399 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
392 | build |
400 | build |
393 | |
401 | |
394 | verblock <<EOF |
402 | verblock <<EOF |
395 | installing $STATICPERL/src/perl |
403 | installing $STATICPERL/src/perl |
… | |
… | |
402 | mkdir "$STATICPERL/patched" |
410 | mkdir "$STATICPERL/patched" |
403 | |
411 | |
404 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
412 | ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten |
405 | rm -rf "$PERL_PREFIX" # by this rm -rf |
413 | rm -rf "$PERL_PREFIX" # by this rm -rf |
406 | |
414 | |
|
|
415 | rcd "$STATICPERL/src/perl" |
|
|
416 | |
407 | "$MAKE" install || fatal "make install: error while installing" |
417 | "$MAKE" install || fatal "make install: error while installing" |
408 | |
418 | |
409 | rcd "$PERL_PREFIX" |
419 | rcd "$PERL_PREFIX" |
410 | |
420 | |
411 | # create a "make install" replacement for CPAN |
421 | # create a "make install" replacement for CPAN |
412 | write_shellscript SP-make-install-make <<'EOF' |
422 | write_shellscript SP-make-make <<'end_of_make' |
|
|
423 | #CAT make-make.sh |
|
|
424 | end_of_make |
|
|
425 | |
|
|
426 | # create a "make install" replacement for CPAN |
|
|
427 | write_shellscript SP-make-install-make <<'end_of_make_install_make' |
413 | #CAT make-install-make.sh |
428 | #CAT make-install-make.sh |
414 | EOF |
429 | end_of_make_install_make |
415 | |
430 | |
416 | # create a "patch modules" helper |
431 | # create a "patch modules" helper |
417 | write_shellscript SP-patch-postinstall <<'EOF' |
432 | write_shellscript SP-patch-postinstall <<'end_of_patch_postinstall' |
418 | #CAT patch-postinstall.sh |
433 | #CAT patch-postinstall.sh |
419 | EOF |
434 | end_of_patch_postinstall |
420 | |
435 | |
421 | # immediately use it |
436 | # immediately use it |
422 | "$PERL_PREFIX/bin/SP-patch-postinstall" |
437 | "$PERL_PREFIX/bin/SP-patch-postinstall" |
423 | |
438 | |
424 | # help to trick CPAN into avoiding ~/.cpan completely |
439 | # help to trick CPAN into avoiding ~/.cpan completely |
425 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
440 | echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" |
426 | |
441 | |
427 | # we call cpan with -MCPAN::MyConfig in this script, which |
442 | # we call cpan with -MCPAN::MyConfig in this script, which |
428 | # is strictly unnecssary as we have to patch CPAN anyway, |
443 | # is strictly unnecessary as we have to patch CPAN anyway, |
429 | # so consider it "for good measure". |
444 | # so consider it "for good measure". |
430 | "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' |
445 | "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' |
431 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
446 | CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); |
|
|
447 | CPAN::Shell->o (conf => pushy_https => "0"); |
432 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
448 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
433 | CPAN::Shell->o (conf => q<init>); |
449 | CPAN::Shell->o (conf => q<init>); |
434 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
450 | CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan"); |
435 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
451 | CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build"); |
436 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
452 | CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs"); |
437 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
453 | CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile"); |
438 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
454 | CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources"); |
439 | CPAN::Shell->o (conf => q<makepl_arg>, "MAP_TARGET=perl"); |
455 | CPAN::Shell->o (conf => q<makepl_arg>, "MAP_TARGET=perl"); |
|
|
456 | CPAN::Shell->o (conf => q<make>, "'"$PERL_PREFIX"'/bin/SP-make-make"); |
440 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make"); |
457 | CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make"); |
441 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
458 | CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>); |
442 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>); |
459 | CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>); |
|
|
460 | CPAN::Shell->o (conf => q<recommends_policy>, q<0>); |
|
|
461 | CPAN::Shell->o (conf => q<suggests_policy>, q<0>); |
443 | CPAN::Shell->o (conf => q<prefer_installer>, "EUMM"); |
462 | CPAN::Shell->o (conf => q<prefer_installer>, q<EUMM>); |
444 | CPAN::Shell->o (conf => q<commit>); |
463 | CPAN::Shell->o (conf => q<commit>); |
445 | ' || fatal "error while initialising CPAN" |
464 | ' || fatal "error while initialising CPAN" |
446 | |
465 | |
|
|
466 | postcpanconfig |
|
|
467 | |
447 | : > "$PERL_PREFIX/staticstamp.install" |
468 | : > "$PERL_PREFIX/staticstamp.install" |
448 | fi |
469 | fi |
449 | |
470 | |
450 | _postinstall |
471 | _postinstall |
|
|
472 | ) || exit |
451 | } |
473 | } |
452 | |
474 | |
453 | import() { |
475 | import() { |
|
|
476 | ( |
454 | IMPORT="$1" |
477 | IMPORT="$1" |
455 | |
478 | |
456 | rcd "$STATICPERL" |
479 | rcd "$STATICPERL" |
457 | |
480 | |
458 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
481 | if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then |
… | |
… | |
469 | |
492 | |
470 | : > "$PERL_PREFIX/staticstamp.install" |
493 | : > "$PERL_PREFIX/staticstamp.install" |
471 | fi |
494 | fi |
472 | |
495 | |
473 | _postinstall |
496 | _postinstall |
|
|
497 | ) || exit |
474 | } |
498 | } |
475 | |
499 | |
476 | ############################################################################# |
500 | ############################################################################# |
477 | # install a module from CPAN |
501 | # install a module from CPAN |
478 | |
502 | |
479 | instcpan() { |
503 | instcpan() { |
480 | [ $NOCHECK_INSTALL ] || install |
504 | [ $NOCHECK_INSTALL ] || install |
481 | |
505 | |
482 | verblock <<EOF |
506 | verblock <<EOF |
483 | installing modules from CPAN |
507 | installing modules from CPAN |
484 | $@ |
508 | $* |
485 | EOF |
509 | EOF |
486 | |
510 | |
487 | MYCONFIG= |
511 | MYCONFIG= |
488 | [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig |
512 | [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig |
489 | |
513 | |
490 | "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" |
514 | "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" |
491 | |
515 | |
492 | if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then |
516 | if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then |
493 | fatal "failure while installing modules from CPAN ($@)" |
517 | fatal "failure while installing modules from CPAN ($*)" |
494 | fi |
518 | fi |
495 | rm -f "$STATICPERL/instcpan.log" |
519 | rm -f "$STATICPERL/instcpan.log" |
496 | } |
520 | } |
497 | |
521 | |
498 | ############################################################################# |
522 | ############################################################################# |
… | |
… | |
501 | instsrc() { |
525 | instsrc() { |
502 | [ $NOCHECK_INSTALL ] || install |
526 | [ $NOCHECK_INSTALL ] || install |
503 | |
527 | |
504 | verblock <<EOF |
528 | verblock <<EOF |
505 | installing modules from source |
529 | installing modules from source |
506 | $@ |
530 | $* |
507 | EOF |
531 | EOF |
508 | |
532 | |
509 | for mod in "$@"; do |
533 | for mod in "$@"; do |
510 | echo |
534 | echo |
511 | echo $mod |
535 | echo $mod |
… | |
… | |
549 | catmkbundle() { |
573 | catmkbundle() { |
550 | { |
574 | { |
551 | read dummy |
575 | read dummy |
552 | echo "#!$PERL_PREFIX/bin/perl" |
576 | echo "#!$PERL_PREFIX/bin/perl" |
553 | cat |
577 | cat |
554 | } <<'MKBUNDLE' |
578 | } <<'end_of_mkbundle' |
555 | #CAT mkbundle |
579 | #CAT mkbundle |
556 | MKBUNDLE |
580 | end_of_mkbundle |
557 | } |
581 | } |
558 | |
582 | |
559 | bundle() { |
583 | bundle() { |
560 | MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}" |
584 | MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}" |
561 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |
585 | catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" |