diff --git a/.gitignore b/.gitignore index e69de29..71366e3 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/buffertools-2.1.3.tgz diff --git a/nodejs-buffertools.spec b/nodejs-buffertools.spec new file mode 100644 index 0000000..39add02 --- /dev/null +++ b/nodejs-buffertools.spec @@ -0,0 +1,82 @@ +%{?nodejs_find_provides_and_requires} + +%global packagename buffertools +%global enable_tests 1 + +Name: nodejs-buffertools +Version: 2.1.3 +Release: 7%{?dist} +Summary: Working with node.js buffers made easy + +License: ISC +URL: https://github.com/bnoordhuis/node-buffertools +Source0: https://registry.npmjs.org/%{packagename}/-/%{packagename}-%{version}.tgz + +# Patch for building on ARM +Patch0: nodejs-buffertools_signed_char.patch + +# Patch to use the nodejs "bindings" module instead of hardcoding the path +Patch1: nodejs-buffertools_use-bindings.patch + +ExclusiveArch: %{nodejs_arches} + +BuildRequires: nodejs-packaging +%if 0%{?enable_tests} +BuildRequires: node-gyp +BuildRequires: nodejs-devel +BuildRequires: npm(bindings) +%endif + +%description +Working with node.js buffers made easy. + + +%prep +%setup -q -n package +%patch0 -p2 +%patch1 -p2 + +%build +export CXXFLAGS="%{optflags}" +node-gyp rebuild + +mkdir -p %{buildroot}%{nodejs_sitearch}/%{packagename}/build/Release +cp -p package.json buffertools.js %{buildroot}%{nodejs_sitearch}/%{packagename}/ +cp -p build/Release/%{packagename}.node %{buildroot}%{nodejs_sitearch}/%{packagename}/build + +%nodejs_symlink_deps + +%check +%nodejs_symlink_deps --check +%{__nodejs} -e 'require("./")' +%if 0%{?enable_tests} +%__nodejs test.js +%endif + + +%files +%{!?_licensedir:%global license %doc} +%doc *.md +%license LICENSE +%{nodejs_sitearch}/%{packagename} + + + +%changelog +* Tue Jan 19 2016 Jared Smith - 2.1.3-7 +- Add missing BuildRequires for bindings + +* Tue Jan 19 2016 Jared Smith - 2.1.3-6 +- Add patch to use npm(buffertools) to handle path to native code + +* Tue Jan 19 2016 Jared Smith - 2.1.3-4 +- Add patch to build on ARM + +* Tue Jan 19 2016 Jared Smith - 2.1.3-3 +- Better handle installation of the output of node-gyp compilation + +* Tue Jan 19 2016 Jared Smith - 2.1.3-2 +- Fix minor packaging issue for package review + +* Thu Oct 22 2015 Jared Smith - 2.1.3-1 +- Initial packaging diff --git a/nodejs-buffertools_signed_char.patch b/nodejs-buffertools_signed_char.patch new file mode 100644 index 0000000..cbb709d --- /dev/null +++ b/nodejs-buffertools_signed_char.patch @@ -0,0 +1,13 @@ +diff --git a/package/buffertools.cc b/package/buffertools.cc +index 038f78f..d8a09a2 100644 +--- a/package/buffertools.cc ++++ b/package/buffertools.cc +@@ -344,7 +344,7 @@ struct IndexOfAction: BinaryAction { + static char toHexTable[] = "0123456789abcdef"; + + // CHECKME is this cache efficient? +-static char fromHexTable[] = { ++static signed char fromHexTable[] = { + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,-1, + 10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, diff --git a/nodejs-buffertools_use-bindings.patch b/nodejs-buffertools_use-bindings.patch new file mode 100644 index 0000000..5001c28 --- /dev/null +++ b/nodejs-buffertools_use-bindings.patch @@ -0,0 +1,39 @@ +diff --git a/package/buffertools.js b/package/buffertools.js +index 0055156..df98de1 100644 +--- a/package/buffertools.js ++++ b/package/buffertools.js +@@ -13,6 +13,7 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + ++var buffertools = require('bindings')('buffertools'); + var SlowBuffer = require('buffer').SlowBuffer; + var Buffer = require('buffer').Buffer; + +@@ -20,12 +21,6 @@ var Buffer = require('buffer').Buffer; + var events = require('events'); + var util = require('util'); + +-try { +- var buffertools = require('./build/Release/buffertools.node'); +-} catch (e) { +- var buffertools = require('./build/Debug/buffertools.node'); +-} +- + exports.extend = function() { + var receivers; + if (arguments.length > 0) { +diff --git a/package/package.json b/package/package.json +index 5baa9bb..90b927f 100644 +--- a/package/package.json ++++ b/package/package.json +@@ -14,6 +14,9 @@ + "type": "git", + "url": "https://github.com/bnoordhuis/node-buffertools.git" + }, ++ "dependencies": { ++ "bindings": "^1.1.0" ++ }, + "engines": { + "node": ">=0.3.0" + }, diff --git a/sources b/sources index e69de29..fd623e8 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +52ed45ed9750bd276eda6c92ee9cf048 buffertools-2.1.3.tgz