Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 643786
Collapse All | Expand All

(-)a/sys-firmware/intel-microcode/intel-microcode-20171117_p20171215.ebuild (-7 / +72 lines)
Lines 18-39 SRC_URI="mirror://gentoo/microcode-${PV} Link Here
18
LICENSE="intel-ucode"
18
LICENSE="intel-ucode"
19
SLOT="0"
19
SLOT="0"
20
KEYWORDS="-* amd64 x86"
20
KEYWORDS="-* amd64 x86"
21
IUSE="initramfs +split-ucode"
21
IUSE="initramfs scan-system +split-ucode"
22
REQUIRED_USE="|| ( initramfs split-ucode )"
22
REQUIRED_USE="|| ( initramfs split-ucode )"
23
23
24
DEPEND="initramfs? ( sys-apps/iucode_tool )"
24
DEPEND="initramfs? ( sys-apps/iucode_tool )
25
	scan-system? ( sys-apps/iucode_tool )"
25
RDEPEND="!<sys-apps/microcode-ctl-1.17-r2" #268586
26
RDEPEND="!<sys-apps/microcode-ctl-1.17-r2" #268586
26
27
27
S=${WORKDIR}
28
S=${WORKDIR}
28
29
29
src_compile() {
30
src_compile() {
30
	if use initramfs ; then
31
	if use initramfs; then
31
		iucode_tool --write-earlyfw=microcode.cpio intel-ucode/ || die
32
		if use scan-system; then
33
			iucode_tool --scan-system --write-earlyfw=initramfs.cpio intel-ucode/ || die "Failed to generate initramfs cpio archive"
34
		else
35
			iucode_tool --write-earlyfw=initramfs.cpio intel-ucode/ || die "Failed to generate initramfs cpio archive"
36
		fi
32
	fi
37
	fi
33
}
38
}
34
39
35
src_install() {
40
src_install() {
36
	insinto /lib/firmware
41
	insinto /lib/firmware/intel-ucode
37
	use initramfs && doins microcode.cpio
42
	if use initramfs; then
38
	use split-ucode && doins -r intel-ucode
43
		doins initramfs.cpio
44
	fi
45
	if use split-ucode; then
46
		if use scan-system; then
47
			local re_signature="^iucode_tool: system has processor\(s\) with signature (0x[0-9a-f]+)$"
48
			local re_bundle="^microcode bundle ([0-9]+): (.*)$"
49
			local re_suitable="^([0-9]+)/([0-9]+): sig (0x[0-9a-f]+), pf_mask (0x[0-9a-f]+), ([0-9]{4}-[0-9]{2}-[0-9]{2}), rev (0x[0-9a-f]+), size ([0-9]+)$"
50
			local -A bundles=()
51
			local -a suitable=()
52
			local line index
53
54
			# Identify suitable bundles
55
			while read -r line; do
56
				if [[ $line =~ $re_signature ]]; then
57
					elog "Signature of detected processor(s): ${BASH_REMATCH[1]}"
58
				elif [[ $line =~ $re_bundle ]]; then
59
					bundles+=(["${BASH_REMATCH[1]}"]="${BASH_REMATCH[2]}")
60
				elif [[ $line =~ $re_suitable ]]; then
61
					index="${BASH_REMATCH[1]}"
62
					index="${index#"${index%%[!0]*}"}" # strip leading zero(s) from bundle index
63
					if [[ -n "${bundles[$index]+set}" ]]; then
64
						elog "Suitable microcode bundle: ${index} (${bundles[$index]})"
65
						suitable+=("$index")
66
					else
67
						ewarn "Ignoring invalid microcode bundle '${index}'"
68
					fi
69
				fi
70
			done < <(iucode_tool --scan-system --list intel-ucode/* 2>&1) # signature is written to stderr
71
			elog ""
72
73
			# Suitable bundles identified?
74
			if (( ${#suitable[@]} == 0 )); then
75
				ewarn "Unable to identify suitable microcode bundle(s)"
76
				ewarn "Please install without USE flag 'scan-system' instead"
77
				die "Failed to identify suitable microcode bundle(s)"
78
			fi
79
80
			# Install identified bundles
81
			insinto /lib/firmware/intel-ucode
82
			for index in ${suitable[@]}; do
83
				doins "${bundles[$index]}"
84
			done
85
		else
86
			doins intel-ucode/*
87
		fi
88
	fi
89
}
90
91
pkg_postinst() {
92
	if use initramfs; then
93
		elog "CPIO archive was installed to '/lib/firmware/intel-ucode/initramfs.cpio'"
94
		elog "This archive needs to be prepended to an existing initramfs image:"
95
		elog "# cat /lib/firmware/intel-ucode/initramfs.cpio existing-image > combined-image"
96
		elog ""
97
	fi
98
	if use split-ucode; then
99
		elog "Split binary ucode files were installed to '/lib/firmware/intel-ucode'"
100
		elog ""
101
	fi
102
	elog "Please refer to the Gentoo Wiki for more detailed information:"
103
	elog "https://wiki.gentoo.org/wiki/Intel_microcode"
39
}
104
}
(-)a/sys-firmware/intel-microcode/metadata.xml (+1 lines)
Lines 8-13 Link Here
8
<use>
8
<use>
9
	<flag name="initramfs">install a small initramfs for use with CONFIG_MICROCODE_EARLY</flag>
9
	<flag name="initramfs">install a small initramfs for use with CONFIG_MICROCODE_EARLY</flag>
10
	<flag name="monolithic">install the large text microcode.dat (used by older kernels via microcode_ctl)</flag>
10
	<flag name="monolithic">install the large text microcode.dat (used by older kernels via microcode_ctl)</flag>
11
	<flag name="scan-system">scan system and only install suitable/applicable microcode</flag>
11
	<flag name="split-ucode">install the split binary ucode files (used by the kernel directly)</flag>
12
	<flag name="split-ucode">install the split binary ucode files (used by the kernel directly)</flag>
12
</use>
13
</use>
13
</pkgmetadata>
14
</pkgmetadata>

Return to bug 643786