aboutsummaryrefslogtreecommitdiffstats
path: root/community/ruby-pg_query/APKBUILD
blob: 1864e30b490b6d469b30bf342b6dbed511f6704b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-pg_query
_gemname=pg_query
# Keep in mind the aport libpg_query when bumping.
pkgver=2.0.3
pkgrel=0
pkgdesc="PostgreSQL query parsing and normalization library for Ruby"
url="https://github.com/pganalyze/pg_query"
# x86, armhf, armv7: fingerprint feature is broken on 32-bit
# mips64*: segfaults
# s390x: Failing tests
# riscv64 blocked by libpg_query
arch="all !x86 !armhf !armv7 !mips64 !mips64le !s390x !riscv64"
license="BSD-3-Clause"
depends="ruby ruby-google-protobuf>=3.15.5"
checkdepends="ruby-rspec"
makedepends="
	libpg_query-dev
	protoc
	ruby-dev
	ruby-rake
	ruby-rake-compiler
	xxhash-dev
	"
source="https://github.com/pganalyze/pg_query/archive/v$pkgver/$pkgname-$pkgver.tar.gz
	unbundle-deps.patch
	rakefile.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

prepare() {
	default_prepare

	# Remove bundled dependencies.
	cd ext/pg_query
	rm protobuf-c.c xxhash.c src_*.c src_*.h
	find . -name 'pg_query*' ! -name 'pg_query_ruby.*' -delete
	rm -Rf include
}

build() {
	# Regenerate Ruby source from pg_query.proto provided by libpg_query
	# package - to be sure that we use correct version.
	protoc --proto_path=/usr/include/pg_query \
		--ruby_out=lib/pg_query \
		/usr/include/pg_query/pg_query.proto
	rake update_json_field_names

	gem build $_gemname.gemspec

	gem install --local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname

	# Needed for running tests.
	cp -l dist/extensions/*/*/$_gemname-*/$_gemname/*.so lib/$_gemname/
}

check() {
	rspec
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	# Remove unnecessary and duplicated files.
	rm -f "$gemdir"/extensions/*/*/$_gemname-*/mkmf.log
	cd "$gemdir"/gems/$_gemname-$pkgver
	rm -rf ext/ lib/$_gemname/*.so LICENSE Rakefile *.md
}

sha512sums="4e83888df7397594092e41d4ed2f1a1ad999a8573c0e4750c7e6dc4af1902fe9ba85bdb051675a6c3a1ba1bd587f4fd47408f032ff94cb6b5abdd953895bfa4e  ruby-pg_query-2.0.3.tar.gz
29a2e0bb3a2cb4478ff3a5f2358bb740d361c1d14381ea65b546858ef39bda4103be407fb07f5c0d7dab5b8198fab26b05e5487f059a31b69bf75dc24bd2e4a1  unbundle-deps.patch
993b494ef8fa0c17a0fcc6f26f37419dc08d7c45404d607aaa44e0315bd32c90f943f6f7886b64463b7b2c9f63ff5ac5ef0079b60cf4d0058a7c390f67aa0591  rakefile.patch"