#!/bin/sh
#
# Copyright (c) 2018  S2 Factory, Inc.  All rights reserved.
#
# Usage:
#     curl -sSL https://s2pan.s2factory.co.jp/sh | sh -x

PWD=`pwd`
set -e

#[ ! -r /etc/os-release ] || type perl | grep -vq /usr/bin/perl || echo "Unexpected PATH for perl?"
if ! perl -MExtUtils::Manifest -e1 2>/dev/null; then
	echo "Require perl-ExtUtils-Manifest perl-Module-CoreList perl-ExtUtils-MakeMaker gcc packages"
	exit 1
fi

if [ ! -r local/bin/cpanm ]; then
	[ -d local/bin ] || mkdir -p local/bin
	curl -sSL http://github.com/miyagawa/cpanminus/raw/master/cpanm -o local/bin/cpanm
	chmod ug+rx local/bin/cpanm
fi

if [ ! -r local/bin/carton ]; then
	local/bin/cpanm --notest --quiet -L local -v Carton
fi

S2PAN=https://s2pan.s2factory.co.jp/
PERL5LIB=${PWD}/local/lib/perl5

echo env PERL_CARTON_MIRROR=${S2PAN} PERL5LIB=${PERL5LIB} local/bin/carton

# Local Variables:
# sh-basic-offset: 8
# sh-indentation: 8
# End:
