Blob Blame History Raw
%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.9.6
Release:	1%{?dist}
Summary:	Distributed compiler

Group:		Development/Tools
License:	GPLv2+
URL:		http://en.opensuse.org/Icecream
Source0:	http://ftp.suse.com/pub/projects/icecream/icecc-%{version}.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
# tarball extracted from http://download.opensuse.org/repositories/home:/coolo/openSUSE_Factory/src/icecream-0.9.5-3.1.src.rpm:
Source8:	%{name}-manpages.tar.bz2
Patch0:		%{name}-rename-scheduler.patch
Patch1:		%{name}-cleanup-conffile.patch

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

BuildRequires:	symlinks

BuildRequires:	fedora-usermgmt-devel
%{?FE_USERADD_REQ}
Provides:	group(icecream)	= 44
Provides:	user(icecream)	= 44

Requires(post):		chkconfig
Requires(preun):	chkconfig initscripts
Requires(postun):	initscripts

%if %{with selinux}
# For SELinux protection:
BuildRequires:	checkpolicy selinux-policy-devel hardlink
# semanage is in policycoreutils (EL-5) or policycoreutils-python (Fedora). File dep will work in both.
Requires(post):		policycoreutils /usr/sbin/semanage
Requires(preun):	policycoreutils /usr/sbin/semanage
Requires(postun):	policycoreutils
%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


# 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 -a 8 -n icecc-%{version}
%patch0 -p1
%patch1 -p0
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
# Remove rpath from local libtool copy
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool

make %{?_smp_mflags}

%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

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

# 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


%define saveFileContext() \
if [ -s /etc/selinux/config ]; then \
	. %{_sysconfdir}/selinux/config; \
	FILE_CONTEXT=%{_sysconfdir}/selinux/%1/contexts/files/file_contexts; \
	if [ "${SELINUXTYPE}" == %1 -a -f ${FILE_CONTEXT} ]; then \
		cp -f ${FILE_CONTEXT} ${FILE_CONTEXT}.%{name}; \
	fi \
fi;

%define relabel() \
. %{_sysconfdir}/selinux/config; \
FILE_CONTEXT=%{_sysconfdir}/selinux/%1/contexts/files/file_contexts; \
selinuxenabled; \
if [ $? == 0  -a "${SELINUXTYPE}" == %1 -a -f ${FILE_CONTEXT}.%{name} ]; then \
	fixfiles -C ${FILE_CONTEXT}.%{name} restore; \
	rm -f ${FILE_CONTEXT}.%name; \
fi;

%pre
%if %{with selinux}
for selinuxvariant in %{selinux_variants}; do
	%saveFileContext ${selinuxvariant}
done
%endif

# 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 ||:
	semanage port -a -S ${selinuxvariant} -t iceccd_port_t -p tcp 10245 2>/dev/null ||:
	semanage port -a -S ${selinuxvariant} -t icecc_scheduler_port_t -p tcp 8766 2>/dev/null ||:
	# tcp 8765 is taken by LIRC. icecream.te knows it.
	#semanage port -a -S ${selinuxvariant} -t icecc_scheduler_port_t -p tcp 8765 2>/dev/null ||:
	semanage port -a -S ${selinuxvariant} -t icecc_scheduler_port_t -p udp 8765 2>/dev/null ||:
	%relabel ${selinuxvariant}
done
restorecon -R %{_localstatedir}/cache/icecream 2>/dev/null ||:
restorecon %{_localstatedir}/log/iceccd 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}
	for selinuxvariant in %{selinux_variants}; do
		%saveFileContext ${selinuxvariant}
		semanage port -d -S ${selinuxvariant} -t iceccd_port_t -p tcp 10245 2>/dev/null ||:
		semanage port -d -S ${selinuxvariant} -t icecc_scheduler_port_t -p tcp 8765 2>/dev/null ||:
		semanage port -d -S ${selinuxvariant} -t icecc_scheduler_port_t -p tcp 8766 2>/dev/null ||:
		semanage port -d -S ${selinuxvariant} -t icecc_scheduler_port_t -p udp 8765 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
%if %{with selinux}
if [ "$1" -eq 0 ]; then # Final removal
	for selinuxvariant in %{selinux_variants}; do
		semodule -s ${selinuxvariant} -r icecream 2>/dev/null ||:
		%relabel ${selinuxvariant}
	done
fi
%endif
exit 0

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%doc COPYING README NEWS TODO
%{_bindir}/icecc
%{_bindir}/icerun
%dir %{_libdir}/icecc/
%dir %{_libdir}/icecc/bin/
%{_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
%{_mandir}/man*/*
%{?with_selinux:%{_datadir}/selinux/*/icecream.pp}

%files devel
%defattr(-,root,root,-)
%dir %{_includedir}/icecc/
%{_includedir}/icecc/*.h
%{_libdir}/libicecc.so
%{_libdir}/pkgconfig/icecc.pc

%changelog
* Tue Aug 03 2010 Michal Schmidt <mschmidt@redhat.com> 0.9.6-1
- New upstream release. With an official tarball this time.
- Dropped icecream-fix-createenv-when-ldconfig-fails.patch
  It was never accepted upstream and it is not necessary with working ldconfig.
- Refreshed icecream-rename-scheduler.patch

* Sun Jun 13 2010 Michal Schmidt <mschmidt@redhat.com> 0.9.5-5
- Mark UDP port 8765 as icecc_scheduler_port_t.

* Sat Jun 12 2010 Michal Schmidt <mschmidt@redhat.com> 0.9.5-4
- Require /usr/sbin/semanage for scriptlets. (BZ#581272)

* Sat Jun 12 2010 Michal Schmidt <mschmidt@redhat.com> 0.9.5-3
- Fix incorrect handling of SELinux in the scriptlets.
- Avoid recursive rpm invocation (fixfiles -R).
- Fixes: BZ#581272

* Thu Mar 25 2010 Michal Schmidt <mschmidt@redhat.com> 0.9.5-2
- SELinux policy fix (current selinux-policy assigns port 8765 to LIRC).

* Thu Mar 25 2010 Michal Schmidt <mschmidt@redhat.com> 0.9.5-1
- Upstream release 0.9.5.
  - new command 'icerun': serialize possibly resource-intensive tasks
  - minor bugfixes
- Refreshed icecream-rename-scheduler.patch.

* Mon Oct 12 2009 Michal Schmidt <mschmidt@redhat.com> 0.9.4-5
- Fix failure to build native environment in SELinux enforcing mode.
- 'cvs rm ...' unused patches.

* Mon Aug 17 2009 Michal Schmidt <mschmidt@redhat.com> 0.9.4-4
- SELinux policy: Allow untrusted binaries to getattr all filesystems.
  (BSD process accounting does vfs_getattr() to check disk space.)

* Fri Aug 14 2009 Michal Schmidt <mschmidt@redhat.com> 0.9.4-3
- Create the logfile for the scheduler in the initscript.
- Allow the scheduler to write to the log in the SELinux policy (BZ#517251).

* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Thu Apr 30 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.4-1
- Upstream release 0.9.4.
- Dropped merged patches.

* Mon Apr 06 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.3-6
- Fix wrong permissions on the cache dir preventing the jobs from being
  distributed.
- SELinux policy update based on review comments on refpolicy ML.

* Mon Mar 02 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.3-5
- Fix a fd leak from iceccd + avoid using system().
- Allows tighter SELinux policy.

* Tue Feb 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Mon Feb 16 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.3-3
- Do not use --disable-rpath, icecream's configure script does not understand
  it and warns about it. We still remove rpath using the sed tricks.
- One more SELinux policy tweak.

* Mon Feb 16 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.3-2
- Updated and re-enabled the SELinux policy. The scheduler is now confined too.

* Mon Feb 16 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.3-1
- new upstream release
- Dropped merged patches.
- Added an upstream patch to fix compilation with gcc 4.4.

* Sat Feb 07 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.2-4
- one more fix for gcc 4.4.
- updated the scheduler renaming patch.

* Sat Feb 07 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.2-3
- add an upstream patch to fix FTBFS with gcc 4.4

* Wed Jan 28 2009 Michal Schmidt <mschmidt@redhat.com> - 0.9.2-2
- Fix the create-env script not to crash on relative paths in ld.so.conf.
- No need to build the native environment as root anymore.
- Disable the SELinux policy for now, it needs more work.

* Thu Nov 13 2008 Michal Schmidt <mschmidt@redhat.com> - 0.9.2-1
- Update to upstream release 0.9.2.
- The license is GPLv2+.
- Add manpages from SUSE src package.
- Add patch to run icecc --build-native as root.

* Tue Sep  2 2008 Michael Schwendt <mschwendt@fedoraproject.org> - 0.8.0-12.20080117svn
- Include unowned icecc directories.
- Add defattr in devel pkg.

* 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.