# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="All exploits from exploit-db.com"
HOMEPAGE="https://www.exploit-db.com/"

if [[ ${PV} != *9999 ]]; then
	EGIT_COMMIT="${PV:0:4}-${PV:4:2}-${PV:6:2}"
	SRC_URI="https://gitlab.com/exploit-database/exploitdb/-/archive/${EGIT_COMMIT}/exploitdb-${EGIT_COMMIT}.tar.bz2 -> ${P}.tar.bz2"
	S="${WORKDIR}/${PN}-${EGIT_COMMIT}"
	KEYWORDS="amd64 x86"
else
	EGIT_REPO_URI="https://gitlab.com/exploit-database/exploitdb.git"
	inherit git-r3
fi

LICENSE="GPL-2"
SLOT="0"
IUSE="doc"

RDEPEND="
	doc? ( app-exploits/exploitdb-papers )
	dev-libs/libxml2:2
	app-alternatives/awk
	x11-misc/xclip"

PATCHES=( "${FILESDIR}"/disable-update2.patch )

src_install() {
	insinto "/etc"
	doins "${FILESDIR}"/searchsploit_rc

	insinto "/usr/share/${PN}"
	doins -r *

	fperms +x "/usr/share/${PN}/searchsploit"
	dosym "../share/${PN}/searchsploit" "/usr/bin/searchsploit"
}