diff options
author | Jakub Jirutka <jakub@jirutka.cz> | 2018-03-24 20:25:24 +0100 |
---|---|---|
committer | Jakub Jirutka <jakub@jirutka.cz> | 2018-03-24 20:26:05 +0100 |
commit | c4bd03b0ec240885be16be8074727b533f81b472 (patch) | |
tree | 5d05c889dc420a21817e2e99629e3fa7fa88152a /testing | |
parent | c663247dc8b524fa41053b242fc7c81ec9ba7f1d (diff) | |
download | aports-c4bd03b0ec240885be16be8074727b533f81b472.tar.bz2 aports-c4bd03b0ec240885be16be8074727b533f81b472.tar.xz |
testing/crystal: new aport
https://crystal-lang.org/
The Crystal Programming Language
Diffstat (limited to 'testing')
-rw-r--r-- | testing/crystal/APKBUILD | 127 | ||||
-rw-r--r-- | testing/crystal/fix-makefile-stderr-redirect.patch | 29 | ||||
-rw-r--r-- | testing/crystal/makefile-allow-extra-flags.patch | 23 | ||||
-rw-r--r-- | testing/crystal/makefile-shell.patch | 78 |
4 files changed, 257 insertions, 0 deletions
diff --git a/testing/crystal/APKBUILD b/testing/crystal/APKBUILD new file mode 100644 index 0000000000..0ca756427d --- /dev/null +++ b/testing/crystal/APKBUILD @@ -0,0 +1,127 @@ +# Contributor: Jakub Jirutka <jakub@jirutka.cz> +# Maintainer: Jakub Jirutka <jakub@jirutka.cz> +# TODO: Fix SSL bindings for LibreSSL (it's probably broken). +pkgname=crystal +pkgver=0.24.2 +pkgrel=1 +_bootver=0.24.2 +_llvmver=5 +pkgdesc="The Crystal Programming Language" +url="https://crystal-lang.org/" +arch="x86_64" +license="Apache-2.0" +depends="gc-dev libatomic_ops libevent-dev libressl-dev libxml2-dev + gcc gmp-dev pcre-dev yaml-dev" +checkdepends="readline-dev zlib-dev" +makedepends="llvm$_llvmver-dev ${BUILD_STATIC:+"llvm$_llvmver-static"}" +subpackages="$pkgname-doc + $pkgname-bash-completion:bashcomp:noarch + $pkgname-zsh-completion:zshcomp:noarch + " +source="$pkgname-$pkgver.tar.gz::https://github.com/crystal-lang/$pkgname/archive/$pkgver.tar.gz + https://dev.alpinelinux.org/archive/crystal/crystal-$_bootver-x86_64-alpine-linux-musl.tar.gz + makefile-shell.patch + fix-makefile-stderr-redirect.patch + makefile-allow-extra-flags.patch + " +builddir="$srcdir/$pkgname-$pkgver" +options="!check" # FIXME + +export CRYSTAL_CONFIG_VERSION="$pkgver" +export CRYSTAL_CACHE_DIR="$srcdir/.cache" + +# Build static crystal binary and upload it to dev.a.o, so it can be used +# for building crystal next time (needed for bootstrapping). +# NOTE: After https://github.com/crystal-lang/crystal/issues/5689 is fixed, +# we can also use prebuilt binary from upstream if needed. +snapshot() { + local binary="$builddir/.build/crystal" + local tarname="$pkgname-$pkgver-$CHOST" + + if [ ! -f "$binary" ] || ! file "$binary" | grep -qw 'statically linked'; then + msg "Building statically linked crystal..." + BUILD_STATIC=1 abuild clean deps unpack prepare build + fi + + cd "$srcdir" + + strip "$builddir"/.build/crystal + install -D -m 755 "$builddir"/.build/crystal "$tarname"/bin/crystal + tar -czf "$tarname.tar.gz" "$tarname" + + msg "Uploading $tarname.tar.gz to dev.alpinelinux.org" + scp "$tarname.tar.gz" dev.alpinelinux.org:/archive/$pkgname/ + + APKBUILD="../APKBUILD" abuild undeps +} + +prepare() { + default_prepare + cd "$builddir" + + cat > Makefile.local <<-EOF + progress = 1 + release = 1 + threads = ${JOBS:-2} + verbose = 1 + EXTRA_FLAGS = --target $CTARGET ${BUILD_STATIC:+"--link-flags=-no-pie"} + CFLAGS = $CFLAGS + CXXFLAGS = $CXXFLAGS + LLVM_CONFIG = /usr/lib/llvm$_llvmver/bin/llvm-config + EOF +} + +build() { + cd "$builddir" + + make crystal \ + CRYSTAL_CONFIG_PATH="lib:/usr/lib/crystal" \ + PATH="$srcdir/$pkgname-$_bootver-$CHOST/bin:$PATH" \ + static=${BUILD_STATIC:-} +} + +check() { + cd "$builddir" + + make spec PATH=".build:$PATH" +} + +package() { + cd "$builddir" + + install -D -m 755 .build/crystal "$pkgdir"/usr/bin/crystal + install -D -m 644 man/crystal.1 "$pkgdir"/usr/share/man/man1/crystal.1 + + # XXX: Move to /usr/share...? + mkdir -p "$pkgdir"/usr/lib + cp -r src "$pkgdir"/usr/lib/$pkgname + + cd "$pkgdir"/usr/lib/$pkgname + rm ext/sigfault.* llvm/ext/llvm_ext.o +} + +bashcomp() { + pkgdesc="Bash completions for $pkgname" + depends="" + install_if="$pkgname=$pkgver-r$pkgrel bash-completion" + + cd "$builddir" + install -D -m 644 etc/completion.bash \ + "$subpkgdir"/usr/share/bash-completion/completions/$pkgname +} + +zshcomp() { + pkgdesc="ZSH completions for $pkgname" + depends="" + install_if="$pkgname=$pkgver-r$pkgrel zsh" + + cd "$builddir" + install -D -m 644 etc/completion.zsh \ + "$subpkgdir"/usr/share/zsh/site-functions/_$pkgname +} + +sha512sums="db9fb973eeb2bc72ef91bb894b7c5aea73e727ff46e739aa431d68e556238f346a688a7a43de284afb4667b49366afce3ca423a523bea521180fa8f19ba6862d crystal-0.24.2.tar.gz +6d7ee01ff5bfaaf79fa80c15575ae4496e17629ed18cb0577db6734266c2dbf5b0bf0a554c7c153e1b81f4c71e62bb803fd4b6513e3d039571ee4f953d85ecf4 crystal-0.24.2-x86_64-alpine-linux-musl.tar.gz +2a81b6eaeb934ef5d4435a80a346425a760a602d04bccc89068dde7ed48a6099c4ea59a291f444127e91e81acde0ee42d857481041869cf6094a2e29f0de184a makefile-shell.patch +2f995903093da9af4263bf2d7fde75715a114b02b74ba26c8290d7b20042be8a2db305a2ea144925f054354f6f6a430750d19fa036bf764562dedb56da12866a fix-makefile-stderr-redirect.patch +d1641f538cb1ae9f817b57e19800b0af91e3723c752fba38b2644b8acc66d80862c6bef22194f1f4c64ae7d8393c2772f0a0ea0a76a199151ef8c74c686ea49f makefile-allow-extra-flags.patch" diff --git a/testing/crystal/fix-makefile-stderr-redirect.patch b/testing/crystal/fix-makefile-stderr-redirect.patch new file mode 100644 index 0000000000..5c5ccb925b --- /dev/null +++ b/testing/crystal/fix-makefile-stderr-redirect.patch @@ -0,0 +1,29 @@ +From 2d5bc81866affe7a625da96161644d17c50cf675 Mon Sep 17 00:00:00 2001 +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sat, 24 Mar 2018 18:15:46 +0100 +Subject: [PATCH] Makefile: Fix redirect to stderr to be more portable + +`>/dev/stderr` does not work in some environments. Moreover, all POSIX +compliant shells supports standard `>&2` for redirect stdout to stderr. + +Upstream-Issue: https://github.com/crystal-lang/crystal/pull/5859 +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 2aa2e4f..a034f44 100644 +--- a/Makefile ++++ b/Makefile +@@ -55,7 +55,7 @@ CXXFLAGS += $(if $(debug),-g -O0) + ifeq (${LLVM_CONFIG},) + $(error Could not locate llvm-config, make sure it is installed and in your PATH, or set LLVM_CONFIG) + else +- $(shell echo $(shell printf '\033[33m')Using $(LLVM_CONFIG) [version=$(shell $(LLVM_CONFIG) --version)]$(shell printf '\033[0m') >/dev/stderr) ++ $(shell echo $(shell printf '\033[33m')Using $(LLVM_CONFIG) [version=$(shell $(LLVM_CONFIG) --version)]$(shell printf '\033[0m') >&2) + endif + + .PHONY: all +-- +2.10.1 (Apple Git-78) + diff --git a/testing/crystal/makefile-allow-extra-flags.patch b/testing/crystal/makefile-allow-extra-flags.patch new file mode 100644 index 0000000000..c3a004592e --- /dev/null +++ b/testing/crystal/makefile-allow-extra-flags.patch @@ -0,0 +1,23 @@ +From 746da810fd045ae2ccad8cecfd746375788b6bfb Mon Sep 17 00:00:00 2001 +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sat, 24 Mar 2018 18:20:59 +0100 +Subject: [PATCH] Makefile: Allow to add EXTRA_FLAGS to FLAGS + +Upstream-Issue: https://github.com/crystal-lang/crystal/pull/5860 +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 2aa2e4fbdb..d18cd58e22 100644 +--- a/Makefile ++++ b/Makefile +@@ -27,7 +27,7 @@ + O := .build + SOURCES := $(shell find src -name '*.cr') + SPEC_SOURCES := $(shell find spec -name '*.cr') +-FLAGS := $(if $(release),--release )$(if $(stats),--stats )$(if $(progress),--progress )$(if $(threads),--threads $(threads) )$(if $(debug),-d )$(if $(static),--static ) ++FLAGS := $(if $(release),--release )$(if $(stats),--stats )$(if $(progress),--progress )$(if $(threads),--threads $(threads) )$(if $(debug),-d )$(if $(static),--static ) $(EXTRA_FLAGS) + SPEC_FLAGS := $(if $(verbose),-v )$(if $(junit_output),--junit_output $(junit_output) ) + EXPORTS := $(if $(release),,CRYSTAL_CONFIG_PATH=`pwd`/src) + SHELL = bash diff --git a/testing/crystal/makefile-shell.patch b/testing/crystal/makefile-shell.patch new file mode 100644 index 0000000000..84b2b79848 --- /dev/null +++ b/testing/crystal/makefile-shell.patch @@ -0,0 +1,78 @@ +From 80f94f33956a758444f6c6918036b41288cd4da9 Mon Sep 17 00:00:00 2001 +From: Julien Reichardt <mi@jrei.ch> +Date: Tue, 2 Jan 2018 14:52:14 +0100 +Subject: [PATCH] Change from `bash` to `sh` (#5468) + +* Removes bash as a dependency +* Better compliance to POSIX + +diff --git a/Makefile b/Makefile +index a4b2281dc1..a6b2f5d1d4 100644 +--- a/Makefile ++++ b/Makefile +@@ -29,8 +29,8 @@ SOURCES := $(shell find src -name '*.cr') + SPEC_SOURCES := $(shell find spec -name '*.cr') + FLAGS := $(if $(release),--release )$(if $(stats),--stats )$(if $(progress),--progress )$(if $(threads),--threads $(threads) )$(if $(debug),-d )$(if $(static),--static ) + SPEC_FLAGS := $(if $(verbose),-v )$(if $(junit_output),--junit_output $(junit_output) ) +-EXPORTS := $(if $(release),,CRYSTAL_CONFIG_PATH=`pwd`/src) +-SHELL = bash ++EXPORTS := $(if $(release),,CRYSTAL_CONFIG_PATH=$PWD/src) ++SHELL = sh + LLVM_CONFIG_FINDER := \ + [ -n "$(LLVM_CONFIG)" ] && command -v "$(LLVM_CONFIG)" || \ + command -v llvm-config-4.0 || command -v llvm-config40 || \ +@@ -118,7 +118,7 @@ $(O)/crystal: $(DEPS) $(SOURCES) + $(BUILD_PATH) $(EXPORTS) ./bin/crystal build $(FLAGS) -o $@ src/compiler/crystal.cr -D without_openssl -D without_zlib + + $(LLVM_EXT_OBJ): $(LLVM_EXT_DIR)/llvm_ext.cc +- $(CXX) -c $(CXXFLAGS) -o $@ $< `$(LLVM_CONFIG) --cxxflags` ++ $(CXX) -c $(CXXFLAGS) -o $@ $< $(shell $(LLVM_CONFIG) --cxxflags) + + $(LIB_CRYSTAL_TARGET): $(LIB_CRYSTAL_OBJS) + $(AR) -rcs $@ $^ +diff --git a/Vagrantfile b/Vagrantfile +index 83bcf8c3ce..859f682dbf 100644 +--- a/Vagrantfile ++++ b/Vagrantfile +@@ -15,7 +15,7 @@ Vagrant.configure("2") do |config| + c.vm.box = "ubuntu/#{box_name}" + + c.vm.provision :shell, inline: %( +- curl -s https://dist.crystal-lang.org/apt/setup.sh | bash ++ curl -s https://dist.crystal-lang.org/apt/setup.sh | sh + apt-get install -y crystal git libgmp3-dev zlib1g-dev libedit-dev libxml2-dev libssl-dev libyaml-dev libreadline-dev g++ + curl -s https://crystal-lang.s3.amazonaws.com/llvm/llvm-3.5.0-1-linux-`uname -m`.tar.gz | tar xz -C /opt + echo 'export LIBRARY_PATH="/opt/crystal/embedded/lib"' > /etc/profile.d/crystal.sh +diff --git a/bin/crystal b/bin/crystal +index 698ed9b2b3..c901d9b37f 100755 +--- a/bin/crystal ++++ b/bin/crystal +@@ -37,7 +37,7 @@ _resolve_symlinks() { + + local dir_context path + path=$(readlink -- "$1") +- if [ $? -eq 0 ]; then ++ if [ $? = 0 ]; then + dir_context=$(dirname -- "$1") + _resolve_symlinks "$(_prepend_dir_context_if_necessary "$dir_context" "$path")" "$@" + else +@@ -141,16 +141,13 @@ CRYSTAL_DIR="$CRYSTAL_ROOT/.build" + export CRYSTAL_PATH=$CRYSTAL_ROOT/src:lib + export CRYSTAL_HAS_WRAPPER=true + +-if [ -x "$CRYSTAL_DIR/crystal" ] +-then ++if [ -x "$CRYSTAL_DIR/crystal" ]; then + __warning_msg "Using compiled compiler at \`.build/crystal'" + exec "$CRYSTAL_DIR/crystal" "$@" +-elif ! command -v crystal > /dev/null +-then ++elif ! command -v crystal > /dev/null; then + __error_msg 'You need to have a crystal executable in your path!' + exit 1 +-elif [ "$(command -v crystal)" = "$SCRIPT_PATH" ] || [ "$(command -v crystal)" = "bin/crystal" ] +-then ++elif [ "$(command -v crystal)" = "$SCRIPT_PATH" ] || [ "$(command -v crystal)" = "bin/crystal" ]; then + export PATH="$(remove_path_item "$(remove_path_item "$PATH" "$SCRIPT_ROOT")" "bin")" + exec "$SCRIPT_PATH" "$@" + else |