Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 69 lines (50 sloc) 1.65 KB
#!/bin/sh
indent() {
sed -u 's/^/ /'
}
BUILD_DIR=$1
CACHE_DIR=$2
# Clear previous cache dir
rm -rf "$CACHE_DIR/perl-deps"
VENDOR_DEPS="$BUILD_DIR/local"
CACHE_DEPS="$CACHE_DIR/local"
PERLOKU_DEPS="$CACHE_DEPS/perloku"
rm -rf "$CACHE_DEPS"
PERL_VERSION="5.14.2"
PERL_PACKAGE="perloku.s3.amazonaws.com/perl-$PERL_VERSION.tgz"
VENDORED_PERL="$BUILD_DIR/vendor/perl"
echo "-----> Vendoring Perl"
mkdir -p $VENDORED_PERL && curl $PERL_PACKAGE -s -o - | tar xzf - -C $VENDORED_PERL
# Set up so we can use Perl right away
export PATH="$VENDORED_PERL/bin:$PATH"
export PERL5LIB="$VENDORED_PERL/lib/$PERL_VERSION:$VENDORED_PERL/lib/site_perl/$PERL_VERSION"
CPANM="perl -S cpanm --notest"
echo "Using Perl $PERL_VERSION" | indent
# Set up local lib while preserving PERL5LIB
local_lib() {
local lib="$PERL5LIB"
eval $(perl -Mlocal::lib=$1)
export PERL5LIB="$PERL5LIB:$lib"
}
local_lib "$PERLOKU_DEPS"
if [ -f $BUILD_DIR/app.psgi ]; then
echo "-----> Installing Starman for PSGI"
$CPANM Starman 2>&1 | indent
fi
if [ -f $BUILD_DIR/carton.lock ]; then
echo "-----> Installing Carton"
$CPANM Carton 2>&1 | indent
echo "-----> Installing dependencies using Carton"
# Wrap cpanm as shell script which invokes the correct perl interpreter
# We need this for carton
mkdir -p /tmp/cpanm-bin
echo "perl -S $(which cpanm) \"\$@\"" > /tmp/cpanm-bin/cpanm
chmod +x /tmp/cpanm-bin/cpanm
export PATH="/tmp/cpanm-bin:$PATH"
perl -S carton install --path "$CACHE_DEPS" 2>&1 | indent
else
echo "-----> Installing dependencies using CPANM"
$CPANM -l "$CACHE_DEPS" --installdeps .
fi
cp -R "$CACHE_DEPS" "$VENDOR_DEPS"
echo "Dependencies installed" | indent
Something went wrong with that request. Please try again.