pastebin - collaborative debugging tool
rovema.kpaste.net RSS


Build Debian kernel manually from source
Posted by Anonymous on Wed 16th Mar 2022 14:18
raw | new post
view followups (newest first): 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.         # dummy for now
  67.         #simatic-ipc-modules-lsp-v1.2.0RC1$ make -C /home/test001/work/kernel_test001/linux-5.10.52/ M=$PWD
  68.  
  69.         rm -Rf simatic_build
  70.         mkdir simatic_build
  71.         cd simatic_build
  72.  
  73.         cp /home/test001/work/dev_current/dev026/elbe/simatickernelmodules/rovema_simatickernelmodules_git20220304_001.bundle .
  74.         git clone rovema_simatickernelmodules_git20220304_001.bundle
  75.  
  76.         cd rovema_simatickernelmodules_git20220304_001/simatic-ipc-modules-lsp-v1.2.0RC1/
  77.         typeset kernel_build_path="$PWD/../../../linux-source-${bconfig.kernel_maj_min}"
  78.         make -C ${kernel_build_path} KSRC="${kernel_build_path}" M=$PWD
  79.  
  80.         #
  81.         # ToDo: Install in root/ dir, and turn that filesystem hieracy into a
  82.         # Debian package
  83.         #
  84.  
  85.         return 1
  86. }
  87.  
  88.  
  89. function build_igb_avb_kernel_module
  90. {
  91.         set -o xtrace
  92.         set -o errexit
  93.         set -o nounset
  94.  
  95.         rm -Rf igb_avb_build
  96.         mkdir igb_avb_build
  97.         cd igb_avb_build
  98.  
  99.         cp /home/test001/work/dev_current/dev026/elbe/igb_avb/rovema_igb_avb_git20220302_001.bundle .
  100.         git clone rovema_igb_avb_git20220302_001.bundle
  101.  
  102.         cd rovema_igb_avb_git20220302_001/kmod
  103.         typeset kernel_build_path="$PWD/../../../linux-source-${bconfig.kernel_maj_min}"
  104.         make -C ${kernel_build_path} KSRC="${kernel_build_path}" M=$PWD clean
  105.         make -C ${kernel_build_path} KSRC="${kernel_build_path}" M=$PWD
  106.  
  107.  
  108.         cd ../lib
  109.         make
  110.  
  111.         #
  112.         # ToDo: Install in root/ dir, and turn that filesystem hieracy into a
  113.         # Debian package
  114.         #
  115.  
  116.         # dummy for now
  117.  
  118.         return 1
  119. }
  120.  
  121. function main
  122. {
  123.         set -o xtrace
  124.         set -o errexit
  125.  
  126. #       build_debian_kernel_from_src
  127.         build_simatic_kernel_modules
  128. #       build_igb_avb_kernel_module
  129. }
  130.  
  131. #
  132. # main
  133. #
  134. builtin getconf
  135.  
  136. main "$@"
  137.  
  138. # 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