#!/bin/sh
#version=$(rpm -q --specfile --qf='%{version}\n' gateway.spec | head -n1)
version=0.6.1
wget https://github.com/mozilla-iot/gateway/archive/v$version.tar.gz
tar zxf v$version.tar.gz
cd gateway-$version
## Download npm libraries
yarnpkg --ignore-optional
## Clean out binary modules (and deps) and link to rpm packages
rm -rf node_modules/{bindings,nan,nanomsg,sqlite3}
ln -s /usr/lib/node_modules/{bindings,nan,nanomsg,sqlite3} node_modules/
rm -rf node_modules/gateway-addon/node_modules/{nan,sqlite3}
ln -s /usr/lib/node_modules/{nan,sqlite3} node_modules/gateway-addon/node_modules/
PATH="/usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:$PWD/node_modules/.bin:/usr/lib/node_modules/.bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin"
webpack
cd ..
tar cfz gateway-v$version.tar.gz gateway-$version
