%define appdir %{_datadir}/%{name} %define setupdir %{appdir}/setup %define apacheconf %{_sysconfdir}/httpd/conf.d %define logrotate %{_sysconfdir}/logrotate.d %define logdir %{_var}/log/%{name} %define cachedir %{_var}/cache/%{name} %define _build_file_context_path selinux_patterns # Upstream loves '_' as version separator in zip file name %define zipname %(echo %{name}_%{version} | tr '.' '_') Name: tcexam Version: 10.0.006 Release: 1%{?dist} Summary: A Web-based Computer-Based Assessment (CBA) software Group: Applications/Web License: GPLv3 URL: http://www.tcexam.org Source0: http://downloads.sourceforge.net/tcexam/%{zipname}.zip Source1: tcexam-setdef Source2: tcexam-db-setup Source3: tcexam-logrotate Source4: tcexam-README.fedora # Move logging to /var/log/tcexam/tce.log # Make it log everything and not just errors # Need to send upstream (at least the log location) Patch0: tcexam-logging.patch Patch1: tcexam-default-font.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch Requires: php >= 5, httpd, php-gd Requires: ImageMagick # For build/runtime setup Requires: php-cli Buildrequires: php-cli %description TCExam is a free Web-based and Open-Source Computer-Based Assessment (CBA) software application hosted on the SourceForge.net repository. TCExam is divided in two main sections: Public and Administration. %package selinux Summary: An SELinux policy for %{name} Group: System Environment/Libraries Requires: %name = %version-%release Requires: selinux-policy Requires(post): policycoreutils Requires(postun): policycoreutils %description selinux This is an SELinux policy for %{name} It contain the rules that enable the running of %{name} in an SELinux environment. Install it if the package policycoreutils is installed on the host. %package mysql Summary: MySQL initialization data for %{name} Group: Applications/Web Requires: %name = %version-%release Requires: php-mysql, mysql-libs %description mysql This package contains MySQL initialization data for %{name} %package postgresql Summary: Postgresql initialization data for %{name} Group: Applications/Web Requires: %name = %version-%release Requires: php-pgsql, postgresql-libs %description postgresql This package contains Postgresql initialization data for %{name} %prep %setup -q -n TCExam # Cleanup DOS CR/LF find . -type f | xargs file |grep 'text' | cut -d: -f1 | xargs sed -i 's/\r$//' %patch0 -p0 %patch1 -p0 # Fix permissions find . -type f | xargs chmod 444 find . -type d | xargs chmod 755 find . -name .noencode | xargs rm -f # We need to edit some config files chmod u+w \ shared/config/tce_config.php \ shared/config/tce_paths.php # cleanups find . -name '.cvsignore' | xargs rm -f %build # PHP date functions want explicit timezone setting if [ -r '/etc/sysconfig/clock' ]; then . '/etc/sysconfig/clock' TZ="$ZONE" else TZ='UTC' fi export TZ # Configure sane defaults %{SOURCE1} K_USE_ERROR_LOG 'true' shared/config/tce_config.php %{SOURCE1} K_PATH_HOST 'localhost' shared/config/tce_paths.php %{SOURCE1} K_PATH_TCEXAM '/tcexam/' shared/config/tce_paths.php %{SOURCE1} K_PATH_MAIN '%{appdir}/' shared/config/tce_paths.php %{SOURCE1} K_PATH_CACHE '%{cachedir}/' shared/config/tce_paths.php %install rm -rf $RPM_BUILD_ROOT mkdir -p "$RPM_BUILD_ROOT%{appdir}" cp -a * "$RPM_BUILD_ROOT%{appdir}" # Cleanup ( cd "$RPM_BUILD_ROOT%{appdir}" || exit 1 rm -rf fonts/utils cache rm -f shared/config/lang/tmx.ini ) mkdir -p "$RPM_BUILD_ROOT%{setupdir}" cp %{SOURCE1} "$RPM_BUILD_ROOT%{setupdir}" # Fix cache for FHS compliance and remove old content mkdir -p $RPM_BUILD_ROOT/%{cachedir}/backup mkdir -p $RPM_BUILD_ROOT/%{cachedir}/lang cp cache/README.TXT $RPM_BUILD_ROOT/%{cachedir} # Updates #cp %{SOURCE20} "$RPM_BUILD_ROOT%{setupdir}" # Extra doc cp %{SOURCE4} README.fedora # Prepare database setup files mkdir -p "$RPM_BUILD_ROOT%{_sbindir}" f=`basename %{SOURCE2}` install -m755 "%{SOURCE2}" $RPM_BUILD_ROOT%{_sbindir} sed -i 's|^DBINIT=.*|DBINIT="%{setupdir}"|' "$RPM_BUILD_ROOT%{_sbindir}/$f" for i in db_data.sql postgresql_db_structure.sql mysql_db_structure.sql do mv "install/$i" $RPM_BUILD_ROOT%{setupdir} done # We remove at destination, so we still have install # for the %doc section rm -rf "$RPM_BUILD_ROOT%{appdir}/install" # Fix log locations for FHS compliance install -d -m 755 $RPM_BUILD_ROOT/%{logdir} install -m 644 /dev/null $RPM_BUILD_ROOT/%{logdir}/tce.log rm -rf $RPM_BUILD_ROOT%{appdir}/admin/log rm -rf $RPM_BUILD_ROOT%{appdir}/public/log # Apache config mkdir -p "$RPM_BUILD_ROOT%{apacheconf}" cat < "$RPM_BUILD_ROOT%{apacheconf}/%{name}.conf" Alias /tcexam %{appdir} Order deny,allow Deny from all Allow from 127.0.0.1 Allow from ::1 AddDefaultCharset UTF-8 php_value date.timezone "UTC" php_value arg_separator.output "&" php_value magic_quotes_gpc On php_value magic_quotes_runtime Off php_value magic_quotes_sybase Off END_OF_FILE # Logrotate mkdir -p "$RPM_BUILD_ROOT%{logrotate}" install -m 644 %{SOURCE3} "$RPM_BUILD_ROOT%{logrotate}/%{name}" rm -f $RPM_BUILD_ROOT%{appdir}/{LATEX_README.TXT,LICENSE.TXT,INSTALL.TXT,README.TXT,TRANSLATORS.TXT,CHANGELOG.TXT,UPGRADE.TXT} %clean rm -rf $RPM_BUILD_ROOT %post # Clean language translation cache rm -f %{cachedir}/lang/language_tmx_*.php if [ $1 -eq 1 ] ; then # Try to set timezone by system default if [ -r %{_sysconfdir}/sysconfig/clock ]; then . %{_sysconfdir}/sysconfig/clock if [ "$ZONE" != "" ]; then TZ="$ZONE"; export TZ %{setupdir}/tcexam-setdef K_TIMEZONE "$ZONE" %{appdir}/shared/config/tce_config.php sed -i 's|date.timezone[ \t]*"[^"]*"|date.timezone "'$ZONE'"|' %{apacheconf}/%{name}.conf fi fi echo "You should run %{_sbindir}/tcexam-db-setup to complete the installation" else # It's an upgrade: : fi %post selinux if [ $1 -eq 1 ] ; then semanage fcontext -a --ftype=-- -t httpd_sys_script_exec_t '%{appdir}/[^/]*\.php' semanage fcontext -a --ftype=-- -t httpd_sys_script_exec_t '%{appdir}/.*/code/[^/]*\.php' semanage fcontext -a -t httpd_sys_content_t '%{appdir}(/.*)?' semanage fcontext -a -t httpd_log_t '%{logdir}/.*' semanage fcontext -a -t httpd_sys_script_rw_t '%{cachedir}' semanage fcontext -a -t httpd_sys_script_rw_t '%{cachedir}/lang(/language_tmx_*.php)?' semanage fcontext -a -t bin_t '%{setupdir}(/.*)?' fi restorecon -R %{appdir} %{logdir} %{cachedir} %{setupdir} || : %preun # Clean language translation cache rm -f %{cachedir}/lang/language_tmx_*.php %postun selinux if [ $1 -eq 0 ] ; then semanage fcontext -d --ftype=-- -t httpd_sys_script_exec_t '%{appdir}/[^/]*\.php' semanage fcontext -d --ftype=-- -t httpd_sys_script_exec_t '%{appdir}/.*/code/[^/]*\.php' semanage fcontext -d -t httpd_sys_content_t '%{appdir}(/.*)?' semanage fcontext -d -t httpd_log_t '%{logdir}/.*' semanage fcontext -d -t httpd_sys_script_rw_t '%{cachedir}' semanage fcontext -d -t httpd_sys_script_rw_t '%{cachedir}/lang(/language_tmx_*.php)?' semanage fcontext -d -t bin_t '%{setupdir}(/.*)?' fi %files %defattr(-,root,root,-) %config(noreplace) %{apacheconf}/%{name}.conf %config(noreplace) %{logrotate}/%{name} %doc LICENSE.TXT INSTALL.TXT README.TXT TRANSLATORS.TXT CHANGELOG.TXT UPGRADE.TXT %doc LATEX_README.TXT install/index.htm %doc README.fedora %dir %{appdir} %dir %{appdir}/admin %{appdir}/admin/index.php %{appdir}/admin/styles %{appdir}/admin/code %{appdir}/admin/doc %{appdir}/admin/README.TXT %config(noreplace) %{appdir}/admin/config %dir %{appdir}/shared %{appdir}/shared/code %{appdir}/shared/radius %{appdir}/shared/phpmailer %{appdir}/shared/jscripts %{appdir}/shared/cas %dir %{appdir}/shared/config %config(noreplace) %{appdir}/shared/config/tcpdf.crt %config(noreplace) %{appdir}/shared/config/tce_config.php %config(noreplace) %{appdir}/shared/config/tce_general_constants.php %config(noreplace) %{appdir}/shared/config/tce_latex.php %config(noreplace) %{appdir}/shared/config/tce_ldap.php %config(noreplace) %{appdir}/shared/config/tce_mime.php %config(noreplace) %{appdir}/shared/config/tce_paths.php %config(noreplace) %{appdir}/shared/config/tce_pdf.php %config(noreplace) %{appdir}/shared/config/tce_user_registration.php %config(noreplace) %{appdir}/shared/config/tce_cas.php # Contains sensitive information... (set owner+permissions) %config(noreplace) %attr(440,apache,apache) %{appdir}/shared/config/tce_db_config.php %config(noreplace) %attr(440,apache,apache) %{appdir}/shared/config/tce_email_config.php %config(noreplace) %attr(440,apache,apache) %{appdir}/shared/config/tce_radius.php %{appdir}/shared/config/lang %dir %{appdir}/public %{appdir}/public/index.php %{appdir}/public/styles %{appdir}/public/code %{appdir}/public/README.TXT %config(noreplace) %{appdir}/public/config %{appdir}/fonts %{appdir}/images %{appdir}/index.php %{appdir}/favicon.ico %attr(-,apache,apache) %dir %{cachedir} %attr(-,apache,apache) %dir %{cachedir}/backup %attr(-,apache,apache) %dir %{cachedir}/lang %{cachedir}/README.TXT %attr(-,apache,apache) %{logdir} %attr(-,root,root) %{_sbindir}/tcexam-db-setup %attr(-,root,root) %dir %{setupdir} %attr(-,root,root) %{setupdir}/db_data.sql %attr(-,root,root) %{setupdir}/tcexam-setdef %files mysql %attr(-,root,root) %{setupdir}/mysql_db_structure.sql %files postgresql %attr(-,root,root) %{setupdir}/postgresql_db_structure.sql %changelog * Tue Feb 23 2010 Oron Peled - 10.0.006-1 - New version from upstream. - Set timezone in tcexam-setdef, so we don't get warnings from php date() function - Add a backup directory (since 10.0.000) * Sun Nov 15 2009 Oron Peled - 9.0.035-1 - New version from upstream. - A reference package before trying to split tcpdf. * Wed Jan 21 2009 Oron Peled - 7.0.029-1 - New version from upstream. - Database schema changed -- update script supplied - Remove fonts/utils. * Wed Jan 21 2009 Oron Peled - 7.0.020-1 - New version from upstream. - Hebrew support + translation merged, removed patches. * Sun Dec 7 2008 Oron Peled - 7.0.006-1 - New version from upstream. - New setup helper -- tcexam-setdef - Hebrew patch+translation sent upstream, waiting for merge. * Sun Nov 9 2008 Oron Peled - 6.0.000-1 - New version from upstream. - Merged (partial) Hebrew translation (to be sent upstream when finished). * Sun Oct 26 2008 Oron Peled - 5.4.006-2 - Add a README.fedora which document the tcexam-db-setup script - Add Hebrew support + partial translation - Explicitly specify the config files, so only sensitive ones are assigned to the apache user. - Create apache configuration in the spec file for macro substitution. - Clean the application cache during build. * Wed Oct 1 2008 Oron Peled - 5.4.006-1 - initial release