Summary: Limited shell for secure file transfers
Name: scponly
Version: 4.8
Release: 1%{_dist_release}
License: GPL
Group: System Environment/Shells
URL: http://sublimation.org/scponly/wiki/
Patch1: scponly-4.8-chown.patch
Patch2: scponly-4.8-docs.patch
Source: http://sublimation.org/scponly/scponly-%{version}.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
Requires: openssh-server
Requires: rsync
Requires: subversion
BuildRequires: openssh-server
BuildRequires: rsync
BuildRequires: subversion

%description
scponly is an alternative 'shell' for system administrators
who would like to provide access to remote users to both
read and write local files without providing any remote
execution priviledges. Functionally, it is best described
as a wrapper to the "tried and true" ssh suite of applications.

%prep
%setup
%patch1 -p1 -b .chown
%patch2 -p1 -b .docs

%build

mkdir build-scp build-rsync build-scp-rsync build-svn build-scp-svn \
	build-rsync-svn build-scp-rsync-svn build-svnserve build-scp-svnserve \
	build-rsync-svnserve build-scp-rsync-svnserve build-svn-svnserve \
	build-scp-svn-svnserve build-rsync-svn-svnserve \
	build-scp-rsync-svn-svnserve


build() {
ln -sf ../configure
ln -sf ../Makefile.in
ln -sf ../setup_chroot.sh.in
ln -sf ../config.h.in
ln -sf ../groups.c
ln -sf ../helper.c
ln -sf ../scponly.c
ln -sf ../scponly.h
ln -sf ../scponly.8
ln -sf ../debuglevel
%configure \
	--cache-file=../config.cache \
	--enable-chrooted-binary \
	$*

%{__make} %{?_smp_mflags} OPTS="%{optflags}"
}

pushd build-scp
build --enable-scp-compat \
	--enable-winscp-compat
popd

pushd build-rsync
build --enable-rsync-compat \
	--disable-scp-compat \
	--without-sftp-server
popd

pushd build-scp-rsync
build --enable-scp-compat \
	--enable-winscp-compat \
	--enable-rsync-compat
popd

pushd build-svn
build --enable-svn-compat \
	--disable-scp-compat \
	--without-sftp-server
popd

pushd build-scp-svn
build --enable-scp-compat \
	--enable-winscp-compat \
	--enable-svn-compat
popd

pushd build-rsync-svn
build --enable-rsync-compat \
	--enable-svn-compat \
	--disable-scp-compat \
	--without-sftp-server
popd

pushd build-scp-rsync-svn
build --enable-scp-compat \
	--enable-winscp-compat \
	--enable-rsync-compat \
	--enable-svn-compat
popd

pushd build-svnserve
build --enable-svnserv-compat \
	--disable-scp-compat \
	--without-sftp-server
popd

pushd build-scp-svnserve
build --enable-scp-compat \
	--enable-winscp-compat \
	--enable-svnserv-compat
popd

pushd build-rsync-svnserve
build --enable-rsync-compat \
	--enable-svnserv-compat \
	--disable-scp-compat \
	--without-sftp-server

popd

pushd build-scp-rsync-svnserve
build --enable-scp-compat \
	--enable-winscp-compat \
	--enable-rsync-compat \
	--enable-svnserv-compat
popd

pushd build-svn-svnserve
build --enable-svn-compat \
	--enable-svnserv-compat \
	--disable-scp-compat \
	--without-sftp-server
popd

pushd build-scp-svn-svnserve
build --enable-scp-compat \
	--enable-winscp-compat \
	--enable-svn-compat \
	--enable-svnserv-compat
popd

pushd build-rsync-svn-svnserve
build --enable-rsync-compat \
	--enable-svn-compat \
	--enable-svnserv-compat \
	--disable-scp-compat \
	--without-sftp-server
popd

pushd build-scp-rsync-svn-svnserve
build --enable-scp-compat \
	--enable-winscp-compat \
	--enable-rsync-compat \
	--enable-svn-compat \
	--enable-svnserv-compat
popd

%install
%{__rm} -rf %{buildroot}

for d in scp rsync scp-rsync svn scp-svn rsync-svn scp-rsync-svn svnserve \
	scp-svnserve rsync-svnserve scp-rsync-svnserve svn-svnserve \
	scp-svn-svnserve rsync-svn-svnserve scp-rsync-svn-svnserve; do
pushd build-$d
cp setup_chroot.sh ../
%{__make} install DESTDIR="%{buildroot}"
mv %{buildroot}%{_bindir}/scponly %{buildroot}%{_bindir}/scponly.$d
mv %{buildroot}%{_sbindir}/scponlyc %{buildroot}%{_sbindir}/scponlyc.$d
popd
done

%clean
%{__rm} -rf %{buildroot}

%post

update-alternatives \
  --install /usr/bin/scponly scponly /usr/bin/scponly.scp 100 \
  --slave /usr/sbin/scponlyc scponlyc /usr/sbin/scponlyc.scp

for d in scp rsync scp-rsync svn scp-svn rsync-svn scp-rsync-svn svnserve \
	scp-svnserve rsync-svnserve scp-rsync-svnserve svn-svnserve \
	scp-svn-svnserve rsync-svn-svnserve scp-rsync-svn-svnserve; do
update-alternatives \
  --install /usr/bin/scponly scponly /usr/bin/scponly.$d 10 \
  --slave /usr/sbin/scponlyc scponlyc /usr/sbin/scponlyc.$d
done

%postun

update-alternatives --remove-all scponly


%files
%defattr(-, root, root, 0755)
%doc AUTHOR BUILDING-JAILS.TXT CHANGELOG CONTRIB COPYING INSTALL README TODO
%doc setup_chroot.sh build_extras/setup_chroot.sh*
%doc %{_mandir}/man8/scponly.8*
%{_bindir}/scponly.*
%{_sbindir}/scponlyc.*
%dir %{_sysconfdir}/scponly/
%config(noreplace) %{_sysconfdir}/scponly/*

%changelog
* Sun Mar 22 2009 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 4.8-1
- initial build for Vine Linux.
