--- App-Staticperl/staticperl.sh 2010/12/28 18:03:47 1.25 +++ App-Staticperl/staticperl.sh 2011/07/09 18:26:27 1.48 @@ -1,18 +1,19 @@ #!/bin/sh ############################################################################# -# configuration to fill in +# configuration to fill in (or to replace in your .staticperlrc) STATICPERL=~/.staticperl CPAN=http://mirror.netcologne.de/cpan # which mirror to use EMAIL="read the documentation " +DLCACHE= # perl build variables MAKE=make -PERL_VERSION=5.12.2 # 5.8.9 is also a good choice +PERL_VERSION=5.12.3 # 5.8.9 is also a good choice PERL_CC=cc PERL_CONFIGURE="" # additional Configure arguments -PERL_CCFLAGS="-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=65536 -D_GNU_SOURCE -DNDEBUG" +PERL_CCFLAGS="-g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG" PERL_OPTIMIZE="-Os -ffunction-sections -fdata-sections -finline-limit=8 -ffast-math" ARCH="$(uname -m)" @@ -31,14 +32,16 @@ # -Wl,--gc-sections makes it impossible to check for undefined references # for some reason so we need to patch away the "-no" after Configure and before make :/ # --allow-multiple-definition exists to work around uclibc's pthread static linking bug -PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" +#PERL_LDFLAGS="-Wl,--no-gc-sections -Wl,--allow-multiple-definition" +PERL_LDFLAGS= PERL_LIBS="-lm -lcrypt" # perl loves to add lotsa crap itself # some configuration options for modules PERL_MM_USE_DEFAULT=1 +PERL_MM_OPT="MAN1PODS= MAN3PODS=" #CORO_INTERFACE=p # needed without nptl on x86, due to bugs in linuxthreads - very slow -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' -export PERL_MM_USE_DEFAULT CORO_INTERFACE EV_EXTRA_DEFS +#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' +export PERL_MM_USE_DEFAULT PERL_MM_OPT # which extra modules to install by default from CPAN that are # required by mkbundle @@ -49,6 +52,7 @@ # overridable functions preconfigure() { : ; } +patchconfig() { : ; } postconfigure() { : ; } postbuild() { : ; } postinstall() { : ; } @@ -65,15 +69,19 @@ ############################################################################# # support -MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}" PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed -unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG +unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG +unset PERL_MB_OPT LC_ALL=C; export LC_ALL # just to be on the safe side +# prepend PATH - not required by staticperl itself, but might make +# life easier when working in e.g. "staticperl cpan / look" +PATH="$PERL_PREFIX/perl/bin:$PATH" + # set version in a way that Makefile.PL can extract VERSION=VERSION; eval \ -$VERSION=0.92 +$VERSION="1.31" BZ2=bz2 BZIP2=bzip2 @@ -126,7 +134,7 @@ # download/configure/compile/install perl clean() { - rm -rf "$STATICPERL/src/perl-$PERL_VERSION" + rm -rf "$STATICPERL/src" } realclean() { @@ -142,23 +150,36 @@ rcd src if ! [ -d "perl-$PERL_VERSION" ]; then - if ! [ -e "perl-$PERL_VERSION.tar.$BZ2" ]; then + PERLTAR=perl-$PERL_VERSION.tar.$BZ2 - URL="$CPAN/src/5.0/perl-$PERL_VERSION.tar.$BZ2" + if ! [ -e $PERLTAR ]; then + URL="$CPAN/src/5.0/$PERLTAR" verblock <perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ - || wget -O perl-$PERL_VERSION.tar.$BZ2~ "$URL" \ + rm -f $PERLTAR~ # just to be on the safe side + { [ "$DLCACHE" ] && cp "$DLCACHE"/$PERLTAR $PERLTAR~ >/dev/null 2>&1; } \ + || wget -O $PERLTAR~ "$URL" \ + || curl -f >$PERLTAR~ "$URL" \ || fatal "$URL: unable to download" - rm -f perl-$PERL_VERSION.tar.$BZ2 - mv perl-$PERL_VERSION.tar.$BZ2~ perl-$PERL_VERSION.tar.$BZ2 + rm -f $PERLTAR + mv $PERLTAR~ $PERLTAR + if [ "$DLCACHE" ]; then + mkdir -p "$DLCACHE" + cp $PERLTAR "$DLCACHE"/$PERLTAR~ && \ + mv "$DLCACHE"/$PERLTAR~ "$DLCACHE"/$PERLTAR + fi fi verblock < staticstamp.configure +} + +write_shellscript() { + { + echo "#!/bin/sh" + echo "STATICPERL=\"$STATICPERL\"" + echo "PERL_PREFIX=\"$PERL_PREFIX\"" + echo "MAKE=\"$MAKE\"" + cat + } >"$PERL_PREFIX/bin/$1" + chmod 755 "$PERL_PREFIX/bin/$1" } build() { @@ -293,6 +332,18 @@ postbuild || fatal "postbuild hook failed" } +_postinstall() { + if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then + NOCHECK_INSTALL=+ + instcpan $STATICPERL_MODULES + [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES + + postinstall || fatal "postinstall hook failed" + + : > "$PERL_PREFIX/staticstamp.postinstall" + fi +} + install() { if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then build @@ -305,6 +356,8 @@ ln -sf "perl/bin/" "$STATICPERL/bin" ln -sf "perl/lib/" "$STATICPERL/lib" + mkdir "$STATICPERL/patched" + ln -sf "$PERL_PREFIX" "$STATICPERL/perl" # might get overwritten rm -rf "$PERL_PREFIX" # by this rm -rf @@ -313,30 +366,24 @@ rcd "$PERL_PREFIX" # create a "make install" replacement for CPAN - cat >"$PERL_PREFIX"/bin/cpan-make-install <"$PERL_PREFIX/lib/CPAN/MyConfig.pm" - "$PERL_PREFIX"/bin/perl -MCPAN -e ' + # we call cpan with -MCPAN::MyConfig in this script, which + # is strictly unnecssary as we have to patch CPAN anyway, + # so consider it "for good measure". + "$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e ' CPAN::Shell->o (conf => urllist => push => "'"$CPAN"'"); CPAN::Shell->o (conf => q, "'"$STATICPERL"'/cpan"); CPAN::Shell->o (conf => q); @@ -345,24 +392,38 @@ 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, "'"$PERL_PREFIX"'/bin/SP-make-install-make"); CPAN::Shell->o (conf => q, q); CPAN::Shell->o (conf => q, q); + CPAN::Shell->o (conf => q, "EUMM"); CPAN::Shell->o (conf => q); ' || fatal "error while initialising CPAN" - touch "$PERL_PREFIX/staticstamp.install" + : > "$PERL_PREFIX/staticstamp.install" fi - if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then - NOCHECK_INSTALL=+ - instcpan $STATICPERL_MODULES - [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES + _postinstall +} - postinstall || fatal "postinstall hook failed" +import() { + IMPORT="$1" + + rcd "$STATICPERL" - touch "$PERL_PREFIX/staticstamp.postinstall" + if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then + verblock < "$PERL_PREFIX/staticstamp.install" fi + + _postinstall } ############################################################################# @@ -376,11 +437,13 @@ $@ EOF - for mod in "$@"; do - "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install => "'"$mod"'"' \ - || fatal "$mod: unable to install from CPAN" - done - rm -rf "$STATICPERL/build" + #"$PERL_PREFIX"/bin/perl -MCPAN::MyConfig -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" + "$PERL_PREFIX"/bin/perl -MCPAN -e 'notest install $_ for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log" + + if grep -q " -- NOT OK\$" "$STATICPERL/instcpan.log"; then + fatal "failure while installing modules from CPAN ($@)" + fi + rm -f "$STATICPERL/instcpan.log" } ############################################################################# @@ -403,7 +466,7 @@ "$MAKE" distclean >/dev/null 2>&1 "$PERL_PREFIX"/bin/perl Makefile.PL || fatal "$mod: error running Makefile.PL" "$MAKE" || fatal "$mod: error building module" - "$PERL_PREFIX"/bin/cpan-make-install || fatal "$mod: error installing module" + "$PERL_PREFIX"/bin/SP-make-install-make install || fatal "$mod: error installing module" "$MAKE" distclean >/dev/null 2>&1 exit 0 ) || exit $? @@ -445,6 +508,7 @@ } bundle() { + MKBUNDLE="${MKBUNDLE:=$PERL_PREFIX/bin/SP-mkbundle}" catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" CACHE="$STATICPERL/cache" @@ -462,9 +526,13 @@ version ) echo "staticperl version $VERSION" ;; - fetch | configure | build | install | clean | realclean | distclean) + fetch | configure | build | install | clean | realclean | distclean ) ( "$command" ) || exit ;; + import ) + ( import "$1" ) || exit + shift + ;; instsrc ) ( instsrc "$@" ) || exit exit @@ -473,9 +541,16 @@ ( instcpan "$@" ) || exit exit ;; + perl ) + ( install ) || exit + exec "$PERL_PREFIX/bin/perl" "$@" + exit + ;; cpan ) ( install ) || exit - "$PERL_PREFIX/bin/cpan" "$@" + PERL="$PERL_PREFIX/bin/perl" + export PERL + exec "$PERL_PREFIX/bin/cpan" "$@" exit ;; mkbundle )