Difference between
modified post 9ca by Anonymous on Wed 23rd Mar 2022 12:34
original post 215770fac3 by Anonymous on Tue 22nd Mar 2022 14:33
Download diff
Show
old version |
new version |
both versions
| 1 | 1 | #!/usr/bin/ksh93 | |
| 2 | 2 | ||
| 3 | 3 | # | |
| 4 | 4 | # Build Debian RT kernel from source, | |
| 5 | 5 | # and retain the kernel build including source and *.o | |
| 6 | 6 | # files so we can build custom kernel modules from | |
| 7 | 7 | # that | |
| 8 | 8 | # | |
| 9 | 9 | ||
| 10 | 10 | compound bconfig=( | |
| 11 | 11 | # config | |
| 12 | 12 | typeset kernel_maj_min='5.10' | |
| 13 | + | typeset kernel_config_name='config.amd64_rt_amd64' | |
| 13 | 14 | typeset igb_avb_src_gitbundle='/home/test001/work/dev_current/dev026/elbe/igb_avb/rovema_igb_avb_git20220302_001.bundle' | |
| 14 | 15 | typeset simatic_src_gitbundle='/home/test001/work/dev_current/dev026/elbe/simatickernelmodules/rovema_simatickernelmodules_git20220304_001.bundle' | |
| 15 | 16 | ||
| 16 | 17 | # calculated values | |
| 17 | 18 | typeset kernel_build_path | |
| 18 | 19 | ) | |
| 19 | 20 | ||
| 20 | 21 | function build_debian_kernel_from_src | |
| 21 | 22 | { | |
| 22 | 23 | set -o xtrace | |
| 23 | 24 | set -o errexit | |
| 24 | 25 | set -o nounset | |
| 25 | 26 | ||
| 26 | 27 | integer res | |
| 27 | 28 | integer num_cpus=$(getconf '_NPROCESSORS_CONF') | |
| 28 | 29 | ||
| 29 | 30 | tar xf "/usr/src/linux-source-${bconfig.kernel_maj_min}.tar.xz" | |
| 30 | 31 | ||
| 31 | 32 | cd "linux-source-${bconfig.kernel_maj_min}" | |
| 32 | 33 | ||
| 33 | 34 | unxz <"/usr/src/linux-patch-${bconfig.kernel_maj_min}-rt.patch.xz" | patch -p1 | |
| 34 | 35 | ||
| 35 | - | cp "/usr/src/linux-config-${bconfig.kernel_maj_min}/config.amd64_rt_amd64.xz" . | |
| 36 | + | cp "/usr/src/linux-config-${bconfig.kernel_maj_min}/${bconfig.kernel_config_name}.xz" . | |
| 36 | - | unxz 'config.amd64_rt_amd64.xz' | |
| 37 | + | unxz "${bconfig.kernel_config_name}.xz" | |
| 37 | 38 | ||
| 38 | 39 | # copy config and make kernel build accept it without | |
| 39 | 40 | # jumping to the $ make menu # menu | |
| 40 | - | cp 'config.amd64_rt_amd64' '.config' | |
| 41 | + | cp "${bconfig.kernel_config_name}" '.config' | |
| 41 | 42 | make oldconfig <'/dev/null' | |
| 42 | 43 | ||
| 43 | 44 | # show any modifications $ make oldconfig # did to the kernel config | |
| 44 | 45 | print '--------------------------------------' | |
| 45 | - | diff -u 'config.amd64_rt_amd64' '.config' || true | |
| 46 | + | diff -u "${bconfig.kernel_config_name}" '.config' || true | |
| 46 | 47 | print '--------------------------------------' | |
| 47 | 48 | ||
| 48 | 49 | make clean | |
| 49 | - | time nice -n 19 make -j$((num_cpus*2)) deb-pkg 2>&1 | tee -a buildlog.log | |
| 50 | + | time nice -n 19 make -j$((num_cpus*4)) deb-pkg 2>&1 | tee -a buildlog.log | |
| 50 | 51 | (( res=$? )) | |
| 51 | 52 | ||
| 52 | 53 | printf '#### Kernel build finished, return code = %d\n' res | |
| 53 | 54 | ||
| 54 | 55 | if (( res == 0 )) ; then | |
| 55 | 56 | # remember the path to the kernel build, but only if we were successful | |
| 56 | 57 | bconfig.kernel_build_path="$PWD/" | |
| 57 | 58 | fi | |
| 58 | 59 | ||
| 59 | 60 | return $res | |
| 60 | 61 | } | |
| 61 | 62 | ||
| 62 | 63 | function build_simatic_kernel_modules | |
| 63 | 64 | { | |
| 64 | 65 | set -o xtrace | |
| 65 | 66 | set -o errexit | |
| 66 | 67 | set -o nounset | |
| 67 | 68 | ||
| 68 | 69 | # dummy for now | |
| 69 | 70 | #simatic-ipc-modules-lsp-v1.2.0RC1$ make -C /home/test001/work/kernel_test001/linux-5.10.52/ M=$PWD | |
| 70 | 71 | ||
| 71 | 72 | rm -Rf simatic_build | |
| 72 | 73 | mkdir simatic_build | |
| 73 | 74 | cd simatic_build | |
| 74 | 75 | ||
| 75 | 76 | cp "${bconfig.simatic_src_gitbundle}" . | |
| 76 | 77 | git clone rovema_simatickernelmodules_git20220304_001.bundle | |
| 77 | 78 | ||
| 78 | 79 | cd rovema_simatickernelmodules_git20220304_001/simatic-ipc-modules-lsp-v1.2.0RC1/ | |
| 79 | 80 | make -C "${bconfig.kernel_build_path}" KSRC="${bconfig.kernel_build_path}" M=$PWD | |
| 80 | 81 | ||
| 81 | 82 | # | |
| 82 | 83 | # ToDo: Install in root/ dir, and turn that filesystem hieracy into a | |
| 83 | 84 | # Debian package | |
| 84 | 85 | # see https://unix.stackexchange.com/questions/30303/how-to-create-a-deb-file-manually | |
| 85 | 86 | # | |
| 86 | 87 | ||
| 87 | 88 | return 1 | |
| 88 | 89 | } | |
| 89 | 90 | ||
| 90 | 91 | ||
| 91 | 92 | function build_igb_avb_kernel_module | |
| 92 | 93 | { | |
| 93 | 94 | set -o xtrace | |
| 94 | 95 | set -o errexit | |
| 95 | 96 | set -o nounset | |
| 96 | 97 | ||
| 97 | 98 | rm -Rf igb_avb_build | |
| 98 | 99 | mkdir igb_avb_build | |
| 99 | 100 | cd igb_avb_build | |
| 100 | 101 | ||
| 101 | 102 | cp "${bconfig.igb_avb_src_gitbundle}" . | |
| 102 | 103 | git clone rovema_igb_avb_git20220302_001.bundle | |
| 103 | 104 | ||
| 104 | 105 | cd rovema_igb_avb_git20220302_001/kmod | |
| 105 | 106 | ||
| 106 | 107 | make -C "${bconfig.kernel_build_path}" KSRC="${bconfig.kernel_build_path}" M=$PWD clean | |
| 107 | 108 | make -C ${bconfig.kernel_build_path} KSRC="${bconfig.kernel_build_path}" M=$PWD | |
| 108 | 109 | ||
| 109 | 110 | ||
| 110 | 111 | cd ../lib | |
| 111 | 112 | make | |
| 112 | 113 | ||
| 113 | 114 | # | |
| 114 | 115 | # ToDo: Install in root/ dir, and turn that filesystem hieracy into a | |
| 115 | 116 | # Debian package | |
| 116 | 117 | # | |
| 117 | 118 | ||
| 118 | 119 | # dummy for now | |
| 119 | 120 | # see https://unix.stackexchange.com/questions/30303/how-to-create-a-deb-file-manually | |
| 120 | 121 | ||
| 121 | 122 | return 1 | |
| 122 | 123 | } | |
| 123 | 124 | ||
| 124 | 125 | function main | |
| 125 | 126 | { | |
| 126 | 127 | set -o xtrace | |
| 127 | 128 | set -o errexit | |
| 128 | 129 | ||
| 129 | 130 | if (( 0 )) ; then | |
| 130 | 131 | build_debian_kernel_from_src | |
| 131 | 132 | else | |
| 132 | 133 | bconfig.kernel_build_path="$PWD/linux-source-${bconfig.kernel_maj_min}/" | |
| 133 | 134 | fi | |
| 134 | 135 | build_simatic_kernel_modules || true | |
| 135 | 136 | build_igb_avb_kernel_module | |
| 136 | 137 | } | |
| 137 | 138 | ||
| 138 | 139 | # | |
| 139 | 140 | # main | |
| 140 | 141 | # | |
| 141 | 142 | builtin getconf | |
| 142 | 143 | ||
| 143 | 144 | main "$@" | |
| 144 | 145 | ||
| 145 | 146 | # EOF. | |
| 146 | 147 |
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.
rovema.kpaste.net RSS