Summary:       The Debian Almquist Shell (formerly NetBSD's ash)
Summary(ja):   Bourne シェル (sh) の機能縮小版 (Debian 版 ash)
Name:          dash
Version:       0.5.7
Release:       1%{?_dist_release}

License:       BSD
Group:         System Environment/Shells
URL:           http://gondor.apana.org.au/~herbert/dash/

Source:        http://gondor.apana.org.au/~herbert/dash/files/%{name}-%{version}.tar.gz

Buildroot:     %{_tmppath}/%{name}-%{version}-root
BuildRequires: bison
BuildRequires: dietlibc >= 0.32
Requires(pre): fileutils grep
Obsoletes:     ash <= 0.4
Provides:      ash = %{version}-%{release}
Conflicts:     mkinitrd <= 1.7

Vendor: Project Vine
Distribution: Vine Linux
Packager: shaolin,daisuke

%description
"dash" is a POSIX compliant shell that is much smaller than "bash".
Dash supports many features that a real sh shell would support, however
it is much smaller in size. This becomes an advantage in situations
where there is a lack of memery (initial ram-disks, etc). dash does
lack a few features, like command line history.

dash is the continuation of the original NetBSD ash fork. dash is much
more up-to-date, and properly maintained.


%description -l ja
"dash" は POSIX 互換シェルで、"bash" よりサイズが大変小さいものです。
dash は、sh シェルコマンドをすべてサポートしており、かつ sh より比較的
サイズが小さく収まっています。そのため、起動直後の RAM ディスクで使う
など、使用可能メモリ量が制限されるような状況で有効に使うことができます。
ただし dash にはコマンドライン履歴などのいくつかの機能が備わっていません。

dash はオリジナルの NetBSD ash から分岐したもので、
ash とは異なり現在でも適切にメンテナンスされ続けています。


%package static
Summary:       The Debian Almquist Shell (statically compiled)
Summary(ja):   Bourne シェル (sh) の機能縮小版 (静的リンク版)
Group:         System Environment/Shells
Obsoletes:     ash <= 0.4
Provides:      ash-static = %{version}-%{release}


%description static
"dash" is a POSIX compliant shell that is much smaller than "bash".
Dash supports many features that a real sh shell would support, however
it is much smaller in size. This becomes an advantage in situations
where there is a lack of memery (initial ram-disks, etc). dash does
lack a few features, like command line history.

dash is the continuation of the original NetBSD ash fork. dash is much
more up-to-date, and properly maintained.

This version is statically compiled.


%description static -l ja
"dash" は POSIX 互換シェルで、"bash" よりサイズが大変小さいものです。
dash は、sh シェルコマンドをすべてサポートしており、かつ sh より比較的
サイズが小さく収まっています。そのため、起動直後の RAM ディスクで使う
など、使用可能メモリ量が制限されるような状況で有効に使うことができます。
ただし dash にはコマンドライン履歴などのいくつかの機能が備わっていません。

dash はオリジナルの NetBSD ash から分岐したもので、
ash とは異なり現在でも適切にメンテナンスされ続けています。

このパッケージは静的リンクされたバージョンです。


%prep
%setup -q


%build
%configure

# building dynamically linked dash
make
mv src/dash src/dash.dynamic

# building statically linked dietlibc dash
make clean
%configure CC="diet gcc"
make CC="diet gcc"
mv src/dash src/dash.static


%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/bin
mkdir -p %{buildroot}%{_mandir}/man1

install -m 755 src/dash.dynamic %{buildroot}/bin/dash
install -m 644 src/dash.1 %{buildroot}%{_mandir}/man1/dash.1
ln -sf dash.1 %{buildroot}%{_mandir}/man1/bsh.1
ln -sf dash %{buildroot}/bin/bsh
ln -sf dash.1 %{buildroot}%{_mandir}/man1/ash.1
ln -sf dash %{buildroot}/bin/ash

install -m 755 src/dash.static %{buildroot}/bin/dash.static
ln -sf dash.static %{buildroot}/bin/bsh.static
ln -sf dash.static %{buildroot}/bin/ash.static


%post
if [ ! -f /etc/shells ]; then
	echo "/bin/dash" > /etc/shells
	echo "/bin/ash" >> /etc/shells
	echo "/bin/bsh" >> /etc/shells
else
	if ! grep '^/bin/dash$' /etc/shells > /dev/null; then
		echo "/bin/dash" >> /etc/shells
	fi
	if ! grep '^/bin/ash$' /etc/shells > /dev/null; then
		echo "/bin/ash" >> /etc/shells
	fi
	if ! grep '^/bin/bsh$' /etc/shells > /dev/null; then
		echo "/bin/bsh" >> /etc/shells
	fi
fi


%postun
if [ "$1" = "0" ]; then
	grep -v '^/bin/ash' < /etc/shells | grep -v '^/bin/dash' | grep -v '^/bin/bsh' > /etc/shells.new
	mv /etc/shells.new /etc/shells
fi


%triggerpostun -- ash
if ! grep '^/bin/ash$' /etc/shells > /dev/null; then
	echo "/bin/ash" >> /etc/shells
fi
if ! grep '^/bin/bsh$' /etc/shells > /dev/null; then
	echo "/bin/bsh" >> /etc/shells
fi

%verifyscript

for n in dash ash bsh; do
    echo -n "Looking for $n in /etc/shells... "
    if ! grep "^/bin/${n}\$" /etc/shells > /dev/null; then
	echo "missing"
	echo "${n} missing from /etc/shells" >&2
    else
	echo "found"
    fi
done


%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root)
/bin/dash
/bin/ash
/bin/bsh
%{_mandir}/man1/*

%files static
%defattr(-,root,root)
/bin/dash.static
/bin/ash.static
/bin/bsh.static


%changelog
* Sun Aug 24 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.5.7-1
- update to 0.5.7

* Sat Apr 23 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 0.5.6-2
- update to 0.5.6
- BR: dietlibc >= 0.32

* Wed Mar 25 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.5.5.1-1
- now ash (not maintained anymore?) replaced with dash
- provide ash/bsh symlinks for compatibility
- split statically-linked version into subpackage

* Sun Oct 12 2008 Shu KONNO <owa@bg.wakwak.com> 0.3.8-6vl5
- applied new versioning policy, spec in utf-8

* Wed Sep 20 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 0.3.8-5vl3
- rebuild to add gpg sign

* Fri Apr 25 2003 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 0.3.8-5v2
- rebuild

* Fri Dec 06 2002 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 0.3.8-5vl1
- based on 0.3.8-5 from Rawhide and built for Vine Linux
- added Japanese summary and description

* Wed Jul 17 2002 Trond Eivind Glomsr <teg@redhat.com> 0.3.8-5
- Update to -38 diff
- man page fixes (#63528)

* Fri Jun 21 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Thu May 23 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Wed Jan 09 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Tue Dec 11 2001 Trond Eivind Glomsr <teg@redhat.com> 0.3.8-1
- 0.3.8
- Patch to make it build
- workaround for oddities in the alpha compiler

* Sun Jun 24 2001 Elliot Lee <sopwith@redhat.com>
- Bump release + rebuild.

* Mon Jan 08 2001 Preston Brown <pbrown@redhat.com>
- ported much newer version from Debian
- alpha is miscompiling mkinit helper utility; work around w/o optimization

* Thu Dec  7 2000 Crutcher Dunnavant <crutcher@redhat.com>
- intial rebuild for 7.1

* Wed Aug 30 2000 Matt Wilson <msw@redhat.com>
- rebuild to cope with glibc locale binary incompatibility, again

* Wed Jul 19 2000 Jakub Jelinek <jakub@redhat.com>
- rebuild to cope with glibc locale binary incompatibility

* Wed Jul 12 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Wed Jun 21 2000 Jakub Jelinek <jakub@redhat.com>
- mksyntax had undefined behaviour, make it conforming.

* Mon Jun 12 2000 Preston Brown <pbrown@redhat.com>
- FHS fixes
- had to disable optimization for sparc, was producing a mksyntax binary that
  infinitely looped!  FIX ME.

* Wed Mar 29 2000 Bill Nottingham <notting@redhat.com>
- fix bug in 'ash -e' handling

* Thu Feb 03 2000 Preston Brown <pbrown@redhat.com>
- gzipped man pages

* Mon Oct 04 1999 Cristian Gafton <gafton@redhat.com>
- rebuild against the lastest glibc in the sparc tree

* Sat Sep 11 1999 Bill Nottingham <notting@redhat.com>
- fix bogosity with fd's > 0
- fix builtin echo to understand -n & -e at the same time

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 17)

* Wed Feb 24 1999 Preston Brown <pbrown@redhat.com>
- Injected new description and group.

* Tue Jan 12 1999 Cristian Gafton <gafton@redhat.com>
- build on glibc 2.1

* Fri Nov 06 1998 Preston Brown <pbrown@redhat.com>
- updated to correct path on SunSITE.

* Fri Aug 28 1998 Jeff Johnson <jbj@redhat.com>
- recompile statically linked binary for 5.2/sparc

* Tue May 05 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr, tr

* Mon Oct 20 1997 Erik Troan <ewt@redhat.com>
- made /bin/ash built shared
- added ash.static
- uses a buildroot and %attr

* Sun Aug 24 1997 Erik Troan <ewt@redhat.com>
- built against glibc
- statically linked

* Wed Apr 16 1997 Erik Troan <ewt@redhat.com>
- fixed preinstall script to >> /etc/shells for bsh.
