# FIXME: Currently broken
# xrc directory not found, hugin needs to be properly installed
# Tried Path:/usr/share/hugin/xrc/
# How does Hugin find the xrc directory on macOS?
# Dear upstream developers, please make apps relocateable
# using relative paths and never take absolute paths like /usr/share
# for granted like in
# hugin_config.h
# #define INSTALL_XRC_DIR "/usr/local/share/hugin/xrc/"

exit 1

APP=Hugin
LOWERAPP=${APP,,}

mkdir -p ./$APP/$APP.AppDir/usr/lib

cd ./$APP/

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

generate_status

echo "deb http://archive.ubuntu.com/ubuntu/ trusty main universe
deb http://ppa.launchpad.net/hugin/hugin-builds/ubuntu trusty main
deb http://ppa.launchpad.net/hugin/nightly/ubuntu trusty main
" > sources.list

apt-get $OPTIONS update

URLS=$(apt-get $OPTIONS -y install --print-uris $LOWERAPP | cut -d "'" -f 2 | grep -e "^http")

wget -c $URLS

cd ./$APP.AppDir/

find ../*.deb -exec dpkg -x {} . \; || true

get_desktop
get_icon
get_apprun

delete_blacklisted

# patch_usr
# Patching only the executable files seems not to be enough for some apps
find usr/ -type f -exec sed -i -e "s|/usr|././|g" {} \;

get_version

get_desktopintegration $LOWERAPP

# Go out of AppImage
cd ..

generate_type2_appimage
