# Copyright 2017 Julian Ospald <hasufell@posteo.de>
# Distributed under the terms of the GNU General Public License v2

require gtk-icon-cache

SUMMARY="Skype for linux"
DESCRIPTION="Skype keeps the world talking, for free.
Skype keeps you together. Call, message and share with others.
 * It's free to download and join.
 * Call, instant message and send photos and documents to anyone else on Skype.
 * Easily text message anywhere in the world.
 * Get your friends together on a group call.
And that's just the start..."
HOMEPAGE="https://www.skype.com"
DOWNLOADS="https://repo.skype.com/deb/pool/main/s/skypeforlinux/${PN}_${PV}_amd64.deb"

LICENCES="Skype-TOS"
SLOT="0"
PLATFORMS="~amd64 -*"
MYOPTIONS=""

DEPENDENCIES="
    run:
        dev-libs/atk
        dev-libs/expat
        dev-libs/glib:2
        dev-libs/libsecret:1
        dev-libs/nspr
        dev-libs/nss
        gnome-platform/GConf:2
        media-libs/fontconfig
        net-print/cups
        sys-apps/dbus
        sys-sound/alsa-lib
        x11-libs/cairo
        x11-libs/gdk-pixbuf:2.0
        x11-libs/gtk+:3
        x11-libs/libX11
        x11-libs/libXScrnSaver
        x11-libs/libXcomposite
        x11-libs/libXcursor
        x11-libs/libXdamage
        x11-libs/libXext
        x11-libs/libXfixes
        x11-libs/libXi
        x11-libs/libXrandr
        x11-libs/libXrender
        x11-libs/libXtst
        x11-libs/libxcb
        x11-libs/libxkbfile
        x11-libs/pango
    suggestion:
        gnome-desktop/gnome-keyring [[
            description = [ Needed for storing credentials to permit auto-login ]
        ]]
"

WORK=${WORKBASE}

pkg_setup() {
    exdirectory --allow /opt
}

src_unpack() {
    default
    unpack ./data.tar.xz
}

src_install() {
    # shared data files
    insinto /usr/share
    doins -r usr/share/{applications,icons,pixmaps}

    # bundled binary/libs and data
    insinto /opt/${PN}/share
    doins -r usr/share/${PN}
    edo chmod +x "${IMAGE}"/opt/${PN}/share/${PN}/${PN}
    # start script, preserve without patching
    exeinto /opt/${PN}/bin
    doexe usr/bin/${PN}

    # link to /usr/bin
    dodir /usr/$(exhost --target)/bin
    edo ln -s ../../../opt/${PN}/bin/${PN} \
        "${IMAGE}"/usr/$(exhost --target)/bin/${PN}
}