From b52fac4d32d2de079432efbc125c928678dd1bab Mon Sep 17 00:00:00 2001 From: David Zuelke Date: Wed, 13 Feb 2019 18:50:18 +0100 Subject: [PATCH] reuse logic in runtimes/pypy3 formulae --- builds/runtimes/pypy3 | 22 ++++++++++++++++++++++ builds/runtimes/pypy3-2.4.0 | 11 +---------- builds/runtimes/pypy3-5.5.0 | 14 ++++---------- builds/runtimes/pypy3-5.7.1 | 9 +-------- builds/runtimes/pypy3-5.8.0 | 9 +-------- 5 files changed, 29 insertions(+), 36 deletions(-) create mode 100755 builds/runtimes/pypy3 diff --git a/builds/runtimes/pypy3 b/builds/runtimes/pypy3 new file mode 100755 index 0000000..6d11006 --- /dev/null +++ b/builds/runtimes/pypy3 @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# fail hard +set -o pipefail +# fail harder +set -eu + +OUT_PREFIX=$1 + +dep_formula=${0#$WORKSPACE_DIR/} # this is the original script, e.g. pypy-5.3.1 +dep_name=$(basename $BASH_SOURCE) # this is us +dep_version=${dep_formula##*"/${dep_name}-"} # "subtract" our name from full version name +dep_package=${dep_name}${dep_version_prefix:-}-v${dep_version}${dep_version_suffix:-} +dep_dirname=${dep_package}-linux64 +dep_archive_name=${dep_dirname}.tar.bz2 +dep_url=https://bitbucket.org/pypy/pypy/downloads/${dep_archive_name} + +echo "Building PyPy3…" + +curl -L "${dep_url}" | tar jx -C "${OUT_PREFIX}" --strip-components 1 # extract to $OUT_PREFIX, drop the first directory level, which is the archive name + +ln "$OUT_PREFIX/bin/pypy3" "$OUT_PREFIX/bin/python" diff --git a/builds/runtimes/pypy3-2.4.0 b/builds/runtimes/pypy3-2.4.0 index 61b1638..7deb446 100755 --- a/builds/runtimes/pypy3-2.4.0 +++ b/builds/runtimes/pypy3-2.4.0 @@ -2,13 +2,4 @@ # Build Path: /app/.heroku/python/ # Build Deps: libraries/sqlite -# NOTICE: This formula only works for the cedar-14 stack, not cedar. - -OUT_PREFIX=$1 - -echo "Building PyPy…" -SOURCE_TARBALL='https://bitbucket.org/pypy/pypy/downloads/pypy3-2.4.0-linux64.tar.bz2' -curl -L $SOURCE_TARBALL | tar jx -cp -R pypy3-2.4.0-linux64/* $OUT_PREFIX - -ln $OUT_PREFIX/bin/pypy3 $OUT_PREFIX/bin/python +source $(dirname $0)/pypy3 diff --git a/builds/runtimes/pypy3-5.5.0 b/builds/runtimes/pypy3-5.5.0 index fde9ffe..f934d00 100755 --- a/builds/runtimes/pypy3-5.5.0 +++ b/builds/runtimes/pypy3-5.5.0 @@ -2,13 +2,7 @@ # Build Path: /app/.heroku/python/ # Build Deps: libraries/sqlite -# NOTICE: This formula only works for the cedar-14 stack, not cedar. - -OUT_PREFIX=$1 - -echo "Building PyPy…" -SOURCE_TARBALL='https://bitbucket.org/pypy/pypy/downloads/pypy3.3-v5.5.0-alpha-linux64.tar.bz2' -curl -L $SOURCE_TARBALL | tar jx -cp -R pypy3-v5.5.0-linux64/* $OUT_PREFIX - -ln $OUT_PREFIX/bin/pypy3 $OUT_PREFIX/bin/python +# version pypy3-5.5.0 is really called pypy3.3-v5.5.0-alpha +dep_version_prefix=".3" +dep_version_suffix="-alpha" +source $(dirname $0)/pypy3 diff --git a/builds/runtimes/pypy3-5.7.1 b/builds/runtimes/pypy3-5.7.1 index fb0e718..7deb446 100755 --- a/builds/runtimes/pypy3-5.7.1 +++ b/builds/runtimes/pypy3-5.7.1 @@ -2,11 +2,4 @@ # Build Path: /app/.heroku/python/ # Build Deps: libraries/sqlite -OUT_PREFIX=$1 - -echo "Building PyPy…" -SOURCE_TARBALL='https://bitbucket.org/pypy/pypy/downloads/pypy3-v5.7.1-linux64.tar.bz2' -curl -L $SOURCE_TARBALL | tar jx -cp -R pypy3-v5.7.1-linux64/* $OUT_PREFIX - -ln $OUT_PREFIX/bin/pypy3 $OUT_PREFIX/bin/python +source $(dirname $0)/pypy3 diff --git a/builds/runtimes/pypy3-5.8.0 b/builds/runtimes/pypy3-5.8.0 index df08b9f..7deb446 100755 --- a/builds/runtimes/pypy3-5.8.0 +++ b/builds/runtimes/pypy3-5.8.0 @@ -2,11 +2,4 @@ # Build Path: /app/.heroku/python/ # Build Deps: libraries/sqlite -OUT_PREFIX=$1 - -echo "Building PyPy…" -SOURCE_TARBALL='https://bitbucket.org/pypy/pypy/downloads/pypy3-v5.8.0-linux64.tar.bz2' -curl -L $SOURCE_TARBALL | tar jx -cp -R pypy3-v5.8.0-linux64/* $OUT_PREFIX - -ln $OUT_PREFIX/bin/pypy3 $OUT_PREFIX/bin/python +source $(dirname $0)/pypy3