File openadmin.spec of Package openadmin

# spec file for package openadmin
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

Name:           openadmin
Version:        3.75
Release:        0
Summary:        A web-based school administration program
License:        GNU General Public License
Group:          Productivity/Networking/Web/Utilities
Source:         %{name}-%{version}.tar.bz2
Source1:        %{name}_include.conf
Requires:       perl
BuildArch:      noarch
AutoReqProv:    no
%if 0%{?suse_version}
BuildRequires:  apache2-devel
BuildRequires:  fdupes
Requires:       apache2
Requires:       apache2-mod_perl
Requires:       cron
Requires:       perl-CGI-Session
Requires:       perl-Crypt-GeneratePassword
Requires:       perl-DBI
Requires:       perl-Data-Password
Requires:       perl-Data-UUID
Requires:       perl-Date-Business
Requires:       perl-FreezeThaw
Requires:       perl-Number-Format
Requires:       perl-Text-CSV_XS
Requires:       perl-Time-modules
Requires:       perl-XML-LibXML
# Below is just for Saskatchewan + provincial SDS system via https
Requires:       perl-XML-Writer
Requires:       perl-XML-Writer-String
Requires:       texlive-latex
Recommends:     mysql-client
%define         apache_serverroot %(/usr/sbin/apxs2 -q DATADIR)
%define         apache_sysconfdir %(/usr/sbin/apxs2 -q SYSCONFDIR)
%if 0%{?fedora_version}
BuildRequires:  httpd-devel
Requires:       cron
Requires:       httpd2
%define         apache_serverroot %(/usr/sbin/apxs -q DATADIR)
%define         apache_sysconfdir %(/usr/sbin/apxs -q SYSCONFDIR)
%define         rootdir %{apache_serverroot}/%{name}
%define         configdir %{_sysconfdir}/%{name}
%define         crondir %{_sysconfdir}/cron.d
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# skip test for devel dependencies required by libtool .la files: skip-check-libtool-deps

Open Admin for schools is an open source web-based school administration
program. Includes student demographics, attendance,
discipline, report card, IEP, Gradebook, Daybook, ...

%setup -q
# docs contains no valid information
rm -rf docs
find -name *~ -exec rm -v {} \;
find school/etc/ -name *.conf.* -exec rm -v {} \;

# ---------------------------------------------------------------------------

mkdir -p %{buildroot}/%{rootdir}
mkdir -p %{buildroot}/%{configdir}
mkdir -p %{buildroot}/%{_sysconfdir}/cron.d
mkdir -p %{buildroot}/%{apache_sysconfdir}/vhosts.d
mkdir -p %{buildroot}/%{_defaultdocdir}/%{name}
cp -a * %{buildroot}/%{rootdir}
# configure using /etc for configs
pushd %{buildroot}/%{rootdir}/school
mv etc/* %{buildroot}/%{configdir}/
rmdir etc
ln -s %{configdir} etc
# adapt configs
pushd %{buildroot}/%{configdir}
for file in *; do
	sed -i "s|/opt/openadmin/YOURSCHOOL|%{rootdir}/school|g" $file
# remove backup files
find %{buildroot} -name *.orig -print0 | xargs -0 rm -v
# be shure, every script is executable
find %{buildroot}/%{rootdir} -name *.pl -print0 | xargs chmod +x
# move utilies to another place
mkdir -p %{buildroot}%{_datadir}/%{name}
mv %{buildroot}/%{rootdir}/utility %{buildroot}%{_datadir}/%{name}/
# include.conf for apache
mkdir -p %{buildroot}/%{apache_sysconfdir}/{vhosts.d,%{name}_auth_users}
tail +4 utility/httpd-redhat.conf | \
   sed 's|/opt/openadmin/SCHOOLNAME|%{rootdir}/school|g;
        s|SCHOOLNAME|school|g' > %{buildroot}/%{apache_sysconfdir}/vhosts.d/%{name}.conf.template
# save some space
%if 0%{?suse_version}
%fdupes -s %{buildroot}/%{rootdir}

%doc Readme
%dir %{rootdir}
%dir %{configdir}
%dir %{_datadir}/%{name}
%config(noreplace) %{configdir}/*
%config(noreplace) %{apache_sysconfdir}/vhosts.d/%{name}.conf.template
%dir %{rootdir}/school/admin/download