[Pkg-javascript-commits] [node-zipfile] 03/09: Imported Upstream version 0.5.0+ds

Jérémy Lal kapouer at moszumanska.debian.org
Sun Mar 16 22:39:20 UTC 2014


This is an automated email from the git hooks/post-receive script.

kapouer pushed a commit to branch master
in repository node-zipfile.

commit 0eb25a7bd8ab43de3385ebad1e38f98dfb83f1ba
Author: Jérémy Lal <kapouer at melix.org>
Date:   Sun Mar 16 22:56:08 2014 +0100

    Imported Upstream version 0.5.0+ds
---
 .gitignore              |  6 ++--
 .travis.yml             | 54 ++++++++++++++++++++++++++++++++++
 CHANGELOG.md            |  9 ++++++
 LICENSE.txt             |  2 +-
 Makefile                |  8 ++---
 README.md               | 78 +++++++------------------------------------------
 binding.gyp             | 57 +++++++++++++++---------------------
 lib/index.js            |  7 ++++-
 lib/zipfile.js          |  5 +---
 package.json            | 41 ++++++++++++++------------
 scripts/package_osx.sh  | 25 ++++++++++++++++
 src/node_zipfile.cpp    | 10 +++----
 test/data/bogus.zip     |  1 +
 test/exceptions.test.js |  2 +-
 test/open.test.js       | 10 ++++++-
 test/unicode.test.js    |  2 +-
 test/write.test.js      |  2 +-
 vcbuild.bat             |  7 ++---
 18 files changed, 181 insertions(+), 145 deletions(-)

diff --git a/.gitignore b/.gitignore
index fb0286e..40aa8ac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,7 +3,7 @@ build
 .DS_Store
 *.o
 *.a
-deps/libzip-0.10/
-lib/node_zipfile.node
+deps/libzip-0.10
+lib/binding
 node_modules
-test/tmp/
\ No newline at end of file
+test/tmp
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..7f44cb0
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,54 @@
+language: cpp
+
+compiler:
+ - gcc
+ - clang
+
+env:
+  matrix:
+   - NODE_NVM_VERSION="0.10"
+   - NODE_NVM_VERSION="0.8"
+  global:
+   - secure: hBUfRqVPovL7PVOJONI8sakIUtggpM74qMPdi5zaMpJhuV/QWfROOVc05ULEr1P0Fra2WpQ62mp8lfa1NbB6sQfT/8Y6u0lucf9SsIUBJzDrSmfXv2NDgpJn9RQmfsZgLfDuTwRLVROkNSTowUq3tnhDIzX/NyB7uOp1TZNEJ8A=
+   - secure: xWyq1Ys9lpMUVCh73q5YDDfC4nLeeydqIS4S+lJ/t/jUCNHDwe1x5XrxRIALi74qNmHg6eTcOeEW5iot/sf1oUJIA1oPt9iMIMolg9iYWJKWN4E6gWcIigYu9ZDl3GJsHyiNs/dVlZjzY1YKzyvgZ2MRfy4l0rPShCxROoCiCIM=
+
+before_install:
+ - COMMIT_MESSAGE=$(git show -s --format=%B $TRAVIS_COMMIT | tr -d '\n')
+ # here we set up the node version on the fly based on the matrix value.
+ # This is done manually so that it is easy to flip the 'language' to
+ # objective-c in another branch (to run the same travis.yml on OS X)
+ - git clone https://github.com/creationix/nvm.git ../.nvm
+ - source ../.nvm/nvm.sh
+ - nvm install $NODE_NVM_VERSION
+ - nvm use $NODE_NVM_VERSION
+ - node --version
+ - npm --version
+ - sudo apt-get -qq update
+ - npm install mocha
+ - npm install aws-sdk
+
+install:
+ # test building from source
+ - npm install --build-from-source
+ - npm test
+ - node-pre-gyp package testpackage
+ - npm test
+
+before_script:
+ # test publishing and installing from remote if
+ # [publish binary] is present in commit message
+ - PUBLISH_BINARY=false
+ - if [[ ${CXX} == "g++" ]] && test "${COMMIT_MESSAGE#*'[publish binary]'}" != "$COMMIT_MESSAGE"; then echo yes;PUBLISH_BINARY=true; fi;
+ - if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp publish info; rm -rf {build,lib/binding}; npm install --fallback-to-build=false; npm test; fi
+ - node-pre-gyp clean
+
+script:
+ # test building with against shared libzip
+ - make clean
+ - sudo apt-get -qq install libzip-dev
+ - npm install --build-from-source --shared_libzip
+ - npm test
+
+after_success:
+ # if success then query and display all published binaries
+ - node-pre-gyp info
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..513129d
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,9 @@
+# changelog
+
+## v0.5.0
+
+ - Now supporting binary deploy through node-pre-gyp (#42). Run `npm install --build-from-source` now to build from source instead of installing from a binary.
+
+## v0.4.3
+
+ - Upgraded libzip to hg at http://hg.nih.at/libzip/rev/66d608d38359 to fix #36
\ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
index f3fcf80..9f0b7ad 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2011, Dane Springmeyer
+Copyright (c) 2014, Mapbox
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
diff --git a/Makefile b/Makefile
index a4841fc..3d06606 100755
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,11 @@
-all: node_zipfile.node
+all: zipfile.node
 
-node_zipfile.node:
-	`npm explore npm -g -- pwd`/bin/node-gyp-bin/node-gyp build
+zipfile.node:
+	PATH=`npm explore npm -g -- pwd`/bin/node-gyp-bin:./node_modules/.bin:$${PATH} && ./node_modules/.bin/node-pre-gyp build
 
 clean:
 	@rm -rf ./build
-	rm -f lib/node_zipfile.node
+	rm -rf lib/bindings/
 	rm -f test/tmp/*
 	rm -rf ./deps/libzip-0.10/
 	rm -rf ./build
diff --git a/README.md b/README.md
index 5dff0bb..2684f73 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
       
 Bindings to [libzip](http://nih.at/libzip/libzip.html) for handling zipfile archives in [node](http://nodejs.org).
 
+[![Build Status](https://secure.travis-ci.org/mapbox/node-zipfile.png)](http://travis-ci.org/mapbox/node-zipfile)
 
 ## Example
 
@@ -14,35 +15,24 @@ Bindings to [libzip](http://nih.at/libzip/libzip.html) for handling zipfile arch
     buffer.toString()
     'PROJCS["Google Maps Global Mercator",GEOGCS .... '
 
-
 ## Depends
 
-node-zipfile 0.3.x depends on node v0.6 and above
-
-node-zipfile 0.1.x-0.2.x works with node v0.2-v0.4
-
-libzip (optionally, otherwise will build against bundled version)
-
+ - Node v0.10.x or v0.8.x
 
 ## Installation
 
-You can install the latest tag via npm:
-
-    npm install zipfile
+Install from binary:
 
-Or install from github master:
+    npm install
 
-    git clone git://github.com/springmeyer/node-zipfile.git
-    cd node-zipfile
-    ./configure
-    make
-    make install
+Install from source:
 
+    npm install --build-from-source
 
 ## Dynamically linking against libzip
 
-node-zipfile depends on libzip, but by default
-bundles a copy in deps/ which is statically linked.
+`node-zipfile` depends on libzip, but by default
+bundles a copy in deps/ which is statically linked and packaged as a binary.
 
 If you want to use an external libzip first install it:
 
@@ -54,59 +44,13 @@ OS X:
   
     brew install libzip
 
-Or from source:
-
-    wget http://nih.at/libzip/libzip-0.10.tar.bz2
-    tar xvf libzip-0.10.tar.bz2
-    cd libzip-0.10
-    ./configure
-    make
-    sudo make install
-
-Then on linux do:
-
-    sudo ldconfig
-
-Now, configure node-zipfile with the --shared-libzip option:
+Then configure node-zipfile with the --shared_libzip option:
  
-    ./configure --shared-libzip
+    npm install  --build-from-source --shared_libzip
 
 If you installed libzip in a custom location then configure like:
   
-    ./configure --shared-libzip --libzip=/opt/local
-
-Otherwise /usr/ and /usr/local will be searched for libzip:
-
-    ./configure --shared-libzip
-    make
-    sudo make install
-    ./test.js
-
-## Building libzip with cmake on windows:
-
-Note: needs cygwin so the .sh shell scripts work that libzip cmake files call.
-
-    git clone git://github.com/springmeyer/node-zipfile.git
-    cd node-zipfile/deps/
-    bsdtar xvf libzip-0.10.tar.bz2
-    cd libzip
-    mkdir build_vc100
-    cd build_vc100
-    cmake -DZLIB_LIBRARY=c:\dev2\zlib\zlib.lib -DZLIB_INCLUDE_DIR=c:\dev2\zlib -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ..\
-
-Then edit lib\zipconf.h removing 'inttypes.h' with:
-
-    #include <stdint.h>
-    #include <limits.h>
-
-Finally build libzip
-
-    nmake /f Makefile zip
-    
-Then compile node-zipfile:
-
-    TODO
- 
+    npm install  --build-from-source --shared_libzip --shared_libzip_includes=/opt/local/include --shared_libzip_libpath=/opt/local/lib
 
 ## License
 
diff --git a/binding.gyp b/binding.gyp
index 008fdb8..8e0a1c5 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -1,37 +1,34 @@
 {
   'includes': [ 'deps/common-libzip.gypi' ],
   'variables': {
-      'libzip%':'internal',
+      'shared_libzip%':'false',
+      'shared_libzip_includes%':'/usr/lib',
+      'shared_libzip_libpath%':'/usr/include'
   },
-  'conditions': [
-      ['OS=="win"', {
-        'variables': {
-          'copy_command%': 'copy',
-        },
-      },{
-        'variables': {
-          'copy_command%': 'cp',
-        },
-      }]
-  ],
   'targets': [
     {
-      'target_name': 'node_zipfile',
+      'target_name': '<(module_name)',
       'conditions': [
-        ['libzip != "internal"', {
+        ['shared_libzip == "false"', {
+            'dependencies': [
+              'deps/libzip.gyp:libzip'
+            ]
+        },
+        {
             'libraries': [
-               '-L<@(libzip)/lib',
+               '-L<@(shared_libzip_libpath)',
                '-lzip'
             ],
-            'include_dirs': [ '<@(libzip)/include' ]
-        },
-        {
-            'dependencies': [
-              'deps/libzip.gyp:libzip'
+            'include_dirs': [
+               '<@(shared_libzip_includes)',
+               '<@(shared_libzip_libpath)/libzip/include',
             ]
         }
         ]
       ],
+      'defines': [
+        'MODULE_NAME=<(module_name)'
+      ],
       'sources': [
         'src/node_zipfile.cpp'
       ],
@@ -39,25 +36,19 @@
     {
       'target_name': 'action_after_build',
       'type': 'none',
-      'dependencies': [ 'node_zipfile' ],
-      'actions': [
-        {
-          'action_name': 'move_node_module',
-          'inputs': [
-            '<@(PRODUCT_DIR)/node_zipfile.node'
-          ],
-          'outputs': [
-            'lib/node_zipfile.node'
-          ],
-          'action': ['<(copy_command)', '<@(PRODUCT_DIR)/node_zipfile.node', 'lib/node_zipfile.node']
-        }
+      'dependencies': [ '<(module_name)' ],
+      'copies': [
+          {
+            'files': [ '<(PRODUCT_DIR)/<(module_name).node' ],
+            'destination': '<(module_path)'
+          }
       ],
       'conditions': [
           ['OS=="win"', {
               'copies': [
                 {
                   'files': [ '<(PRODUCT_DIR)/libzip.dll' ],
-                  'destination': 'lib/'
+                  'destination': '<(module_path)'
                 }
               ]
           }]
diff --git a/lib/index.js b/lib/index.js
index 790f152..c7748be 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -1 +1,6 @@
-module.exports = require('./zipfile');
+var binary = require('node-pre-gyp');
+var path = require('path');
+var binding_path = binary.find(path.resolve(path.join(__dirname,'../package.json')));
+var zipfile = require(binding_path);
+
+exports = module.exports = zipfile;
diff --git a/lib/zipfile.js b/lib/zipfile.js
index 4885cc4..ed39ab5 100644
--- a/lib/zipfile.js
+++ b/lib/zipfile.js
@@ -1,4 +1 @@
-var zipfile = require('./node_zipfile.node');
-
-exports = module.exports = zipfile;
-
+module.exports = require('./index.js');
diff --git a/package.json b/package.json
index cc69204..9b8af6d 100644
--- a/package.json
+++ b/package.json
@@ -1,34 +1,39 @@
 {
   "name"          : "zipfile",
-  "version"       : "0.4.0",
+  "version"       : "0.5.0",
   "main"          : "./lib/index.js",
   "description"   : "C++ library for handling zipfiles in node",
   "keywords"      : ["zipfile", "uncompress", "unzip", "zlib"],
-  "url"           : "http://github.com/springmeyer/node-zipfile",
-   "repositories" : [
-       {
+  "url"           : "http://github.com/mapbox/node-zipfile",
+  "repository" : {
            "type" : "git",
-           "url"  : "git://github.com/springmeyer/node-zipfile.git" 
-       } 
-   ],
+           "url"  : "git://github.com/mapbox/node-zipfile.git"
+  },
   "author"        : "Dane Springmeyer <dane at dbsgeo.com>",
   "contributors"  : [],
   "licenses"      : ["BSD"],
-  "dependencies"  : {},
+  "dependencies"  : {
+    "node-pre-gyp": "0.5.x"
+  },
+  "bundledDependencies":["node-pre-gyp"],
   "devDependencies": {
     "mocha": "*",
     "mkdirp": "~0.3.0",
     "jshint"  : "~0.5.x"
-   },
+  },
   "bin"           : { 
-       "unzip.js" : "./bin/unzip.js" 
-   },
-   "directories"  : {
-       "examples" : "examples",
-       "src": "src"
-   },
-  "engines"       : { "node": ">= 0.6.13 && < 0.11.0" },
+    "unzip.js"    : "./bin/unzip.js"
+  },
+  "engines"       : { "node": ">= 0.6.13 < 0.11.0" },
   "scripts"       : {
-      "test"    : "mocha -R spec"
-   }
+    "test"        : "mocha -R spec",
+    "install"     : "node-pre-gyp install --fallback-to-build"
+  },
+  "binary": {
+    "module_name" : "zipfile",
+    "module_path" : "./lib/binding/",
+    "host"        : "https://mapbox-node-binary.s3.amazonaws.com",
+    "remote_path" : "./{module_name}/v{version}",
+    "package_name": "{node_abi}-{platform}-{arch}.tar.gz"
+  }
 }
diff --git a/scripts/package_osx.sh b/scripts/package_osx.sh
new file mode 100755
index 0000000..293c7ef
--- /dev/null
+++ b/scripts/package_osx.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+CURRENT_DIR="$( cd "$( dirname $BASH_SOURCE )" && pwd )"
+cd $CURRENT_DIR/../
+source ~/.nvm/nvm.sh
+nvm use 0.10
+
+set -u -e
+
+npm install node-gyp
+npm install aws-sdk
+export PATH=`pwd`/node_modules/.bin:$PATH
+
+function doit {
+    rm -rf build
+    node-pre-gyp clean build package testpackage "$@"
+    npm test
+    ./node_modules/.bin/node-pre-gyp publish info "$@"
+    npm install --fallback-to-build=false
+    npm test
+}
+
+doit
+nvm use 0.8
+doit --target=0.8.26
\ No newline at end of file
diff --git a/src/node_zipfile.cpp b/src/node_zipfile.cpp
index 3a08709..1792d1c 100644
--- a/src/node_zipfile.cpp
+++ b/src/node_zipfile.cpp
@@ -124,7 +124,7 @@ Handle<Value> ZipFile::New(const Arguments& args) {
 	int err;
     char errstr[1024];
     struct zip *za;
-    if ((za=zip_open(input_file.c_str(), 0, &err)) == NULL) {
+    if ((za=zip_open(input_file.c_str(), ZIP_CHECKCONS, &err)) == NULL) {
         zip_error_to_str(errstr, sizeof(errstr), err, errno);
         std::stringstream s;
         s << "cannot open file: " << input_file << " error: " << errstr << "\n";
@@ -197,7 +197,7 @@ Handle<Value> ZipFile::readFileSync(const Arguments& args) {
     int err;
     char errstr[1024];
     struct zip *za;
-    if ((za=zip_open(zf->file_name_.c_str(), 0, &err)) == NULL) {
+    if ((za=zip_open(zf->file_name_.c_str(), ZIP_CHECKCONS, &err)) == NULL) {
         zip_error_to_str(errstr, sizeof(errstr), err, errno);
         std::stringstream s;
         s << "cannot open file: " << zf->file_name_ << " error: " << errstr << "\n";
@@ -279,7 +279,7 @@ Handle<Value> ZipFile::readFile(const Arguments& args) {
     // libzip is not threadsafe so we open a new zip archive for each thread
     int err;
     char errstr[1024];
-    if ((closure->za=zip_open(zf->file_name_.c_str() , 0, &err)) == NULL) {
+    if ((closure->za=zip_open(zf->file_name_.c_str() , ZIP_CHECKCONS, &err)) == NULL) {
         zip_error_to_str(errstr, sizeof(errstr), err, errno);
         std::stringstream s;
         s << "cannot open file: " << zf->file_name_ << " error: " << errstr << "\n";
@@ -372,7 +372,6 @@ void ZipFile::Work_AfterReadFile(uv_work_t* req) {
     delete closure;
 }
 
-
 extern "C" {
     static void init(Handle<Object> target) {
         ZipFile::Initialize(target);
@@ -386,6 +385,7 @@ extern "C" {
         versions->Set(String::NewSymbol("v8"), String::New(V8::GetVersion()));
         target->Set(String::NewSymbol("versions"), versions);
     }
-    NODE_MODULE(node_zipfile, init);
+    #define MAKE_MODULE(_modname) NODE_MODULE( _modname, init)
+    MAKE_MODULE(MODULE_NAME)
 }
 
diff --git a/test/data/bogus.zip b/test/data/bogus.zip
new file mode 100644
index 0000000..7e538b6
--- /dev/null
+++ b/test/data/bogus.zip
@@ -0,0 +1 @@
+bogus data
diff --git a/test/exceptions.test.js b/test/exceptions.test.js
index 5ac9685..90c8f41 100644
--- a/test/exceptions.test.js
+++ b/test/exceptions.test.js
@@ -1,4 +1,4 @@
-var zipfile = require('zipfile');
+var zipfile = require('..');
 var assert = require('assert');
 
 describe('Exceptions', function(){
diff --git a/test/open.test.js b/test/open.test.js
index c7188c7..7d3aa01 100644
--- a/test/open.test.js
+++ b/test/open.test.js
@@ -1,4 +1,4 @@
-var zipfile = require('zipfile');
+var zipfile = require('..');
 var assert = require('assert');
 
 describe('Opening', function(){
@@ -23,4 +23,12 @@ describe('Opening', function(){
         assert.equal(zf.count, 2);
         assert.deepEqual(zf.names, ['one.txt', 'two.txt']);
     });
+
+    it('test opening invalid archive', function(){
+        // created by doing:
+        // echo 'this is not a zip archive' > test/data/invalid.zip
+        assert.throws(function() { new zipfile.ZipFile('./test/data/invalid.zip'); });
+        // echo 'bogus data' > test/data/bogus.zip
+        assert.throws(function() { new zipfile.ZipFile('./test/data/bogus.zip'); });
+    });
 });
diff --git a/test/unicode.test.js b/test/unicode.test.js
index 3331558..eee465f 100644
--- a/test/unicode.test.js
+++ b/test/unicode.test.js
@@ -1,4 +1,4 @@
-var zipfile = require('zipfile');
+var zipfile = require('..');
 var assert = require('assert');
 var fs = require('fs');
 var existsSync = require('fs').existsSync || require('path').existsSync;
diff --git a/test/write.test.js b/test/write.test.js
index 0cab917..f1ffb68 100644
--- a/test/write.test.js
+++ b/test/write.test.js
@@ -1,4 +1,4 @@
-var zipfile = require('zipfile');
+var zipfile = require('..');
 var assert = require('assert');
 var path = require('path');
 var fs = require('fs');
diff --git a/vcbuild.bat b/vcbuild.bat
index 8723ca6..2d55a27 100644
--- a/vcbuild.bat
+++ b/vcbuild.bat
@@ -1,7 +1,4 @@
 rd /q /s build
-del lib\\node_zipfile.node
-npm install
-copy build\Release\libzip.dll lib
-rem test!
-set NODE_PATH=lib
+rd /q /s lib\\binding
+npm install --build-from-source
 npm test

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/node-zipfile.git



More information about the Pkg-javascript-commits mailing list