File posh.spec of Package posh

#
# spec file for package posh
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           posh
Version:        0.13.2
Release:        0
Summary:        Policy-compliant Ordinary SHell
License:        GPL-2.0+
Group:          System/Shells
Url:            https://salsa.debian.org/clint/posh
Source0:        posh-debian-0.13.2.tar.bz2
Source1:        posh-rpmlintrc
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  bison
BuildRequires:  fdupes
BuildRequires:  makeinfo
BuildRequires:  ncurses-devel
BuildRequires:  patchutils
BuildRequires:  pkg-config
BuildRequires:  screen
BuildRequires:  sed
BuildRequires:  update-alternatives
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
The posh is a reimplementation of the Bourne SHell, a command interpreter
for both interactive and script use. This shell is based on a version of
pdksh. It is currently SUSv3 compliance with the following exceptions:
echo -n, binary -a and -o to test, local scoping.
This package might replace the system Bourne SHell /bin/sh with the posh,
the Policy-compliant Ordinary SHell. To do this use the tool
"update-alternatives" with the option "--config sh".

%prep
%setup -q -n posh-debian-%version

%build
autoreconf --install --symlink
%configure
make %{?_smp_mflags}

%install
%make_install
mkdir -p %{buildroot}/bin
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
ln -sf %{_bindir}/%name %{buildroot}/bin/%name
ln -sf %{_bindir}/%name %{buildroot}%{_sysconfdir}/alternatives/sh
#ln -sf %{_sysconfdir}/alternatives/sh %{buildroot}%{_bindir}/sh

%post -p /bin/posh
%{_sbindir}/update-alternatives --quiet \
        --install %{_bindir}/sh sh %{_bindir}/posh 100

%preun -p /bin/posh
if test "$1" = 0; then
	%{_sbindir}/update-alternatives --quiet --remove sh %{_bindir}/posh
fi

%files
%defattr(-,root,root)
#
# Warning: never add /usr/bin/sh as this symbolic link becomes
# removed making the system unusable, Ignore rpmlinit here.
#
%license COPYING
%ghost %config %{_sysconfdir}/alternatives/sh
/bin/%name
%{_bindir}/%name
%{_mandir}/man1/%{name}.1%{ext_man}

%changelog
openSUSE Build Service is sponsored by