--- App-Staticperl/staticperl.sh 2010/12/07 09:48:47 1.5 +++ App-Staticperl/staticperl.sh 2010/12/07 20:03:15 1.9 @@ -3,7 +3,6 @@ ############################################################################# # configuration to fill in -PERLVER=5.12.2 # 5.8.9 is also a good choice STATICPERL=~/.staticperl CPAN=http://mirror.netcologne.de/cpan/ # which mirror to use EMAIL="read the documentation " @@ -11,7 +10,8 @@ MKBUNDLE="$STATICPERL/mkbundle" # perl build variables -PREFIX="$STATICPERL/perl" # where the perl gets installed +PERL_PREFIX="$STATICPERL/perl" # where the perl gets installed +PERL_VERSION=5.12.2 # 5.8.9 is also a good choice PERL_CONFIGURE="" # additional Configure arguments PERL_CPPFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG -USITELIB_EXP -USITEARCHEXP -UARCHLIB_EXP" PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" @@ -48,6 +48,7 @@ EXTRA_MODULES="" # overridable functions +preconfigure() { : ; } postconfigure() { : ; } postbuild() { : ; } postinstall() { : ; } @@ -115,10 +116,7 @@ # download/configure/compile/install perl clean() { - cd "$STATICPERL/src/perl-$PERLVER" 2>/dev/null || return - - rm -f staticstamp.configure - make distclean >/dev/null 2>&1 + rm -rf "$STATICPERL/src/perl-$PERL_VERSION" } fetch() { @@ -127,22 +125,23 @@ mkdir -p src rcd src - if ! [ -d "perl-$PERLVER" ]; then - if ! [ -e "perl-$PERLVER.tar.$BZ2" ]; then + if ! [ -d "perl-$PERL_VERSION" ]; then + if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then - URL="$CPAN/src/5.0/perl-$PERLVER.tar.$BZ2" + URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" verblock <perl-$PERLVER.tar.$BZ2~ "$URL" \ - || wget -O perl-$PERLVER.tar.$BZ2~ "$URL" \ + rm -f perl-$PERL_VERSION.tar.$BZ2~ # just to be on the safe side + wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ + || curl >perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ || fatal "$URL: unable to download" - mv perl-$PERLVER.tar.$BZ2~ perl-$PERLVER.tar.$BZ2 + mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 fi verblock </dev/null 2>&1 # I hate them grep -q -- -fstack-protector Configure && \ sedreplace 's/-fstack-protector/-fno-stack-protector/g' Configure + preconfigure + # trace configure \ sh Configure -Duselargefiles \ -Uuse64bitint \ @@ -198,13 +200,13 @@ -Doptimize="$PERL_OPTIMIZE" \ -Dldflags="$PERL_LDFLAGS" \ -Dlibs="$PERL_LIBS" \ - -Dprefix="$PREFIX" \ - -Dbin="$PREFIX/bin" \ - -Dprivlib="$PREFIX/lib" \ - -Darchlib="$PREFIX/lib" \ + -Dprefix="$PERL_PREFIX" \ + -Dbin="$PERL_PREFIX/bin" \ + -Dprivlib="$PERL_PREFIX/lib" \ + -Darchlib="$PERL_PREFIX/lib" \ -Uusevendorprefix \ - -Dsitelib="$PREFIX/lib" \ - -Dsitearch="$PREFIX/lib" \ + -Dsitelib="$PERL_PREFIX/lib" \ + -Dsitearch="$PERL_PREFIX/lib" \ -Usitelibexp \ -Uman1dir \ -Uman3dir \ @@ -232,13 +234,13 @@ build() { configure - rcd "$STATICPERL/src/perl-$PERLVER" + rcd "$STATICPERL/src/perl-$PERL_VERSION" verblock <"$PREFIX"/bin/cpan-make-install <"$PERL_PREFIX"/bin/cpan-make-install <"$PERL_PREFIX/lib/CPAN/MyConfig.pm" - # trick CPAN into avoiding ~/.cpan completely - echo 1 >"$PREFIX/lib/CPAN/MyConfig.pm" + "$PERL_PREFIX"/bin/perl -MCPAN -e ' + CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); + CPAN::Shell->o (conf => q, "'"$STATICPERL"'/cpan"); + CPAN::Shell->o (conf => q); + CPAN::Shell->o (conf => q, "'"$STATICPERL"'/cpan"); + CPAN::Shell->o (conf => q, "'"$STATICPERL"'/cpan/build"); + CPAN::Shell->o (conf => q, "'"$STATICPERL"'/cpan/prefs"); + CPAN::Shell->o (conf => q , "'"$STATICPERL"'/cpan/histfile"); + CPAN::Shell->o (conf => q, "'"$STATICPERL"'/cpan/sources"); + CPAN::Shell->o (conf => q, "'"$PERL_PREFIX"'/bin/cpan-make-install"); + CPAN::Shell->o (conf => q, q); + CPAN::Shell->o (conf => q, q); + CPAN::Shell->o (conf => q); + ' || fatal "error while initialising CPAN" - "$PREFIX"/bin/perl -MCPAN -e ' - CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); - CPAN::Shell->o (conf => q, "'"$STATICPERL"'/cpan"); - CPAN::Shell->o (conf => q); - CPAN::Shell->o (conf => q, "'"$STATICPERL"'/cpan"); - CPAN::Shell->o (conf => q, "'"$STATICPERL"'/cpan/build"); - CPAN::Shell->o (conf => q, "'"$STATICPERL"'/cpan/prefs"); - CPAN::Shell->o (conf => q , "'"$STATICPERL"'/cpan/histfile"); - CPAN::Shell->o (conf => q, "'"$STATICPERL"'/cpan/sources"); - CPAN::Shell->o (conf => q, "'"$PREFIX"'/bin/cpan-make-install"); - CPAN::Shell->o (conf => q, q); - CPAN::Shell->o (conf => q, q); - CPAN::Shell->o (conf => q); - ' || fatal "error while initialising CPAN" - - NOCHECK_INSTALL=+ - instcpan $STATICPERL_MODULES - [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES + touch "$PERL_PREFIX/staticstamp.install" + fi - postinstall || fatal "postinstall hook failed" + if ! [ -e "$PERL_PREFIX/staticstamp.postinstall"; then + NOCHECK_INSTALL=+ + instcpan $STATICPERL_MODULES + [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES - touch "$PREFIX/staticstamp.install" + postinstall || fatal "postinstall hook failed" + + touch "$PERL_PREFIX/staticstamp.postinstall" + fi } ############################################################################# @@ -313,7 +319,7 @@ EOF for mod in "$@"; do - "$PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ + "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ || fatal "$mod: unable to install from CPAN" done rm -rf "$STATICPERL/build" @@ -337,9 +343,9 @@ rcd $mod make -f Makefile.aperl map_clean >/dev/null 2>&1 make distclean >/dev/null 2>&1 - "$PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" + "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" make || fatal "$mod: error building module" - "$PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" + "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" make distclean >/dev/null 2>&1 exit 0 ) || exit $? @@ -351,8 +357,8 @@ podusage() { echo - if [ -e "$PREFIX/bin/perl" ]; then - "$PREFIX/bin/perl" -MPod::Usage -e \ + if [ -e "$PERL_PREFIX/bin/perl" ]; then + "$PERL_PREFIX/bin/perl" -MPod::Usage -e \ 'pod2usage -input => *STDIN, -output => *STDOUT, -verbose => '$1', -exitval => 0, -noperldoc => 1' <"$0" \ 2>/dev/null && exit fi @@ -371,7 +377,7 @@ catmkbundle() { { read dummy - echo "#!$PREFIX/bin/perl" + echo "#!$PERL_PREFIX/bin/perl" cat } <<'MKBUNDLE' #CAT mkbundle @@ -381,13 +387,13 @@ bundle() { catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" - "$PREFIX/bin/perl" -- "$MKBUNDLE" "$@" + "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@" } if [ $# -gt 0 ]; then while [ $# -gt 0 ]; do mkdir -p "$STATICPERL" || fatal "$STATICPERL: cannot create" - mkdir -p "$PREFIX" || fatal "$PREFIX: cannot create" + mkdir -p "$PERL_PREFIX" || fatal "$PERL_PREFIX: cannot create" command="${1#--}"; shift case "$command" in @@ -395,28 +401,28 @@ verblock <