Blob Blame History Raw
%bcond_without	doc

%if 0%{?fedora}
%bcond_without  fedora
%bcond_without	selinux
%else
%bcond_with	fedora
# I'd need to modify the policy a bit to make it work on RHEL,
# so default to off when not building for Fedora.
%bcond_with	selinux
%endif


Name:		icecream
Version:	0.8.0
Release:	11.20080117svn%{?dist}
Summary:	Distributed compiler

Group:		Development/Tools
License:	GPLv2
URL:		http://en.opensuse.org/Icecream
# The source was pulled from SVN repository:
# svn export -r 657903 svn://anonsvn.kde.org/home/kde/trunk/icecream icecream-0.8.0
# tar -cjvf icecream-0.8.0.tar.bz2 icecream-0.8.0/
Source0:	icecream-0.8.0.tar.bz2
Source1:	icecream.sh.in
Source2:	icecream.csh.in
Source3:	icecream.fc
Source4:	icecream.te
Source5:	icecream.if
Source6:	initscript-iceccd
Source7:	initscript-scheduler
# This patch was generated with:
# svn export -r 761849 svn://anonsvn.kde.org/home/kde/branches/work/icecream-make-it-cool icecream-mic
# diff -Nurp icecream-0.8.0 icecream-mic > icecream-make-it-cool.patch
# bzip2 icecream-make-it-cool.patch
Patch0:		icecream-make-it-cool.patch.bz2
Patch1:		icecream-rename-scheduler.patch
Patch2:		icecream-cleanup-conffile.patch
Patch3:		icecream-compile-fix.patch

BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires:	automake autoconf libtool symlinks
# To build manpages from KDE-style Docbook sources:
%{?with_doc:BuildRequires:	%{!?el5:kdelibs3 kdelibs3-devel} %{?el5:kdelibs kdelibs-devel}}

%if %{with selinux}
# For SELinux protection:
BuildRequires:	checkpolicy selinux-policy-devel hardlink
%define selinux_policyver %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp) 
%if "%{selinux_policyver}" != ""
Requires:	selinux-policy >= %{selinux_policyver}
%endif
%define selinux_variants mls strict targeted 
%endif

BuildRequires:	fedora-usermgmt-devel
%{?FE_USERADD_REQ}
Requires(post):		chkconfig policycoreutils
Requires(preun):	chkconfig initscripts policycoreutils 
Requires(postun):	initscripts policycoreutils

Provides:	group(icecream) = 44
Provides:	user(icecream)  = 44


# description copied from Debian icecc package
%description
Icecream is a distributed compile system. It allows parallel compiling by
distributing the compile jobs to several nodes of a compile network running the
icecc daemon. The icecc scheduler routes the jobs and provides status and
statistics information to the icecc monitor. Each compile node can accept one
or more compile jobs depending on the number of processors and the settings of
the daemon. Link jobs and other jobs which cannot be distributed are executed
locally on the node where the compilation is started.

%package	devel
Summary:	Development files for %{name}
Group:		Development/Libraries
Requires:	%{name} = %{version}-%{release}

%description	devel
This package contains development files for %{name}.

%prep
%setup -q
%patch0 -p1
%patch1 -p0
%patch2 -p0
%patch3 -p1
make -f Makefile.cvs
sed -e 's|@LIBDIR@|%{_libdir}|g' %{SOURCE1} > icecream.sh
sed -e 's|@LIBDIR@|%{_libdir}|g' %{SOURCE2} > icecream.csh
mkdir SELinux
cp -p %{SOURCE3} %{SOURCE4} %{SOURCE5} SELinux
mkdir fedora
cp -p %{SOURCE6} %{SOURCE7} fedora

%build
%configure --disable-static --enable-shared
make %{?_smp_mflags}

%if %{with doc}
pushd doc
for i in man-*.docbook; do
	meinproc --stylesheet %{_datadir}/apps/ksgmltools2/customization/kde-man.xsl $i
	manfile=${i#man-}
	manfile=${manfile%.docbook}
	mv manpage.troff $manfile
done
popd
%endif

%if %{with selinux}
pushd SELinux
for selinuxvariant in %{selinux_variants}; do
	make NAME=${selinuxvariant} -f %{_datadir}/selinux/devel/Makefile
	mv icecream.pp icecream.pp.${selinuxvariant}
	make NAME=${selinuxvariant} -f %{_datadir}/selinux/devel/Makefile clean
done
popd
%endif

%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
rm -f %{buildroot}/%{_libdir}/libicecc.la

# move the symlinks elsewhere
mkdir -p %{buildroot}/%{_libdir}/icecc/bin
for i in cc gcc c++ g++; do
	ln -s %{buildroot}/%{_bindir}/icecc %{buildroot}/%{_libdir}/icecc/bin/$i
	rm -f %{buildroot}/%{_bindir}/$i
done

# relativize the symlinks
symlinks -cs %{buildroot}/%{_libdir}/icecc/bin

%if %{with doc}
# install manpages
mkdir -p %{buildroot}/%{_mandir}/man{1,7,8}
mv doc/scheduler.1 doc/icecc-scheduler.1
for i in doc/*.1 doc/*.7; do
	install -m 644 $i %{buildroot}/%{_mandir}/man${i##*.}
done
%endif

# install config file and initscripts
install -D -m 644 suse/sysconfig.icecream %{buildroot}/%{_sysconfdir}/sysconfig/icecream
install -D -m 755 fedora/initscript-iceccd %{buildroot}/%{_sysconfdir}/rc.d/init.d/iceccd
install -D -m 755 fedora/initscript-scheduler \
	%{buildroot}/%{_sysconfdir}/rc.d/init.d/icecc-scheduler
install -d -m 755 %{buildroot}/%{_sysconfdir}/profile.d
install -p -m 644 icecream.sh icecream.csh %{buildroot}/%{_sysconfdir}/profile.d

# create default working dir
mkdir -p %{buildroot}/%{_localstatedir}/cache/icecream

%if %{with selinux}
for selinuxvariant in %{selinux_variants}; do
	install -d %{buildroot}/%{_datadir}/selinux/${selinuxvariant}
	install -p -m 644 -D SELinux/icecream.pp.${selinuxvariant} \
		 %{buildroot}/%{_datadir}/selinux/${selinuxvariant}/icecream.pp
done
# Hardlink identical policy module packages together
/usr/sbin/hardlink -cv %{buildroot}%{_datadir}/selinux
%endif

%pre
# https://fedoraproject.org/wiki/PackageUserRegistry
%__fe_groupadd 44 -r icecream &>/dev/null || :
%__fe_useradd  44 -r -s /sbin/nologin -d %{_localstatedir}/cache/icecream -M \
	-c 'Icecream distributed compiler' -g icecream icecream &>/dev/null ||:

%post
/sbin/ldconfig
# if [ "$1" -le 1 ]; then # First install
%if %{with selinux}
for selinuxvariant in %{selinux_variants}; do
	semodule -s ${selinuxvariant} -i \
		%{_datadir}/selinux/${selinuxvariant}/icecream.pp 2>/dev/null ||:
done
fixfiles -R %{name} restore ||:
restorecon -R %{_localstatedir}/cache/icecream 2>/dev/null ||:
restorecon %{_localstatedir}/log/iceccd 2>/dev/null ||:
semanage port -a -t iceccd_port_t -p tcp 10245 2>/dev/null ||:
semanage port -a -t icecc_scheduler_port_t -p tcp 8765 2>/dev/null ||:
semanage port -a -t icecc_scheduler_port_t -p udp 8765 2>/dev/null ||:
%endif
# fi
/sbin/chkconfig --add iceccd
/sbin/chkconfig --add icecc-scheduler
exit 0

%preun
if [ "$1" -eq 0 ]; then # Final removal
	/sbin/service iceccd stop > /dev/null 2>&1
	/sbin/service icecc-scheduler stop > /dev/null 2>&1
	/sbin/chkconfig --del iceccd
	/sbin/chkconfig --del icecc-scheduler
#	rm -rf %{_localstatedir}/cache/icecream

%if %{with selinux}
	semanage port -d -t iceccd_port_t -p tcp 10245 2>/dev/null ||:
	semanage port -d -t icecc_scheduler_port_t -p tcp 8765 2>/dev/null ||:
	semanage port -d -t icecc_scheduler_port_t -p udp 8765 2>/dev/null ||:
	for selinuxvariant in %{selinux_variants}; do
		semodule -s ${selinuxvariant} -r icecream 2>/dev/null ||:
	done
%endif

fi
exit 0

%postun
/sbin/ldconfig
if [ "$1" -ge 1 ]; then # Upgrade
	/sbin/service iceccd condrestart > /dev/null 2>&1
	/sbin/service icecc-scheduler condrestart > /dev/null 2>&1
fi
exit 0

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%doc COPYING ChangeLog README BENCH NEWS TODO
%{_bindir}/icecc
%{_libdir}/icecc/bin/cc
%{_libdir}/icecc/bin/gcc
%{_libdir}/icecc/bin/c++
%{_libdir}/icecc/bin/g++
%{_libdir}/icecc/icecc-create-env
%{_libdir}/libicecc.so.*
%{_sbindir}/iceccd
%{_sbindir}/icecc-scheduler
%config(noreplace) %{_sysconfdir}/sysconfig/icecream
%config(noreplace) %{_sysconfdir}/profile.d/icecream.*sh
%{_sysconfdir}/rc.d/init.d/iceccd
%{_sysconfdir}/rc.d/init.d/icecc-scheduler
%{_localstatedir}/cache/icecream
%{?with_doc:%{_mandir}/man*/*}
%{?with_selinux:%{_datadir}/selinux/*/icecream.pp}

%files devel
%{_includedir}/icecc/*.h
%{_libdir}/libicecc.so
%{_libdir}/pkgconfig/icecc.pc

%changelog
* Thu Mar 13 2008 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-11.20080117svn
- Minor SELinux policy fix.

* Sun Feb 10 2008 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-10.20080117svn
- Compile fix (added missing #includes).
- Conditional building of SELinux policy and documentation.
- Fix build on RHEL5.

* Tue Jan 29 2008 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-9.20080117svn
- SELinux policy fixes.

* Thu Jan 17 2008 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-8.20080117svn
- Update to current icecream-make-it-cool branch.

* Tue Jan  8 2008 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-7.20071101svn
- Build fix. meinproc is now in kdelibs3. BuildRequire that instead of kdelibs.

* Thu Nov 29 2007 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-6.20071101svn
- Rewritten the profile scripts to make icecream work together with ccache.

* Tue Nov 27 2007 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-5.20071101svn
- SELinux: Allow iceccd to contact the scheduler via UDP.
- Don't add icecream to PATH in the profile scripts if ccache is installed
  to avoid recursive invocations (bz #377761).

* Tue Nov 20 2007 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-4.20071101svn
- Add a SELinux policy for iceccd
- Initscripts as sources instead of patches in the .spec file
- Don't touch /var/log/iceccd in the initscript. Let iceccd create it.

* Mon Nov 12 2007 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-3.20071101svn
- Add icecc to $PATH using scripts in profile.d

* Tue Nov  6 2007 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-2.20071101svn
- Use the _datadir macro instead of hardcoded /usr/share

* Thu Nov 01 2007 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-1.20071101svn
- Initial package for Fedora.