--- App-Staticperl/staticperl.sh 2010/12/07 10:40:39 1.6 +++ App-Staticperl/staticperl.sh 2010/12/10 20:29:17 1.14 @@ -4,13 +4,11 @@ # configuration to fill in STATICPERL=~/.staticperl -CPAN=http://mirror.netcologne.de/cpan/ # which mirror to use +CPAN=http://mirror.netcologne.de/cpan # which mirror to use EMAIL="read the documentation " -MKBUNDLE="$STATICPERL/mkbundle" # perl build variables -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" @@ -48,21 +46,32 @@ EXTRA_MODULES="" # overridable functions +preconfigure() { : ; } postconfigure() { : ; } postbuild() { : ; } postinstall() { : ; } # now source user config, if any -[ -r /etc/staticperlrc ] && . /etc/staticperlrc -[ -r ~/.staticperlrc ] && . ~/.staticperlrc -[ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" +if [ "$STATICPERLRC" ]; then + . "$STATICPERLRC" +else + [ -r /etc/staticperlrc ] && . /etc/staticperlrc + [ -r ~/.staticperlrc ] && . ~/.staticperlrc + [ -r "$STATICPERL/rc" ] && . "$STATICPERL/rc" +fi ############################################################################# # support +MKBUNDLE="${MKBUNDLE:=$STATICPERL/mkbundle}" +PERL_PREFIX="${PERL_PREFIX:=$STATICPERL/perl}" # where the perl gets installed + +unset PERL5OPT PERL5LIB PERLLIB PERL_UNICODE PERLIO_DEBUG +export LC_ALL=C # just to be on the safe side + # set version in a way that Makefile.PL can extract VERSION=VERSION; eval \ -$VERSION=0.1 +$VERSION=0.9 BZ2=bz2 BZIP2=bzip2 @@ -105,7 +114,7 @@ distclean() { verblock </dev/null || return - - rm -f staticstamp.configure - make distclean >/dev/null 2>&1 + rm -rf "$STATICPERL/src/perl-$PERL_VERSION" } fetch() { @@ -151,8 +157,9 @@ EOF mkdir -p unpack - $BZIP2 -d /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 \ @@ -247,59 +256,73 @@ } install() { - [ -e "$PERL_PREFIX/staticstamp.install" ] && return + if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then + build - build - - verblock <"$PERL_PREFIX"/bin/cpan-make-install <"$PERL_PREFIX"/bin/cpan-make-install <"$PERL_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" - # trick CPAN into avoiding ~/.cpan completely - echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm" + touch "$PERL_PREFIX/staticstamp.install" + fi - "$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" - - NOCHECK_INSTALL=+ - instcpan $STATICPERL_MODULES - [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES + if ! [ -e "$PERL_PREFIX/staticstamp.postinstall" ]; then + NOCHECK_INSTALL=+ + instcpan $STATICPERL_MODULES + [ $EXTRA_MODULES ] && instcpan $EXTRA_MODULES - postinstall || fatal "postinstall hook failed" + postinstall || fatal "postinstall hook failed" - touch "$PERL_PREFIX/staticstamp.install" + touch "$PERL_PREFIX/staticstamp.postinstall" + fi } ############################################################################# @@ -382,7 +405,9 @@ bundle() { catmkbundle >"$MKBUNDLE~" || fatal "$MKBUNDLE~: cannot create" chmod 755 "$MKBUNDLE~" && mv "$MKBUNDLE~" "$MKBUNDLE" - "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" "$@" + CACHE="$STATICPERL/cache" + mkdir -p "$CACHE" + "$PERL_PREFIX/bin/perl" -- "$MKBUNDLE" --cache "$CACHE" "$@" } if [ $# -gt 0 ]; then @@ -392,10 +417,10 @@ command="${1#--}"; shift case "$command" in + version ) + echo "staticperl version $VERSION" + ;; fetch | configure | build | install | clean | distclean) - verblock <