File pdksh.spec of Package pdksh

#
# spec file for package pdksh (Version 5.2.14)
#
# Copyright (c) 2010 SUSE LINUX Products 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/
#

# norootforbuild


Name:           pdksh
Url:            http://www.cs.mun.ca/~michael/pdksh/
License:        GPLv2+ ; Public Domain, Freeware
Group:          System/Shells
BuildRequires:  update-alternatives
PreReq:         /bin/ln /bin/rm /etc/bash.bashrc /bin/true
PreReq:         update-alternatives
AutoReqProv:    on
Version:        5.2.14
Release:        929
Summary:        Public Domain Korn Shell
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Source:         pdksh-5.2.14.tar.bz2
Patch:          pdksh-5.2.14.dif
Patch1:         pdksh-5.2.14-patches.1
Patch2:         pdksh-5.2.14-patches.2
Patch3:         pdksh-5.2.14-10711.patch
Patch4:         pdksh-5.2.14-73718.patch

%description
A public domain Korn Shell clone.



%prep
%setup
%patch1 -p 0 -b .patches.1
%patch2 -p 0 -b .patches.2
%patch3 -p 0 -b .10711
%patch4 -p 0 -b .73718
%patch

%build
export CFLAGS="$RPM_OPT_FLAGS -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
./configure --prefix=/%{_exec_prefix} --verbose --mandir=%{_mandir} --bindir=/bin
make

%install
make install bindir=%{buildroot}/bin mandir=%{buildroot}/%{_mandir}/man1
mv %{buildroot}/bin/ksh %{buildroot}/bin/pdksh
mv %{buildroot}%{_mandir}/man1/ksh.1 %{buildroot}%{_mandir}/man1/pdksh.1
mkdir -p %{buildroot}/usr/bin
ln -sf /bin/pdksh %{buildroot}/usr/bin/pdksh
# create ghost files
ln -sf /bin/true	  %{buildroot}/bin/ksh
ln -sf /bin/true	  %{buildroot}/%{_bindir}/ksh
ln -sf ../man1/pdksh.1.gz %{buildroot}/%{_mandir}/man1/ksh.1.gz

%post
test -e etc/bash.bashrc && ln -sf bash.bashrc etc/ksh.kshrc || true
%{_sbindir}/update-alternatives --install /bin/ksh ksh /bin/pdksh 15 \
  --slave %{_bindir}/ksh usr-bin-ksh /bin/pdksh \
  --slave %{_mandir}/man1/ksh.1.gz ksh.1.gz %{_mandir}/man1/pdksh.1.gz

%preun
if test $1 -eq 0 ; then
    %{_sbindir}/update-alternatives --remove ksh /bin/pdksh
fi

%postun
if test ! -x bin/pdksh ; then
    if test ! -x %{_lib}/ast/ksh ; then
	rm -f etc/ksh.kshrc
    fi
fi

%files
%defattr(-,root,root)
%doc BUG-REPORTS  NEWS  NOTES  PROJECTS  README
/bin/pdksh
%ghost %verify(not link) /bin/ksh
%ghost %verify(not link) %{_bindir}/ksh
%{_bindir}/pdksh
%ghost %verify(not link) %{_mandir}/man1/ksh.1.gz
%doc %{_mandir}/man1/pdksh.1.gz

%changelog
openSUSE Build Service is sponsored by