Summary: A smaller version of the Bourne shell (sh).
Name: ash
Version: 0.3.8
Release: 8
License: BSD
Group: System Environment/Shells
Source: ftp://ftp.debian.org/debian/dists/woody/main/source/shells/%{name}_%{version}.orig.tar.gz
Patch0: ftp://ftp.debian.org/debian/dists/woody/main/source/shells/%{name}_%{version}-38.diff.gz
Patch2: ash-0.3.8-tempfile.patch
Patch1: ash-0.3.8-build.patch
Patch3: ash-0.3.8-mannewline.patch
Patch4: ash-0.3.8-segv.patch
Prereq: fileutils grep
BuildPrereq: pmake >= 1.45 byacc
Buildroot: %{_tmppath}/%{name}-%{version}-root
Conflicts: mkinitrd <= 1.7

%description
A shell is a basic system program that interprets keyboard and mouse
commands. The ash shell is a clone of Berkeley's Bourne shell
(sh). Ash supports all of the standard sh shell commands, but is
considerably smaller than sh. The ash shell lacks some Bourne shell
features (for example, command-line histories), but it uses a lot less
memory.

You should install ash if you need a lightweight shell with many of
the same capabilities as the sh shell.

%prep
%setup -q -n ash-%{version}.orig
%patch0 -p1 -b .linux
%patch2 -p1 -b .tempfile
%ifarch alpha
%patch1 -p1 -b .alpha
%endif
%patch3 -p1

%patch4 -p0 -b .segv

chmod -R a+rX .

%build
chmod u+x debian/bsdyacc
pmake CFLAGS="-g ${RPM_OPT_FLAGS} \
    -DBSD=1 -DSMALL -D_GNU_SOURCE \
    -DGLOB_BROKEN -D__COPYRIGHT\(x\)= \
    -D__RCSID\(x\)= -D_DIAGASSERT\(x\)=" \
    YACC=`pwd`/debian/bsdyacc
mv sh sh.dynamic

pmake CFLAGS="-g ${RPM_OPT_FLAGS} \
    -DBSD=1 -DSMALL -D_GNU_SOURCE \
    -DGLOB_BROKEN -D__COPYRIGHT\(x\)= \
    -D__RCSID\(x\)= -D_DIAGASSERT\(x\)=" \
    YACC=`pwd`/debian/bsdyacc LDFLAGS="-static"
mv sh sh.static


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

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

install -m 755 sh.static %{buildroot}/bin/ash.static

%post
if [ ! -f /etc/shells ]; then
        echo "/bin/ash" > /etc/shells
        echo "/bin/bsh" >> /etc/shells
else
        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/bsh' > /etc/shells.new
        mv /etc/shells.new /etc/shells
fi

%verifyscript

for n in 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/ash
/bin/ash.static
/bin/bsh
%{_mandir}/man1/*

%changelog
* Thu Feb 6 2003 Lon Hohberger <lhh@redhat.com> 0.3.8-8
- Fix for #83605

* Wed Jan 22 2003 Tim Powers <timp@redhat.com>
- rebuilt

* Thu Dec 19 2002 Tim Powers <timp@redhat.com>
- bump and rebuild

* Wed Jul 17 2002 Trond Eivind Glomsrød <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ød <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.