App-Staticperl

 view release on metacpan or  search on metacpan

staticperl.sh  view on Meta::CPAN

      postinstall || fatal "postinstall hook failed"

      : > "$PERL_PREFIX/staticstamp.postinstall"
   fi
}

install() {
(
   if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
      build

      verblock <<EOF
installing $STATICPERL/src/perl
to $PERL_PREFIX
EOF

      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

      rcd "$STATICPERL/src/perl"

      "$MAKE" install || fatal "make install: error while installing"

      rcd "$PERL_PREFIX"

      # create a "make install" replacement for CPAN
      write_shellscript SP-make-make <<'end_of_make'
#CAT make-make.sh
end_of_make

      # create a "make install" replacement for CPAN
      write_shellscript SP-make-install-make <<'end_of_make_install_make'
#CAT make-install-make.sh
end_of_make_install_make

      # create a "patch modules" helper
      write_shellscript SP-patch-postinstall <<'end_of_patch_postinstall'
#CAT patch-postinstall.sh
end_of_patch_postinstall

      # immediately use it
      "$PERL_PREFIX/bin/SP-patch-postinstall"

      # help to trick CPAN into avoiding ~/.cpan completely
      echo 1 >"$PERL_PREFIX/lib/CPAN/MyConfig.pm"

      # 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<cpan_home>, "'"$STATICPERL"'/cpan");
         CPAN::Shell->o (conf => q<init>);
         CPAN::Shell->o (conf => q<cpan_home>, "'"$STATICPERL"'/cpan");
         CPAN::Shell->o (conf => q<build_dir>, "'"$STATICPERL"'/cpan/build");
         CPAN::Shell->o (conf => q<prefs_dir>, "'"$STATICPERL"'/cpan/prefs");
         CPAN::Shell->o (conf => q<histfile> , "'"$STATICPERL"'/cpan/histfile");
         CPAN::Shell->o (conf => q<keep_source_where>, "'"$STATICPERL"'/cpan/sources");
         CPAN::Shell->o (conf => q<makepl_arg>, "MAP_TARGET=perl");
         CPAN::Shell->o (conf => q<make>, "'"$PERL_PREFIX"'/bin/SP-make-make");
         CPAN::Shell->o (conf => q<make_install_make_command>, "'"$PERL_PREFIX"'/bin/SP-make-install-make");
         CPAN::Shell->o (conf => q<prerequisites_policy>, q<follow>);
         CPAN::Shell->o (conf => q<build_requires_install_policy>, q<yes>);
         CPAN::Shell->o (conf => q<recommends_policy>, q<0>);
         CPAN::Shell->o (conf => q<suggests_policy>, q<0>);
         CPAN::Shell->o (conf => q<prefer_installer>, q<EUMM>);
         CPAN::Shell->o (conf => q<commit>);
      ' || fatal "error while initialising CPAN"

      : > "$PERL_PREFIX/staticstamp.install"
   fi

   _postinstall
) || exit
}

import() {
(
   IMPORT="$1"

   rcd "$STATICPERL"

   if ! [ -e "$PERL_PREFIX/staticstamp.install" ]; then
      verblock <<EOF
import perl from $IMPORT to $STATICPERL
EOF

      rm -rf bin cpan lib patched perl src
      mkdir -m 755 perl perl/bin
      ln -s perl/bin/ bin
      ln -s "$IMPORT" perl/bin/

      echo "$IMPORT" > "$PERL_PREFIX/.import"

      : > "$PERL_PREFIX/staticstamp.install"
   fi

   _postinstall
) || exit
}

#############################################################################
# install a module from CPAN

instcpan() {
   [ $NOCHECK_INSTALL ] || install

   verblock <<EOF
installing modules from CPAN
$*
EOF

   MYCONFIG=
   [ -e "$PERL_PREFIX/.import" ] || MYCONFIG=-MCPAN::MyConfig

   "$PERL_PREFIX"/bin/perl $MYCONFIG -MCPAN -e 'notest (install => $_) for @ARGV' -- "$@" | tee "$STATICPERL/instcpan.log"



( run in 0.715 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )