cmd: zed: rc: drop "should be owned by root and 0600"
[zfs.git] / copy-builtin
blobcd6f259092ed46977d77f02d404c471013c1d0dd
1 #!/bin/sh
3 set -ef
5 usage()
7 echo "usage: $0 <kernel source tree>" >&2
8 exit 1
11 [ "$#" -eq 1 ] || usage
12 KERNEL_DIR="$1"
14 if ! [ -e 'zfs_config.h' ]
15 then
16 echo "$0: you did not run configure, or you're not in the ZFS source directory."
17 echo "$0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin."
19 exit 1
20 fi >&2
22 make clean ||:
23 make gitrev
25 rm -rf "$KERNEL_DIR/include/zfs" "$KERNEL_DIR/fs/zfs"
26 cp -R include "$KERNEL_DIR/include/zfs"
27 cp -R module "$KERNEL_DIR/fs/zfs"
28 cp zfs_config.h "$KERNEL_DIR/include/zfs/"
30 cat > "$KERNEL_DIR/fs/zfs/Kconfig" <<EOF
31 config ZFS
32 tristate "ZFS filesystem support"
33 depends on EFI_PARTITION
34 select ZLIB_INFLATE
35 select ZLIB_DEFLATE
36 help
37 This is the ZFS filesystem from the OpenZFS project.
39 See https://github.com/openzfs/zfs
41 To compile this file system support as a module, choose M here.
43 If unsure, say N.
44 EOF
46 add_after()
48 FILE="$1"
49 MARKER="$2"
50 NEW="$3"
52 while IFS='' read -r LINE
54 printf "%s\n" "$LINE"
56 if [ -n "$MARKER" ] && [ "$LINE" = "$MARKER" ]
57 then
58 printf "%s\n" "$NEW"
59 MARKER=''
60 if IFS='' read -r LINE
61 then
62 [ "$LINE" != "$NEW" ] && printf "%s\n" "$LINE"
65 done < "$FILE" > "$FILE.new"
67 mv "$FILE.new" "$FILE"
70 add_after "$KERNEL_DIR/fs/Kconfig" 'if BLOCK' 'source "fs/zfs/Kconfig"'
71 add_after "$KERNEL_DIR/fs/Makefile" 'endif' 'obj-$(CONFIG_ZFS) += zfs/'
73 echo "$0: done. now you can build the kernel with ZFS support." >&2
74 echo "$0: make sure you enable ZFS support (CONFIG_ZFS) before building." >&2