--- /dev/null
+#! /bin/sh -xe
+
+if [ -d NOW ]; then
+ echo "NOW directory already exists"
+else
+ git clone https://github.com/CESNET/NOW/
+fi
+
+tag=`cd NOW; git rev-parse HEAD`
+short=`echo ${tag} | cut -c 1-7`
+v=`cd NOW; ruby -r./version.rb -e 'print Now::VERSION'`
+rel=0.`cd NOW; git show --format='format:%ai' HEAD | head -n 1 | cut -f1 -d' ' | sed 's/-//g'`git${short}
+
+rm -rf NOW-${tag}/
+cp -a NOW/ NOW-${tag}/
+tar --exclude .git -cf - NOW-${tag}/ | pigz --best > NOW-${short}.tar.gz
+rm -rf NOW-${tag}/
+cp -vp NOW-${short}.tar.gz NOW.conf ~/rpmbuild/SOURCES/
+
+sed -i \
+ -e "s/\(%global commit0 \+\).*/\1${tag}/" \
+ -e "s/\(Version: \+\).*/\1${v}/" \
+ -e "s/\(Release: \+\).*/\1${rel}/" \
+ NOW.spec
+
+rpmbuild -bs --nodeps NOW.spec