aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWynn Wolf Arbor2020-06-04 15:07:24 +0200
committerWynn Wolf Arbor2020-06-04 16:01:30 +0200
commit74e9da1ae9dcee56112cb36b610856fe3620e6fc (patch)
tree543849658401bbcaf59fac4270d6e0994b44ee36
parent344f0f271daac9ad77c5b1da2ed59c3a3e394e13 (diff)
downloadkern-74e9da1ae9dcee56112cb36b610856fe3620e6fc.tar.gz
Drop nvim(1) dependency in diff_kernel
Commit 1b8d91f ("Use configuration file under /boot instead of /proc/config.gz") enables us to drop neovim as a dependency, since we can now access all configuration data through actual files. Use git-diff(1) (which has automatic paging & colours) if available to show the changes between kernel configurations, else fall back to diff(1). Since the exit code of diff utilities is >0 if inputs are different, ignore the exit code of the diff utility in test_diff() to continue like normal.
-rwxr-xr-xkern9
-rw-r--r--kern.14
2 files changed, 10 insertions, 3 deletions
diff --git a/kern b/kern
index 1f49a67..040d150 100755
--- a/kern
+++ b/kern
@@ -77,7 +77,12 @@ config_kernel() {
diff_kernel() {
diff=${1:-$(get_running_config)}
- nvim -d .config "$diff"
+
+ if command -v git >/dev/null; then
+ git diff --no-index "$diff" .config
+ else
+ diff -u "$diff" .config
+ fi
}
build_kernel() {
@@ -101,7 +106,7 @@ test_diff() {
dt=$(mktemp)
sed -nE '/^(# )?CONFIG_.*/p' "$(get_running_config)" > "$dt"
if ! sed -nE '/^(# )?CONFIG_.*/p' .config | diff -q "$dt" -; then
- diff_kernel
+ diff_kernel || true
printf "Continue? [y/N] "
read -r response
if test "$response" != "y"; then
diff --git a/kern.1 b/kern.1
index ac3e4e2..77a3a8b 100644
--- a/kern.1
+++ b/kern.1
@@ -97,7 +97,9 @@ If no template is given, this command uses the output of
as the template name.
.It Sy diff Op Ar config
Uses
-.Xr nvim 1
+.Xr git-diff 1
+if available, otherwise
+.Xr diff 1
to display the differences between the generated kernel configuration and
.Em config .
.Pp