]>
Commit | Line | Data |
---|---|---|
dda702fd | 1 | #!/usr/bin/env bash |
2ee4a18b ED |
2 | |
3 | set -e | |
4 | ||
5 | usage() | |
6 | { | |
7 | echo "usage: $0 <kernel source tree>" >&2 | |
8 | exit 1 | |
9 | } | |
10 | ||
11 | [ "$#" -eq 1 ] || usage | |
12 | KERNEL_DIR="$(readlink --canonicalize-existing "$1")" | |
13 | ||
2ee4a18b ED |
14 | if ! [ -e 'zfs_config.h' ] |
15 | then | |
16 | echo >&2 | |
17 | echo " $0: you did not run configure, or you're not in the ZFS source directory." >&2 | |
18 | echo " $0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin." >&2 | |
19 | echo >&2 | |
20 | exit 1 | |
21 | fi | |
22 | ||
23 | make clean || true | |
109d2c93 | 24 | make gitrev |
2ee4a18b ED |
25 | |
26 | rm -rf "$KERNEL_DIR/include/zfs" "$KERNEL_DIR/fs/zfs" | |
27 | cp --recursive include "$KERNEL_DIR/include/zfs" | |
28 | cp --recursive module "$KERNEL_DIR/fs/zfs" | |
93ce2b4c | 29 | cp zfs_config.h "$KERNEL_DIR/include/zfs/" |
2ee4a18b | 30 | |
2ee4a18b ED |
31 | cat > "$KERNEL_DIR/fs/zfs/Kconfig" <<"EOF" |
32 | config ZFS | |
c90ea655 | 33 | tristate "ZFS filesystem support" |
9a512dca RY |
34 | depends on EFI_PARTITION |
35 | select ZLIB_INFLATE | |
36 | select ZLIB_DEFLATE | |
2ee4a18b | 37 | help |
d0249a4b | 38 | This is the ZFS filesystem from the OpenZFS project. |
2ee4a18b | 39 | |
d0249a4b | 40 | See https://github.com/openzfs/zfs |
2ee4a18b ED |
41 | |
42 | To compile this file system support as a module, choose M here. | |
43 | ||
44 | If unsure, say N. | |
45 | EOF | |
46 | ||
2ee4a18b ED |
47 | add_after() |
48 | { | |
49 | local FILE="$1" | |
50 | local MARKER="$2" | |
51 | local NEW="$3" | |
52 | local LINE | |
53 | ||
54 | while IFS='' read -r LINE | |
55 | do | |
56 | echo "$LINE" | |
57 | ||
58 | if [ -n "$MARKER" -a "$LINE" = "$MARKER" ] | |
59 | then | |
60 | echo "$NEW" | |
61 | MARKER='' | |
62 | if IFS='' read -r LINE | |
63 | then | |
64 | [ "$LINE" != "$NEW" ] && echo "$LINE" | |
65 | fi | |
66 | fi | |
67 | done < "$FILE" > "$FILE.new" | |
68 | ||
69 | mv "$FILE.new" "$FILE" | |
70 | } | |
71 | ||
72 | add_after "$KERNEL_DIR/fs/Kconfig" 'if BLOCK' 'source "fs/zfs/Kconfig"' | |
73 | add_after "$KERNEL_DIR/fs/Makefile" 'endif' 'obj-$(CONFIG_ZFS) += zfs/' | |
74 | ||
75 | echo >&2 | |
76 | echo " $0: done." >&2 | |
77 | echo " $0: now you can build the kernel with ZFS support." >&2 | |
78 | echo " $0: make sure you enable ZFS support (CONFIG_ZFS) before building." >&2 | |
79 | echo >&2 |