app-misc/test-merge-mixed - 1 (flow)

Search

Install

Install this version:

emerge -a =app-misc/test-merge-mixed-1

Package Information

Description:
Test ebuild with files, hardlinks and symlinks, to benchmark merging
Homepage:
https://wiki.gentoo.org/wiki/No_homepage
License:
GPL-3

Ebuild Details

Version EAPI Keywords Slot
1 8 amd64 0
View Raw Ebuild
# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DESCRIPTION="Test ebuild with files, hardlinks and symlinks, 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 i size

	mkdir -p "${destdir}"/{files/{0..49},hardlinks,symlinks} || die

	# 5,000 files of random content in 50 directories: 4,000 files of
	# 1 to 4 KiB, 900 files of 16 to 512 KiB, and 100 files of 1 to 8 MiB.
	for (( i = 0; i < 5000; i++ )); do
		if (( i % 50 == 0 )); then
			size=$(( (RANDOM % 8 + 1) * 1024 * 1024 ))
		elif (( i % 5 == 0 )); then
			size=$(( (RANDOM % 32 + 1) * 16 * 1024 ))
		else
			size=$(( 1024 + RANDOM % 3073 ))
		fi
		head -c ${size} /dev/urandom > "${destdir}/files/$(( i % 50 ))/${i}" || die
	done

	# 50 groups of three hardlinks.
	pushd "${destdir}/hardlinks" >/dev/null || die
	for (( i = 0; i < 50; i++ )); do
		head -c 4096 /dev/urandom > ${i}-a || die
		ln ${i}-a ${i}-b || die
		ln ${i}-a ${i}-c || die
	done
	popd >/dev/null || die

	pushd "${destdir}/symlinks" >/dev/null || die
	# 200 symlinks to files and 5 to directories.
	for (( i = 0; i < 200; i++ )); do
		ln -s ../files/$(( i % 50 ))/${i} file-${i} || die
	done
	for (( i = 0; i < 5; i++ )); do
		ln -s ../files/${i} dir-${i} || die
	done
	# 20 chains of symlinks to symlinks, whose merge is deferred until
	# their target is merged.
	for (( i = 0; i < 20; i++ )); do
		ln -s chain-${i}-b chain-${i}-a || die
		ln -s chain-${i}-c chain-${i}-b || die
		ln -s file-${i} chain-${i}-c || die
	done
	# Dangling and circular symlinks.
	for (( i = 0; i < 5; i++ )); do
		ln -s nonexistent-${i} dangling-${i} || die
	done
	ln -s loop-b loop-a || die
	ln -s loop-a loop-b || die
	popd >/dev/null || die
}