diff --git a/DIFF_COLORS b/DIFF_COLORS new file mode 100644 index 0000000..8d87064 --- /dev/null +++ b/DIFF_COLORS @@ -0,0 +1,4 @@ +# Configuration file for the color diff utility + +# 'none' shuts colorization off. +#COLOR none diff --git a/colordiff.csh b/colordiff.csh new file mode 100644 index 0000000..3f71856 --- /dev/null +++ b/colordiff.csh @@ -0,0 +1,9 @@ + +# color-diff initialization + +/usr/libexec/diffconf.sh -c +if ( $status == 1 ) then + exit +endif + +alias diff 'diff --color=auto' diff --git a/colordiff.sh b/colordiff.sh new file mode 100644 index 0000000..780fd6e --- /dev/null +++ b/colordiff.sh @@ -0,0 +1,5 @@ +# color-diff initialization + +/usr/libexec/diffconf.sh -c || return + +alias diff='diff --color=auto' 2>/dev/null diff --git a/diffconf.sh b/diffconf.sh new file mode 100644 index 0000000..ddba4b8 --- /dev/null +++ b/diffconf.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +case "$1" in + -c | --interactive-color) + ! diff -qsi "^COLOR.*none" /etc/DIFF_COLORS + ;; + *) + echo >&2 "Invalid / no option passed, so far only -c | --interactive-color is supported." + exit 1 + ;; +esac diff --git a/diffutils.spec b/diffutils.spec index 3c90eaf..20bc059 100644 --- a/diffutils.spec +++ b/diffutils.spec @@ -1,9 +1,13 @@ Summary: GNU collection of diff utilities Name: diffutils Version: 3.12 -Release: 3%{?dist} +Release: 4%{?dist} URL: https://www.gnu.org/software/diffutils/diffutils.html Source: https://ftp.gnu.org/gnu/diffutils/diffutils-%{version}.tar.xz +Source2: colordiff.sh +Source3: colordiff.csh +Source4: DIFF_COLORS +Source5: diffconf.sh # upstream fixes # cross compile build of 3.12 diffutils fails Patch: diffutils-3.12-cross-compiler-build-fail.patch @@ -46,6 +50,11 @@ make PR_PROGRAM=%{_bindir}/pr %install %make_install +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d +install -pm 644 %{SOURCE2} %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/profile.d +install -pm 644 %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir} +install -Dpm 755 %{SOURCE5} $RPM_BUILD_ROOT%{_libexecdir}/diffconf.sh + rm -f $RPM_BUILD_ROOT%{_infodir}/dir %find_lang %{name} @@ -60,8 +69,14 @@ make check %{_bindir}/* %{_mandir}/*/* %{_infodir}/diffutils.info* +%config(noreplace) %{_sysconfdir}/profile.d/colordiff.*sh +%config(noreplace) %{_sysconfdir}/DIFF_COLORS +%{_libexecdir}/diffconf.sh %changelog +* Sat Oct 25 2025 Fedora Release Engineering - 3.12-4 +- add automatic color alias for diff (copied from grep) + * Wed Jul 23 2025 Fedora Release Engineering - 3.12-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild