diff --git a/.gitignore b/.gitignore index e69de29..604da8c 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +/pg-0.12.3.tgz +/pgsql-data.tar.gz diff --git a/nodejs-pg-0.12.3-procpid-rename-to-pid.patch b/nodejs-pg-0.12.3-procpid-rename-to-pid.patch new file mode 100644 index 0000000..8d45ab4 --- /dev/null +++ b/nodejs-pg-0.12.3-procpid-rename-to-pid.patch @@ -0,0 +1,12 @@ +diff -Naur a/test/integration/connection-pool/error-tests.js b/test/integration/connection-pool/error-tests.js +--- a/test/integration/connection-pool/error-tests.js ++++ b/test/integration/connection-pool/error-tests.js +@@ -5,7 +5,7 @@ + //first make pool hold 2 clients + helper.pg.defaults.poolSize = 2; + +-var killIdleQuery = 'SELECT procpid, (SELECT pg_terminate_backend(procpid)) AS killed FROM pg_stat_activity WHERE current_query LIKE \'\''; ++var killIdleQuery = 'SELECT pid, (SELECT pg_terminate_backend(pid)) AS killed FROM pg_stat_activity WHERE state LIKE \'idle\''; + + //get first client + helper.pg.connect(helper.config, assert.success(function(client) { diff --git a/nodejs-pg.spec b/nodejs-pg.spec new file mode 100644 index 0000000..3c41904 --- /dev/null +++ b/nodejs-pg.spec @@ -0,0 +1,100 @@ +%{?nodejs_find_provides_and_requires} + +%global enable_tests 0 + +Name: nodejs-pg +Version: 0.12.3 +Release: 1%{?dist} +Summary: PostgreSQL client for Node.js - pure JavaScript and libpq with the same API +# License text is included in README.md +License: MIT +Group: System Environment/Libraries +URL: https://github.com/brianc/node-postgres +Source0: http://registry.npmjs.org/pg/-/pg-%{version}.tgz +# The tests need postgresql-server to be running. postgresql-setup does not +# allow the creation of a database within a chroot so bundle a database. +# Source1 is generated by running Source10, which creates the necessary +# databases/tables/users before compressing the /var/lib/pgsql directory. +Source1: pgsql-data.tar.gz +Source10: setup-db.sh + +# One of the tests needs to be patched to work with Postgres 9.2. +# http://www.postgresql.org/docs/devel/static/release-9-2.html +# "Rename pg_stat_activity.procpid to pid, to match other system tables" +Patch0: nodejs-pg-0.12.3-procpid-rename-to-pid.patch + +BuildRequires: nodejs-devel +BuildRequires: node-gyp +BuildRequires: postgresql-devel + +%if 0%{?enable_tests} +BuildRequires: npm(generic-pool) +BuildRequires: postgresql-server +%endif + +ExclusiveArch: %{ix86} x86_64 %{arm} +# Replace with this when it gets fixed. +# ExclusiveArch: %%{nodejs_arches} + +%description +PostgreSQL client for Node.js with pure JavaScript client and native +libpq bindings that share the same API. + +Supported PostgreSQL features include: + - parameterized queries + - named statements with query plan caching + - asynchronous notifications with LISTEN/NOTIFY + - bulk import & export with COPY TO/COPY FROM + - extensible js<->postgresql data-type coercion + + +%prep +%setup -q -n package +%setup -T -D -a 1 -q -n package +%patch0 -p1 +%nodejs_fixdep generic-pool '~2.0.2' + + +%build +export CXXFLAGS="%{optflags}" +node-gyp rebuild + + +%install +mkdir -p %{buildroot}%{nodejs_sitelib}/pg +cp -pr package.json lib/ wscript \ + %{buildroot}%{nodejs_sitelib}/pg +mkdir -p %{buildroot}%{nodejs_sitelib}/pg/build +# The following is usually named ".node" but for some +# reason upstream have chosen a different naming scheme. +cp -p build/Release/binding.node \ + %{buildroot}%{nodejs_sitelib}/pg/build + +%nodejs_symlink_deps + + +# https://github.com/brianc/node-postgres/wiki/Testing +%if 0%{?enable_tests} +%check +ln -sf %{nodejs_sitelib} . +chmod 700 pgsql pgsql/data +pwd=$(pwd) +pg_ctl start -D "${pwd}"/pgsql/data/ -s -o "-p 5432 -k /tmp" -w -t 300 +%__nodejs script/create-test-tables.js pg://test@localhost:5432/test +make test-unit +make test-integration connectionString=pg://test@localhost:5432/test +# Not sure yet why this test hangs so comment out for now. +# make test-native connectionString=pg://test@localhost:5432/test +make test-binary connectionString=pg://test@localhost:5432/test +pg_ctl stop -D "${pwd}"/pgsql/data/ -s -m fast +%endif + + +%files +%doc README.md +%{nodejs_sitelib}/pg + + +%changelog +* Wed Feb 13 2013 Jamie Nguyen - 0.12.3-1 +- initial package diff --git a/setup-db.sh b/setup-db.sh new file mode 100744 index 0000000..33e41c2 --- /dev/null +++ b/setup-db.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +rm -rf /var/lib/pgsql/data +postgresql-setup initdb +sed -i \ + -e 's|peer|trust|g' \ + -e 's|ident|trust|g' \ + /var/lib/pgsql/data/pg_hba.conf +systemctl start posgresql +createuser -U postgres -s test +psql -U postgres << EOF +CREATE DATABASE "test" OWNER "test" TEMPLATE template0 ENCODING 'UTF-8'; +EOF +systemctl stop postgresql +cd /var/lib +tar -cvpz pgsql/ -f ./pgsql-data.tar.gz diff --git a/sources b/sources index e69de29..c75f3d6 100644 --- a/sources +++ b/sources @@ -0,0 +1,2 @@ +ef01686c74bffba07ff94571480fb1a8 pg-0.12.3.tgz +5340dabf90ba3bfb2a279c6d4960e1da pgsql-data.tar.gz