-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel-build
executable file
·108 lines (92 loc) · 3.93 KB
/
kernel-build
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
#!/bin/bash
usage() {
printf "Usage: $0 [-k][options]\n"
printf " -k kernel version to install (example 5.14.14)\n"
printf "\n"
exit 1
}
remove_old_kernel() {
emerge -C gentoo-sources
rm -Rf /usr/src/*-gentoo*
find /boot/ /lib/modules/ -mindepth 1 -maxdepth 1 -name \*gentoo\* ! -name \*$(uname -r) -exec rm -R {} \;
}
prepare_kernel() {
emerge -b =gentoo-sources-$kernelversion --nodeps
eselect kernel set linux-$kernelversion-gentoo
wget https://raw.githubusercontent.com/damentz/liquorix-package/$kernelmajversion/master/linux-liquorix/debian/config/kernelarch-x86/config-arch-64 -O ${tmp_conf}
sed -i "s/CONFIG_CRYPTO_CRC32C=m/CONFIG_CRYPTO_CRC32C=y/; s/CONFIG_FW_LOADER_USER_HELPER=y/CONFIG_FW_LOADER_USER_HELPER=n/; s/CONFIG_I2C_NVIDIA_GPU=/#CONFIG_I2C_NVIDIA_GPU=/; s/CONFIG_R8169=m/CONFIG_R8169=y/" ${tmp_conf}
#echo -e "CONFIG_SND_HDA_INPUT_BEEP=y\nCONFIG_SND_HDA_INPUT_BEEP_MODE=0" >> config-arch-64
#echo -e "CONFIG_AUFS_FS=y\nCONFIG_AUFS_BRANCH_MAX_127=y\nCONFIG_AUFS_BRANCH_MAX_511=n\nCONFIG_AUFS_BRANCH_MAX_1023=n\nCONFIG_AUFS_BRANCH_MAX_32767=n\nCONFIG_AUFS_HNOTIFY=y\nCONFIG_AUFS_EXPORT=n\nCONFIG_AUFS_XATTR=y\nCONFIG_AUFS_FHSM=y\nCONFIG_AUFS_RDU=n\nCONFIG_AUFS_DIRREN=n\nCONFIG_AUFS_SHWH=n\nCONFIG_AUFS_BR_RAMFS=y\nCONFIG_AUFS_BR_FUSE=n\nCONFIG_AUFS_BR_HFSPLUS=n\nCONFIG_AUFS_DEBUG=n" >> ${tmp_conf}
sed -i "s/CONFIG_ISO9660_FS=m/CONFIG_ISO9660_FS=y/" ${tmp_conf}
}
aufs_patches() {
cd /usr/src/linux-$kernelversion-gentoo/
git clone --single-branch --branch aufs$kernelmajversion git://github.com/sfjro/aufs5-standalone.git
patch -p1 < aufs5-standalone/aufs5-kbuild.patch
patch -p1 < aufs5-standalone/aufs5-base.patch
patch -p1 < aufs5-standalone/aufs5-mmap.patch
cp -R aufs5-standalone/{Documentation,fs} .
cp aufs5-standalone/include/uapi/linux/aufs_type.h include/uapi/linux/
cd -
}
build_kernel() {
genkernel --kernel-ld=ld.bfd --kernel-config=${tmp_conf} --luks --lvm all
XZ_OPT="--lzma1=preset=9e,dict=128MB,nice=273,depth=200,lc=4" tar --lzma -cf /var/cache/binpkgs/s/kernel.tar.lzma /boot/*$kernelversion-gentoo /lib/modules/$kernelversion-gentoo &
}
build_gnu_kernel() {
cp -R /usr/src/linux-$kernelversion-gentoo/ /usr/src/linux-$kernelversion-gentoo-gnu/
cd /usr/src/linux-$kernelversion-gentoo-gnu/
wget https://linux-libre.fsfla.org/pub/linux-libre/releases/$kernelversion-gnu/deblob-$kernelmajversion https://linux-libre.fsfla.org/pub/linux-libre/releases/$kernelversion-gnu/deblob-check
chmod +x deblob-$kernelmajversion deblob-check
PYTHON="python2.7" ./deblob-$kernelmajversion
cd -
genkernel --kernel-ld=ld.bfd --kernel-config=${tmp_conf} --luks --lvm --kerneldir=/usr/src/linux-$kernelversion-gentoo-gnu/ all
XZ_OPT="--lzma1=preset=9e,dict=128MB,nice=273,depth=200,lc=4" tar --lzma -cf /var/cache/binpkgs/s/kernel-libre.tar.lzma /boot/*$kernelversion-gentoo-gnu /lib/modules/$kernelversion-gentoo-gnu &
rm -Rf /usr/src/linux-$kernelversion-gentoo-gnu/
}
clean(){
rm -v ${tmp_conf}
}
# Main
if [ $(id -u) != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
while getopts ":k:h:" opt; do
case $opt in
k)
kernelversion=$OPTARG
;;
h)
usage
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
;;
:)
echo "Option -$OPTARG requires an argument." >&2
usage
;;
esac
done
if [ $OPTIND -eq 1 ]; then usage; fi
kernelmajorversion=${kernelversion%.*}
if [ ! -d '/var/cache/binpkgs/s/' ]; then
mkdir -p /var/cache/binpkgs/s/
fi
export BINPKG_COMPRESS="xz" XZ_OPT="--x86 --lzma2=preset=9e,dict=128MB,nice=273,depth=200,lc=4"
# create temporary configuration file used for configuration download and patching
tmp_conf=$(mktemp "/tmp/config_${kernelversion}.XXXXXXXXXX")
echo "temporary_config_file: ${tmp_conf}"
remove_old_kernel
prepare_kernel
#aufs_patches
build_kernel
cd /usr/src/linux/
make clean
make LD=ld.bfd prepare
make LD=ld.bfd modules_prepare
wait
LD=ld.bfd emerge -b @module-rebuild
clean