#!/usr/bin/bash
git_branch=release
option=$1

if [ "$option" == "clean" ]
then
  rm -R glaxnimate/build
fi

if [ ! -e glaxnimate/.git ]
then
 git clone https://gitlab.com/mattbas/glaxnimate
 cd glaxnimate
 git submodule init
 git submodule update --init --recursive
 git checkout $git_branch
else
 cd glaxnimate
 if [ "$option" == "clean" ]
 then
  rm -R build
 fi
 git pull
 git submodule update --recursive
 git checkout $git_branch
fi
if [ ! -e build ]; then mkdir build; fi
cd build
ver=`git describe --tags`
cmake .. -DCPACK_DEBIAN_FILE_NAME=glaxnimate.deb -DVERSION_SUFFIX="deb-$ver"
make -j8
make translations
cpack -G DEB
sha1sum glaxnimate-$sver.deb >checksum.txt
mv glaxnimate.deb glaxnimate-${ver}_arm64.deb
echo 
