# defining macros needed by SELinux %global with_selinux 1 %global selinuxtype targeted %global forgeurl https://github.com/cweiske/surrogator Version: 0.3.1 %forgemeta Name: surrogator Summary: Simple open source Libravatar compatible avatar image server written in PHP Release: %autorelease Group: System Environment/Daemons License: AGPL-3.0 URL: %{forgeurl} Source0: %{forgesource} Source1: surrogator.config.php Source2: surrogator.conf Source3: README-Fedora Source4: %{name}.te Source5: %{name}.if Source6: %{name}.fc Requires: php >= 5 %if 0%{?with_selinux} # This ensures that the *-selinux package and all its dependencies are not pulled # into containers and other systems that do not use SELinux Requires: (%{name}-selinux if selinux-policy-%{selinuxtype}) %endif BuildArch: noarch %description Simple open source Libravatar compatible avatar image server written in PHP. Features: * Delivers images for email addresses * Very easy to setup. * No graphics processing is done on the server, keeping the CPU load low. All avatar images get pre-generated for a set of sizes * If no image at the user requested size is found, the next larger image gets returned. * Supports the mm fallback image (mystery man) %package httpd Summary: A httpd config to enable surrogator on an Apache server Requires: surrogator Requires: httpd %description httpd Simple open source Libravatar compatible avatar image server written in PHP. This package contains an http config file that enables the service on an Apache server. %if 0%{?with_selinux} # SELinux subpackage %package selinux Summary: SELinux policy module for surrogator Group: System Environment/Base Requires: selinux-policy-%{selinuxtype} Requires(post): selinux-policy-%{selinuxtype} BuildRequires: selinux-policy-devel %description selinux This package installs and sets up the SELinux policy security module for surrogator. %endif %prep %forgesetup cp %{SOURCE1} surrogator.config.php cp %{SOURCE2} surrogator.conf cp %{SOURCE3} README-Fedora %build %if 0%{?with_selinux} # SELinux policy (originally from selinux-policy-contrib) # this policy module will override the production module mkdir selinux cp -p %{SOURCE4} selinux/ cp -p %{SOURCE5} selinux/ cp -p %{SOURCE6} selinux/ make -f %{_datadir}/selinux/devel/Makefile %{name}.pp bzip2 -9 %{name}.pp %endif %install install -dm 755 %{buildroot} install -Dm 644 -t %{buildroot}%{_sysconfdir} %{SOURCE1} install -Dm 644 -t %{buildroot}%{_docdir}/%{name} %{SOURCE3} install -Dm 644 -t %{buildroot}%{_sysconfdir}/httpd/conf.d %{SOURCE2} install -Dm 644 -t %{buildroot}%{_datadir}/%{name}/res res/*.png res/*.svg install -Dm 644 -t %{buildroot}%{_datadir}/%{name}/www www/avatar.php res/www/* install -dm 755 %{buildroot}%{_var}/cache/%{name} install -dm 755 %{buildroot}%{_sharedstatedir}/%{name} install -Dm 755 surrogator.php %{buildroot}%{_bindir}/%{name} install -Dm 644 -t %{buildroot}%{_datadir}/%{name}/www www/avatar.php res/www/* %if 0%{?with_selinux} install -D -m 0644 %{name}.pp.bz2 %{buildroot}%{_datadir}/selinux/packages/%{selinuxtype}/%{name}.pp.bz2 install -D -p -m 0644 selinux/%{name}.if %{buildroot}%{_datadir}/selinux/devel/include/distributed/%{name}.if %endif %if 0%{?with_selinux} # SELinux contexts are saved so that only affected files can be # relabeled after the policy module installation %pre selinux %selinux_relabel_pre -s %{selinuxtype} %post selinux %selinux_modules_install -s %{selinuxtype} %{_datadir}/selinux/packages/%{selinuxtype}/%{name}.pp.bz2 %postun selinux if [ $1 -eq 0 ]; then %selinux_modules_uninstall -s %{selinuxtype} %{name} fi %posttrans selinux %selinux_relabel_post -s %{selinuxtype} # if with_selinux %endif %files %defattr(-,root,root) %{_datadir}/%{name} %{_var}/cache/%{name} %{_sharedstatedir}/%{name} %{_bindir}/%{name} %config(noreplace) %{_sysconfdir}/%{name}.config.php %doc README.rst %doc data/%{name}.config.php.dist %doc %{_docdir}/%{name}/* %license LICENSE %files httpd %config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf %license LICENSE %if 0%{?with_selinux} %files selinux %{_datadir}/selinux/packages/%{selinuxtype}/%{name}.pp.* %{_datadir}/selinux/devel/include/distributed/%{name}.if %ghost %verify(not md5 size mode mtime) %{_sharedstatedir}/selinux/%{selinuxtype}/active/modules/200/%{name} %endif %changelog %autochangelog