#!/bin/sh -x
rm -rf sinopia
git clone https://github.com/rlidwka/sinopia.git
rm -f sinopia/npm-shrinkwrap.json
patch -p0 <sinopia.patch
( cd sinopia; NODE=node4 npm install )
rm -rf sinopia/node_modules/crypt3/build
rm -rf sinopia/node_modules/fs-ext/build
rm -rf sinopia/node_modules/dtrace-provider/build
version=`grep '"version":' sinopia/package.json | tail -1 | sed -e 's;.*: ";;' -e 's;".*;;'`
date=`date '+%Y%m%d'`
tar cvf - --exclude .git sinopia | xz -9 >sinopia-$version-$date.tar.xz
rm -rf sinopia
