blob: 18d5c6f5acd6188f87909115b45213082c66157e (
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
#
# Original Author: © 2007-2009 Mir Calculate, Ltd.
# Purpose: Installing linux-desktop, linux-server.
# Build the kernel from source.
# @ECLASS: calculate-kernel-7.eclass
# @MAINTAINER:
# support@calculate.ru
# @AUTHOR:
# Author: Mir Calculate
# @BLURB: Functions for calculate-sources
# @DESCRIPTION:
# This eclass use for calculate-sources ebuild
inherit calculate eutils kernel-2
EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst
REQUIRED_USE="minimal? ( vmlinuz )"
CDEPEND="vmlinuz? ( || ( app-arch/xz-utils app-arch/lzma-utils )
grub? ( sys-boot/grub )
)
firmware? ( || ( sys-kernel/linux-firmware
sys-firmware/eth-firmware ) )"
DEPEND="${CDEPEND}
>=sys-devel/bison-1.875
>=sys-devel/flex-2.5.4
themes? ( || ( media-gfx/splash-themes-calculate
sys-boot/plymouth-calculate-plugin ) )
!minimal? ( virtual/pkgconfig )
"
RDEPEND="${CDEPEND} vmlinuz? ( sys-kernel/dracut )"
detect_version
detect_arch
IUSE="+vmlinuz desktop pae minimal themes firmware +grub"
if [[ ${KV_MAJOR} -lt 3 ]]
then
die "Eclass is used only for kernel-3"
fi
SLOT=${PV}
EXTRAVERSION="-${KERNELNAME:-calculate}"
KV_FULL="${PV}${EXTRAVERSION}"
S="${WORKDIR}/linux-${KV_FULL}"
calculate-kernel-7_pkg_setup() {
kernel-2_pkg_setup
eqawarn "!!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!"
eqawarn "After the kernel assemble perform command to update modules:"
eqawarn " emerge @modules-rebuild"
}
calculate-kernel-7_src_unpack() {
kernel-2_src_unpack
cd ${S}
local GENTOOARCH="${ARCH}"
unset ARCH
emake defconfig || die "kernel configure failed"
ARCH="${GENTOOARCH}"
}
vmlinuz_clean_localversion() {
sed -ri 's/^(CONFIG_LOCALVERSION=")[^"]+"/\1"/' .config
sed -ri 's/^(CONFIG_LOCALVERSION_AUTO)=.*$/# \1 is not set/' .config
rm -f localversion*
}
vmlinuz_src_compile() {
# disable sandbox
local GENTOOARCH="${ARCH}"
unset ARCH
cd ${S}
vmlinuz_clean_localversion
emake olddefconfig || die "kernel configure failed"
emake && emake modules || die "kernel build failed"
[ -f .config ] && cp .config .config.save
ARCH="${GENTOOARCH}"
}
calculate-kernel-7_src_compile() {
use vmlinuz && vmlinuz_src_compile
}
vmlinuz_src_install() {
# dracut change this files in chroot of ramdisk
SANDBOX_WRITE="${SANDBOX_WRITE}:/run/blkid:/etc/ld.so.cache~:/etc/ld.so.cache:/etc/mtab"
cd ${S}
dodir /usr/share/${PN}/${PV}/boot
INSTALL_PATH=${D}/usr/share/${PN}/${PV}/boot emake install
INSTALL_MOD_PATH=${D} emake modules_install
/sbin/depmod -b ${D} ${KV_FULL}
/usr/bin/dracut --xz -a calculate $PLYMOUTH -a video -k ${D}/lib/modules/${KV_FULL} \
--kver ${KV_FULL} \
${D}/usr/share/${PN}/${PV}/boot/initramfs-${KV_FULL}
# move firmware to share, because /lib/firmware installation does collisions
mv ${D}/lib/firmware ${D}/usr/share/${PN}/${PV}
insinto /usr/share/${PN}/${PV}/boot/
newins .config config-${KV_FULL}
# recreate symlink in /lib/modules because symlink point to tmp/portage after make install
rm ${D}/lib/modules/${KV_FULL}/build
rm ${D}/lib/modules/${KV_FULL}/source
dosym /usr/src/linux-${KV_FULL} \
"/lib/modules/${KV_FULL}/source" ||
die "cannot install source symlink"
dosym /usr/src/linux-${KV_FULL} \
"/lib/modules/${KV_FULL}/build" ||
die "cannot install build symlink"
}
# FUNCTION: clean_for_minimal
# DESCRIPTION:
# Clear kernel sources, keeping only need for custom modules compilation
clean_for_minimal() {
local GENTOOARCH="${ARCH}"
unset ARCH
ARCH="${GENTOOARCH}"
mkdir backup
cp Module.symvers backup
emake distclean &>/dev/null || die "cannot perform distclean"
mv .config.save .config
ebegin "kernel: >> Running modules_prepare..."
emake modules_prepare &>/dev/null
eend $? "Failed modules prepare"
einfo "Cleaning sources"
for rmpath in $(ls arch | grep -v x86)
do
rm -r arch/$rmpath
done
mv backup/Module.symvers .
rmdir backup
KEEPLIST="scripts/Makefile.lib scripts/module-common.lds \
scripts/gcc-version.sh scripts/Makefile.help \
scripts/Makefile.modinst scripts/Makefile.asm-generic \
scripts/Makefile.modbuiltin scripts/Makefile.fwinst \
scripts/Makefile.modfinal \
scripts/Makefile.extrawarn scripts/Makefile.kasan \
scripts/depmod.sh scripts/Makefile.host \
scripts/Makefile.gcc-plugins \
Module.symvers \
scripts/Makefile.ubsan \
scripts/Makefile.kcov \
scripts/subarch.include \
scripts/Kbuild.include scripts/Makefile.modpost \
scripts/gcc-goto.sh scripts/Makefile.headersinst \
scripts/Makefile.build scripts/basic/fixdep \
scripts/Makefile.clean scripts/mod/modpost \
tools/objtool/objtool \
include/config/kernel.release include/config/auto.conf \
arch/x86/Makefile_32.cpu arch/x86/Makefile \
System.map Kconfig Makefile Kbuild"
find . -type f -a \! -wholename ./.config \
$(echo $KEEPLIST | sed -r 's/(\S+)(\s|$)/-a \! -wholename .\/\1 /g') \
-a \! -name "*.h" -delete
find . -type l -delete
rm -r drivers
rm -r Documentation
}
calculate-kernel-7_src_install() {
use vmlinuz && vmlinuz_src_install
use minimal && clean_for_minimal
kernel-2_src_install
if ! use vmlinuz
then
dodir /usr/share/${PN}/${PV}/boot
insinto /usr/share/${PN}/${PV}/boot
newins .config config-${KV_FULL}
fi
use vmlinuz && touch ${D}/usr/src/linux-${KV_FULL}/.calculate
}
vmlinuz_pkg_postinst() {
# install kernel into /boot
calculate_update_ver /boot vmlinuz ${KV_FULL} /usr/share/${PN}/${PV}/boot/vmlinuz-${KV_FULL}
calculate_update_ver /boot config ${KV_FULL} /usr/share/${PN}/${PV}/boot/config-${KV_FULL}
calculate_update_ver /boot initramfs ${KV_FULL} /usr/share/${PN}/${PV}/boot/initramfs-${KV_FULL} .img
calculate_update_ver /boot System.map ${KV_FULL} /usr/share/${PN}/${PV}/boot/System.map-${KV_FULL}
# install firmware into /
mkdir -p ${ROOT}/lib/firmware
cp -a ${ROOT}/usr/share/${PN}/${PV}/firmware/* ${ROOT}/lib/firmware/
calculate_update_depmod
calculate_update_modules
}
calculate-kernel-7_pkg_postinst() {
kernel-2_pkg_postinst
KV_OUT_DIR=${ROOT}/usr/src/linux-${KV_FULL}
use vmlinuz && cp -p /usr/share/${PN}/${PV}/boot/System.map* ${KV_OUT_DIR}/System.map
if ! use minimal
then
cd ${KV_OUT_DIR}
local GENTOOARCH="${ARCH}"
unset ARCH
ebegin "kernel: >> Running modules_prepare..."
(emake oldconfig && emake modules_prepare) &>/dev/null
eend $? "Failed modules prepare"
ARCH="${GENTOOARCH}"
fi
use vmlinuz && vmlinuz_pkg_postinst
use vmlinuz && calculate_fix_lib_modules_contents
}
|