commit: c2525c65b9f3d5849963bab6beb40817d7720218 Author: Robert Trace <bugzilla-gentoo <AT> farcaster <DOT> org> AuthorDate: Tue Jan 3 05:15:46 2017 +0000 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> CommitDate: Tue Jan 3 05:15:46 2017 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=c2525c65
Strip kernel & modules Rebased and tweaked to apply since the original patch was ~7 years old. Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> doc/genkernel.8.txt | 7 +++++++ gen_cmdline.sh | 13 +++++++++++++ gen_compile.sh | 9 +++++++++ gen_determineargs.sh | 1 + gen_funcs.sh | 6 ++++++ 5 files changed, 36 insertions(+) diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt index a2d3c22..ca8eff0 100644 --- a/doc/genkernel.8.txt +++ b/doc/genkernel.8.txt @@ -384,6 +384,13 @@ OUTPUT SETTINGS Directory structure to include in the initramfs, only available on >=2.6 kernels +*--strip*=<all|kernel|modules|none>:: + Strip debug symbols from the installed kernel, modules, all + (default) or none. + +*--no-strip*:: + Alias for *--strip=none*. + *--*[*no-*]*firmware*:: Enable or disables copying of firmware into initramfs. diff --git a/gen_cmdline.sh b/gen_cmdline.sh index 0e1e7ef..37d1b5c 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -174,6 +174,11 @@ longusage() { echo " Compress or do not compress the generated initramfs" echo " --compress-initramfs-type=<arg>" echo " Compression type for initramfs (best, xz, lzma, bzip2, gzip, lzop)" + echo " --strip=(all|kernel|modules|none)" + echo " Strip debug symbols from the installed kernel, modules," + echo " all (default) or none" + echo " --no-strip" + echo " Don't strip installed kernel or modules (alias for --strip=none)" echo echo "For a detailed list of supported initramfs options and flags; issue:" echo " man 8 genkernel" @@ -669,6 +674,14 @@ parse_cmdline() { CMD_NICE=0 print_info 2 "CMD_NICE: ${CMD_NICE}" ;; + --strip=*) + CMD_STRIP_TYPE=`parse_opt "$*"` + print_info 2 "CMD_STRIP_TYPE: ${CMD_STRIP_TYPE}" + ;; + --no-strip) + CMD_STRIP_TYPE=none + print_info 2 "CMD_STRIP_TYPE: ${CMD_STRIP_TYPE}" + ;; all) BUILD_KERNEL=1 BUILD_MODULES=1 diff --git a/gen_compile.sh b/gen_compile.sh index 7cc4733..ef72a23 100755 --- a/gen_compile.sh +++ b/gen_compile.sh @@ -306,6 +306,14 @@ compile_modules() { compile_generic modules kernel export UNAME_MACHINE="${ARCH}" [ "${INSTALL_MOD_PATH}" != '' ] && export INSTALL_MOD_PATH + if [ "${CMD_STRIP_TYPE}" == "all" -o "${CMD_STRIP_TYPE}" == "modules" ] + then + print_info 1 " >> Installing ${KV} modules (and stripping)" + INSTALL_MOD_STRIP=1 + export INSTALL_MOD_STRIP + else + print_info 1 " >> Installing ${KV} modules" + fi MAKEOPTS="${MAKEOPTS} -j1" compile_generic "modules_install" kernel print_info 1 " >> Generating module dependency data..." if [ "${INSTALL_MOD_PATH}" != '' ] @@ -315,6 +323,7 @@ compile_modules() { depmod -a -e -F "${KERNEL_OUTPUTDIR}"/System.map ${KV} fi unset UNAME_MACHINE + unset INSTALL_MOD_STRIP } compile_kernel() { diff --git a/gen_determineargs.sh b/gen_determineargs.sh index 313dbd0..5f77c07 100755 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -142,6 +142,7 @@ determine_real_args() { set_config_with_override BOOL KEYMAP CMD_KEYMAP "yes" set_config_with_override BOOL DOKEYMAPAUTO CMD_DOKEYMAPAUTO set_config_with_override STRING BUSYBOX_CONFIG CMD_BUSYBOX_CONFIG + set_config_with_override STRING STRIP_TYPE CMD_STRIP_TYPE "all" set_config_with_override BOOL INSTALL CMD_INSTALL "yes" set_config_with_override BOOL DEBUGCLEANUP CMD_DEBUGCLEANUP "yes" diff --git a/gen_funcs.sh b/gen_funcs.sh index 6234189..0e22a86 100755 --- a/gen_funcs.sh +++ b/gen_funcs.sh @@ -388,6 +388,12 @@ copy_image_with_preserve() { cp "${newSrceImage}" "${BOOTDIR}/${currDestImage}" || gen_die "Could not copy the ${symlinkName} image to ${BOOTDIR}!" + if [ "${CMD_STRIP_TYPE}" = "all" -o "${CMD_STRIP_TYPE}" = "kernel" ] + then + print_info 5 " Stripping ${BOOTDIR}/${currDestImage}" + strip --strip-debug "${BOOTDIR}/${currDestImage}" >/dev/null 2>&1 + fi + if [ "${SYMLINK}" = '1' ] then print_info 5 " Make new symlink(s) (from ${BOOTDIR}):"