#!/bin/bash

USER=evilsocket
PROJECT=opensnitch
RELEASE=$(curl -s https://api.github.com/repos/${USER}/${PROJECT}/releases/latest | grep tarball_url | cut -d '"' -f 4 | awk -F "/" {'print $8'})

RSS_FEED="https://github.com/${USER}/${PROJECT}/releases.atom"
# xdg-open ${RSS_FEED}
echo ${RSS_FEED}

WORKDIR=/var/tmp/build_opensnitch
mkdir -p ${WORKDIR} && cd ${WORKDIR}

REPO=git://git@github.com/evilsocket/opensnitch.git
REPO=https://github.com/evilsocket/opensnitch.git
echo "Release verion is: ${RELEASE}"
#git clone -b ${RELEASE} ${REPO}
#git clone --no-checkout -o upstream ${REPO}
gbp clone ${REPO}
cd opensnitch
git checkout -b ${RELEASE}
gbp export-orig

DIST=$(lsb_release --short --codename)
ARCH=$(dpkg --print-architecture)
#DIST=ascii ARCH=amd64 git-pbuilder create
DIST=${DIST} ARCH=${ARCH} git-pbuilder update

gbp buildpackage \
	--git-pbuilder \
	--git-arch=${ARCH} \
	--git-dist=${DIST} \
	--git-upstream-tree=TAG \
	--git-upstream-tag='v%(version)s' \
	--git-ignore-branch
