Perlbrew

From HalfgeekKB
Jump to navigation Jump to search

perlbrew is a manager for sudo-free, user-level perl installations.

Installation

cd ~/tmp
wget --no-check-certificate https://raw.github.com/gugod/App-perlbrew/master/perlbrew
perl perlbrew self-install
cat 'source ~/perl5/perlbrew/etc/bashrc' >> ~/.bashrc # restart bash for this to take effect

At this point, you should also install patchperl, but the default command to do this failed for me because of a certificate issue.

This issue can be worked around by patching perlbrew to skip SSL cert checks in wget and curl modes (and not have fetch installed).

perl -i -p -E 's/(--silent --location)/-k $1/g; s/(--quiet -O)/--no-check-certificate $1/g' ~/perl5/perlbrew/bin/perlbrew

Install patchperl and cpanm.

perlbrew install-patchperl
perlbrew install-cpanm

Add a new perl install

Do this in a screen session. It is a long-running process that you won't want interrupted by connectivity problems.

perlbrew install --as $your_install_name stable
  • The --as switch is optional. Omitting it causes the version to be used instead of a name when managing.
  • The stable specifier may be replaced with any version number or blead.
  • Other options are available.

This is a full perl install process and will take a substantial about of time. You will be given a tail -f command to follow the log if desired.

I believe it is supposed to work to install the same version twice as long as the names are different. However, there can be only one build directory per version, so don't try to perform the actual installs simultaneously; wait for one to finish before starting the next.

Fixes for build failures

cwd.t linktest

When building 5.18.2, I got this failure:

#   Failed test at t/cwd.t line 209.
#                   '/home/username/perl5/perlbrew/build/perl-5.18.2/dist/Cwd/t/linktest'
#     doesn't match '(?^i:\/home\/username\/perl5\/perlbrew\/build\/perl\-5\.18\.2\/dist\/Cwd\/t\/_ptrslt_\/_path_\/_to_\/_a_\/_dir_$)'

A corresponding error reported by someone else said that this manual hack on Cwd.pm got the issue out of the way without forcing the install:

# ~/perl5/perlbrew/build/perl-5.18.2/lib/Cwd.pm, line 579:
        unless (opendir(PARENT, $dotdots))
        {
            # probably a permissions issue.  Try the native command.
            require File::Spec;
            $start = readlink($start) if -l $start; # ADD this line to resolve a symlink
            return File::Spec->rel2abs( $start, _backtick_pwd() );
        }

Currently rebuilding to see if it works.

Image::Magick

One process that is claimed to work for installing Image::Magick is given on perltricks.com.

The given process has a new IM library installed under ~/local. I'm likely to modify it to something like ~/opt/ImageMagick-VERSION-NAME. This should be documented here.

Proposed install script (has not been tested yet!):

IM=ImageMagick-6.8.9-0
IM_DOWNLOADS="http://www.imagemagick.org/download"
OPT="$HOME/opt"
FONT_PATH="$HOME/.fonts"
PB_NAME="your perlbrew install name"
PB_DIR="$PERLBREW_ROOT/perls/$PB_NAME"
PB_PERL="$PB_DIR/bin/perl"
PB_CORE="$PB_DIR"/lib/5.*.*/*/CORE
PREFIX="$OPT/$IM-$PB_NAME"

WITHOUT_THREADS=`"$PB_PERL" -MConfig -E '$Config{useithreads} or say "--without-threads"'`

wget "$IM_DOWNLOADS/$IM.tar.xz" &&
tar xJvf "$IM.tar.xz" &&
cd "$IM" &&
LDFLAGS=-L"$PB_CORE" \
	./configure \
		--prefix "$PREFIX" \
		--with-perl="$PB_PERL" \
		--enable-shared \
		$WITHOUT_THREADS \ 
		--with-fontpath="$FONT_PATH" \
		--with-rsvg \
		&&
read -p "Press enter to make and install." &&
make install