description="Library for accessing ssh client services through C libraries"
url="https://www.libssh.org/"

packager="Spiky <spiky@nutyx.org>"
contributors="Greg,Tnut,Spiky"

makedepends=(libgcrypt zlib cmake cmocka doxygen openssl zlib)

name=libssh
version=0.10.4

source=($url/files/${version%.*}/$name-$version.tar.xz)

prepare() {
sed 's/cmocka_unit_test(torture_path_expand_tilde_unix),//' \
    -i libssh-${version}/tests/unittests/torture_misc.c
mkdir -pv build
}

build() {
cd build

cmake ../$name-$version \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DWITH_GSSAPI=OFF \
-DWITH_GCRYPT=ON \
-DWITH_TESTING=ON

make
make DESTDIR=$PKG install
}

uptodate() {
local url ext
url="https://www.libssh.org/files/"
ext=".tar.xz"
latest="`lynx -read_timeout=20 -dump -listonly -nonumbers \
$url?C=M\;O=D|grep [0-9]/$|head -1`"

lynx -read_timeout=20 -dump -listonly -nonumbers \
$latest?C=M\;O=A|grep $name-[0-9]|grep [0-9]$ext$| \
sed "s@$latest$name-@@"|sed "s@$ext@@"|tail -1
}
