#!/bin/bash

echo
echo
echo "Cleaning up files..."
echo

./cleanup-junk

echo
echo
echo "Copying latest dev build..."
echo

#Copy across latest dev build

  #########################################################################
 ####  Change "~/Labrador-master" to your Labrador GitHub directory.  ####
#########################################################################
cp ~/Labrador-master/Desktop_Interface/bin/Labrador Labrador
cp -r ~/Labrador-master/Desktop_Interface/bin/waveforms waveforms
cp -r ~/Labrador-master/Desktop_Interface/bin/firmware firmware

echo
echo
echo "Running linuxdeployqt..."
echo

#Linuxdeployqt
export PATH=$PWD/labradeb/usr/lib:$PATH
./linuxdeployqt* Labrador -qmake=/usr/bin/qmake

echo
echo
echo "Moving linuxdeployqt files..."
echo

#Move to LABRADEPLOY directory
mkdir LABRADEPLOY
mv lib LABRADEPLOY
mv plugins LABRADEPLOY
mv translations LABRADEPLOY
mv qt.conf LABRADEPLOY
mv Labrador LABRADEPLOY
mv waveforms LABRADEPLOY
mv firmware LABRADEPLOY

#Clean up unwanted shortcut
rm AppRun

echo
echo
echo "Building .deb..."
echo

#Replace old folder in deb
rm -r labradeb/usr/share/espotek/labrador
cp -r LABRADEPLOY labradeb/usr/share/espotek/labrador

#build the deb.
dpkg-deb --build labradeb

echo
echo
echo "Final cleanup..."
echo

./cleanup-junk

#install the new deb
#./labradeb-install

