pentoo-overlay/dev-go/go-cve-dictionary/go-cve-dictionary-0.3.1.ebuild

143 lines
4.4 KiB
Bash

# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
EGO_PN="github.com/kotakanbe/go-cve-dictionary"
EGO_VENDOR=(
"github.com/asaskevich/govalidator v9"
"github.com/cheggaaa/pb v2.0.6" # need pb.v2
"github.com/dgrijalva/jwt-go v3.2.0"
"github.com/fatih/color v1.7.0"
"gopkg.in/fatih/color.v1 v1.7.0 github.com/fatih/color"
"github.com/go-redis/redis v6.13.2"
"github.com/go-sql-driver/mysql v1.4.0"
"github.com/go-stack/stack v1.7.0"
"github.com/google/subcommands 5bae204cdfb2d92dcc333d56014bae6a2f6c58b1"
"github.com/hashicorp/go-version v1.2.0"
"github.com/htcat/htcat v1.0.2"
"github.com/inconshreveable/log15 v2.13"
"github.com/jinzhu/gorm v1.9.1"
"github.com/jinzhu/inflection 04140366298a54a039076d798123ffa108fff46c"
"github.com/k0kubun/pp v2.3.0"
"github.com/knqyf263/go-cpe 659663f6eca2ff32258e282557e7808115ea498a"
"github.com/labstack/echo v3.3.5"
"github.com/labstack/gommon 0.2.6"
"github.com/lib/pq 90697d60dd844d5ef6ff15135d0203f65d2f53b8"
"github.com/mattn/go-colorable v0.0.9"
"gopkg.in/mattn/go-colorable.v0 v0.0.9 github.com/mattn/go-colorable"
"github.com/mattn/go-isatty v0.0.3"
"gopkg.in/mattn/go-isatty.v0 v0.0.3 github.com/mattn/go-isatty"
"github.com/mattn/go-runewidth v0.0.2"
"gopkg.in/mattn/go-runewidth.v0 v0.0.2 github.com/mattn/go-runewidth"
"github.com/olekukonko/tablewriter d4647c9c7a84d847478d890b816b7d8b62b0b279"
"github.com/pkg/errors v0.8.0"
"github.com/valyala/bytebufferpool e746df99fe4a3986f4d4f79e13c1e0117ce9c2f7"
"github.com/valyala/fasttemplate dcecefd839c4193db0d35b88ec65b4c12d360ab0"
"gopkg.in/VividCortex/ewma.v1 v1.1.1 github.com/VividCortex/ewma"
"gopkg.in/cheggaaa/pb.v2 v2.0.6 github.com/cheggaaa/pb"
)
inherit golang-vcs-snapshot user
DESCRIPTION="Build a local copy of CVE (NVD and Japanese JVN). Server mode for easy querying"
HOMEPAGE="https://vuls.io/ https://github.com/kotakanbe/go-cve-dictionary"
SRC_URI="https://github.com/kotakanbe/go-cve-dictionary/archive/v${PV}.tar.gz -> ${P}.tar.gz
${EGO_VENDOR_URI}"
KEYWORDS="~amd64"
LICENSE="Apache-2.0"
IUSE="policykit"
SLOT=0
DEPEND="
dev-go/go-sqlite3:=
dev-go/go-crypto:=
>=dev-lang/go-1.12"
RDEPEND="policykit? ( sys-auth/polkit )"
pkg_setup() {
if use policykit; then
enewgroup vuls
enewuser vuls -1 -1 "/var/lib/vuls" vuls
fi
}
src_prepare() {
cp "${FILESDIR}"/go-cve-dictionary.initd "${T}" || die
if ! use policykit; then
sed -e "s/^USER=\"vuls\"/USER=\"root\"/" \
-e "s/^GROUP=\"vuls\"/GROUP=\"root\"/" \
-i "${T}"/go-cve-dictionary.initd || die
fi
default
}
src_compile() {
GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
GOCACHE="${T}/go-cache" \
go build -v -work -x -ldflags="-X main.version=${PV} -s -w" ./... "${EGO_PN}" || die
}
src_install() {
GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
GOCACHE="${T}/go-cache" \
go install -v -work -x -ldflags="-X main.version=${PV} -s -w" ./... "${EGO_PN}" || die
rm -rf "${S}/src/${EGO_PN}/vendor" || die
golang_install_pkgs
exeinto "$(get_golibdir_gopath)"/bin
doexe bin/${PN}
newinitd "${T}"/go-cve-dictionary.initd go-cve-dictionary
newconfd "${FILESDIR}"/go-cve-dictionary.confd go-cve-dictionary
if use policykit; then
insinto "/usr/share/polkit-1/rules.d"
doins "${FILESDIR}"/polkit/10-${PN}.rules
insinto "/usr/share/polkit-1/actions"
doins "${FILESDIR}"/polkit/io.vuls.pkexec.${PN}.policy
dodir "/usr/bin"
cat > "${D}/usr/bin/${PN}" <<-_EOF_ || die
#!/bin/sh
pkexec --user vuls "$(get_golibdir_gopath)/bin/${PN}" "\$@"
_EOF_
fperms 0755 "/usr/bin/${PN}"
else
dosym "$(get_golibdir_gopath)/bin/${PN}" "/usr/bin/${PN}"
fi
keepdir "/var/log/vuls" "/var/lib/vuls"
dodoc src/"${EGO_PN}"/{README.md,Dockerfile}
}
pkg_postinst() {
if use policykit; then
# enewuser is not support "--no-create-home"
chown -R vuls:vuls \
"${EROOT%/}/var/lib/vuls" \
"${EROOT%/}/var/log/vuls" || die
chmod 0750 \
"${EROOT%/}/var/lib/vuls" \
"${EROOT%/}/var/log/vuls" || die
fi
ewarn "\nRun \"go-cve-dictionary\" as server mode before scanning:"
ewarn " ~# rc-service go-cve-dictionary {fetchnvd,fetchjvn,start}\n"
}