Add default-editor subpackage (#1854444)

Reference: https://fedoraproject.org/wiki/Changes/UseNanoByDefault
This commit is contained in:
Neal Gompa 2020-07-16 23:31:57 -04:00
parent f1e1d2d934
commit cf1ce689f1
4 changed files with 48 additions and 1 deletions

5
nano-default-editor.csh Normal file
View File

@ -0,0 +1,5 @@
# Ensure GNU nano is set as EDITOR if it isn't already set
if ( ! ($?EDITOR) ) then
setenv EDITOR "/usr/bin/nano"
endif

8
nano-default-editor.fish Normal file
View File

@ -0,0 +1,8 @@
# Ensure GNU nano is set as EDITOR if it isn't already set
# This is set as a universal variable so that any other definition
# by the user would win
# Cf. https://fishshell.com/docs/current/index.html#variables-scope
if ! set -q EDITOR;
set -Ux EDITOR /usr/bin/nano
end

5
nano-default-editor.sh Normal file
View File

@ -0,0 +1,5 @@
# Ensure GNU nano is set as EDITOR if it isn't already set
if [ -z "$EDITOR" ]; then
export EDITOR="/usr/bin/nano"
fi

View File

@ -1,12 +1,17 @@
Summary: A small text editor Summary: A small text editor
Name: nano Name: nano
Version: 4.9.3 Version: 4.9.3
Release: 1%{?dist} Release: 2%{?dist}
License: GPLv3+ License: GPLv3+
URL: https://www.nano-editor.org URL: https://www.nano-editor.org
Source: https://www.nano-editor.org/dist/latest/%{name}-%{version}.tar.xz Source: https://www.nano-editor.org/dist/latest/%{name}-%{version}.tar.xz
Source2: nanorc Source2: nanorc
# Shell snippets for default-editor setup
Source11: nano-default-editor.sh
Source12: nano-default-editor.csh
Source13: nano-default-editor.fish
BuildRequires: file-devel BuildRequires: file-devel
BuildRequires: gettext-devel BuildRequires: gettext-devel
BuildRequires: gcc BuildRequires: gcc
@ -20,6 +25,15 @@ Conflicts: filesystem < 3
%description %description
GNU nano is a small and friendly text editor. GNU nano is a small and friendly text editor.
%package default-editor
Summary: Sets GNU nano as the default editor
Requires: nano = %{version}-%{release}
BuildArch: noarch
%description default-editor
This package ensures the EDITOR shell variable
is set in common shells to GNU nano.
%prep %prep
%autosetup -S git %autosetup -S git
@ -53,6 +67,11 @@ install -m 0644 ./nanorc %{buildroot}%{_sysconfdir}/nanorc
%find_lang %{name} %find_lang %{name}
# install nano-default-editor snippets
install -Dpm 0644 %{SOURCE11} %{buildroot}%{_sysconfdir}/profile.d/%{basename:%{S:11}}
install -Dpm 0644 %{SOURCE12} %{buildroot}%{_sysconfdir}/profile.d/%{basename:%{S:12}}
install -Dpm 0644 %{SOURCE13} %{buildroot}%{_datadir}/fish/vendor_conf.d/%{basename:%{S:13}}
%files -f build/%{name}.lang %files -f build/%{name}.lang
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README THANKS TODO %doc AUTHORS COPYING ChangeLog INSTALL NEWS README THANKS TODO
%doc build/doc/sample.nanorc %doc build/doc/sample.nanorc
@ -63,7 +82,17 @@ install -m 0644 ./nanorc %{buildroot}%{_sysconfdir}/nanorc
%{_infodir}/nano.info* %{_infodir}/nano.info*
%{_datadir}/nano %{_datadir}/nano
%files default-editor
%dir %{_sysconfdir}/profile.d
%config(noreplace) %{_sysconfdir}/profile.d/nano-default-editor.*
%dir %{_datadir}/fish/vendor_conf.d
%{_datadir}/fish/vendor_conf.d/nano-default-editor.fish
%changelog %changelog
* Thu Jul 16 2020 Neal Gompa <ngompa13@gmail.com> - 4.9.3-2
- Add default-editor subpackage (#1854444)
* Mon May 25 2020 Kamil Dudka <kdudka@redhat.com> - 4.9.3-1 * Mon May 25 2020 Kamil Dudka <kdudka@redhat.com> - 4.9.3-1
- new upstream release - new upstream release