# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="Test ebuild with many small files, to benchmark merging"
HOMEPAGE="https://wiki.gentoo.org/wiki/No_homepage"
S="${WORKDIR}"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="amd64"
RESTRICT="binchecks strip"

src_install() {
	local destdir="${ED}/usr/share/${PN}"
	local d

	# 50,000 files of random content in 500 directories, with 100 files
	# of 1, 2, 3 or 4 KiB per directory.
	for (( d = 0; d < 500; d++ )); do
		local size=$(( (d % 4 + 1) * 1024 ))
		mkdir -p "${destdir}/${d}" || die
		head -c $(( size * 100 )) /dev/urandom |
			split -b ${size} -a 2 -d - "${destdir}/${d}/f" || die
	done
}