diff --git a/0001-Add-functions-and-configuration-snippets-hierarchy.patch b/0001-Add-functions-and-configuration-snippets-hierarchy.patch new file mode 100644 index 0000000..04548f4 --- /dev/null +++ b/0001-Add-functions-and-configuration-snippets-hierarchy.patch @@ -0,0 +1,98 @@ +[Backport by amluto: use basename instead of string replace] + +From c1b384e5d3f2f46e7d7a1b41e31c7aadc1d9ce28 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Fabian Homborg +Date: Tue, 20 Oct 2015 23:21:57 +0200 +Subject: [PATCH] Add functions and configuration snippets hierarchy + +This allows "vendors" (i.e. third-party upstreams interested in +supporting fish) to add auto-loaded functions and eager-loaded +configuration "snippets", while still allowing both the user and the administrator to +fully override all of that. + +This has been inspired by systemd's configuration hierarchy, and implements a similar scheme +whereby files with the same name in higher-ranking directories override files in lower-ranking ones. + +Fixes #1956 +--- + Makefile.in | 3 +++ + doc_src/index.hdr.in | 1 + + fish.pc.in | 2 ++ + share/config.fish | 14 +++++++++++++- + 4 files changed, 19 insertions(+), 1 deletion(-) + +diff --git a/Makefile.in b/Makefile.in +index 88155b2d58fd..056a3d814457 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -660,9 +660,12 @@ install-force: all install-translations + true ;\ + done; + $(INSTALL) -m 755 -d $(DESTDIR)$(sysconfdir)/fish ++ $(INSTALL) -m 755 -d $(DESTDIR)$(sysconfdir)/fish/conf.d + $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish + $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/completions + $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/vendor_completions.d ++ $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/vendor_functions.d ++ $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/vendor_conf.d + $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/functions + $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/man/man1 + $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools +diff --git a/doc_src/index.hdr.in b/doc_src/index.hdr.in +index 9531876b5aca..a0f7ec0a2001 100644 +--- a/doc_src/index.hdr.in ++++ b/doc_src/index.hdr.in +@@ -1088,6 +1088,7 @@ function on_exit --on-process %self + end + \endfish + ++Right after reading /usr/share/fish/config.fish and before reading /etc/fish/config.fish, fish will also read files in ~/.config/fish/conf.d/, /etc/fish/conf.d and /usr/share/fish/vendor_conf.d (the exact values depend on $XDG_CONFIG_HOME, $__fish_sysconfdir and $__fish_datadir). If there are files with the same name in two or all of these, fish will only attempt to read the first (skipping all files with that name if it is unreadable). ~/.config takes precedence over /etc/ which takes precedence over /usr. The path to the latter can also be gotten via `pkg-config` as "confdir", and is meant for third-party applications to integrate with fish. + + \section other Other features + +diff --git a/fish.pc.in b/fish.pc.in +index cae82246b808..c8fabd7e8fbf 100644 +--- a/fish.pc.in ++++ b/fish.pc.in +@@ -1,6 +1,8 @@ + prefix=@prefix@ + datadir=@datadir@ + completionsdir=${datadir}/fish/vendor_completions.d ++functionsdir=${datadir}/fish/vendor_functions.d ++confdir=${datadir}/fish/vendor_conf.d + + Name: fish + Description: fish, the friendly interactive shell +diff --git a/share/config.fish b/share/config.fish +index b1d404eecdac..40000740971b 100644 +--- a/share/config.fish ++++ b/share/config.fish +@@ -49,7 +49,7 @@ end + # default functions/completions are included in the respective path. + + if not set -q fish_function_path +- set fish_function_path $configdir/fish/functions $__fish_sysconfdir/functions $__fish_datadir/functions ++ set fish_function_path $configdir/fish/functions $__fish_sysconfdir/functions $__fish_datadir/vendor_functions.d $__fish_datadir/functions + end + + if not contains $__fish_datadir/functions $fish_function_path +@@ -151,3 +151,15 @@ function . --description 'Evaluate contents of file (deprecated, see "source")' + source $argv + end + end ++ ++# As last part of initialization, source the conf directories ++# Implement precedence (User > Admin > Vendors > Fish) by basically doing "basename" ++set -l sourcelist ++for file in $configdir/fish/conf.d/* $__fish_sysconfdir/conf.d/* $__fish_datadir/vendor_conf.d/* ++ set -l basename (basename -- $file) ++ contains -- $basename $sourcelist; and continue ++ set sourcelist $sourcelist $basename ++ # Also skip non-files or unreadable files ++ # This allows one to use e.g. symlinks to /dev/null to "mask" something (like in systemd) ++ [ -f $file -a -r $file ]; and source $file ++end +-- +2.5.0 + diff --git a/fish.spec b/fish.spec index 1b2de1d..49d824e 100644 --- a/fish.spec +++ b/fish.spec @@ -1,6 +1,6 @@ Name: fish Version: 2.2.0 -Release: 10%{?dist} +Release: 11%{?dist} Summary: A friendly interactive shell Group: System Environment/Shells @@ -24,6 +24,9 @@ Patch2: pr-2393-2.patch # Fix C++11 build Patch3: fish_tests_c++11.patch +# Add in config directories +Patch4: 0001-Add-functions-and-configuration-snippets-hierarchy.patch + %if 0%{?rhel} BuildRequires: python34-devel %global __python %{__python34} @@ -51,6 +54,7 @@ nothing to learn or configure. %patch1 -p2 %patch2 -p2 %patch3 -p2 +%patch4 -p1 # This is unused. If we fiddle with Python versions, its presence will # be confusing. @@ -78,6 +82,11 @@ rm %{buildroot}/usr/share/pkgconfig/fish.pc cp README.md %{buildroot}%{_pkgdocdir} cp CONTRIBUTING.md %{buildroot}%{_pkgdocdir} +# filesystem will own a couple of config directories so that other packages +# can ship fish config snippets without requiring fish: +rmdir %{buildroot}%{_datadir}/fish/vendor_completions.d +rmdir %{buildroot}%{_datadir}/fish/vendor_conf.d + %check # fish_tests is somewhat sensitive to the contents of the filesystem. @@ -107,11 +116,14 @@ fi %files -f %{name}.lang %{_mandir}/man1/*.1* %{_bindir}/* -%config(noreplace) %{_sysconfdir}/fish +%config(noreplace) %{_sysconfdir}/fish/ %{_datadir}/fish/ %{_pkgdocdir} %changelog +* Fri Feb 26 2016 luto@kernel.org - 2.2.0-11 +- Add function/snippet hierarchy (backported from upstream) + * Thu Feb 04 2016 luto@kernel.org - 2.2.0-10 - Fix build on GCC 6