#!/usr/bin/env bash
name='lynx'
release='1'
version='2.8.9'
_relver=${version}rel.1
url='https://lynx.invisible-island.net/'
description='A text browser for the World Wide Web'
email='akarsu@protonmail.com'
maintainer='akarsu'
license=('GPL')
source=("https://invisible-mirror.net/archives/lynx/tarballs/lynx$_relver.tar.bz2"
        'CVE-2021-38165.diff')
depends=(libidn2 ncurses openssl)
makedepends=()
md5sums=('44316f1b8a857b59099927edc26bef79' 'SKIP')
group=(www.client)
uses=()
arch=('x86_64')

cd $name$_relver

patch --forward --strip=1 --input="./CVE-2021-38165.diff"

setup(){
    ./configure --prefix=/usr \
        --libdir=/usr/lib64/ \
        --sysconfdir=/etc \
        --with-ssl=/usr \
        --enable-nls \
        --enable-ipv6
}

build(){
    make $jobs
}

package(){
    make DESTDIR="$DESTDIR" install $jobs
    sed -i -e "s|^HELPFILE.*$|HELPFILE:file:///usr/share/doc/lynx/lynx_help/lynx_help_main.html|" "${DESTDIR}/etc/lynx.cfg"

    install -d "${DESTDIR}/usr/share/doc/lynx"
    cp -rf lynx_help "${DESTDIR}/usr/share/doc/lynx"
}

