LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File mksh.spec of Package mksh (Project shells)

#
# spec file for package mksh
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2013 Guido Berhoerster.
# Copyright (c) 2013 Thorsten Glaser.
#
# 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:           mksh
Version:        48b
Release:        0
License:        MirOS and ISC
Summary:        MirBSD Korn Shell
Url:            http://www.mirbsd.org/mksh.htm
Group:          System/Shells
Source:         https://www.mirbsd.org/MirOS/dist/mir/mksh/%{name}-R%{version}.tgz
%if 0%{?suse_version}
# PATCH-FEATURE-OPENSUSE mksh-vendor-mkshrc.patch gber@opensuse.org -- Add support for a vendor-supplied kshrc which is read by interactive shells before $ENV or $HOME/.mkshrc are processed
Patch0:         mksh-vendor-mkshrc.patch
BuildRequires:  ed
# for %%check
BuildRequires:  perl
# only for versions not yet supporting mksh
Requires(post): grep
Requires(postun): awk
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
The MirBSD Korn Shell is an actively developed free implementation of the Korn
Shell programming language and a successor to the Public Domain Korn Shell
(pdksh).

%prep
%setup -q -n %{name}
%patch0 -p1
%if 0%{?suse_version}
ed -s sh.h <<'EOF'
,s/#define MKSH_VERSION "R\([^"]*\)"/#define MKSH_VERSION "R\1 openSUSE"/
w
EOF
ed -s check.t <<'EOF'
,s/@(#)\(MIRBSD\|LEGACY\) KSH R\(.*\)/@(#)\1 KSH R\2 openSUSE/
w
EOF
%endif
ln -s . examples

%build
export CFLAGS='%{optflags}'
%if 0%{?suse_version}
export CPPFLAGS='-DMKSH_VENDOR_MKSHRC_PATH=\"/etc/mkshrc\"'
%endif
# filter compiler warnings and errors from configuration tests
{
# work around bugs in gcc 4.8 (deb#717734 rh#922974) and gcc 4.1.2 in SLE 10
%if 0%{?suse_version} == 1310 || 0%{?sles_version} == 10
    sh Build.sh -r || touch build.failed
%else
    sh Build.sh -r -c lto || touch build.failed
%endif
    mv test.sh test-mksh.sh
# work around bugs in gcc 4.8 (deb#717734 rh#922974) and gcc 4.1.2 in SLE 10
%if 0%{?suse_version} == 1310 || 0%{?sles_version} == 10
    sh Build.sh -L -r || touch build.failed
%else
    sh Build.sh -L -r -c lto || touch build.failed
%endif
    mv test.sh test-lksh.sh
} 2>&1 | sed '/conftest.c:/s/: warning:/: W:/'
test ! -e build.failed

%install
install -d %{buildroot}/bin
for shell in mksh lksh; do
    install -D -p -m 755 ${shell} %{buildroot}%{_bindir}/${shell}
    install -D -p -m 644 ${shell}.1 %{buildroot}%{_mandir}/man1/${shell}.1
    ln -s %{_bindir}/${shell} %{buildroot}/bin/${shell}
done
install -d %{buildroot}%{_sysconfdir}
ln -s %{_sysconfdir}/bash.bashrc %{buildroot}%{_sysconfdir}/mkshrc

%check
for shell in mksh lksh; do
    ./test-${shell}.sh -v -f -C regress:no-ctty
done

%clean
rm -Rf %{buildroot}

# only for versions not yet supporting mksh
%post
for entry in /bin/mksh %{_bindir}/mksh; do
    grep -q ${entry} %{_sysconfdir}/shells ||\
        printf '%%s\n' ${entry} >>%{_sysconfdir}/shells
done

%postun
test -x %{_bindir}/mksh && awk '
($1 != "/bin/mksh") && ($1 == "%{_bindir}/mksh") {
    line[n++] = $0
}
END {
    for (i = 0; i < n; i++) {
        print line[i] >"%{_sysconfdir}/shells"
    }
}' '%{_sysconfdir}/shells' || true

%files
%defattr(-,root,root)
%doc examples/dot.mkshrc
%{_sysconfdir}/mkshrc
/bin/mksh
/bin/lksh
%{_bindir}/mksh
%{_bindir}/lksh
%{_mandir}/man1/mksh.1*
%{_mandir}/man1/lksh.1*

%changelog