Skip to content

Instantly share code, notes, and snippets.

@ivoronin
Created August 6, 2012 06:17
Show Gist options
  • Save ivoronin/3271302 to your computer and use it in GitHub Desktop.
Save ivoronin/3271302 to your computer and use it in GitHub Desktop.
core/linux PKGBUILD patch for building debuginfo package
diff -ur linux.orig/PKGBUILD linux/PKGBUILD
--- linux.orig/PKGBUILD 2012-08-28 21:53:04.757568936 +0400
+++ linux/PKGBUILD 2012-08-28 22:05:23.470891452 +0400
@@ -24,8 +24,8 @@
'i915-i2c-crash-3.5.x.patch')
md5sums=('24153eaaa81dedc9481ada8cd9c3b83d'
'01e0536109d2a06b1701b5051edfcea2'
- '4eb50449b069bd699d92a290dce76d00'
- '74c0ce9291ad8aaf26546fe85a1a7d18'
+ 'f2abe8d7f67936cc0cc8fc50a8d5dcf0'
+ 'ab1872774f43493dabb6e12ef763f5b7'
'eb14dcfd80c00852ef81ded6e826826a'
'9d3c56a4b999c8bfbd4018089a62f662'
'c1d58e712112cf8f95e7831012a1e67a'
@@ -134,6 +134,7 @@
# add vmlinux
install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
+ objcopy --strip-debug "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
# install fallback mkinitcpio.conf file and preset file for kernel
install -D -m644 "${srcdir}/linux.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
@@ -155,7 +156,7 @@
# remove the firmware
rm -rf "${pkgdir}/lib/firmware"
# gzip -9 all modules to save 100MB of space
- find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
+ find "${pkgdir}" -name '*.ko' -exec objcopy --strip-debug {} \; -exec gzip -9 {} \;
# make room for external modules
ln -s "../extramodules-${_basekernel}${_kernelname:--ARCH}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
# add real version for building modules and running depmod from post_install/upgrade
@@ -169,6 +170,39 @@
depmod -b "$pkgdir" -F System.map "$_kernver"
}
+_package-debuginfo() {
+ pkgdesc="Debug information for the Linux Kernel and modules"
+ depends=('linux')
+
+ cd "${srcdir}/linux-${_basekernel}"
+
+ KARCH=x86
+
+ # get kernel version
+ _kernver="$(make kernelrelease)"
+
+ mkdir -p "${pkgdir}"/usr/lib/debug/lib/modules/"${_kernver}"
+ make INSTALL_MOD_PATH="${pkgdir}"/usr/lib/debug modules_install
+
+ # add vmlinux
+ _kernfile="${pkgdir}/usr/lib/debug/lib/modules/${_kernver}/vmlinux"
+ install -D -m644 vmlinux "${_kernfile}"
+ objcopy --only-keep-debug "${_kernfile}"
+
+ # gzip -9 vmlinux
+ gzip -9 "${_kernfile}"
+ mv "${_kernfile}".gz "${_kernfile}"
+
+ # remove build and source links
+ rm -f "${pkgdir}"/usr/lib/debug/lib/modules/${_kernver}/{source,build,modules.builtin,modules.order}
+
+ # remove the firmware
+ rm -rf "${pkgdir}"/usr/lib/debug/lib/firmware
+
+ # gzip -9 all modules
+ find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \; -exec mv {}.gz {}.gz.debug \;
+}
+
_package-headers() {
pkgdesc="Header files and scripts for building modules for ${pkgbase} kernel"
provides=("kernel26${_kernelname}-headers=${pkgver}")
@@ -317,7 +351,7 @@
rm -f "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
}
-pkgname=("${pkgbase}" "${pkgbase}-headers" "${pkgbase}-docs")
+pkgname=("${pkgbase}" "${pkgbase}-debuginfo" "${pkgbase}-headers" "${pkgbase}-docs")
for _p in ${pkgname[@]}; do
eval "package_${_p}() {
_package${_p#${pkgbase}}
diff -ur linux.orig/config linux/config
--- linux.orig/config 2012-08-28 21:53:04.757568936 +0400
+++ linux/config 2012-08-28 22:04:59.507558470 +0400
@@ -5620,7 +5620,8 @@
# CONFIG_DEBUG_KOBJECT is not set
# CONFIG_DEBUG_HIGHMEM is not set
CONFIG_DEBUG_BUGVERBOSE=y
-# CONFIG_DEBUG_INFO is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_INFO_REDUCED=n
# CONFIG_DEBUG_VM is not set
# CONFIG_DEBUG_VIRTUAL is not set
# CONFIG_DEBUG_WRITECOUNT is not set
diff -ur linux.orig/config.x86_64 linux/config.x86_64
--- linux.orig/config.x86_64 2012-08-28 21:53:04.760902270 +0400
+++ linux/config.x86_64 2012-08-28 22:05:06.900891696 +0400
@@ -5389,7 +5389,8 @@
# CONFIG_DEBUG_STACK_USAGE is not set
# CONFIG_DEBUG_KOBJECT is not set
CONFIG_DEBUG_BUGVERBOSE=y
-# CONFIG_DEBUG_INFO is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_INFO_REDUCED=n
# CONFIG_DEBUG_VM is not set
# CONFIG_DEBUG_VIRTUAL is not set
# CONFIG_DEBUG_WRITECOUNT is not set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment