summaryrefslogtreecommitdiff
blob: 2107fd4d4b8fcc75fbcbd796a0380dc1d8d95fa8 (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
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit mount-boot

MY_PV=${PV/_/-}

DESCRIPTION="Memory tester based on PCMemTest"
HOMEPAGE="https://www.memtest.org/"
SRC_URI="https://github.com/memtest86plus/memtest86plus/archive/refs/tags/v${MY_PV}.tar.gz -> ${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="bios32 bios64 +boot efi32 efi64 iso32 iso64"

ISODEPS="
	dev-libs/libisoburn
	sys-fs/dosfstools
	sys-fs/mtools
"
BDEPEND="
	iso32? ( ${ISODEPS} )
	iso64? ( ${ISODEPS} )
"

S=${WORKDIR}/memtest86plus-${MY_PV}

src_prepare() {
	sed -i -e "s#/sbin/mkdosfs#mkfs.vfat#" build{32,64}/Makefile || die
	sed -i -e "s/^AS = as/AS +=/" -e "/^CC/d" build{32,64}/Makefile || die
	default
}

src_compile() {
	pushd build32
		use bios32 && emake memtest.bin
		use efi32 && emake memtest.efi
		use iso32 && emake iso
	popd

	pushd build64
		use bios64 && emake memtest.bin
		use efi64 && emake memtest.efi
		use iso32 && emake iso
	popd
}

install_memtest_images() {
	use bios32 && newins build32/memtest.bin memtest32.bios
	use bios64 && newins build64/memtest.bin memtest64.bios
	use efi32 && newins build32/memtest.efi memtest.efi32
	use efi64 && newins build64/memtest.efi memtest.efi64
}

src_install() {
	default
	if use boot; then
		exeinto /etc/grub.d/
		newexe "${FILESDIR}"/39_memtest86+-r2 39_memtest86+
		insinto /boot/memtest86plus
		install_memtest_images
	fi

	insinto /usr/share/${PN}
	install_memtest_images
	use iso32 && newins build32/memtest.iso memtest32.iso
	use iso64 && newins build64/memtest.iso memtest64.iso
}