summaryrefslogtreecommitdiff
blob: aa7debe0b5912116f4969893511f474bd295581d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

DESCRIPTION="Daemon protecting your computer against BadUSB"
HOMEPAGE="https://github.com/USBGuard/usbguard"
SRC_URI="https://github.com/USBGuard/usbguard/releases/download/${P}/${P}.tar.gz"

LICENSE="GPL-2+"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="bash-completion dbus ldap policykit systemd"

REQUIRED_USE="policykit? ( dbus )"

CDEPEND="
	dev-libs/pegtl
	>=dev-libs/libsodium-0.4.5:=
	>=dev-libs/protobuf-2.5.0:=
	>=sys-cluster/libqb-0.16.0:=
	sys-devel/gcc:*[cxx]
	>=sys-libs/libcap-ng-0.7.0
	>=sys-libs/libseccomp-2.0.0
	>=sys-process/audit-2.7.7
	bash-completion? ( >=app-shells/bash-completion-2.0 )
	dbus? (
		>=dev-libs/dbus-glib-0.100
		dev-libs/glib:2
		sys-apps/dbus
		policykit? ( sys-auth/polkit[introspection] )
	)
	ldap? ( net-nds/openldap )
	systemd? ( sys-apps/systemd )
	"
RDEPEND="${CDEPEND}
	virtual/udev
	"
DEPEND="${CDEPEND}
	app-text/asciidoc
	dev-cpp/catch:1
	dbus? (
		dev-libs/libxml2
		dev-libs/libxslt
		dev-util/gdbus-codegen
	)
	"

src_configure() {
	local myargs=(
		$(use_with dbus)
		$(use_with ldap)
		$(use_with policykit polkit)
		$(use_enable systemd)
	)

	econf "${myargs[@]}"
}

src_install() {
	default

	keepdir /var/lib/log/usbguard

	newinitd "${FILESDIR}"/${P}-usbguard.openrc usbguard
	use dbus && newinitd "${FILESDIR}"/${P}-usbguard-dbus.openrc usbguard-dbus
}

pkg_postinst() {
	ewarn
	ewarn 'BEFORE STARTING USBGUARD please be sure to create/generate'
	ewarn '                         a rules file at /etc/usbguard/rules.conf'
	ewarn '                         so that you do not'
	ewarn '                                            GET LOCKED OUT'
	ewarn "                         of this system (\"$(hostname)\")."
	ewarn
	ewarn 'This command may be of help:'
	ewarn '  sudo sh -c "usbguard generate-policy > /etc/usbguard/rules.conf"'
	ewarn
}