summaryrefslogtreecommitdiff
path: root/sys-process/atop/atop-2.12.1.ebuild
blob: a49caf19bb4426ce753ebd7d30f0e57564cb2ae3 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

# Check on bumps of atop
# https://www.atoptool.nl/downloadnetatop.php
NETATOP_VER=3.2.2

# Controls 'netatop' kernel module
MODULES_OPTIONAL_IUSE="modules"
NETATOP_P=netatop-${NETATOP_VER}
NETATOP_S="${WORKDIR}"/${NETATOP_P}

PYTHON_COMPAT=( python3_{13..14} )

inherit linux-mod-r1 python-single-r1 systemd toolchain-funcs flag-o-matic

DESCRIPTION="Resource-specific view of processes"
HOMEPAGE="https://www.atoptool.nl/ https://github.com/Atoptool/atop"
SRC_URI="
	https://www.atoptool.nl/download/${P}.tar.gz
	modules? ( https://www.atoptool.nl/download/${NETATOP_P}.tar.gz )
"

# Module is GPL-2 as well
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~alpha amd64 ~arm arm64 ~hppa ~mips ppc ~ppc64 ~riscv x86"
IUSE="video_cards_nvidia"
REQUIRED_USE="${PYTHON_REQUIRED_USE}"

RDEPEND="
	dev-libs/glib
	sys-libs/ncurses:=
	virtual/zlib:=
	>=sys-process/acct-6.6.4-r1
	video_cards_nvidia? (
		${PYTHON_DEPS}
		$(python_gen_cond_dep '
			dev-python/nvidia-ml-py[${PYTHON_USEDEP}]
		')
	)
"
DEPEND="${RDEPEND}"
BDEPEND="virtual/pkgconfig"

PATCHES=(
	"${FILESDIR}"/${PN}-2.11.0-build.patch
	"${FILESDIR}"/${PN}-2.12.0-respect-opt.patch
	"${FILESDIR}"/${PN}-2.12.0-atopgpud.patch
)

pkg_setup() {
	if use modules; then
		linux-mod-r1_pkg_setup
	fi

	if use video_cards_nvidia ; then
		python-single-r1_pkg_setup
	fi
}

pkg_pretend() {
	if use kernel_linux ; then
		CONFIG_CHECK="~BSD_PROCESS_ACCT"
		check_extra_config
	fi
}

src_prepare() {
	append-cflags -std=gnu17 # bug #945250
	default

	if use modules ; then
		cd "${WORKDIR}"/${NETATOP_P} || die
		eapply "${FILESDIR}/netatop-3.2.2-strict-prototype.patch"

		sed \
			-e "s#\`uname -r\`#${KV_FULL}#g" \
			-e "s#\$(shell uname -r)#${KV_FULL}#g" \
			-i Makefile || die

		grep -rq "uname -r" && die "found uname calls"

		cd "${S}" || die
	fi

	tc-export CC PKG_CONFIG

	# bug #191926
	sed -i 's: root : :' atop.cronsysv || die

	# Prefixify
	sed -i "s:/\(usr\|etc\|var\):${EPREFIX}/\1:g" Makefile || die
}

src_compile() {
	default

	local modlist=( "netatop=:../${NETATOP_P}::netatop.ko" )
	linux-mod-r1_src_compile

	if use modules ; then
		# Don't let the Makefile try to build the module for us
		emake -C "${NETATOP_S}" netatopd
	fi
}

src_install() {
	linux-mod-r1_src_install

	if use modules ; then
		dosbin "${NETATOP_S}"/netatopd
		doman "${NETATOP_S}"/man/*

		systemd_dounit "${NETATOP_S}"/netatop.service

		newinitd "${NETATOP_S}"/netatop.rc netatop
	fi

	emake DESTDIR="${D}" genericinstall

	if use video_cards_nvidia ; then
		systemd_dounit "${S}"/atopgpu.service

		newinitd "${FILESDIR}"/atopgpud.initd atopgpud

		python_fix_shebang "${ED}/usr/sbin/atopgpud"
	else
		rm "${ED}"/usr/sbin/atopgpud || die
	fi

	# useless -${PV} copies ?
	rm "${ED}"/usr/bin/atop*-${PV} || die

	newinitd atop.rc.openrc ${PN}
	newinitd atopacct.rc.openrc atopacct

	systemd_dounit "${S}"/${PN}.service
	systemd_dounit "${S}"/atopacct.service

	dodoc atop.cronsysv AUTHORS README

	exeinto /usr/share/${PN}
	doexe ${PN}.daily

	insinto /etc/default
	newins ${PN}{.default,}

	keepdir /var/log/${PN}
}