File rc.spec of Package rc

%if 0%{?fedora} < 17 && 0%{?rhel} < 7
%global _bindir   /bin
%endif

Summary:          Re-implementation for Unix of the Plan 9 shell
Name:             rc
Version:          1.7.4
Release:          1%{?dist}
License:          zlib
Group:            System Environment/Shells
URL:              http://tobold.org/article/rc
Source0:          http://static.tobold.org/%{name}/%{name}-%{version}.tar.gz
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
Conflicts:        filesystem < 3
Provides:         /bin/rc
%endif
Requires(post):   grep
Requires(postun): sed
BuildRequires:    readline-devel
BuildRoot:        %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

%description
Rc is a command interpreter for Plan 9 that provides similar facilities to
UNIX's Bourne shell, with some small additions and less idiosyncratic syntax.
This is a re-implementation for Unix, by Byron Rakitzis, of the Plan 9 shell.

%prep
%setup -q

%build
%configure --with-edit=gnu
make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT INSTALL='install -p' install

%check
make check

%post
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
grep -q "^/bin/%{name}$" %{_sysconfdir}/shells 2>/dev/null || \
  echo "/bin/%{name}" >> %{_sysconfdir}/shells
%endif
grep -q "^%{_bindir}/%{name}$" %{_sysconfdir}/shells 2>/dev/null || \
  echo "%{_bindir}/%{name}" >> %{_sysconfdir}/shells

%postun
if [ ! -x %{_bindir}/%{name} ]; then
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
  sed -e 's@^/bin/%{name}$@POSTUNREMOVE@' -e '/^POSTUNREMOVE$/d' -i %{_sysconfdir}/shells
%endif
  sed -e 's@^%{_bindir}/%{name}$@POSTUNREMOVE@' -e '/^POSTUNREMOVE$/d' -i %{_sysconfdir}/shells
fi

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%{!?_licensedir:%global license %%doc}
%license COPYING
%doc ChangeLog AUTHORS EXAMPLES NEWS README
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1*

%changelog
* Wed May 13 2015 Robert Scheck <robert@fedoraproject.org> 1.7.4-1
- Upgrade to 1.7.4

* Sat May 09 2015 Robert Scheck <robert@fedoraproject.org> 1.7.3-1
- Upgrade to 1.7.3

* Wed Apr 08 2015 Robert Scheck <robert@fedoraproject.org> 1.7.2-1
- Upgrade to 1.7.2
- Initial spec file for Fedora and Red Hat Enterprise Linux
openSUSE Build Service is sponsored by