-
Notifications
You must be signed in to change notification settings - Fork 33
/
perl-install
executable file
·54 lines (45 loc) · 1.63 KB
/
perl-install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
while getopts fh OPT
do
case $OPT in
"f") FLAG_FORCE="TRUE" ;;
"h") FLAG_HELP="TRUE" ;;
* ) FLAG_HELP="TRUE" ;;
esac
done
shift `expr $OPTIND - 1`
TARGET_VERSION="$1"
LOCATION="$2"
CONFIGURE_OPTIONS=${@:4}
if [ "x"$FLAG_HELP != "x" -o "x$LOCATION" = "x" ]; then
echo "[usage] perl-install [-f] VERSION LOCATION [-- CONFIGURE_OPTIONS]"
echo " ex: perl-install 5.18.2 ~/local/perl-5.18"
exit 0
fi
cd $(dirname $0)
set -e
mkdir -p ./bin
curl -s https://raw.githubusercontent.com/tokuhirom/Perl-Build/master/perl-build > ./bin/perl-build
curl -s -L http://cpanmin.us/ > ./bin/fatpack_cpanm
set +e
if [ "x"$FLAG_FORCE = "x" -a -d "$LOCATION" -a -x "$LOCATION/bin/perl" ]; then
check=$("$LOCATION"/bin/perl -v | grep "This is perl" | grep "v$TARGET_VERSION")
if [ "x$check" != "x" ]; then
echo "perl $TARGET_VERSION already installed on $LOCATION"
echo "To do force re-install, use '-f' option"
exit 0
fi
fi
echo "Start to build perl $TARGET_VERSION ..."
perl ./bin/perl-build -DDEBUGGING=-g $CONFIGURE_OPTIONS "$TARGET_VERSION" "$LOCATION" > /tmp/$USER-perl-install.log 2>&1
if [ $? -ne 0 ]; then
echo "perl-build failed. see log: /tmp/$USER-perl-install.log"
exit 1
fi
"$LOCATION"/bin/perl ./bin/fatpack_cpanm --notest App::cpanminus Carton Server::Starter > /tmp/$USER-perl-install-cpanm.log 2>&1
if [ $? -ne 0 ]; then
echo "failed to install cpanm/carton. see log: /tmp/$USER-perl-install-cpanm.log"
exit 2
fi
echo "perl $TARGET_VERSION (and cpanm/carton) successfully installed on $LOCATION"
echo "To use this perl, do 'export PATH=$LOCATION/bin:\$PATH'."