Blob Blame History Raw
%{?nodejs_find_provides_and_requires}

%global enable_tests 0

Name:       nodejs-pg
Version:    0.12.3
Release:    5%{?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

%if 0%{?fedora} >= 19
ExclusiveArch: %{nodejs_arches}
%else
ExclusiveArch: %{ix86} x86_64 %{arm}
%endif

%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 "<modulename>.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
%nodejs_symlink_deps --check
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
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.12.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Fri Feb 14 2014 T.C. Hollingsworth <tchollingsworth@gmail.com> - 0.12.3-4
- rebuild for icu-53 (via v8)

* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.12.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Sun Jul 07 2013 Jamie Nguyen <jamielinux@fedoraproject.org> - 0.12.3-2
- restrict to compatible arches

* Wed Feb 13 2013 Jamie Nguyen <jamielinux@fedoraproject.org> - 0.12.3-1
- initial package