wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh
. ./functions.sh

TITLE=Gitg
APP=${TITLE,,}

sudo add-apt-repository -y ppa:thomir/gitg
sudo apt-get update

sudo apt-get -y install $APP

mkdir -p $APP/$APP.AppDir
cd $APP/$APP.AppDir
find /var/cache/apt/archives/*$APP* -exec dpkg -x {} . \; || true

# Copy in the indirect dependencies
copy_deps ; copy_deps ; copy_deps # Three runs to ensure we catch indirect ones

cp ./usr/share/applications/$LOWERAPP.desktop .
cp ./usr/share/icons/hicolor/128x128/apps/$LOWERAPP.png .
rm -rf ./usr/share/icons/hicolor/48x48/

patch_usr

get_apprun

delete_blacklisted

VERSION=$(ls /var/cache/apt/archives/gitg_* | cut -d "_" -f 2 | cut -d "-" -f 1 | cut -d "+" -f 1 )
echo $VERSION

get_desktopintegration $LOWERAPP

# Go out of AppImage
cd ..

generate_appimage
