# -*- Mode: rpm-spec -*-

%define name zsh
%define version 5.2
%define rversion %{version}
%define dversion %{version}
%define release 1%{?_dist_release}
## %define _sysconfdir /etc

Summary: A shell with lots of features.
Summary(ja): 多機能シェル
Name: %{name}
Version: %{version}
Release: %{release}
License: distributable (see LICENCE file)
Group: System Environment/Shells
Url: http://www.zsh.org
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz
Source1: zcfg-vine.tar.bz2
# fixed that _apt fail  completions rpm package name.
Patch0: zsh-4.3.4-apt4rpm.patch
Patch1: zsh-4.3.4-sshcomp.patch
Patch2: zsh-4.2.0-completion_tar_archive.patch
Patch3: zsh-5.0.7-fixpath.patch
Requires(post,preun): /sbin/install-info
Requires(post,postun): grep
BuildRoot: %{_tmppath}/%{name}-buildroot
BuildRequires: texinfo, ncurses-devel
BuildRequires: findutils grep
BuildRequires: man-db

Vendor: Project Vine
Distribution: Vine Linux
Packager: iwaim
Epoch: 1

%description
Zsh is a UNIX command interpreter (shell) usable as an
interactive login shell and as a shell script command
processor. Of the standard shells, zsh most closely resembles
ksh but includes many enhancements. Zsh has command-line editing,
built-in spelling correction, programmable command completion,
shell functions (with autoloading), a history mechanism, and a
lots of other features

Install the zsh package if you'd like to try out a different shell.

%description -l ja
Zsh 対話的に使える コマンドラインインタプリタ(シェル)です。
規格上Zsh はksh ににているが多くの拡張がされている。
スペルコレクション,プログラマブル補完,
シェルファンクションズ(オートロード),等の多くの機能がある。

%prep
%setup -q -a 1 -n %{name}-%{rversion}
#%patch0 -p1
#%patch1 -p1
#%patch2 -p1
%patch3 -p1

# remove temporary files
find|grep '~$'|xargs rm -f

%build

%ifnarch sparc
%configure \
	   --enable-etcdir=%{_sysconfdir} \
	   --enable-fndir=%{_datadir}/zsh/functions \
	   --enable-site-fndir=%{_datadir}/zsh/site-functions \
	   --enable-function-subdirs \
	   --enable-scriptdir=%{_datadir}/zsh/scripts \
	   --enable-site-scriptdir=%{_datadir}/zsh/site-scripts \
	   --with-tcsetpgrp
%else
%configure \
	   --enable-etcdir=%{_sysconfdir} \
	   --enable-fndir=%{_datadir}/zsh/functions \
	   --enable-site-fndir=%{_datadir}/zsh/site-functions \
	   --enable-function-subdirs \
	   --enable-scriptdir=%{_datadir}/zsh/scripts \
	   --enable-site-scriptdir=%{_datadir}/zsh/site-scripts
	   --disable-lfs
%endif
make

%install
rm -rf $RPM_BUILD_ROOT
%makeinstall fndir=%{buildroot}%{_datadir}/zsh/functions sitefndir=%{buildroot}%{_datadir}/zsh/site-functions scriptdir=%{buildroot}%{_datadir}/zsh/scripts sitescriptdir=%{buildroot}%{_datadir}/zsh/site-scripts \
             runhelpdir=%{buildroot}%{_datadir}/zsh/${VERSION}/help

make install.info DESTDIR=$RPM_BUILD_ROOT

mkdir -p %{buildroot}%{_sysbindir}
pushd %{buildroot}%{_sysbindir} && {
    ln -s ..%{_bindir}/zsh ./zsh
} && popd

# copy Mandrake Configuration files.
mkdir -p %{buildroot}%{_sysconfdir}
cp -a zcfg/* %{buildroot}%{_sysconfdir}

# Copy documentation.
#rm -rf docroot
mkdir -p docroot/{Info_html,Examples,Documentation}/
cp -a README docroot/
cp -a Functions/Misc/* Misc/* Util/* docroot/Examples/
cp -a INSTALL ChangeLog* docroot/Documentation
cp -a StartupFiles docroot/
cp -a Etc/* docroot/Documentation
cp -a NEWS docroot/
#cp -a Doc/*html docroot/Info_html/

find docroot/ -type f|xargs perl -p -i -e 's|^#!%{prefix}/local/bin/zsh|#!%{_bi
ndir}/zsh|'
find docroot/ -type f|xargs perl -p -i -e 's|^#!%{prefix}/local/bin/perl|#!%{_b
indir}/perl|'

rm -f docroot/StartupFiles/.distfiles
rm -f docroot/Examples/{Makefile*,*.yo}
rm -f docroot/Documentation/{Makefile*,*.yo}
mv docroot/Examples/compctl-examples docroot/StartupFiles

find docroot/ -name 'Makefile*' -o -name '.yo'|xargs rm -f

%clean
rm -rf %{buildroot}

%post
if [ ! -f %{_sysconfdir}/shells ]; then
	echo "/bin/zsh" > %{_sysconfdir}/shells
else
	grep '^/bin/zsh' %{_sysconfdir}/shells > /dev/null || echo "/bin/zsh" >> /etc/shells
fi
/sbin/install-info %{_infodir}/zsh.info.gz %{_infodir}/dir

%preun
if [ "$1" = 0 ]; then
    /sbin/install-info --delete %{_infodir}/zsh.info.gz %{_infodir}/dir
fi

%postun
if [ ! -x /bin/zsh ]; then
	grep -v '^/bin/zsh$' %{_sysconfdir}/shells | grep -v '^/bin/zsh$'> /etc/shells.rpm
	mv %{_sysconfdir}/shells.rpm /etc/shells
fi

%files
%defattr(-,root,root,0755)
%doc LICENCE
%doc docroot/README docroot/NEWS
%doc docroot/Documentation/ docroot/Examples/ docroot/Info_html/ docroot/StartupFiles/
%config %{_sysconfdir}/z*
%{_sysbindir}/zsh
%{_bindir}/zsh*
%{_libdir}/zsh
%{_infodir}/*.info*
%exclude %{_infodir}/dir*
%{_mandir}/man*/*
%{_datadir}/zsh

%changelog
* Thu Dec 31 2015 IWAI, Masaharu <iwaim.sub@gmail.com> 5.2-1
- update to 5.2
- fix buit date for 5.0.7-1 in changelog

* Thu Jan  1 2015 IWAI, Masaharu <iwaim.sub@gmail.com> 5.0.7-1
- update to 5.0.7
- add BuildRequires: man-db
- update fixpath patch (Patch3)
- add install path 'runhelpdir'
- add help files
- drop too old Zsh Guide (Source3)

* Tue Dec 31 2013 IWAI, Masaharu <iwaim.sub@gmail.com> 5.0.2-2
- rebuild with current VineSeed

* Tue Dec 25 2012 IWAI, Masaharu <iwai@alib.jp> 5.0.2-1
- new upstream release

* Thu Nov 29 2012 IWAI, Masaharu <iwai@alib.jp> 5.0.0-1
- new upstream release

* Sat Aug  6 2011 IWAI, Masaharu <iwai@alib.jp> 4.3.12-1
- new upstream release

* Tue Dec 21 2010 IWAI, Masaharu <iwai@alib.jp> 4.3.11-1
- new upstream release

* Sun Aug 15 2010 IWAI, Masaharu <iwai@alib.jp> 4.3.10-2
- rebuild with new toolchain

* Tue Feb 23 2010 IWAI, Masaharu <iwai@alib.jp> 4.3.10-1
- new upstream release
- update fixpath patch (Patch3)
- drop unnecessary patch: fix subversion completion patch (Patch4)
- fix '--with-tcsetpgrp' option: apply besides SPARC arch
- add LICENCE file in %%doc directory: fixed typo
- exclude %%{_infodir}/dir* in %%files section
- drop Prefix tag
- replace Prereq to Requires(*)
- BuildRequires: findutils grep

* Wed Jan 27 2010 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 4.3.4-4
- fix files error (LICENSE is no longer exist)

* Wed Jan 27 2010 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 4.3.4-3
- add --with-tcsetpgrp into configure section
- add BR: texinfo, ncurses-devel

* Thu Jan  7 2010 IWAI, Masaharu <iwai@alib.jp> 4.3.4-2
- add fix subversion completion patch (Patch4): <BTS:VineLinux:869>
  - see http://svn.haxx.se/users/archive-2008-06/0095.shtml
- add Packager tag
- add LICENSE file in %%doc directory
- fix License tag's value

* Fri Aug 15 2008 Shu KONNO <owa@bg.wakwak.com> 4.3.4-1vl5
- applied new versioning policy, spec in utf-8

* Wed Oct 31 2007 IWAI, Masaharu <iwai@alib.jp> 4.3.4-0vl1
- new upstream release
- update apt4rpm patch ( Patch0 )
- update sshcomp patch ( Patch1 )
- add fixpath patch ( Patch3 )
- update %%build and %%install section

* Tue Apr 12 2005 IWAI, Masaharu <iwai@alib.jp> 4.2.5-0vl1
- new upstream release

* Tue Mar  8 2005 IWAI, Masaharu <iwai@alib.jp> 4.2.4-0vl1
- new upstream release

* Sat Aug 14 2004 IWAI, Masaharu <iwai@alib.jp> 4.2.1-0vl1
- new upstream release
- update apt4rpm patch ( Patch0 )
- drop unnecessary patch for fixed upstream: job_table_full patch ( Patch3 )
- update 'Copy documentation' script: moved NEWS document in upstream archive

* Sat Jul 7 2004 HAYASHI Kentarou <linjian@gigo-ice.org> 4.2.0-0vl2
- add job_table_full.patch (Patch3)
  see Zsh Mailing List 2004/msg00488.html

* Mon Mar 29 2004 IWAI, Masaharu <iwai@alib.jp> 4.2.0-0vl1
- new upstream release
- update completion tar archive patch (Patch2)
- update file list: include directories in %%{_libdir} and %%{_datadir}

* Sun Dec 28 2003 IWAI, Masaharu <iwai@alib.jp> 4.0.9-0vl1
- upstream update
- update apt4rpm.patch (Patch0)

* Fri Jun 20 2003 IWAI Masaharu <iwai@alib.jp> 4.0.7-0vl1
- upstream update
- update apt4rpm.patch(Patch0)

* Sat May  3 2003 IWAI Masaharu <iwai@alib.jp> 4.0.6-0vl3
- add completion_tar_archive.patch (Patch2)
  for tar's "z" option to accept bz2 tarball with zsh completion.

* Mon Dec  2 2002 IWAI Masaharu <iwai@alib.jp> 4.0.6-0vl2
- add apt-cache showsrc option in apt4rpm patch (Patch0)

* Thu Aug 15 2002 IWAI Masaharu <iwai@alib.jp> 4.0.6-0vl1
- upstream update

* Sun Aug 11 2002 IWAI Masaharu <iwai@alib.jp> 4.0.5-0vl1
- upstream update
- apt-cache showsrc option changed unavailable in apt4rpm patch (Patch0)

* Tue Dec  4 2001 Kazuhisa TAKEI <takei@vinelinux.org> 4.0.4-0vl1
- loading vine specific profile scripts moved from zshrc to zprofile
- fixed other bug($PATH,zmodload)


* Mon Aug 27 2001 Shoji Matsumoto <shom@vinelinux.org> 4.0.2-0vl3
- rebuilding current Seed
- change ssh completion (Patch1)

* Thu Aug 16 2001 Kazuhisa TAKEI <takei@vinelinux.org> 4.0.2-0vl2
- fixed bug rpm package name completions in _apt

* Thu Jul 19 2001 Kazuhisa TAKEI<takei@vinelinux.org> 4.0.2-0vl1
- 4.0.2

* Sun Jun  3 2001 Kazuhisa TAKEI<takei@vinelinux.org> 4.0.1-0vl1
- upstream 4.0.1 release
- fixed bug zshrc( add /usr/X11R6/bin $PATH)
- fixed lack 'Epoch:'

* Thu Apr 26 2001 Kazuhisa TAKEI<takei@vinelinux.org> 4.0.1-0vl0.4.pre.3
- fixed version number invalid

* Fri Apr 20 2001 <sagami@vinelinux.org>
- 4.0.1-0vl0.3.pre.4
- install infopage/manpage and added PreReq = /sbin/install-info
- fixed/added scripts in post/postun/preun for install-info

* Fri Apr 13 2001 Kazuhisa TAKEI<takei@vinelinux.org> 4.0.1-0vl0.3.pre.3
- upstream update
- fixed /etc/zshrc bugs

* Tue Apr  3 2001 Kazuhisa TAKEI<takei@vinelinux.org> 4.0.1-0vl0.0.pre.2
- upstream update
- remove all patches

* Tue Oct  3 2000 Kazuhisa TAKEI<takei@vinelinux.org> 3.1.9-4vl1
- can read /etc/profile.d/*.sh

* Wed Sep 13 2000 Kazuhisa TAKEI<takei@vinelinux.org>
- 3.1.9-4vl0
- convert from Mandrake Linux to Vine Linux
- add Japanise Summary and description

* Sat Aug 26 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.9-4mdk
- Set some %config file to (noreplace).
- Make -A to complete spec file for _rpm.

* Thu Jul 20 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.9-3mdk
- Get /usr/share/man also in the completion for perl manpages.
- BM.

* Wed Jul  5 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.9-2mdk
- Fix buildroot hardcoded in binary.

* Wed Jun 21 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.9-1mdk
- Use makeinstall macros (not easy this one :\).
- 3.1.9.

* Mon Jun  5 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.8-1mdk
- 3.1.8.

* Sun May 28 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev22-3mdk
- Fix path (%{prefix}/ucb -> %{_bindir}/X11)
- Fix keys (home-end-suppr-delete) directly in the zsh binary.

* Sun Apr 16 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev22-2mdk
- Remove doble .so in %{_libdir}/zsh/*.

* Thu Apr 13 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev22-1mdk
- 3.1.6dev22.

* Fri Mar 31 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev20-3mdk
- Fix completion of rpm with -qp*.

* Mon Mar 27 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev20-2mdk
- Upgrade zshguide.

* Sat Mar 25 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev20-1mdk
- 3.1.6-dev20

* Wed Mar 22 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev19-3mdk
- Move global configuration here.
- Adjust groups.

* Tue Feb 22 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev19-2mdk
- Add new zshguide from pws.
- Separate the doc to the doc package

* Sun Feb 20 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev19-1mdk
- Clean Up spec (thanks specs-helper).
- Remove all our patchs (now all is commited to upstream main).
- 3.1.6dev19.

* Fri Feb 18 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev18-3mdk
- Recompile with glibc2.1.3 (first one).

* Thu Feb 17 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev18-2mdk
- Add --freshen completion.

* Tue Feb 15 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev18-1mdk
- Fix descriptions and summary.
- 3.1.6dev18.

* Thu Feb 10 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev17-2mdk
- Remove Makefile in %doc.
- BuildRequires: autoconf tetex.
- Lot of modications in the default config as suggested by Bart
  Schaefer <schaefer@zsh.org>.
- 3.1.6dev17.

* Mon Jan 24 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev16-1mdk
- dev16.
- Redo the tar_archive patchs.

* Tue Jan 18 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev15-1mdk
- dev15.
- Fix doc generation with dev15.
- remove META-FAQ.
- disable lfs on sparc.

* Thu Jan  6 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6dev14-1mdk
- dev14 (note the name change).

* Mon Jan  3 2000 Chmouel Boudjnah <chmouel@mandrakesoft.com> 3.1.6pws13-3mdk
- Remove temporary files.

* Fri Dec 31 1999 Chmouel Boudjnah <chmouel@mandrakesoft.com>
- 3.1.6pws13 (mainly bug fixes).
- fix %post.
- fix rpm completion

* Thu Dec 09 1999 Chmouel Boudjnah <chmouel@mandrakesoft.com>
- 3.1.6pws11 (mainly bug fixes).

* Tue Dec  7 1999 Chmouel Boudjnah <chmouel@mandrakesoft.com>
- Add run-help and perl-build the documentation.

* Tue Nov 30 1999 Francis Galiegue <francis@mandrakesoft.com>

- Completion machine patch - we use GNU make and GNU tar
- Small fix to %post script

* Tue Nov 30 1999 Chmouel Boudjnah <chmouel@mandrakesoft.com>
- 3.1.6pws10
- Fix zprofile.
- Clean-up Franciseries.
- Clean-up specs.

* Mon Nov 29 1999 Francis Galiegue <francis@mandrakesoft.com>
- Grrr... Rebuilt on kenobi, toy ain't a cooker

* Mon Nov 29 1999 Francis Galiegue <francis@mandrakesoft.com>

- Completion system now handles bzip2'ed manpages and tarballs
- Some cool options

* Wed Nov 10 1999 Chmouel Boudjnah <chmouel@mandrakesoft.com>
- Add zshguide.txt to documentation.

* Thu Oct 07 1999 Chmouel Boudjnah <chmouel@mandrakesoft.com>

- Fix bug in %{_sysconfdir}/zsh use USERNAME instead of USER.
- Improve %{_sysconfdir}/z* to source the /etc/profile.d/ files.

* Mon Oct 04 1999 Chmouel Boudjnah <chmouel@mandrakesoft.com>

- 3.1.6-pws6
- Fix bad link.
- Fix bad manpages.

* Tue Aug 17 1999 Thierry Vignaud <tvignaud@mandrakesoft.com>
- fix typo in examples directory name

* Sun Aug  8 1999 Chmouel Boudjnah <chmouel@mandrakesoft.com>

- Copy documentation (yes a lot).
- Remove the completion machine and put them in [[ {etc,root}(skel|files) ]] package.

* Sat Aug  7 1999 Chmouel Boudjnah <chmouel@mandrakesoft.com>

- By defaut we launch the completion machine.
- Put zsh in %{_bindir}/
- Rewrite of Spec file for this new major version.

# end of file