summaryrefslogtreecommitdiff
path: root/bcc/build-kheaders-targz.sh
blob: 06eed93f25c507ef9165738b5f93894c21c77c34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
script_full_path=$( cd "$(dirname "$0")" ; pwd -P )

if [ $# -ne 2 ]; then
    echo "illegal number of parameters, usage: ./build KERNEL_PATH out.tar.gz"
    exit 1
fi

# Please provide absolute paths
KERNEL_PATH=$1
OUT_TAR=$2

KERNEL_PATH="$(dirname $(readlink -e $KERNEL_PATH))/$(basename $KERNEL_PATH)"
if [ ! -d "$KERNEL_PATH" ]; then
        echo "Kernel directory couldn't be found"
        exit 3
fi

# kdir=$(basename $KERNEL_PATH)

cd $KERNEL_PATH
find arch -name include -type d -print | xargs -n1 -i: find : -type f > /tmp/kernel-headers.h
find include >> /tmp/kernel-headers.h

grep "include/generated/autoconf.h" /tmp/kernel-headers.h > /dev/null 2>&1
retgrep=$?
if [ $retgrep -ne 0 ]; then
	>&2 echo ""
	>&2 echo "The kernel sources at ${KERNEL_PATH} you pointed to aren't configured and built."
	>&2 echo "Please atleast run in your kernel sources:"
	>&2 echo $'make defconfig\nmake'
	>&2 echo $'\nNote: You dont need to do the full build since headers are generated early on.\n'
	>&2 echo "Note: Please build your kernel in tree (build and source should be in same directory)"
	>&2 echo ""
	exit $retgrep
fi

cat /tmp/kernel-headers.h | tar -zcf $OUT_TAR -T -
rm /tmp/kernel-headers.h