New paste Repaste Download
#!/usr/bin/env bash
set -euo pipefail
export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/bin:/usr/lib/llvm/17/bin"
export LD_LIBRARY_PATH=/usr/lib/llvm/17/lib64
hostname=$(hostname)
installdir="/boot/${hostname}/"
kernelstring="$(eselect kernel list|grep '*'|awk '{print $2}')"
kernelver="$(sed 's/linux-//' <<< ${kernelstring})-${hostname}"
workdir="/usr/src/linux"
threads=$(nproc)
export COMMON_FLAGS="-O2 -march=native -pipe"
export LDFLAGS="-Wl,-O2 -Wl,--as-needed"
export KCFLAGS="$COMMON_FLAGS"
export KCPPFLAGS="$COMMON_FLAGS"
export LLVM=1
#export LLVM_IAS=1
#export CC="clang"
#export CPP="clang-cpp" # necessary for xorg-server and possibly other packages
#export CXX="clang++"
#export AR="llvm-ar"
#export NM="llvm-nm"
#export RANLIB="llvm-ranlib"
which clang
#### do not edit below this line
scriptdir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
[ $(id -u) -ne 0 ] && echo "Bitte als root ausführen" && exit 1
[ ! -d /boot/grub ] && echo "Please mount boot first" && exit 1
if [ ! -d /boot/grub ] ;then
  sh "${scriptdir}/../md-bootusb/mount_boot.sh"
fi
_init_sources() {
  echo "Kernel sources updated"
  echo "Pasting old last working config..."
  cp /usr/src/config-linux{,.bak}
  cp /usr/src/config-linux "${workdir}"/.config
}
_config() {
  cd /usr/src/linux
  make nconfig
  cp .config ../config-linux
}
_make() {
  #make clean
  LD="ld -j ${threads}" nice make -j${threads} 2>&1 |tee make.log
}
_makeprof() {
  cd /usr/src/linux
  #LD="ld -j ${threads}" nice make CFLAGS_GCOV="-fprofile-generate --coverage -fprofile-values -finline-functions -fipa-bit-cp" -j${threads}
  LD="ld -j ${threads}" nice make -j${threads}
}
_install() {
  cd /usr/src/linux
  nice make -j${threads} modules_install
  nice make install
  find /boot -maxdepth 1 -type f -name "*${hostname}*" -exec mv {} ${installdir} \;
}
_module_rebuild() {
  nice emerge @module-rebuild
}
_update_grub(){
echo "updating grub..."
sed -i "s/^kernelver.*/kernelver=\"${kernelver}\"/" /boot/grub/${hostname}.cfg
}
_build_initramfs(){
  sh "${scriptdir}/build_initramfs.sh"
}
_sync_usbboot(){
  sh "${scriptdir}/../md-bootusb/sync_usbboot.sh"
}
_build() {
    export INSTALL_MOD_STRIP=1
    cd "${workdir}"
    _make
    _install
    _update_grub
    _build_initramfs
    _module_rebuild
    _sync_usbboot
  }
_buildprof() {
    cd "${workdir}"
    _makeprof
    _install
    _update_grub
    _build_initramfs
    _module_rebuild
    _sync_usbboot
  }
[[ ! -f "${workdir}/.config" ]] && _init_sources
  cd /usr/src/linux
case ${1:-build} in
  build)
    _build
    ;;
  buildprof)
    _buildprof
    ;;
  config)
    _config
    ;;
  install)
    _install
    _update_grub
    _build_initramfs
    _module_rebuild
    _sync_usbboot
    ;;
#  strip)
#    _strip
#    ;;
esac
Filename: maintenance/kernelbuild/build_kernel.sh. Size: 3kb. View raw, , hex, or download this file.

This paste expires on 2024-11-20 11:48:57.805835. Pasted through v1-api.