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