Skip to content
This repository was archived by the owner on Sep 1, 2019. It is now read-only.
Open
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
53 changes: 26 additions & 27 deletions rakudup
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#!/usr/bin/env bash
# https://github.com/stmuk/rakudup

RAKUDO_ROOT="${HOME}/.rakudup"
RAKUDO_ROOT=$HOME/.rakudup

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why did you remove "" here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No need really, just for consistency with the other line below.


set -e

if [ ! -z "$DEBUG" ]
then
set -x
if [[ $DEBUG ]]; then
set -x

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This breaks DEBUG=0

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

You sure it does?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Yes! I think it would have to be [ $DEBUG ] since [[ 0 ]] is [ "0" ] which is true.

I now remember why I use Perl! grrrr

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

DEBUG=0
if [[ $DEBUG ]]; then echo foo; fi       # foo
if [ ! -z "$DEBUG" ]; then echo bar; fi  # bar

Looks identical to me

fi

if [ ! -d ${RAKUDO_ROOT} ]; then
mkdir ${RAKUDO_ROOT}
if [[ ! -d $RAKUDO_ROOT ]]; then
mkdir -- "$RAKUDO_ROOT"
fi

if [[ ! $(git --version) =~ ^git ]]; then
Expand All @@ -24,51 +23,51 @@ if [[ ! $(perl -v) =~ "Perl 5" ]]; then
exit 1
fi

TMP=${RAKUDO_ROOT}/tmp
TMP=$RAKUDO_ROOT/tmp

RELEASE=$(git clone -q --no-checkout --depth 1 git@github.com:rakudo/rakudo.git ${TMP} > /dev/null 2>&1 && cd $dir && git -C ${TMP} show master:VERSION && rm -rf ${TMP})
RELEASE=$(git clone -q --no-checkout --depth 1 git@github.com:rakudo/rakudo.git -- "$TMP" > /dev/null 2>&1 && cd -- "$dir" && git -C "$TMP" show master:VERSION && rm -rf -- "$TMP")

RAKUDO_SRC="${RAKUDO_ROOT}/${RELEASE}/src"
RAKUDO_INSTALL="${RAKUDO_ROOT}/${RELEASE}/install"
RAKUDO_SRC="$RAKUDO_ROOT/$RELEASE/src"
RAKUDO_INSTALL="$RAKUDO_ROOT/$RELEASE/install"

if [[ -d ${RAKUDO_INSTALL} ]]; then
if [[ -d $RAKUDO_INSTALL ]]; then
echo "${RELEASE} already installed not updating"
exit 1
fi

echo "Getting Rakudo ${RELEASE}"
echo "Getting Rakudo $RELEASE"

git clone -q -c advice.detachedHead=false --depth=1 -b ${RELEASE} https://github.com/rakudo/rakudo.git ${RAKUDO_SRC}

cd ${RAKUDO_SRC}
echo "Building Rakudo ${RELEASE}. This will take several minutes on a modern CPU."
echo "'tail -f ${RAKUDO_SRC}/build.log' for progress"
cd -- "$RAKUDO_SRC" || exit 1

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'll add the exit but don't care about the case where directory starts with dash! (Although it is interesting!)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

What? But that's the whole point…

echo "Building Rakudo $RELEASE. This will take several minutes on a modern CPU."
echo "'tail -f -- \"$RAKUDO_SRC/build.log\"' for progress"

CFLAGS="-pipe" perl Configure.pl --gen-moar --prefix=${RAKUDO_INSTALL} --make-install > ${RAKUDO_SRC}/build.log 2>&1
CFLAGS="-pipe" perl Configure.pl --gen-moar "--prefix=$RAKUDO_INSTALL" --make-install > "$RAKUDO_SRC/build.log" 2>&1

if [[ $? == 1 ]]; then
exit $?
fi

echo "Built Rakudo ${RELEASE} OK in ${SECONDS} sec(s)"
echo "Built Rakudo $RELEASE OK in $SECONDS sec(s)"

ln -sf ${RAKUDO_INSTALL} "${RAKUDO_ROOT}/install"
ln -sf -- "$RAKUDO_INSTALL" "$RAKUDO_ROOT/install"

echo "Installing zef (module installer)"
git clone -q --depth=1 https://github.com/ugexe/zef.git ${RAKUDO_SRC}/zef
cd ${RAKUDO_SRC}/zef && ${RAKUDO_INSTALL}/bin/perl6 -Ilib bin/zef install .
git clone -q --depth=1 https://github.com/ugexe/zef.git -- "$RAKUDO_SRC/zef"
cd -- "$RAKUDO_SRC/zef" && "$RAKUDO_INSTALL/bin/perl6" -Ilib bin/zef install .

if [[ ! -d "${RAKUDO_ROOT}/site" ]]; then
mkdir "${RAKUDO_ROOT}/site"
if [[ ! -d "$RAKUDO_ROOT/site" ]]; then
mkdir -- "$RAKUDO_ROOT/site"
fi

ln -sf "${RAKUDO_INSTALL}/share/perl6/site/bin" "${RAKUDO_ROOT}/site/bin"
ln -sf -- "$RAKUDO_INSTALL/share/perl6/site/bin" "$RAKUDO_ROOT/site/bin"

ADDPATH="export PATH=${RAKUDO_ROOT}/install/bin:${RAKUDO_ROOT}/site/bin:\$PATH"
ADDPATH="export PATH=$RAKUDO_ROOT/install/bin:$RAKUDO_ROOT/site/bin:\$PATH"

if [[ -z $(grep .rakudup "${HOME}/.profile") ]]; then
echo ${ADDPATH} >> $HOME/.profile
echo "'${ADDPATH}' added to end of .profile for next login"
if ! grep .rakudup -- "$HOME/.profile"; then
printf "%s\n" "$ADDPATH" >> "$HOME/.profile"
echo "'$ADDPATH' added to end of .profile for next login"
echo "or use this command to take effect now"
fi

Expand Down