From e28c1012b7199566511849bd21deb66cd532ea3f Mon Sep 17 00:00:00 2001 From: David Zuelke Date: Wed, 13 Feb 2019 18:34:58 +0100 Subject: [PATCH] reuse logic in runtimes/pypy formulae --- builds/runtimes/pypy | 22 ++++++++++++++++++++++ builds/runtimes/pypy-5.3.1 | 11 +---------- builds/runtimes/pypy-5.6.0 | 11 +---------- builds/runtimes/pypy-5.7.0 | 11 +---------- builds/runtimes/pypy-5.7.1 | 11 +---------- builds/runtimes/pypy-5.8.0 | 9 +-------- 6 files changed, 27 insertions(+), 48 deletions(-) create mode 100755 builds/runtimes/pypy diff --git a/builds/runtimes/pypy b/builds/runtimes/pypy new file mode 100755 index 0000000..d2142a1 --- /dev/null +++ b/builds/runtimes/pypy @@ -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}2-v${dep_version} # it's always "pypy2-…" +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 PyPy…" + +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/pypy" "$OUT_PREFIX/bin/python" diff --git a/builds/runtimes/pypy-5.3.1 b/builds/runtimes/pypy-5.3.1 index cc1be00..97ff496 100755 --- a/builds/runtimes/pypy-5.3.1 +++ b/builds/runtimes/pypy-5.3.1 @@ -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/pypy2-v5.3.1-linux64.tar.bz2' -curl -L $SOURCE_TARBALL | tar jx -cp -R pypy2-v5.3.1-linux64/* $OUT_PREFIX - -ln $OUT_PREFIX/bin/pypy $OUT_PREFIX/bin/python +source $(dirname $0)/pypy diff --git a/builds/runtimes/pypy-5.6.0 b/builds/runtimes/pypy-5.6.0 index 685fa1d..97ff496 100755 --- a/builds/runtimes/pypy-5.6.0 +++ b/builds/runtimes/pypy-5.6.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/pypy2-v5.6.0-linux64.tar.bz2' -curl -L $SOURCE_TARBALL | tar jx -cp -R pypy2-v5.6.0-linux64/* $OUT_PREFIX - -ln $OUT_PREFIX/bin/pypy $OUT_PREFIX/bin/python +source $(dirname $0)/pypy diff --git a/builds/runtimes/pypy-5.7.0 b/builds/runtimes/pypy-5.7.0 index c16d5e3..97ff496 100755 --- a/builds/runtimes/pypy-5.7.0 +++ b/builds/runtimes/pypy-5.7.0 @@ -2,13 +2,4 @@ # Build Path: /app/.heroku/python/ # Build Deps: libraries/sqlite -# NOTICE: This formula only works for the cedar-14 and heroku-16 stacks, not cedar. - -OUT_PREFIX=$1 - -echo "Building PyPy…" -SOURCE_TARBALL='https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.7.0-linux64.tar.bz2' -curl -L $SOURCE_TARBALL | tar jx -cp -R pypy2-v5.7.0-linux64/* $OUT_PREFIX - -ln $OUT_PREFIX/bin/pypy $OUT_PREFIX/bin/python +source $(dirname $0)/pypy diff --git a/builds/runtimes/pypy-5.7.1 b/builds/runtimes/pypy-5.7.1 index 86e34c6..97ff496 100755 --- a/builds/runtimes/pypy-5.7.1 +++ b/builds/runtimes/pypy-5.7.1 @@ -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/pypy2-v5.7.1-linux64.tar.bz2' -curl -L $SOURCE_TARBALL | tar jx -cp -R pypy2-v5.7.1-linux64/* $OUT_PREFIX - -ln $OUT_PREFIX/bin/pypy $OUT_PREFIX/bin/python +source $(dirname $0)/pypy diff --git a/builds/runtimes/pypy-5.8.0 b/builds/runtimes/pypy-5.8.0 index 6e8b6ac..97ff496 100755 --- a/builds/runtimes/pypy-5.8.0 +++ b/builds/runtimes/pypy-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/pypy2-v5.8.0-linux64.tar.bz2' -curl -L $SOURCE_TARBALL | tar jx -cp -R pypy2-v5.8.0-linux64/* $OUT_PREFIX - -ln $OUT_PREFIX/bin/pypy $OUT_PREFIX/bin/python +source $(dirname $0)/pypy