summaryrefslogtreecommitdiff
blob: 00364313d593812ad6f146d62610a5ceaa88de9a (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit tmpfiles toolchain-funcs

DESCRIPTION="simple Mode S decoder for RTLSDR devices"
HOMEPAGE="https://github.com/flightaware/dump1090"

if [[ ${PV} == *9999 ]] ; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/flightaware/${PN}.git"
else
	KEYWORDS="amd64 x86"
	SRC_URI="https://github.com/flightaware/dump1090/archive/v${PV}.tar.gz -> ${P}.tar.gz"
fi

LICENSE="BSD"
SLOT="0"
IUSE="bladerf hackrf +rtlsdr minimal"

DEPEND="
	sys-libs/ncurses:=[tinfo]
	bladerf? ( net-wireless/bladerf:= virtual/libusb:1 )
	hackrf? ( net-libs/libhackrf:= virtual/libusb:1 )
	rtlsdr? ( net-wireless/rtl-sdr:= virtual/libusb:1 )"
RDEPEND="${DEPEND}"
BDEPEND="virtual/pkgconfig"

PATCHES=(
	"${FILESDIR}/${P}-32bit-fix.patch"
	"${FILESDIR}/${P}-further-32bit-fix.patch"
)

src_prepare() {
	default
	sed -i -e '/CFLAGS/s# -O3 -g -Wall -Wmissing-declarations -Werror -W # #' Makefile || die
	sed -i -e "/LIBS_CURSES/s#-lncurses#$($(tc-getPKG_CONFIG) --libs ncurses)#" Makefile || die
}

src_compile() {
	emake CC="$(tc-getCC)" \
		BLADERF=$(usex bladerf) \
		RTLSDR=$(usex rtlsdr) \
		HACKRF=$(usex hackrf) \
		CPUFEATURES=yes \
		LIMESDR=no
}

src_install() {
	dobin ${PN}
	dobin view1090
	dodoc README.md README-json.md
	# DSP config for bladerf
	if use bladerf; then
		insinto usr/share/${PN}/bladerf
		doins bladerf/*
	fi

	newtmpfiles "${FILESDIR}"/tmpfilesd-dump1090-5.0.conf ${PN}.conf
	newconfd "${FILESDIR}"/dump1090-5.0.confd ${PN}
	newinitd "${FILESDIR}"/dump1090-5.0.initd ${PN}

	if use !minimal; then
		insinto /usr/share/${PN}
		doins -r tools

		# Some tooling expects the -fa variant directory to contain the files
		dosym ../../usr/share/${PN} /usr/share/dump1090-fa

		# Older HTML
		insinto /usr/share/${PN}/html
		doins -r public_html/*
		# Newer HTML
		insinto /usr/share/skyaware/html
		doins -r public_html_merged/*

		# One of these this should be included into other lighttpd configs
		insinto /usr/share/${PN}/lighttpd
		# Old style:
		doins debian/lighttpd/89-dump1090-fa.conf
		doins debian/lighttpd/88-dump1090-fa-statcache.conf
		# New style:
		doins debian/lighttpd/89-skyaware.conf

		# See README.md for how to use custom wisdom files
		exeinto /usr/share/${PN}/wisdom
		doexe debian/generate-wisdom
		insinto /usr/share/${PN}/wisdom
		doins wisdom.*
		doins wisdom/wisdom.*
		# For /etc/dump1090-fa/wisdom.local
		keepdir /etc/dump1090-fa/

		# Tooling to generate custom wisdom:
		exeinto /usr/libexec/${PN}
		doexe starch-benchmark
	fi
}

pkg_postinst() {
	tmpfiles_process ${PN}.conf
}