Diff clamav-0.103.10 with a clamav-1.0.3

/usr/portage/app-antivirus/clamav/clamav-1.0.3.ebuild 2023-10-09 14:52:28.176368317 +0300
3 3

  
4 4
EAPI=8
5 5

  
6
inherit autotools flag-o-matic systemd tmpfiles
6
LLVM_MAX_SLOT=13
7
PYTHON_COMPAT=( python3_{10..12} )
8

  
9
# Auto-Generated by cargo-ebuild 0.5.4-r1
10
CRATES="
11
	adler@1.0.2
12
	ansi_term@0.12.1
13
	atty@0.2.14
14
	autocfg@1.1.0
15
	bindgen@0.65.1
16
	bit_field@0.10.1
17
	bitflags@1.3.2
18
	block-buffer@0.10.3
19
	bumpalo@3.12.0
20
	bytemuck@1.13.0
21
	byteorder@1.4.3
22
	cbindgen@0.20.0
23
	cexpr@0.6.0
24
	cfg-if@1.0.0
25
	clang-sys@1.4.0
26
	clap@2.34.0
27
	color_quant@1.1.0
28
	cpufeatures@0.2.5
29
	crc32fast@1.3.2
30
	crossbeam-channel@0.5.6
31
	crossbeam-deque@0.8.2
32
	crossbeam-epoch@0.9.13
33
	crossbeam-utils@0.8.14
34
	crunchy@0.2.2
35
	crypto-common@0.1.6
36
	digest@0.10.6
37
	either@1.8.1
38
	exr@1.5.3
39
	fastrand@1.8.0
40
	flate2@1.0.25
41
	flume@0.10.14
42
	futures-core@0.3.26
43
	futures-sink@0.3.26
44
	generic-array@0.14.6
45
	getrandom@0.2.8
46
	gif@0.11.4
47
	glob@0.3.1
48
	half@2.2.1
49
	hashbrown@0.12.3
50
	heck@0.3.3
51
	hermit-abi@0.1.19
52
	hermit-abi@0.2.6
53
	hex@0.4.3
54
	image@0.24.5
55
	indexmap@1.9.2
56
	instant@0.1.12
57
	itoa@1.0.5
58
	jpeg-decoder@0.3.0
59
	js-sys@0.3.61
60
	lazy_static@1.4.0
61
	lazycell@1.3.0
62
	lebe@0.5.2
63
	libc@0.2.139
64
	libloading@0.7.4
65
	lock_api@0.4.9
66
	log@0.4.17
67
	memchr@2.5.0
68
	memoffset@0.7.1
69
	minimal-lexical@0.2.1
70
	miniz_oxide@0.6.2
71
	nanorand@0.7.0
72
	nom@7.1.3
73
	num-complex@0.4.3
74
	num-integer@0.1.45
75
	num-rational@0.4.1
76
	num-traits@0.2.15
77
	num_cpus@1.15.0
78
	once_cell@1.17.0
79
	peeking_take_while@0.1.2
80
	pin-project@1.0.12
81
	pin-project-internal@1.0.12
82
	png@0.17.7
83
	prettyplease@0.2.4
84
	primal-check@0.3.3
85
	proc-macro2@1.0.66
86
	quote@1.0.26
87
	rayon@1.6.1
88
	rayon-core@1.10.2
89
	redox_syscall@0.2.16
90
	regex@1.7.1
91
	regex-syntax@0.6.28
92
	remove_dir_all@0.5.3
93
	rustc-hash@1.1.0
94
	rustdct@0.7.1
95
	rustfft@6.1.0
96
	ryu@1.0.12
97
	scoped_threadpool@0.1.9
98
	scopeguard@1.1.0
99
	serde@1.0.152
100
	serde_derive@1.0.152
101
	serde_json@1.0.93
102
	sha2@0.10.6
103
	shlex@1.1.0
104
	simd-adler32@0.3.4
105
	smallvec@1.10.0
106
	spin@0.9.5
107
	strength_reduce@0.2.4
108
	strsim@0.8.0
109
	syn@1.0.107
110
	syn@2.0.15
111
	tempfile@3.3.0
112
	textwrap@0.11.0
113
	thiserror@1.0.38
114
	thiserror-impl@1.0.38
115
	threadpool@1.8.1
116
	tiff@0.8.1
117
	toml@0.5.11
118
	transpose@0.2.2
119
	typenum@1.16.0
120
	unicode-ident@1.0.6
121
	unicode-segmentation@1.10.1
122
	unicode-width@0.1.10
123
	vec_map@0.8.2
124
	version_check@0.9.4
125
	wasi@0.11.0+wasi-snapshot-preview1
126
	wasm-bindgen@0.2.84
127
	wasm-bindgen-backend@0.2.84
128
	wasm-bindgen-macro@0.2.84
129
	wasm-bindgen-macro-support@0.2.84
130
	wasm-bindgen-shared@0.2.84
131
	weezl@0.1.7
132
	which@4.4.0
133
	winapi@0.3.9
134
	winapi-i686-pc-windows-gnu@0.4.0
135
	winapi-x86_64-pc-windows-gnu@0.4.0
136
	zune-inflate@0.2.42
137
"
138

  
139
inherit cargo cmake flag-o-matic llvm python-any-r1 systemd tmpfiles
140

  
141
MY_P=${P//_/-}
7 142

  
8 143
DESCRIPTION="Clam Anti-Virus Scanner"
9 144
HOMEPAGE="https://www.clamav.net/"
10
SRC_URI="https://www.clamav.net/downloads/production/${P}.tar.gz"
145
SRC_URI="https://github.com/Cisco-Talos/clamav/archive/refs/tags/${MY_P}.tar.gz
146
	${CARGO_CRATE_URIS}"
147
S=${WORKDIR}/clamav-${MY_P}
11 148

  
12
LICENSE="GPL-2 unRAR"
149
LICENSE="Apache-2.0 BSD GPL-2 ISC MIT MPL-2.0 Unicode-DFS-2016 ZLIB"
13 150
SLOT="0/lts"
14
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos"
15
IUSE="bzip2 doc clamonacc clamdtop clamsubmit iconv ipv6 libclamav-only milter metadata-analysis-api selinux systemd test xml"
16

  
17
REQUIRED_USE="libclamav-only? ( !clamonacc !clamdtop !clamsubmit !milter !metadata-analysis-api )"
151
if [[ ${PV} != *_rc* ]] ; then
152
	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos"
153
fi
154

  
155
IUSE="doc clamonacc +clamapp experimental jit libclamav-only milter rar selinux +system-mspack systemd test"
156

  
157
REQUIRED_USE="libclamav-only? ( !clamonacc !clamapp !milter )
158
	clamonacc? ( clamapp )
159
	milter? ( clamapp )
160
	test? ( !libclamav-only )"
18 161

  
19 162
RESTRICT="!test? ( test )"
20 163

  
21 164
# Require acct-{user,group}/clamav at build time so that we can set
22 165
# the permissions on /var/lib/clamav in src_install rather than in
23 166
# pkg_postinst; calling "chown" on the live filesystem scares me.
24
CDEPEND="acct-group/clamav
167
COMMON_DEPEND="
168
	acct-group/clamav
25 169
	acct-user/clamav
170
	app-arch/bzip2
171
	dev-libs/json-c:=
26 172
	dev-libs/libltdl
27
	dev-libs/libmspack
28
	|| ( dev-libs/libpcre2 >dev-libs/libpcre-6 )
29
	dev-libs/tomsfastmath
173
	dev-libs/libpcre2:=
174
	dev-libs/libxml2
175
	dev-libs/openssl:=
30 176
	>=sys-libs/zlib-1.2.2:=
31
	bzip2? ( app-arch/bzip2 )
32
	clamdtop? ( sys-libs/ncurses:0 )
33
	clamsubmit? ( net-misc/curl dev-libs/json-c:= )
34
	elibc_musl? ( sys-libs/fts-standalone )
35
	iconv? ( virtual/libiconv )
177
	virtual/libiconv
36 178
	!libclamav-only? ( net-misc/curl )
37
	dev-libs/openssl:0=
179
	clamapp? ( sys-libs/ncurses:= net-misc/curl )
180
	elibc_musl? ( sys-libs/fts-standalone )
181
	jit? ( <sys-devel/llvm-$((${LLVM_MAX_SLOT} + 1)):= )
38 182
	milter? ( mail-filter/libmilter:= )
39
	xml? ( dev-libs/libxml2 )"
40

  
41
# We need at least autoconf-2.69-r5 because that's the first (patched)
42
# version of it in Gentoo that supports ./configure --runstatedir.
43
BDEPEND=">=sys-devel/autoconf-2.69-r5
44
	virtual/pkgconfig"
183
	rar? ( app-arch/unrar )
184
	system-mspack? ( dev-libs/libmspack )
185
	test? ( dev-python/pytest )
186
"
187

  
188
# rust-bin < 1.71 has an executable stack
189
# which is not supported on selinux #911589
190
BDEPEND="
191
	virtual/pkgconfig
192
	>=virtual/rust-1.71
193
	doc? ( app-doc/doxygen )
194
	test? (
195
		${PYTHON_DEPS}
196
		$(python_gen_any_dep 'dev-python/pytest[${PYTHON_USEDEP}]')
197
	)
198
"
45 199

  
46
DEPEND="${CDEPEND}
47
	metadata-analysis-api? ( dev-libs/json-c:* )
200
DEPEND="${COMMON_DEPEND}
48 201
	test? ( dev-libs/check )"
49
RDEPEND="${CDEPEND}
202

  
203
RDEPEND="${COMMON_DEPEND}
50 204
	selinux? ( sec-policy/selinux-clamav )"
51 205

  
52
PATCHES=(
53
	"${FILESDIR}/${PN}-0.102.1-libxml2_pkgconfig.patch" #661328
54
	"${FILESDIR}/${PN}-0.102.2-fix-curl-detection.patch" #709616
55
	"${FILESDIR}/${PN}-0.103.0-system-tomsfastmath.patch" # 649394
56
	"${FILESDIR}/${PN}-0.103.1-upstream-openrc.patch"
57
)
58

  
59
src_prepare() {
60
	default
61

  
62
	# Be extra sure that we're using the system copy of tomsfastmath
63
	einfo "removing bundled copy of dev-libs/tomsfastmath"
64
	rm -r libclamav/tomsfastmath || \
65
		die "failed to remove bundled tomsfastmath"
206
python_check_deps() {
207
	python_has_version -b "dev-python/pytest[${PYTHON_USEDEP}]"
208
}
66 209

  
67
	AT_NO_RECURSIVE="yes" eautoreconf
210
pkg_setup() {
211
	use jit && llvm_pkg_setup
212
	use test && python-any-r1_pkg_setup
68 213
}
69 214

  
70 215
src_configure() {
71 216
	use elibc_musl && append-ldflags -lfts
72 217
	use ppc64 && append-flags -mminimal-toc
73 218

  
74
	# according to configure help it should be
75
	# $(use_enable xml)
76
	# but that does not work
77
	# do not add this, since --disable-xml seems to override
78
	# --without-xml
79
	JSONUSE="--without-libjson"
80

  
81
	if use clamsubmit || use metadata-analysis-api; then
82
		# either of those 2 requires libjson.
83
		# clamsubmit will be built as soon as libjson and curl are found
84
		# but we only install the binary if requested
85
		JSONUSE="--with-libjson=${EPREFIX}/usr"
86
	fi
87

  
88
	local myeconfargs=(
89
		$(use_enable bzip2)
90
		$(use_enable clamonacc)
91
		$(use_enable clamdtop)
92
		$(use_enable ipv6)
93
		$(use_enable milter)
94
		$(use_enable test check)
95
		$(use_with xml)
96
		$(use_with iconv)
97
		${JSONUSE}
98
		$(use_enable libclamav-only)
99
		$(use_with !libclamav-only libcurl)
100
		--with-system-libmspack
101
		--cache-file="${S}"/config.cache
102
		--disable-experimental
103
		--disable-static
104
		--disable-zlib-vcheck
105
		--enable-id-check
106
		--with-dbdir="${EPREFIX}"/var/lib/clamav
107
		# Don't call --with-zlib=/usr (see bug #699296)
108
		--with-zlib
109
		--disable-llvm
110
		--enable-openrc
111
		--runstatedir=/run
219
	local mycmakeargs=(
220
		-DAPP_CONFIG_DIRECTORY="${EPREFIX}"/etc/clamav
221
		-DBYTECODE_RUNTIME=$(usex jit llvm interpreter)
222
		-DCLAMAV_GROUP="clamav"
223
		-DCLAMAV_USER="clamav"
224
		-DDATABASE_DIRECTORY="${EPREFIX}"/var/lib/clamav
225
		-DENABLE_APP=$(usex clamapp ON OFF)
226
		-DENABLE_CLAMONACC=$(usex clamonacc ON OFF)
227
		-DENABLE_DOXYGEN=$(usex doc)
228
		-DENABLE_EXPERIMENTAL=$(usex experimental ON OFF)
229
		-DENABLE_EXTERNAL_MSPACK=$(usex system-mspack ON OFF)
230
		-DENABLE_JSON_SHARED=ON
231
		-DENABLE_MAN_PAGES=ON
232
		-DENABLE_MILTER=$(usex milter ON OFF)
233
		-DENABLE_SHARED_LIB=ON
234
		-DENABLE_STATIC_LIB=OFF
235
		-DENABLE_SYSTEMD=$(usex systemd ON OFF)
236
		-DENABLE_TESTS=$(usex test ON OFF)
237
		-DENABLE_UNRAR=$(usex rar ON OFF)
238
		-DOPTIMIZE=ON
112 239
	)
113
	econf "${myeconfargs[@]}"
240

  
241
	if use test ; then
242
		# https://bugs.gentoo.org/818673
243
		# Used to enable some more tests but doesn't behave well in
244
		# sandbox necessarily(?) + needs certain debug symbols present
245
		# in e.g. glibc.
246
		mycmakeargs+=(
247
			-DCMAKE_DISABLE_FIND_PACKAGE_Valgrind=ON
248
			-DPYTHON_FIND_VERSION="${EPYTHON#python}"
249
		)
250
	fi
251

  
252
	if use jit ; then
253
		# Suppress CMake warnings that variables aren't consumed if we aren't using LLVM
254
		# https://github.com/Cisco-Talos/clamav/blob/main/INSTALL.md#llvm-optional-see-bytecode-runtime-section
255
		# https://github.com/Cisco-Talos/clamav/blob/main/INSTALL.md#bytecode-runtime
256
		mycmakeargs+=(
257
			-DLLVM_ROOT_DIR="$(get_llvm_prefix -d ${LLVM_MAX_SLOT})"
258
			-DLLVM_FIND_VERSION="$(best_version sys-devel/llvm:${LLVM_MAX_SLOT} | cut -c 16-)"
259
		)
260
	fi
261

  
262
	cmake_src_configure
114 263
}
115 264

  
116 265
src_install() {
117
	default
118

  
119
	rm -rf "${ED}"/var/lib/clamav || die
266
	cmake_src_install
267
	# init scripts
268
	newinitd "${FILESDIR}/clamd.initd" clamd
269
	newinitd "${FILESDIR}/freshclam.initd" freshclam
270
	use clamonacc && \
271
		newinitd "${FILESDIR}/clamonacc.initd" clamonacc
272
	use milter && \
273
		newinitd "${FILESDIR}/clamav-milter.initd" clamav-milter
120 274

  
121 275
	if ! use libclamav-only ; then
122
		if use systemd; then
276
		if use systemd ; then
123 277
			# The tmpfiles entry is behind USE=systemd because the
124 278
			# upstream OpenRC service files should (and do) ensure that
125 279
			# the directories they need exist and have the correct
......
128 282
			# fundamentally flawed, and the maintainer is not up to
129 283
			# the task of fixing it.
130 284
			dotmpfiles "${FILESDIR}/tmpfiles.d/clamav.conf"
131
			systemd_newunit "${FILESDIR}/clamd_at.service" "clamd@.service"
285
			systemd_newunit "${FILESDIR}/clamd_at.service-0.104.0" "clamd@.service"
132 286
			systemd_dounit "${FILESDIR}/clamd.service"
133 287
			systemd_newunit "${FILESDIR}/freshclamd.service-r1" \
134 288
							"freshclamd.service"
135 289
		fi
136 290

  
137
		insinto /etc/logrotate.d
138
		newins "${FILESDIR}/clamd.logrotate" clamd
139
		newins "${FILESDIR}/freshclam.logrotate" freshclam
140
		use milter && \
141
			newins "${FILESDIR}/clamav-milter.logrotate-r1" clamav-milter
142

  
143
		# Modify /etc/{clamd,freshclam}.conf to be usable out of the box
144
		sed -i -e "s:^\(Example\):\# \1:" \
145
			-e "s/^#\(PidFile .*\)/\1/" \
146
			-e "s/^#\(LocalSocket .*\)/\1/" \
147
			-e "s/^#\(User .*\)/\1/" \
148
			-e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamd.log:" \
149
			-e "s:^\#\(LogTime\).*:\1 yes:" \
150
			-e "s/^#\(DatabaseDirectory .*\)/\1/" \
151
			"${ED}"/etc/clamd.conf.sample || die
152

  
153
		sed -i -e "s:^\(Example\):\# \1:" \
154
			-e "s/^#\(PidFile .*\)/\1/" \
155
			-e "s/^#\(DatabaseOwner .*\)/\1/" \
156
			-e "s:^\#\(UpdateLogFile\) .*:\1 ${EPREFIX}/var/log/clamav/freshclam.log:" \
157
			-e "s:^\#\(NotifyClamd\).*:\1 ${EPREFIX}/etc/clamd.conf:" \
158
			-e "s:^\#\(ScriptedUpdates\).*:\1 yes:" \
159
			-e "s/^#\(DatabaseDirectory .*\)/\1/" \
160
			"${ED}"/etc/freshclam.conf.sample || die
161

  
162
		if use milter ; then
163
			# Note: only keep the "unix" ClamdSocket and MilterSocket!
164
			sed -i -e "s:^\(Example\):\# \1:" \
291
		if use clamapp ; then
292
			# Modify /etc/{clamd,freshclam}.conf to be usable out of the box
293
			sed -e "s:^\(Example\):\# \1:" \
165 294
				-e "s/^#\(PidFile .*\)/\1/" \
166
				-e "s/^#\(ClamdSocket unix:.*\)/\1/" \
295
				-e "s/^#\(LocalSocket .*\)/\1/" \
167 296
				-e "s/^#\(User .*\)/\1/" \
168
				-e "s/^#\(MilterSocket unix:.*\)/\1/" \
169
				-e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamav-milter.log:" \
170
				"${ED}"/etc/clamav-milter.conf.sample || die
171

  
172
			cat >> "${ED}"/etc/conf.d/clamd <<-EOF
173
				MILTER_NICELEVEL=19
174
				START_MILTER=no
175
			EOF
297
				-e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamd.log:" \
298
				-e "s:^\#\(LogTime\).*:\1 yes:" \
299
				-e "s/^#\(DatabaseDirectory .*\)/\1/" \
300
				"${ED}"/etc/clamav/clamd.conf.sample > \
301
				"${ED}"/etc/clamav/clamd.conf || die
176 302

  
177
			systemd_newunit "${FILESDIR}/clamav-milter.service-r1" clamav-milter.service
178
		fi
303
			sed -e "s:^\(Example\):\# \1:" \
304
				-e "s/^#\(PidFile .*\)/\1/" \
305
				-e "s/^#\(DatabaseOwner .*\)/\1/" \
306
				-e "s:^\#\(UpdateLogFile\) .*:\1 ${EPREFIX}/var/log/clamav/freshclam.log:" \
307
				-e "s:^\#\(NotifyClamd\).*:\1 ${EPREFIX}/etc/clamav/clamd.conf:" \
308
				-e "s:^\#\(ScriptedUpdates\).*:\1 yes:" \
309
				-e "s/^#\(DatabaseDirectory .*\)/\1/" \
310
				"${ED}"/etc/clamav/freshclam.conf.sample > \
311
				"${ED}"/etc/clamav/freshclam.conf || die
312

  
313
			if use milter ; then
314
				# Note: only keep the "unix" ClamdSocket and MilterSocket!
315
				sed -e "s:^\(Example\):\# \1:" \
316
					-e "s/^#\(PidFile .*\)/\1/" \
317
					-e "s/^#\(ClamdSocket unix:.*\)/\1/" \
318
					-e "s/^#\(User .*\)/\1/" \
319
					-e "s/^#\(MilterSocket unix:.*\)/\1/" \
320
					-e "s:^\#\(LogFile\) .*:\1 ${EPREFIX}/var/log/clamav/clamav-milter.log:" \
321
					"${ED}"/etc/clamav/clamav-milter.conf.sample > \
322
					"${ED}"/etc/clamav/clamav-milter.conf || die
179 323

  
180
		local i
181
		for i in clamd freshclam clamav-milter
182
		do
183
			if [[ -f "${ED}"/etc/"${i}".conf.sample ]]; then
184
				mv "${ED}"/etc/"${i}".conf{.sample,} || die
324
				systemd_newunit "${FILESDIR}/clamav-milter.service-0.104.0" clamav-milter.service
185 325
			fi
186
		done
187 326

  
188
		# These both need to be writable by the clamav user.
189
		# TODO: use syslog by default; that's what it's for.
190
		diropts -o clamav -g clamav
191
		keepdir /var/lib/clamav
192
		keepdir /var/log/clamav
327
			local i
328
			for i in clamd freshclam clamav-milter
329
			do
330
				if [[ -f "${ED}"/etc/"${i}".conf.sample ]] ; then
331
					mv "${ED}"/etc/"${i}".conf{.sample,} || die
332
				fi
333
			done
334

  
335
			# These both need to be writable by the clamav user
336
			# TODO: use syslog by default; that's what it's for.
337
			diropts -o clamav -g clamav
338
			keepdir /var/lib/clamav
339
			keepdir /var/log/clamav
340
		fi
193 341
	fi
194 342

  
195 343
	if use doc ; then
196 344
		local HTML_DOCS=( docs/html/. )
197 345
		einstalldocs
198

  
199
		if ! use libclamav-only ; then
200
			doman docs/man/*.[1-8]
201
		fi
202 346
	fi
203 347

  
204
	find "${ED}" -name '*.la' -delete || die
205
}
206

  
207
src_test() {
348
	# Don't install man pages for utilities we didn't install
208 349
	if use libclamav-only ; then
209
		ewarn "Test target not available when USE=libclamav-only is set, skipping tests ..."
210
		return 0
350
		rm -r "${ED}"/usr/share/man || die
211 351
	fi
212 352

  
213
	emake quick-check
353
	find "${ED}" -name '*.la' -delete || die
214 354
}
215 355

  
216 356
pkg_postinst() {
......
231 371
		ewarn "before starting clamav for the first time."
232 372
	fi
233 373

  
234
	ewarn "This version of ClamAV provides separate OpenRC services"
235
	ewarn "for clamd, freshclam, clamav-milter, and clamonacc. The"
236
	ewarn "clamd service now starts only the clamd daemon itself. You"
237
	ewarn "should add freshclam (and perhaps clamav-milter) to any"
238
	ewarn "runlevels that previously contained clamd."
374
	 if ! systemd_is_booted ; then
375
		ewarn "This version of ClamAV provides separate OpenRC services"
376
		ewarn "for clamd, freshclam, clamav-milter, and clamonacc. The"
377
		ewarn "clamd service now starts only the clamd daemon itself. You"
378
		ewarn "should add freshclam (and perhaps clamav-milter) to any"
379
		ewarn "runlevels that previously contained clamd."
380
	fi
239 381
}
Thank you!