--- /dev/null
+How to debug with gdb
+=====================
+* Load the module with debugging symbols into gdb:
+ $ gdb liveboot-123-kernel-dbg/ethoip6-8.0.36-dbg/vhost_net.ko
+* Make the source code directories known to gdb:
+ gdb) directory liveboot-123-kernel-dbg/ethoip6-8.0.36/
+ gdb) directory liveboot-123-kernel-dbg/linux-3.4.51-4-pserver/
+* Happy debugging! :)
--- /dev/null
+#!/bin/bash
+
+set -eux
+
+script_dir="$( cd "$( dirname "$0" )" && pwd )"
+workdir="$(mktemp -d)"
+liveboot_id="$LIVEBOOT_BUILD_NUMBER"
+assembledir="$workdir/liveboot-$liveboot_id-kernel-dbg"
+
+
+cidb_query() {
+ local qry="$1"
+ export PGPASSWORD="cidb"
+ psql -t -A -q -U cidb -h jenkins --command "$qry"
+}
+
+liveboot_name="$(cidb_query "SELECT l.build_name from liveboot AS l JOIN jenkins_build AS j ON l.jenkins_build_id = j.id WHERE j.jenkins_build_number = $liveboot_id;")"
+kernel_ver="$(cidb_query "SELECT p.version from package_list_view AS p JOIN liveboot AS l ON l.package_list_id = p.package_list_id JOIN jenkins_build AS j ON l.jenkins_build_id = j.id WHERE j.jenkins_build_number = $liveboot_id AND p.name = 'profitbricks-linux-image-pserver';")"
+ethoip6_ver="$(cidb_query "SELECT p.version from package_list_view AS p JOIN liveboot AS l ON l.package_list_id = p.package_list_id JOIN jenkins_build AS j ON l.jenkins_build_id = j.id WHERE j.jenkins_build_number = $liveboot_id AND p.name = 'profitbricks-ethoip6-modules-pserver';")"
+resultfile="/srv/liveboot/debug_archives/$liveboot_name-kernel-dbg.tar.xz"
+
+[ -e $resultfile ] && {
+ echo "Error: $resultfile already exists"
+ exit 1
+}
+
+mkdir -p "$assembledir"
+cd "$workdir"
+
+sudo aptitude update
+
+# assemble ethoip6 debug directory
+aptitude download profitbricks-linux-source-pserver=$kernel_ver
+dpkg -x profitbricks-linux-source-pserver_$kernel_ver*.deb kernel_source
+mv kernel_source/usr/src/linux-*-pserver $assembledir/
+
+aptitude download profitbricks-linux-image-pserver-dbg=$kernel_ver
+dpkg -x profitbricks-linux-image-pserver-dbg_$kernel_ver*.deb kernel_dbg
+mkdir -p $assembledir/linux-$kernel_ver-pserver-dbg
+mv kernel_dbg/usr/lib/debug/vmlinux* kernel_dbg/usr/lib/debug/lib/modules/*-pserver $assembledir/linux-$kernel_ver-pserver-dbg
+
+# assemble ethoip6 debug directory
+
+aptitude download ethoip6-sources=$ethoip6_ver
+dpkg -x ethoip6-sources_$ethoip6_ver*.deb ethoip6_src
+mv ethoip6_src/usr/src/ethoip6* $assembledir/
+
+aptitude download profitbricks-ethoip6-modules-pserver-dbg=$ethoip6_ver
+dpkg -x profitbricks-ethoip6-modules-pserver-dbg_$ethoip6_ver*.deb ethoip6_dbg
+mkdir -p $assembledir/ethoip6-$ethoip6_ver-dbg
+find ethoip6_dbg -name "*.ko" -exec mv {} $assembledir/ethoip6-$ethoip6_ver-dbg/ \;
+
+cp "$script_dir/README" $assembledir/
+tar --owner=root -Ipixz -cf "$resultfile" liveboot-$liveboot_id-kernel-dbg -C $workdir
+
+rm -rf "$workdir"