105 lines
2.8 KiB
Bash
Executable File
105 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -xeu
|
|
|
|
export KERNEL_DIR="${HOME}/linux-6.5.1"
|
|
pushd "${KERNEL_DIR}"
|
|
|
|
################################################################################
|
|
|
|
# package management
|
|
sudo apt-get clean
|
|
sudo apt-get update
|
|
sudo apt-get upgrade -y
|
|
sudo apt-get install \
|
|
bash \
|
|
bc \
|
|
binutils \
|
|
debhelper \
|
|
rsync \
|
|
bison \
|
|
build-essential \
|
|
ccache \
|
|
clang \
|
|
cpio \
|
|
curl \
|
|
dash \
|
|
dwarves \
|
|
eatmydata \
|
|
flex \
|
|
gcc \
|
|
git \
|
|
kmod \
|
|
libclang-dev \
|
|
libelf-dev \
|
|
libncurses-dev \
|
|
libncurses5-dev \
|
|
libssl-dev \
|
|
lld \
|
|
llvm \
|
|
make \
|
|
neovim \
|
|
openssl \
|
|
pahole \
|
|
perl-base \
|
|
tmux \
|
|
vim \
|
|
-y
|
|
# https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/scripts/min-tool-version.sh?h=v6.5.1
|
|
command -v rustup || curl --proto '=https' --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain "$(scripts/min-tool-version.sh rustc)" --profile minimal -y
|
|
rustup toolchain list | grep "$(scripts/min-tool-version.sh rustc)" || rustup override set "$(scripts/min-tool-version.sh rustc)"
|
|
rustup component list | grep clippy | grep '(installed)' || rustup component add clippy
|
|
rustup component list | grep rust-src | grep '(installed)' || rustup component add rust-src
|
|
command -v bindgen || cargo install --locked --version "$(scripts/min-tool-version.sh bindgen)" bindgen
|
|
|
|
# ccache/dev-env setup
|
|
export CCACHE='ccache --max-size 100G'
|
|
export CC="${CCACHE} clang"
|
|
export CXX="${CCACHE} clang++"
|
|
export LLVM_IAS=1
|
|
export LLVM=1
|
|
export CLIPPY=1
|
|
|
|
################################################################################
|
|
|
|
# make sure that the Rust tooling is what Linux expects
|
|
make rustavailable
|
|
|
|
################################################################################
|
|
|
|
# clean everything
|
|
[ -f .config ] && rm -vf .config*
|
|
[ -d .git ] && git clean --force -d -x -X
|
|
make mrproper
|
|
|
|
################################################################################
|
|
|
|
#[ -f /root/.kernel-config ] && cp /root/.kernel-config .config
|
|
|
|
echo "-$(date +%Y.%m.%d.%H.%M.%S)" > localversion
|
|
|
|
yes "" | make localmodconfig
|
|
grep 'CONFIG_RUST=y' .config || echo 'CONFIG_RUST=y' >> .config
|
|
|
|
################################################################################
|
|
|
|
# ENABLE debug
|
|
#./scripts/config --file .config -d DEBUG_INFO_NONE -e DEBUG_KERNEL \
|
|
# -e DEBUG_INFO -e DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT -e KALLSYMS -e KALLSYMS_ALL
|
|
|
|
# DISABLE debug
|
|
./scripts/config --file .config -d DEBUG_INFO \
|
|
-d DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT -d DEBUG_INFO_DWARF4 \
|
|
-d DEBUG_INFO_DWARF5 -e CONFIG_DEBUG_INFO_NONE
|
|
|
|
# Fix for Debian
|
|
./scripts/config --file .config --set-str SYSTEM_TRUSTED_KEYS ''
|
|
|
|
################################################################################
|
|
|
|
LINUX_MAKE_TARGET='bindeb-pkg'
|
|
|
|
make -j "$(nproc --all)" "${LINUX_MAKE_TARGET}"
|
|
|
|
popd
|