aboutsummaryrefslogtreecommitdiffstats
path: root/copy-builtin
diff options
context:
space:
mode:
authorilliliti <[email protected]>2021-05-08 15:58:26 +0000
committerGitHub <[email protected]>2021-05-08 08:58:26 -0700
commit36e8abee95576de588802afadd2c44c674e00acb (patch)
tree2212380e07434d4f9d147b0b1aa1214c54d8a5ce /copy-builtin
parent93c8e91fe7f5c55612131db64297106d7e5d1cdd (diff)
copy-builtin: posix conformance
This commits contains changes to allow running `copy-builtin` without bash + some minor improvements. changed shebang to /bin/sh added -f option to `set` to globally disable unneeded globbing replaced all `echo` commands within add_after() with `printf` alternative to avoid possible issues with options (-neE) dropped non-portable superfluous `readlink` command replaced superfluous `true` command with `:` builtin alternative replaced non-portable `--recursive` option of `cp` command with `-R` alternative dropped non-portable `local` keyword Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: illiliti <[email protected]> Closes #12004
Diffstat (limited to 'copy-builtin')
-rwxr-xr-xcopy-builtin45
1 files changed, 20 insertions, 25 deletions
diff --git a/copy-builtin b/copy-builtin
index 36e19545d..cd6f25909 100755
--- a/copy-builtin
+++ b/copy-builtin
@@ -1,6 +1,6 @@
-#!/usr/bin/env bash
+#!/bin/sh
-set -e
+set -ef
usage()
{
@@ -9,26 +9,25 @@ usage()
}
[ "$#" -eq 1 ] || usage
-KERNEL_DIR="$(readlink --canonicalize-existing "$1")"
+KERNEL_DIR="$1"
if ! [ -e 'zfs_config.h' ]
then
- echo >&2
- echo " $0: you did not run configure, or you're not in the ZFS source directory." >&2
- echo " $0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin." >&2
- echo >&2
+ echo "$0: you did not run configure, or you're not in the ZFS source directory."
+ echo "$0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin."
+
exit 1
-fi
+fi >&2
-make clean || true
+make clean ||:
make gitrev
rm -rf "$KERNEL_DIR/include/zfs" "$KERNEL_DIR/fs/zfs"
-cp --recursive include "$KERNEL_DIR/include/zfs"
-cp --recursive module "$KERNEL_DIR/fs/zfs"
+cp -R include "$KERNEL_DIR/include/zfs"
+cp -R module "$KERNEL_DIR/fs/zfs"
cp zfs_config.h "$KERNEL_DIR/include/zfs/"
-cat > "$KERNEL_DIR/fs/zfs/Kconfig" <<"EOF"
+cat > "$KERNEL_DIR/fs/zfs/Kconfig" <<EOF
config ZFS
tristate "ZFS filesystem support"
depends on EFI_PARTITION
@@ -46,22 +45,21 @@ EOF
add_after()
{
- local FILE="$1"
- local MARKER="$2"
- local NEW="$3"
- local LINE
+ FILE="$1"
+ MARKER="$2"
+ NEW="$3"
while IFS='' read -r LINE
do
- echo "$LINE"
+ printf "%s\n" "$LINE"
- if [ -n "$MARKER" -a "$LINE" = "$MARKER" ]
+ if [ -n "$MARKER" ] && [ "$LINE" = "$MARKER" ]
then
- echo "$NEW"
+ printf "%s\n" "$NEW"
MARKER=''
if IFS='' read -r LINE
then
- [ "$LINE" != "$NEW" ] && echo "$LINE"
+ [ "$LINE" != "$NEW" ] && printf "%s\n" "$LINE"
fi
fi
done < "$FILE" > "$FILE.new"
@@ -72,8 +70,5 @@ add_after()
add_after "$KERNEL_DIR/fs/Kconfig" 'if BLOCK' 'source "fs/zfs/Kconfig"'
add_after "$KERNEL_DIR/fs/Makefile" 'endif' 'obj-$(CONFIG_ZFS) += zfs/'
-echo >&2
-echo " $0: done." >&2
-echo " $0: now you can build the kernel with ZFS support." >&2
-echo " $0: make sure you enable ZFS support (CONFIG_ZFS) before building." >&2
-echo >&2
+echo "$0: done. now you can build the kernel with ZFS support." >&2
+echo "$0: make sure you enable ZFS support (CONFIG_ZFS) before building." >&2