wrs_build_kernel 1.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
#!/bin/bash

# check variables, like all scripts herein do
WRS_SCRIPT_NAME=$(basename $0)
if [ -z "$WRS_BASE_DIR" ]; then
    echo "$0: Plesae set WRS_BASE_DIR" >& 2
    exit 1
fi
. ${WRS_BASE_DIR}/scripts/wrs_functions

11
wrs_check_vars WRS_OUTPUT_DIR WRS_DOWNLOAD_DIR CROSS_COMPILE
12 13

wrs_echo "--- Linux kernel for switch"
14

15
tarname="linux-${KVER}.tar.xz"
16
patchdir="${WRS_BASE_DIR}/../patches/kernel/v${KVER}"
17
wrs_download $tarname
18 19 20 21 22 23

mkdir -p $WRS_OUTPUT_DIR/build || wrs_die "mkdir build"
mkdir -p $WRS_OUTPUT_DIR/images || wrs_die "mkdir images"

# go to the build dir and compile it, using our configuration
cd $WRS_OUTPUT_DIR/build
24
dirname="linux-${KVER}"
25
rm -rf $dirname
26 27
# xz archive, so use "J" for tar
tar xJf ${WRS_DOWNLOAD_DIR}/$tarname || wrs_die "untar $tarname"
28

29
# apply patches
30
cd $dirname
31
for n in ${patchdir}/00*; do
32 33 34 35 36
    patch -p1 < $n || wrs_die "patch kernel"
done


# copy the config and replace "-j" level. First remove it in case it's left in
37
CFG=$WRS_BASE_DIR/../configs/wrs_linux_defconfig
38 39 40 41
if [ "x$WRS_KERNEL_CONFIG" != "x" ]; then
    if [ -f $WRS_KERNEL_CONFIG ]; then
	CFG=$WRS_KERNEL_CONFIG
    else
42
	wrs_warn "WRS_KERNEL_CONFIG does not refer to a regular file: ignoring it"
43 44 45 46 47 48 49
	sleep 3
    fi
fi

cp $CFG .config
export ARCH=arm
make oldconfig  || wrs_die "kernel config"
50

51
make $WRS_MAKE_J zImage modules  || wrs_die "kernel compilation"
52

53
mkdir -p $WRS_OUTPUT_DIR/images/lib/modules/$KVER/kernel
54

55
cp $(find . -name '*.ko') $WRS_OUTPUT_DIR/images/lib/modules/$KVER/kernel
56
cp arch/$ARCH/boot/zImage $WRS_OUTPUT_DIR/images