aboutsummaryrefslogtreecommitdiff
path: root/personal/linux-zfs/build
diff options
context:
space:
mode:
Diffstat (limited to 'personal/linux-zfs/build')
-rwxr-xr-xpersonal/linux-zfs/build74
1 files changed, 74 insertions, 0 deletions
diff --git a/personal/linux-zfs/build b/personal/linux-zfs/build
new file mode 100755
index 0000000..e20e179
--- /dev/null
+++ b/personal/linux-zfs/build
@@ -0,0 +1,74 @@
+#!/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 ;}
+
+ROOT=$PWD
+ver=$(make -C linux -s kernelversion)
+
+# Prepare the kernel sources first.
+(
+ out "Preparing the kernel"
+ cd linux
+ patch -p1 < kernel-no-perl.patch
+
+ cp .config oldconfig
+ ./scripts/config -e modules
+ make olddefconfig
+ make prepare
+)
+
+(
+ out "Preparing zfs modules"
+ cd zfs
+
+ sed -i 's|CDDL|GPL|g' META
+
+ ./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --sbindir=/usr/bin \
+ --disable-systemd \
+ --disable-sysvinit \
+ --disable-nls \
+ --enable-linux-builtin \
+ --with-linux="$ROOT/linux"
+
+ sed -i "/^KERNEL_DIR/s|^.*|KERNEL_DIR=$ROOT/linux|" copy-builtin
+ ./copy-builtin "$ROOT/linux"
+)
+
+(
+ cd linux
+
+ # Enable zfs
+ ./scripts/config -e zfs -d modules
+
+ out "Compiling the kernel"
+ make
+
+ out "Installing the kernel"
+ install -Dm644 "$(make -s image_name)" "$1/boot/vmlinuz-$ver"
+ install -Dm644 System.map "$1/boot/System.map-$ver"
+ install -Dm644 oldconfig "$1/boot/Config-$ver"
+)