Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,18 @@ There are various environment variables that will control how a build is done.
generation process if it has heavy dependencies, such as Dist::Zilla, and
testing is being done on a freshly built perl.

Makes a local::lib that symlinks to `${LOCAL_LIB_CACHE}-split`. If you
give that as a cached directory, it will make your builds go faster.

Defaults to true.

* `LOCAL_LIB_CACHE`

The directory used to cache the local::lib used if you specify
`local-lib cache`.

Defaults to `$HOME/.perlbrew-cache`.

* `CPAN_MIRROR`

The CPAN mirror that dependencies will be installed from.
Expand Down Expand Up @@ -278,6 +288,51 @@ Commands
or built if not, and added to the library path. This is taken care
of by the `build-perl` step.

There is a special local::lib name you can give:
`cache`, which works together with [Travis's caching
feature](https://docs.travis-ci.com/user/caching). Its location
defaults to `$HOME/.perlbrew-cache` but can be overridden
by supplying the environment variable `LOCAL_LIB_CACHE`. Use it
like this:

cache:
directories:
- $HOME/.perlbrew-cache # keeps between builds here
- $HOME/.perlbrew-cache-split # used by split builds
perl:
- "5.8.4@moo"
before_install:
- git clone git://github.com/travis-perl/helpers ~/travis-perl-helpers
- source ~/travis-perl-helpers/init
- build-perl
- local-lib cache # makes a local::lib symlinked to cache
- perl -V
- build-dist
- cd $BUILD_DIR
install:
- cpan-install --deps # installs prereqs, including recommends

Alternatively, this will also work and the `build-perl` will do the
`local-lib` step for you:

cache:
directories:
- $HOME/.perlbrew-cache # keeps between builds here
perl:
- "5.8.4@cache"
before_install:
- git clone git://github.com/travis-perl/helpers ~/travis-perl-helpers
- source ~/travis-perl-helpers/init
- build-perl
# no need for local-lib cache
- perl -V
- build-dist
- cd $BUILD_DIR
install:
- cpan-install --deps # installs prereqs, including recommends
before_cache:
- local-lib-cachestore # saves for local::lib next time

local::lib
----------
A number of [predefined local::lib](share/local-libs.txt) directories are
Expand Down
17 changes: 12 additions & 5 deletions bin/local-lib
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ source "$HELPERS_ROOT/lib/debug.sh"

declare -a ll_roots
if [ -z "$1" ]; then
ll_roots=("$(mktemp -d -t local-lib-XXXXXX)")
ll_roots=("${LOCAL_LIB_CACHE}-split") # can cache
[ -n "$TRAVIS_PERL_DEBUG" ] && \
(echo "ON SPLITDIR"; find "${LOCAL_LIB_CACHE}-split" -ls) 1>&2
else
for lib; do
if [ -z "$LL_NO_INSTALL" ]; then
# redirect since output of this gets eval-ed
if $HELPERS_ROOT/bin/local-lib-installer "$lib" 1>&2; then
ll_roots+=("$PERLBREW_HOME/libs/$PERLBREW_PERL@$lib")
if [ "$lib" == "cache" ]; then
$HELPERS_ROOT/bin/local-lib-cache use
else
if [ -z "$LL_NO_INSTALL" ]; then
# redirect since output of this gets eval-ed
if $HELPERS_ROOT/bin/local-lib-installer "$lib" 1>&2; then
ll_roots+=("$PERLBREW_HOME/libs/$PERLBREW_PERL@$lib")
fi
fi
fi
ll_roots+=("$PERLBREW_HOME/libs/$PERLBREW_PERL@$lib")
done
fi

Expand Down
37 changes: 37 additions & 0 deletions bin/local-lib-cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# usage:
# $0 use
# copies from cache location to perlbrew location
# $0 store
# copies from perlbrew location to cache location

# locations:
cache_location="$LOCAL_LIB_CACHE"
full_version="$PERLBREW_PERL@cache"
perlbrew_location="$PERLBREW_HOME/libs/$full_version"

[ -z "$HELPERS_ROOT" ] && export HELPERS_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
source "$HELPERS_ROOT/lib/debug.sh"
exec 1>&2 # since local-lib calls this, then evals stdout - any echo to stderr

if [ -z "$PERLBREW_ROOT" ]; then
echo "Must be run under perlbrew!"
exit 1
fi

source "$PERLBREW_ROOT/etc/bashrc"

set -e

if [ "$1" == "use" ]; then
perlbrew lib create "$full_version"
perlbrew use "$full_version"
rm -rf "$perlbrew_location"
ln -s "$cache_location" "$perlbrew_location"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the cache location could just be used directly rather than using a symlink.

[ -n "$TRAVIS_PERL_DEBUG" ] && \
(id; echo "ON USE"; find "$perlbrew_location" "$cache_location" -ls)
else
echo "Unknown arg '$1'"
exit 1
fi
1 change: 1 addition & 0 deletions init
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export SYSTEM_CORES="$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n
[ -z "$AUTHOR_TESTING" ] && export AUTHOR_TESTING=1
[ -z "$SPLIT_BUILD" ] && export SPLIT_BUILD=1
[ "$COVERAGE" == "1" ] && export COVERAGE=coveralls # drop this eventually
[ -z "$LOCAL_LIB_CACHE" ] && export LOCAL_LIB_CACHE="$HOME/.perlbrew-cache"
[ -z "$PERL_AUTOINSTALL_PREFER_CPAN" ] && export PERL_AUTOINSTALL_PREFER_CPAN=1
[ -z "$PERL_MM_USE_DEFAULT" ] && export PERL_MM_USE_DEFAULT=1
[ -z "$NONINTERACTIVE_TESTING" ] && export NONINTERACTIVE_TESTING=1
Expand Down