diff options
author | Robert Trace <bugzilla-gentoo@farcaster.org> | 2017-01-02 21:15:46 -0800 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2017-01-02 21:15:46 -0800 |
commit | c2525c65b9f3d5849963bab6beb40817d7720218 (patch) | |
tree | 71a641f9533c4c739d326b2b21dc486059dc5ebc | |
parent | Allow complete override of MODULES_* (diff) | |
download | genkernel-c2525c65b9f3d5849963bab6beb40817d7720218.tar.gz genkernel-c2525c65b9f3d5849963bab6beb40817d7720218.tar.bz2 genkernel-c2525c65b9f3d5849963bab6beb40817d7720218.zip |
Strip kernel & modules
Rebased and tweaked to apply since the original patch was ~7 years old.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r-- | doc/genkernel.8.txt | 7 | ||||
-rwxr-xr-x | gen_cmdline.sh | 13 | ||||
-rwxr-xr-x | gen_compile.sh | 9 | ||||
-rwxr-xr-x | gen_determineargs.sh | 1 | ||||
-rwxr-xr-x | gen_funcs.sh | 6 |
5 files changed, 36 insertions, 0 deletions
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}):" |