Created
July 16, 2020 03:17
-
-
Save elmobp/1fea91fd2afd044c59b0e105dbfc1fea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -z "${PERLBREWURL}" ]; then | |
PERLBREWURL=https://gist.githubusercontent.com/elmobp/ab8a797c239c6a2bb5d4a01eb32bbea4/raw/5e44c8ebef848ea05b92cc03b564d91343119473/install.pl | |
fi | |
clean_exit () { | |
[ ! -z "$LOCALINSTALLER" -a -f "$LOCALINSTALLER" ] && rm $LOCALINSTALLER | |
exit $1 | |
} | |
if [ -z "$TMPDIR" -o ! -d "$TMPDIR" ]; then | |
if [ -d "/tmp" ]; then | |
TMPDIR="/tmp" | |
else | |
TMPDIR="." | |
fi | |
fi | |
# TMPDIR could have been exported as variable | |
# so it is required to change to such directory always | |
cd $TMPDIR || clean_exit 1 | |
LOCALINSTALLER=$(mktemp perlbrew.XXXXXX) | |
echo | |
if type curl >/dev/null 2>&1; then | |
PERLBREWDOWNLOAD="curl -f -sS -Lo $LOCALINSTALLER $PERLBREWURL" | |
elif type fetch >/dev/null 2>&1; then | |
PERLBREWDOWNLOAD="fetch -o $LOCALINSTALLER $PERLBREWURL" | |
elif type wget >/dev/null 2>&1; then | |
PERLBREWDOWNLOAD="wget -nv -O $LOCALINSTALLER $PERLBREWURL" | |
else | |
echo "Need either wget, fetch or curl to use $0" | |
clean_exit | |
fi | |
echo "## Download the latest perlbrew" | |
$PERLBREWDOWNLOAD || clean_exit 1 | |
echo | |
echo "## Installing perlbrew" | |
# loop thru available well known Perl installations | |
for PERL in "/usr/bin/perl" "/usr/local/bin/perl" | |
do | |
[ -x "$PERL" ] && echo "Using Perl <$PERL>" && break | |
done | |
if [ ! -x "$PERL" ]; then | |
echo "Need /usr/bin/perl or /usr/local/bin/perl to use $0" | |
clean_exit 2 | |
fi | |
[ ! -x "$LOCALINSTALLER" ] && chmod +x "$LOCALINSTALLER" | |
$PERL "$LOCALINSTALLER" self-install || clean_exit 3 | |
echo "## Installing patchperl" | |
$PERL "$LOCALINSTALLER" -f -q install-patchperl || clean_exit 4 | |
echo | |
echo "## Done." | |
rm "./$LOCALINSTALLER" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment