Merge pull request #195786 from jtojnar/plv8
postgresqlPackages.plv8: 3.0.0 → 3.1.4
This commit is contained in:
commit
a42c1c674a
|
@ -1,87 +0,0 @@
|
|||
{ lib, stdenv, fetchFromGitHub, v8, perl, postgresql
|
||||
# For test
|
||||
, runCommand, coreutils, gnugrep }:
|
||||
|
||||
let self = stdenv.mkDerivation rec {
|
||||
pname = "plv8";
|
||||
version = "3.0.0";
|
||||
|
||||
nativeBuildInputs = [ perl ];
|
||||
buildInputs = [ v8 postgresql ];
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "plv8";
|
||||
repo = "plv8";
|
||||
rev = "v${version}";
|
||||
sha256 = "KJz8wnGcTXnVn6umpP+UquuJTtQrkBTJ33rB/JIH4kU=";
|
||||
};
|
||||
|
||||
makefile = "Makefile.shared";
|
||||
|
||||
buildFlags = [ "all" ];
|
||||
|
||||
makeFlags = [
|
||||
# Nixpkgs build a v8 monolith instead of separate v8_libplatform.
|
||||
"V8_OUTDIR=${v8}/lib"
|
||||
];
|
||||
|
||||
installFlags = [
|
||||
# PGXS only supports installing to postgresql prefix so we need to redirect this
|
||||
"DESTDIR=${placeholder "out"}"
|
||||
];
|
||||
|
||||
preConfigure = ''
|
||||
# We build V8 as a monolith, so this is unnecessary.
|
||||
substituteInPlace Makefile.shared --replace "-lv8_libplatform" ""
|
||||
patchShebangs ./generate_upgrade.sh
|
||||
substituteInPlace generate_upgrade.sh \
|
||||
--replace " 2.3.10)" " 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.15)"
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
# Move the redirected to proper directory.
|
||||
# There appear to be no references to the install directories
|
||||
# so changing them does not cause issues.
|
||||
mv "$out/nix/store"/*/* "$out"
|
||||
rmdir "$out/nix/store"/* "$out/nix/store" "$out/nix"
|
||||
'';
|
||||
|
||||
NIX_CFLAGS_COMPILE = [
|
||||
# V8 depends on C++14.
|
||||
"-std=c++14"
|
||||
# Without this, PostgreSQL will crash at runtime.
|
||||
# The flags are only included in Makefile, not Makefile.shared.
|
||||
# https://github.com/plv8/plv8/pull/469
|
||||
"-DJSONB_DIRECT_CONVERSION" "-DV8_COMPRESS_POINTERS=1" "-DV8_31BIT_SMIS_ON_64BIT_ARCH=1"
|
||||
];
|
||||
|
||||
passthru.tests.smoke = runCommand "${pname}-test" {} ''
|
||||
export PATH=${lib.makeBinPath [ (postgresql.withPackages (_: [self])) coreutils gnugrep ]}
|
||||
db="$PWD/testdb"
|
||||
initdb "$db"
|
||||
postgres -k "$db" -D "$db" &
|
||||
pid="$!"
|
||||
|
||||
for i in $(seq 1 100); do
|
||||
if psql -h "$db" -d postgres -c "" 2>/dev/null; then
|
||||
break
|
||||
elif ! kill -0 "$pid"; then
|
||||
exit 1
|
||||
else
|
||||
sleep 0.1
|
||||
fi
|
||||
done
|
||||
|
||||
psql -h "$db" -d postgres -c 'CREATE EXTENSION plv8; DO $$ plv8.elog(NOTICE, plv8.version); $$ LANGUAGE plv8;' 2> "$out"
|
||||
grep -q "${version}" "$out"
|
||||
kill -0 "$pid"
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "V8 Engine Javascript Procedural Language add-on for PostgreSQL";
|
||||
homepage = "https://plv8.github.io/";
|
||||
maintainers = with maintainers; [ marsam ];
|
||||
platforms = [ "x86_64-linux" ];
|
||||
license = licenses.postgresql;
|
||||
};
|
||||
}; in self
|
|
@ -0,0 +1,47 @@
|
|||
diff --git a/Makefile b/Makefile
|
||||
index 38879cc..6e78eeb 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -20,6 +20,7 @@ OBJS = $(SRCS:.cc=.o)
|
||||
MODULE_big = plv8-$(PLV8_VERSION)
|
||||
EXTENSION = plv8
|
||||
PLV8_DATA = plv8.control plv8--$(PLV8_VERSION).sql $(wildcard upgrade/*.sql)
|
||||
+USE_SYSTEM_V8 = 0
|
||||
|
||||
|
||||
# Platform detection
|
||||
@@ -41,6 +42,7 @@ PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
PG_VERSION_NUM := $(shell cat `$(PG_CONFIG) --includedir-server`/pg_config*.h \
|
||||
| perl -ne 'print $$1 and exit if /PG_VERSION_NUM\s+(\d+)/')
|
||||
|
||||
+ifeq ($(USE_SYSTEM_V8),0)
|
||||
AUTOV8_DIR = build/v8
|
||||
AUTOV8_OUT = build/v8/out.gn/obj
|
||||
AUTOV8_STATIC_LIBS = -lv8_libplatform -lv8_libbase
|
||||
@@ -66,6 +68,7 @@ v8:
|
||||
make -f Makefiles/Makefile.macos v8
|
||||
endif
|
||||
endif
|
||||
+endif
|
||||
|
||||
# enable direct jsonb conversion by default
|
||||
CCFLAGS += -DJSONB_DIRECT_CONVERSION
|
||||
@@ -83,6 +86,7 @@ ifdef BIGINT_GRACEFUL
|
||||
endif
|
||||
|
||||
|
||||
+ifeq ($(USE_SYSTEM_V8),0)
|
||||
# We're gonna build static link. Rip it out after include Makefile
|
||||
SHLIB_LINK := $(filter-out -lv8, $(SHLIB_LINK))
|
||||
|
||||
@@ -101,6 +105,7 @@ else
|
||||
SHLIB_LINK += -lrt -std=c++14
|
||||
endif
|
||||
endif
|
||||
+endif
|
||||
|
||||
DATA = $(PLV8_DATA)
|
||||
ifndef DISABLE_DIALECT
|
||||
--
|
||||
2.37.3
|
||||
|
142
pkgs/servers/sql/postgresql/ext/plv8/default.nix
Normal file
142
pkgs/servers/sql/postgresql/ext/plv8/default.nix
Normal file
|
@ -0,0 +1,142 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, fetchFromGitHub
|
||||
, v8
|
||||
, perl
|
||||
, postgresql
|
||||
# For test
|
||||
, runCommand
|
||||
, coreutils
|
||||
, gnugrep
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "plv8";
|
||||
version = "3.1.4";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "plv8";
|
||||
repo = "plv8";
|
||||
rev = "v${finalAttrs.version}";
|
||||
sha256 = "GoPP2nAeDItBt3Lug49s+brD0gIy3iDlJpbyHRuMcZ4=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# Allow building with system v8.
|
||||
# https://github.com/plv8/plv8/pull/505 (rejected)
|
||||
./0001-build-Allow-using-V8-from-system.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
perl
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
v8
|
||||
postgresql
|
||||
];
|
||||
|
||||
buildFlags = [ "all" ];
|
||||
|
||||
makeFlags = [
|
||||
# Nixpkgs build a v8 monolith instead of separate v8_libplatform.
|
||||
"USE_SYSTEM_V8=1"
|
||||
"SHLIB_LINK=-lv8"
|
||||
"V8_OUTDIR=${v8}/lib"
|
||||
];
|
||||
|
||||
installFlags = [
|
||||
# PGXS only supports installing to postgresql prefix so we need to redirect this
|
||||
"DESTDIR=${placeholder "out"}"
|
||||
];
|
||||
|
||||
# No configure script.
|
||||
dontConfigure = true;
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs ./generate_upgrade.sh
|
||||
# https://github.com/plv8/plv8/pull/506
|
||||
substituteInPlace generate_upgrade.sh \
|
||||
--replace " 2.3.10 " " 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.15 "
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
# Move the redirected to proper directory.
|
||||
# There appear to be no references to the install directories
|
||||
# so changing them does not cause issues.
|
||||
mv "$out/nix/store"/*/* "$out"
|
||||
rmdir "$out/nix/store"/* "$out/nix/store" "$out/nix"
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
tests =
|
||||
let
|
||||
postgresqlWithSelf = postgresql.withPackages (_: [
|
||||
finalAttrs.finalPackage
|
||||
]);
|
||||
in {
|
||||
smoke = runCommand "plv8-smoke-test" {} ''
|
||||
export PATH=${lib.makeBinPath [
|
||||
postgresqlWithSelf
|
||||
coreutils
|
||||
gnugrep
|
||||
]}
|
||||
db="$PWD/testdb"
|
||||
initdb "$db"
|
||||
postgres -k "$db" -D "$db" &
|
||||
pid="$!"
|
||||
|
||||
for i in $(seq 1 100); do
|
||||
if psql -h "$db" -d postgres -c "" 2>/dev/null; then
|
||||
break
|
||||
elif ! kill -0 "$pid"; then
|
||||
exit 1
|
||||
else
|
||||
sleep 0.1
|
||||
fi
|
||||
done
|
||||
|
||||
psql -h "$db" -d postgres -c 'CREATE EXTENSION plv8; DO $$ plv8.elog(NOTICE, plv8.version); $$ LANGUAGE plv8;' 2> "$out"
|
||||
grep -q "${finalAttrs.version}" "$out"
|
||||
kill -0 "$pid"
|
||||
'';
|
||||
|
||||
regression = stdenv.mkDerivation {
|
||||
name = "plv8-regression";
|
||||
inherit (finalAttrs) src patches nativeBuildInputs buildInputs dontConfigure;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
# The regression tests need to be run in the order specified in the Makefile.
|
||||
echo -e "include Makefile\nprint_regress_files:\n\t@echo \$(REGRESS)" > Makefile.regress
|
||||
REGRESS_TESTS=$(make -f Makefile.regress print_regress_files)
|
||||
|
||||
${postgresql}/lib/pgxs/src/test/regress/pg_regress \
|
||||
--bindir='${postgresqlWithSelf}/bin' \
|
||||
--temp-instance=regress-instance \
|
||||
--dbname=contrib_regression \
|
||||
$REGRESS_TESTS
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
touch "$out"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "V8 Engine Javascript Procedural Language add-on for PostgreSQL";
|
||||
homepage = "https://plv8.github.io/";
|
||||
maintainers = with maintainers; [ marsam ];
|
||||
platforms = [ "x86_64-linux" ];
|
||||
license = licenses.postgresql;
|
||||
};
|
||||
})
|
|
@ -32,7 +32,7 @@ self: super: {
|
|||
|
||||
plr = super.callPackage ./ext/plr.nix { };
|
||||
|
||||
plv8 = super.callPackage ./ext/plv8.nix {
|
||||
plv8 = super.callPackage ./ext/plv8 {
|
||||
v8 = self.v8_8_x;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue