2e6f2a4
%if 0%{?fedora}
ba64180
%bcond_without	fedora
d592b35
%bcond_without	selinux
2e6f2a4
%else
2e6f2a4
%bcond_with	fedora
2e6f2a4
# I'd need to modify the policy a bit to make it work on RHEL,
2e6f2a4
# so default to off when not building for Fedora.
2e6f2a4
%bcond_with	selinux
2e6f2a4
%endif
2e6f2a4
2e6f2a4
92794d0
Name:		icecream
0c0d6f5
Version:	0.9.6
0c0d6f5
Release:	1%{?dist}
92794d0
Summary:	Distributed compiler
92794d0
92794d0
Group:		Development/Tools
6908d74
License:	GPLv2+
92794d0
URL:		http://en.opensuse.org/Icecream
0c0d6f5
Source0:	http://ftp.suse.com/pub/projects/icecream/icecc-%{version}.tar.bz2
8d4b890
Source1:	icecream.sh.in
8d4b890
Source2:	icecream.csh.in
30e4dae
Source3:	icecream.fc
30e4dae
Source4:	icecream.te
30e4dae
Source5:	icecream.if
30e4dae
Source6:	initscript-iceccd
30e4dae
Source7:	initscript-scheduler
cde2f7b
# tarball extracted from http://download.opensuse.org/repositories/home:/coolo/openSUSE_Factory/src/icecream-0.9.5-3.1.src.rpm:
6908d74
Source8:	%{name}-manpages.tar.bz2
0acd02d
Patch0:		%{name}-rename-scheduler.patch
0acd02d
Patch1:		%{name}-cleanup-conffile.patch
89496dd
92794d0
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
92794d0
6908d74
BuildRequires:	symlinks
2e6f2a4
c0da1ec
BuildRequires:	fedora-usermgmt-devel
c0da1ec
%{?FE_USERADD_REQ}
c0da1ec
Provides:	group(icecream)	= 44
c0da1ec
Provides:	user(icecream)	= 44
c0da1ec
c0da1ec
Requires(post):		chkconfig
c0da1ec
Requires(preun):	chkconfig initscripts
c0da1ec
Requires(postun):	initscripts
c0da1ec
2e6f2a4
%if %{with selinux}
30e4dae
# For SELinux protection:
30e4dae
BuildRequires:	checkpolicy selinux-policy-devel hardlink
c0da1ec
# semanage is in policycoreutils (EL-5) or policycoreutils-python (Fedora). File dep will work in both.
c0da1ec
Requires(post):		policycoreutils /usr/sbin/semanage
c0da1ec
Requires(preun):	policycoreutils /usr/sbin/semanage
c0da1ec
Requires(postun):	policycoreutils
30e4dae
%define selinux_policyver %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp) 
30e4dae
%if "%{selinux_policyver}" != ""
30e4dae
Requires:	selinux-policy >= %{selinux_policyver}
30e4dae
%endif
30e4dae
%define selinux_variants mls strict targeted 
2e6f2a4
%endif
92794d0
30e4dae
92794d0
# description copied from Debian icecc package
92794d0
%description
92794d0
Icecream is a distributed compile system. It allows parallel compiling by
92794d0
distributing the compile jobs to several nodes of a compile network running the
92794d0
icecc daemon. The icecc scheduler routes the jobs and provides status and
92794d0
statistics information to the icecc monitor. Each compile node can accept one
92794d0
or more compile jobs depending on the number of processors and the settings of
92794d0
the daemon. Link jobs and other jobs which cannot be distributed are executed
92794d0
locally on the node where the compilation is started.
92794d0
92794d0
%package	devel
92794d0
Summary:	Development files for %{name}
92794d0
Group:		Development/Libraries
92794d0
Requires:	%{name} = %{version}-%{release}
92794d0
92794d0
%description	devel
92794d0
This package contains development files for %{name}.
92794d0
92794d0
%prep
6908d74
%setup -q -a 8 -n icecc-%{version}
aa93b14
%patch0 -p1
92794d0
%patch1 -p0
8d4b890
sed -e 's|@LIBDIR@|%{_libdir}|g' %{SOURCE1} > icecream.sh
8d4b890
sed -e 's|@LIBDIR@|%{_libdir}|g' %{SOURCE2} > icecream.csh
30e4dae
mkdir SELinux
30e4dae
cp -p %{SOURCE3} %{SOURCE4} %{SOURCE5} SELinux
30e4dae
mkdir fedora
30e4dae
cp -p %{SOURCE6} %{SOURCE7} fedora
92794d0
92794d0
%build
b342985
%configure --disable-static --enable-shared
6908d74
# Remove rpath from local libtool copy
6908d74
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
6908d74
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
2e6f2a4
6908d74
make %{?_smp_mflags}
2e6f2a4
2e6f2a4
%if %{with selinux}
30e4dae
pushd SELinux
30e4dae
for selinuxvariant in %{selinux_variants}; do
30e4dae
	make NAME=${selinuxvariant} -f %{_datadir}/selinux/devel/Makefile
30e4dae
	mv icecream.pp icecream.pp.${selinuxvariant}
30e4dae
	make NAME=${selinuxvariant} -f %{_datadir}/selinux/devel/Makefile clean
30e4dae
done
30e4dae
popd
2e6f2a4
%endif
92794d0
92794d0
%install
92794d0
rm -rf %{buildroot}
92794d0
make install DESTDIR=%{buildroot}
92794d0
rm -f %{buildroot}/%{_libdir}/libicecc.la
92794d0
92794d0
# move the symlinks elsewhere
92794d0
mkdir -p %{buildroot}/%{_libdir}/icecc/bin
92794d0
for i in cc gcc c++ g++; do
92794d0
	ln -s %{buildroot}/%{_bindir}/icecc %{buildroot}/%{_libdir}/icecc/bin/$i
92794d0
	rm -f %{buildroot}/%{_bindir}/$i
92794d0
done
92794d0
92794d0
# relativize the symlinks
92794d0
symlinks -cs %{buildroot}/%{_libdir}/icecc/bin
92794d0
92794d0
# install manpages
92794d0
mkdir -p %{buildroot}/%{_mandir}/man{1,7,8}
6908d74
mv mans/scheduler.1 mans/icecc-scheduler.1
6908d74
for i in mans/*.1 mans/*.7; do
92794d0
	install -m 644 $i %{buildroot}/%{_mandir}/man${i##*.}
92794d0
done
92794d0
92794d0
# install config file and initscripts
92794d0
install -D -m 644 suse/sysconfig.icecream %{buildroot}/%{_sysconfdir}/sysconfig/icecream
92794d0
install -D -m 755 fedora/initscript-iceccd %{buildroot}/%{_sysconfdir}/rc.d/init.d/iceccd
92794d0
install -D -m 755 fedora/initscript-scheduler \
92794d0
	%{buildroot}/%{_sysconfdir}/rc.d/init.d/icecc-scheduler
8d4b890
install -d -m 755 %{buildroot}/%{_sysconfdir}/profile.d
8d4b890
install -p -m 644 icecream.sh icecream.csh %{buildroot}/%{_sysconfdir}/profile.d
92794d0
92794d0
# create default working dir
92794d0
mkdir -p %{buildroot}/%{_localstatedir}/cache/icecream
92794d0
2e6f2a4
%if %{with selinux}
30e4dae
for selinuxvariant in %{selinux_variants}; do
30e4dae
	install -d %{buildroot}/%{_datadir}/selinux/${selinuxvariant}
30e4dae
	install -p -m 644 -D SELinux/icecream.pp.${selinuxvariant} \
30e4dae
		 %{buildroot}/%{_datadir}/selinux/${selinuxvariant}/icecream.pp
30e4dae
done
30e4dae
# Hardlink identical policy module packages together
30e4dae
/usr/sbin/hardlink -cv %{buildroot}%{_datadir}/selinux
2e6f2a4
%endif
30e4dae
1c5d14a
1c5d14a
%define saveFileContext() \
1c5d14a
if [ -s /etc/selinux/config ]; then \
1c5d14a
	. %{_sysconfdir}/selinux/config; \
1c5d14a
	FILE_CONTEXT=%{_sysconfdir}/selinux/%1/contexts/files/file_contexts; \
1c5d14a
	if [ "${SELINUXTYPE}" == %1 -a -f ${FILE_CONTEXT} ]; then \
1c5d14a
		cp -f ${FILE_CONTEXT} ${FILE_CONTEXT}.%{name}; \
1c5d14a
	fi \
1c5d14a
fi;
1c5d14a
1c5d14a
%define relabel() \
1c5d14a
. %{_sysconfdir}/selinux/config; \
1c5d14a
FILE_CONTEXT=%{_sysconfdir}/selinux/%1/contexts/files/file_contexts; \
1c5d14a
selinuxenabled; \
1c5d14a
if [ $? == 0  -a "${SELINUXTYPE}" == %1 -a -f ${FILE_CONTEXT}.%{name} ]; then \
1c5d14a
	fixfiles -C ${FILE_CONTEXT}.%{name} restore; \
1c5d14a
	rm -f ${FILE_CONTEXT}.%name; \
1c5d14a
fi;
1c5d14a
92794d0
%pre
1c5d14a
%if %{with selinux}
1c5d14a
for selinuxvariant in %{selinux_variants}; do
1c5d14a
	%saveFileContext ${selinuxvariant}
1c5d14a
done
1c5d14a
%endif
1c5d14a
92794d0
# https://fedoraproject.org/wiki/PackageUserRegistry
92794d0
%__fe_groupadd 44 -r icecream &>/dev/null || :
92794d0
%__fe_useradd  44 -r -s /sbin/nologin -d %{_localstatedir}/cache/icecream -M \
30e4dae
	-c 'Icecream distributed compiler' -g icecream icecream &>/dev/null ||:
92794d0
92794d0
%post
92794d0
/sbin/ldconfig
30e4dae
# if [ "$1" -le 1 ]; then # First install
2e6f2a4
%if %{with selinux}
30e4dae
for selinuxvariant in %{selinux_variants}; do
30e4dae
	semodule -s ${selinuxvariant} -i \
30e4dae
		%{_datadir}/selinux/${selinuxvariant}/icecream.pp 2>/dev/null ||:
1c5d14a
	semanage port -a -S ${selinuxvariant} -t iceccd_port_t -p tcp 10245 2>/dev/null ||:
1c5d14a
	semanage port -a -S ${selinuxvariant} -t icecc_scheduler_port_t -p tcp 8766 2>/dev/null ||:
e9e2b71
	# tcp 8765 is taken by LIRC. icecream.te knows it.
1c5d14a
	#semanage port -a -S ${selinuxvariant} -t icecc_scheduler_port_t -p tcp 8765 2>/dev/null ||:
e9e2b71
	semanage port -a -S ${selinuxvariant} -t icecc_scheduler_port_t -p udp 8765 2>/dev/null ||:
1c5d14a
	%relabel ${selinuxvariant}
30e4dae
done
83c739d
restorecon -R %{_localstatedir}/cache/icecream 2>/dev/null ||:
83c739d
restorecon %{_localstatedir}/log/iceccd 2>/dev/null ||:
2e6f2a4
%endif
30e4dae
# fi
1c5d14a
92794d0
/sbin/chkconfig --add iceccd
92794d0
/sbin/chkconfig --add icecc-scheduler
30e4dae
exit 0
92794d0
92794d0
%preun
30e4dae
if [ "$1" -eq 0 ]; then # Final removal
92794d0
	/sbin/service iceccd stop > /dev/null 2>&1
92794d0
	/sbin/service icecc-scheduler stop > /dev/null 2>&1
92794d0
	/sbin/chkconfig --del iceccd
92794d0
	/sbin/chkconfig --del icecc-scheduler
30e4dae
#	rm -rf %{_localstatedir}/cache/icecream
2e6f2a4
2e6f2a4
%if %{with selinux}
30e4dae
	for selinuxvariant in %{selinux_variants}; do
1c5d14a
		%saveFileContext ${selinuxvariant}
1c5d14a
		semanage port -d -S ${selinuxvariant} -t iceccd_port_t -p tcp 10245 2>/dev/null ||:
1c5d14a
		semanage port -d -S ${selinuxvariant} -t icecc_scheduler_port_t -p tcp 8765 2>/dev/null ||:
1c5d14a
		semanage port -d -S ${selinuxvariant} -t icecc_scheduler_port_t -p tcp 8766 2>/dev/null ||:
1c5d14a
		semanage port -d -S ${selinuxvariant} -t icecc_scheduler_port_t -p udp 8765 2>/dev/null ||:
30e4dae
	done
2e6f2a4
%endif
2e6f2a4
92794d0
fi
92794d0
exit 0
92794d0
92794d0
%postun
92794d0
/sbin/ldconfig
30e4dae
if [ "$1" -ge 1 ]; then # Upgrade
92794d0
	/sbin/service iceccd condrestart > /dev/null 2>&1
92794d0
	/sbin/service icecc-scheduler condrestart > /dev/null 2>&1
92794d0
fi
1c5d14a
%if %{with selinux}
1c5d14a
if [ "$1" -eq 0 ]; then # Final removal
1c5d14a
	for selinuxvariant in %{selinux_variants}; do
1c5d14a
		semodule -s ${selinuxvariant} -r icecream 2>/dev/null ||:
1c5d14a
		%relabel ${selinuxvariant}
1c5d14a
	done
1c5d14a
fi
1c5d14a
%endif
92794d0
exit 0
92794d0
92794d0
%clean
92794d0
rm -rf %{buildroot}
92794d0
92794d0
%files
92794d0
%defattr(-,root,root,-)
6908d74
%doc COPYING README NEWS TODO
92794d0
%{_bindir}/icecc
cde2f7b
%{_bindir}/icerun
2531906
%dir %{_libdir}/icecc/
2531906
%dir %{_libdir}/icecc/bin/
92794d0
%{_libdir}/icecc/bin/cc
92794d0
%{_libdir}/icecc/bin/gcc
92794d0
%{_libdir}/icecc/bin/c++
92794d0
%{_libdir}/icecc/bin/g++
92794d0
%{_libdir}/icecc/icecc-create-env
92794d0
%{_libdir}/libicecc.so.*
92794d0
%{_sbindir}/iceccd
92794d0
%{_sbindir}/icecc-scheduler
92794d0
%config(noreplace) %{_sysconfdir}/sysconfig/icecream
8d4b890
%config(noreplace) %{_sysconfdir}/profile.d/icecream.*sh
92794d0
%{_sysconfdir}/rc.d/init.d/iceccd
92794d0
%{_sysconfdir}/rc.d/init.d/icecc-scheduler
92794d0
%{_localstatedir}/cache/icecream
6908d74
%{_mandir}/man*/*
2e6f2a4
%{?with_selinux:%{_datadir}/selinux/*/icecream.pp}
92794d0
92794d0
%files devel
2531906
%defattr(-,root,root,-)
2531906
%dir %{_includedir}/icecc/
92794d0
%{_includedir}/icecc/*.h
92794d0
%{_libdir}/libicecc.so
92794d0
%{_libdir}/pkgconfig/icecc.pc
92794d0
92794d0
%changelog
0c0d6f5
* Tue Aug 03 2010 Michal Schmidt <mschmidt@redhat.com> 0.9.6-1
0c0d6f5
- New upstream release. With an official tarball this time.
0c0d6f5
- Dropped icecream-fix-createenv-when-ldconfig-fails.patch
0c0d6f5
  It was never accepted upstream and it is not necessary with working ldconfig.
0c0d6f5
- Refreshed icecream-rename-scheduler.patch
0c0d6f5
e9e2b71
* Sun Jun 13 2010 Michal Schmidt <mschmidt@redhat.com> 0.9.5-5
e9e2b71
- Mark UDP port 8765 as icecc_scheduler_port_t.
e9e2b71
c0da1ec
* Sat Jun 12 2010 Michal Schmidt <mschmidt@redhat.com> 0.9.5-4
c0da1ec
- Require /usr/sbin/semanage for scriptlets. (BZ#581272)
c0da1ec
1c5d14a
* Sat Jun 12 2010 Michal Schmidt <mschmidt@redhat.com> 0.9.5-3
1c5d14a
- Fix incorrect handling of SELinux in the scriptlets.
1c5d14a
- Avoid recursive rpm invocation (fixfiles -R).
1c5d14a
- Fixes: BZ#581272
1c5d14a
e587591
* Thu Mar 25 2010 Michal Schmidt <mschmidt@redhat.com> 0.9.5-2
e587591
- SELinux policy fix (current selinux-policy assigns port 8765 to LIRC).
e587591
cde2f7b
* Thu Mar 25 2010 Michal Schmidt <mschmidt@redhat.com> 0.9.5-1
cde2f7b
- Upstream release 0.9.5.
cde2f7b
  - new command 'icerun': serialize possibly resource-intensive tasks
cde2f7b
  - minor bugfixes
cde2f7b
- Refreshed icecream-rename-scheduler.patch.
cde2f7b
6ba4033
* Mon Oct 12 2009 Michal Schmidt <mschmidt@redhat.com> 0.9.4-5
6ba4033
- Fix failure to build native environment in SELinux enforcing mode.
6ba4033
- 'cvs rm ...' unused patches.
6ba4033
99712f1
* Mon Aug 17 2009 Michal Schmidt <mschmidt@redhat.com> 0.9.4-4
99712f1
- SELinux policy: Allow untrusted binaries to getattr all filesystems.
99712f1
  (BSD process accounting does vfs_getattr() to check disk space.)
99712f1
c36f75c
* Fri Aug 14 2009 Michal Schmidt <mschmidt@redhat.com> 0.9.4-3
c36f75c
- Create the logfile for the scheduler in the initscript.
c36f75c
- Allow the scheduler to write to the log in the SELinux policy (BZ#517251).
c36f75c
11323f8
* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.4-2
11323f8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
11323f8
ba64180
* Thu Apr 30 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.4-1
ba64180
- Upstream release 0.9.4.
ba64180
- Dropped merged patches.
ba64180
7934e6f
* Mon Apr 06 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.3-6
7934e6f
- Fix wrong permissions on the cache dir preventing the jobs from being
7934e6f
  distributed.
7934e6f
- SELinux policy update based on review comments on refpolicy ML.
7934e6f
60f91a5
* Mon Mar 02 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.3-5
60f91a5
- Fix a fd leak from iceccd + avoid using system().
60f91a5
- Allows tighter SELinux policy.
60f91a5
ca22a38
* Tue Feb 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.3-4
ca22a38
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
ca22a38
b342985
* Mon Feb 16 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.3-3
b342985
- Do not use --disable-rpath, icecream's configure script does not understand
b342985
  it and warns about it. We still remove rpath using the sed tricks.
b342985
- One more SELinux policy tweak.
b342985
d592b35
* Mon Feb 16 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.3-2
d592b35
- Updated and re-enabled the SELinux policy. The scheduler is now confined too.
d592b35
5d367fa
* Mon Feb 16 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.3-1
5d367fa
- new upstream release
5d367fa
- Dropped merged patches.
5d367fa
- Added an upstream patch to fix compilation with gcc 4.4.
5d367fa
aa93b14
* Sat Feb 07 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.2-4
aa93b14
- one more fix for gcc 4.4.
aa93b14
- updated the scheduler renaming patch.
aa93b14
9c942a1
* Sat Feb 07 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.2-3
9c942a1
- add an upstream patch to fix FTBFS with gcc 4.4
9c942a1
0acd02d
* Wed Jan 28 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.2-2
0acd02d
- Fix the create-env script not to crash on relative paths in ld.so.conf.
0acd02d
- No need to build the native environment as root anymore.
0acd02d
- Disable the SELinux policy for now, it needs more work.
0acd02d
6908d74
* Thu Nov 13 2008 Michal Schmidt <mschmidt@redhat.com> - 0.9.2-1
6908d74
- Update to upstream release 0.9.2.
6908d74
- The license is GPLv2+.
6908d74
- Add manpages from SUSE src package.
6908d74
- Add patch to run icecc --build-native as root.
6908d74
2531906
* Tue Sep  2 2008 Michael Schwendt <mschwendt@fedoraproject.org> - 0.8.0-12.20080117svn
2531906
- Include unowned icecc directories.
2531906
- Add defattr in devel pkg.
2531906
83c739d
* Thu Mar 13 2008 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-11.20080117svn
83c739d
- Minor SELinux policy fix.
83c739d
2e6f2a4
* Sun Feb 10 2008 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-10.20080117svn
2e6f2a4
- Compile fix (added missing #includes).
2e6f2a4
- Conditional building of SELinux policy and documentation.
2e6f2a4
- Fix build on RHEL5.
2e6f2a4
2e6f2a4
* Tue Jan 29 2008 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-9.20080117svn
2e6f2a4
- SELinux policy fixes.
2e6f2a4
89496dd
* Thu Jan 17 2008 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-8.20080117svn
89496dd
- Update to current icecream-make-it-cool branch.
89496dd
1dbccc9
* Tue Jan  8 2008 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-7.20071101svn
1dbccc9
- Build fix. meinproc is now in kdelibs3. BuildRequire that instead of kdelibs.
1dbccc9
4570b12
* Thu Nov 29 2007 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-6.20071101svn
4570b12
- Rewritten the profile scripts to make icecream work together with ccache.
4570b12
89116ae
* Tue Nov 27 2007 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-5.20071101svn
89116ae
- SELinux: Allow iceccd to contact the scheduler via UDP.
89116ae
- Don't add icecream to PATH in the profile scripts if ccache is installed
89116ae
  to avoid recursive invocations (bz #377761).
89116ae
30e4dae
* Tue Nov 20 2007 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-4.20071101svn
30e4dae
- Add a SELinux policy for iceccd
30e4dae
- Initscripts as sources instead of patches in the .spec file
30e4dae
- Don't touch /var/log/iceccd in the initscript. Let iceccd create it.
30e4dae
8d4b890
* Mon Nov 12 2007 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-3.20071101svn
8d4b890
- Add icecc to $PATH using scripts in profile.d
8d4b890
92794d0
* Tue Nov  6 2007 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-2.20071101svn
92794d0
- Use the _datadir macro instead of hardcoded /usr/share
92794d0
92794d0
* Thu Nov 01 2007 Michal Schmidt <mschmidt@redhat.com> - 0.8.0-1.20071101svn
92794d0
- Initial package for Fedora.