pastebin - collaborative debugging tool
rovema.kpaste.net RSS


Build Debian kernel manually from source
Posted by Anonymous on Fri 11th Mar 2022 09:29
raw | new post
view followups (newest first): Build Debian kernel manually from source by Anonymous and Build Debian kernel manually from source by Anonymous
modification of post by Anonymous (view diff)

  1. #!/usr/bin/ksh93
  2.  
  3. #
  4. # Build Debian RT kernel from source,
  5. # and retain the kernel build including source and *.o
  6. # files so we can build custom kernel modules from
  7. # that
  8. #
  9.  
  10. compound bconfig=(
  11.         # config
  12.         typeset kernel_maj_min='5.10'
  13.        
  14.         # calculated values
  15.         typeset kernel_build_path
  16. )
  17.  
  18. function build_debian_kernel_from_src
  19. {
  20.         set -o xtrace
  21.         set -o errexit
  22.         set -o nounset
  23.        
  24.         integer res
  25.         integer num_cpus=$(getconf '_NPROCESSORS_CONF')
  26.  
  27.         tar xf "/usr/src/linux-source-${bconfig.kernel_maj_min}.tar.xz"
  28.        
  29.         cd "linux-source-${bconfig.kernel_maj_min}"
  30.  
  31.         unxz <"/usr/src/linux-patch-${bconfig.kernel_maj_min}-rt.patch.xz" | patch -p1
  32.  
  33.         cp "/usr/src/linux-config-${bconfig.kernel_maj_min}/config.amd64_rt_amd64.xz" .
  34.         unxz 'config.amd64_rt_amd64.xz'
  35.  
  36.         # copy config and make kernel build accept it without
  37.         # jumping to the $ make menu # menu
  38.         cp 'config.amd64_rt_amd64' '.config'
  39.         make oldconfig <'/dev/null'
  40.        
  41.         # show any modifications $ make oldconfig # did to the kernel config
  42.         print '--------------------------------------'
  43.         diff -u 'config.amd64_rt_amd64' '.config' || true
  44.         print '--------------------------------------'
  45.  
  46.         make clean
  47.         time nice -n 19 make -j$((num_cpus*2)) deb-pkg 2>&1 | tee -a buildlog.log
  48.         (( res=$? ))
  49.  
  50.         printf '#### Finished, return code = %d\n' res
  51.  
  52.         if (( res == 0 )) ; then
  53.                 # remember the path to the kernel build, but only if we were successful
  54.                 bconfig.kernel_build_path="$PWD"
  55.         fi
  56.  
  57.         return $res
  58. }
  59.  
  60. function build_simatic_kernel_modules
  61. {
  62.         set -o xtrace
  63.         set -o errexit
  64.         set -o nounset
  65.        
  66.         cd "${bconfig.kernel_build_path}"
  67.  
  68.         # dummy for now
  69.         #simatic-ipc-modules-lsp-v1.2.0RC1$ make -C /home/test001/work/kernel_test001/linux-5.10.52/ M=$PWD
  70.         return 1
  71. }
  72.  
  73.  
  74. function build_igb_avb_kernel_module
  75. {
  76.         set -o xtrace
  77.         set -o errexit
  78.         set -o nounset
  79.        
  80.         cd "${bconfig.kernel_build_path}"
  81.  
  82.         # dummy for now
  83.  
  84.         return 1
  85. }
  86.  
  87. function main
  88. {
  89.         set -o xtrace
  90.         set -o errexit
  91.  
  92.         build_debian_kernel_from_src
  93.         build_simatic_kernel_modules
  94.         build_igb_avb_kernel_module
  95. }
  96.  
  97. #
  98. # main
  99. #
  100. builtin getconf
  101.  
  102. main "$@"
  103.  
  104. # EOF.

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at