# Obarun        : 66 init/supervisor
# Maintainer    : Eric Vidal <eric@obarun.org>
# Maintainer    : Jean-Michel T.Dydak <jean-michel@obarun.org>
# Maintainer    : YianIris <yianiris At disroot Dot org>
# Obarun PkgSrc : https://git.obarun.org/pkg/obextra/vte3
#----------------
#--------------------------------------------------------------
# DESCRIPTION ]

pkgbase=vte3
pkgver=0.66.2
pkgrel=2
pkgdesc='Virtual Terminal Emulator widget'

pkgname=(
    'vte3'
    'vte-common'
)

url='https://wiki.gnome.org/Apps/Terminal/VTE'

track=commit
target=6a0a9fed4d54122df31c13d601b1509597a36f2b  # tags/0.66.2^0
source=(
    git+https://gitlab.gnome.org/GNOME/vte.git#$track=$target
)

#----------------------
# BUILD CONFIGURATION ]

makedepends=(
    'gobject-introspection'
    'vala'
    'git'
    'gperf'
    'meson'
)

#------------------------
# INSTALL CONFIGURATION ]

depends=(
    'gtk3'
    'pcre2'
    'gnutls'
    'fribidi'
)

#--------------------
# BUILD PREPARATION ]

pkgver() {
    cd vte
    git describe --tags | sed 's/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
    cd vte
}

#----------------
# BUILD CONTROL ]

_flags=(
    -Ddocs=true
    -Db_lto=false
    -D_systemd=false
)

#--------
# BUILD ]

build() {
    arch-meson vte build "${_flags[@]}"
    meson compile -C build
}

#--------
# CHECK ]

check() {
    meson test -C build --print-errorlogs
}

#----------
# PACKAGE ]

_pick() {
    local p="$1" f d; shift
    for f; do
        d="$srcdir/$p/${f#$pkgdir/}"
        mkdir -p "$(dirname "$d")"
        mv "$f" "$d"
        rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
    done
}

package_vte3() {
    depends+=(
        'vte-common'
    )
    provides+=(
        'libvte-2.91.so'
    )

    meson install -C build --destdir "$pkgdir"

    ### Split vte-common
    _pick vte-common "$pkgdir"/etc/profile.d
    _pick vte-common "$pkgdir"/usr/lib/vte-urlencode-cwd
}

package_vte-common() {
    pkgdesc='Files shared by VTE libraries'

    depends=(
        'sh'
    )

    mv vte-common/* "$pkgdir"
}

#-------------------------
# LICENCE AND VALIDATION ]

arch=(x86_64)
license=(LGPL)

sha512sums=(' ')
