diff options
Diffstat (limited to 'personal/linux/build')
-rwxr-xr-x | personal/linux/build | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/personal/linux/build b/personal/linux/build new file mode 100755 index 0000000..6f77fd3 --- /dev/null +++ b/personal/linux/build @@ -0,0 +1,76 @@ +#!/bin/sh -e + +# POSIX install functions, similar to 'install -Dm' +# and 'install -Dm* -t' +kinstall() { + # usage: kinstall 644 file /usr/bin/prog + mkdir -p "${3%/*}"; rmdir "$3" 2>/dev/null ||: + cp "$2" "$3" + [ -d "$3" ] && set -- "$1" "$3/${2##*/}" + chmod "$1" "${3:-$2}" +} + +kinstall_t() { + # usage: kinstall_t 644 /usr/bin prog1 prog2 + mod=$1 dir=$2; mkdir -p "$dir" + shift 2 + for file; do + cp "$file" "$dir" + chmod "$mod" "$dir/${file##*/}" + done +} + +# Use an out function similar to KISS' log. +out() { printf '\033[1;33m-> \033[1;36mlinux \033[m%s\n' "$@" >&2 ;} + +patch -p1 < kernel-no-perl.patch + +cp .config oldconfig +make olddefconfig + +# Store the build version in a file and a variable. +make kernelrelease > version +read ver < version + +modulepath="$1/usr/lib/modules/$ver/build" + +out "Compiling the kernel" +make + +out "Installing the kernel" +kinstall 644 "$(make -s image_name)" "$1/boot/vmlinuz-$ver" +kinstall 644 System.map "$1/boot/System.map-$ver" +kinstall 644 .config "$1/boot/Config-$ver" + +out "Installing kernel modules" +make INSTALL_MOD_PATH="$1/usr" modules_install + +out "Creating module source directory" +rm -f "${modulepath%/*}/build" "${modulepath%/*}/source" +kinstall_t 644 "$modulepath/arch/x86" arch/x86/Makefile +kinstall_t 644 "$modulepath/arch/x86/kernel" arch/x86/kernel/asm-offsets.s +kinstall_t 644 "$modulepath/kernel" kernel/Makefile +kinstall_t 644 "$modulepath/drivers/md" drivers/md/*.h +kinstall_t 644 "$modulepath/net/mac80211" net/mac80211/*.h +kinstall_t 755 "$modulepath/tools/objtool" tools/objtool/objtool +kinstall_t 644 "$modulepath" .config Makefile Module.symvers \ + System.map version vmlinux + + +cp -a scripts "$modulepath/scripts" +cp -a include "$modulepath/include" +cp -a arch/x86/include "$modulepath/arch/x86/include" + +find . -name 'Kconfig*' | while read -r file; do + kinstall 644 "$file" "$modulepath/$file" +done + +out "Removing junk" +find -L "${modulepath%/*}" -type l -exec rm -rf {} + +find "${modulepath%/*}" -type f -name '*.o' -exec rm -rf {} + + +out "Linking /usr/src/linux to the module directory" +mkdir -p "$1/usr/src" +ln -sf "${modulepath#$1}" "$1/usr/src/linux" + +out Done. |