Blob Blame History Raw
%define selinux_variants mls strict targeted
%define selinux_policyver %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp)

%define logwatch_root %{_datadir}/logwatch
%define logwatch_conf %{logwatch_root}/dist.conf
%define logwatch_scripts %{logwatch_root}/scripts

Name:           cyphesis
Version:        0.5.11
Release:        2%{?dist}
Summary:        WorldForge game server
Group:          System Environment/Libraries
License:        GPL
URL:            http://www.worldforge.org
Source0:        http://dl.sourceforge.net/worldforge/%{name}-%{version}.tar.gz
Source1:        cyphesis.te
Source2:        cyphesis.if
Source3:        cyphesis.fc
Source4:        logwatch.logconf.cyphesis
Source5:        logwatch.script.cyphesis
Source6:        logwatch.serviceconf.cyphesis
Source7:        logwatch.shared.applycyphesisdate
Patch0:         cyphesis-0.5.8-init.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires:  python-devel libgcrypt-devel pkgconfig atlascpp-devel
BuildRequires:  varconf-devel libsigc++20-devel mercator-devel skstream-devel
BuildRequires:  postgresql-devel readline-devel avahi-devel
BuildRequires:  checkpolicy selinux-policy-devel hardlink

Requires:       postgresql-server
Requires(post): /sbin/chkconfig
Requires(post): /sbin/service
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
Requires(postun): /sbin/service

%description
Cyphesis is a WorldForge server suitable running small games. It is also
designed by be used as an AI subsystem in a network of distributed servers. It
includes a terrain engine based on the Mercator library, a persistence system
based on PostgreSQL, and an AI engine using goal trees implemented in Python.
It is the server used in most current WorldForge games.


%package selinux
Summary: SELinux policy files for the WorldForge game server
Group: Amusements/Games
Requires: %{name} = %{version}-%{release}
%if "%{selinux_policyver}" != ""
Requires:       selinux-policy >= %{selinux_policyver}
%endif
Requires(post):         /usr/sbin/semodule /usr/sbin/semanage /sbin/fixfiles
Requires(preun):        /sbin/service /usr/sbin/semodule /usr/sbin/semanage /sbin/fixfiles /usr/sbin/setsebool
Requires(postun):       /usr/sbin/semodule
%description selinux
SELinux policy files for the WorldForge game server

%package logwatch
Summary: logwatch scripts for the WorldForge game server
Group: Amusements/Games
Requires: %{name} = %{version}-%{release} logwatch
%description logwatch
logwatch scripts for the WorldForge game server


%prep
%setup -q
%patch0

chmod a-x rulesets/basic/world/objects/*/*.py
chmod a-x rulesets/basic/mind/dictlist.py
mkdir SELinux
cp  %{SOURCE1} %{SOURCE2} %{SOURCE3} SELinux/

# Use a /etc/sysconfig/cyphesis variable to determine if
# we should load the world data into the cyphesis server
# via cyclient or not.  This should allow us to use a single
# init.d script for both starting cyphesis and populating the world.
echo "POPULATE_WORLD=1" >> cyphesis.sysconfig


%build
%configure
make %{?_smp_mflags}

# Build the selinux policy file
pushd SELinux
for variant in %{selinux_variants}
do
    make NAME=${variant} -f %{_datadir}/selinux/devel/Makefile
    mv %{name}.pp %{name}.pp.${variant}
    make NAME=${variant} -f %{_datadir}/selinux/devel/Makefile clean
done
popd

%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}

install -d %{buildroot}%{_sysconfdir}/init.d
install -m 755 %{name}.init %{buildroot}%{_sysconfdir}/init.d/%{name}

install -d %{buildroot}%{_sysconfdir}/sysconfig
install -m 644 %{name}.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/%{name}

# Install logwatch files
install -pD -m 0644 %{SOURCE4} %{buildroot}%{logwatch_conf}/logfiles/%{name}.conf
install -pD -m 0755 %{SOURCE5} %{buildroot}%{logwatch_scripts}/services/%{name}
install -pD -m 0644 %{SOURCE6} %{buildroot}%{logwatch_conf}/services/%{name}.conf
install -pD -m 0755 %{SOURCE7} %{buildroot}%{logwatch_scripts}/shared/applycyphesisdate


# Install selinux policies
pushd SELinux
for variant in %{selinux_variants}
do
    install -d %{buildroot}%{_datadir}/selinux/${variant}
    install -p -m 644 %{name}.pp.${variant} \
           %{buildroot}%{_datadir}/selinux/${variant}/%{name}.pp
done
popd
# Hardlink identical policy module packages together
/usr/sbin/hardlink -cv %{buildroot}%{_datadir}/selinux

%check
make check

%pre
user_uid=`id -u cyphesis 2>/dev/null`
if [ x"$user_uid" = x ] ; then
    useradd  -r -d %{_datadir}/%{name} -M -c 'Cyphesis Game Server' \
            cyphesis >/dev/null || :
fi

%post
/sbin/chkconfig --add cyphesis

%post selinux
# Install SELinux policy modules
for selinuxvariant in %{selinux_variants}
do
  /usr/sbin/semodule -s ${selinuxvariant} -i \
    %{_datadir}/selinux/${selinuxvariant}/%{name}.pp &> /dev/null || :
done
/usr/sbin/semanage port -a -t %{name}_port_t -p tcp 6767 &> /dev/null || :
/usr/sbin/semanage port -a -t %{name}_port_t -p tcp 6769 &> /dev/null || :
/usr/sbin/semanage port -a -t %{name}_port_t -p udp 32771 &> /dev/null || :
/sbin/fixfiles -R %{name} restore || :
/sbin/service %{name} condrestart > /dev/null 2>&1 || :


%preun
if [ "$1" = "0" ]; then
    /sbin/service cyphesis stop > /dev/null 2>&1
    /sbin/chkconfig --del cyphesis
fi

%preun selinux
if [ "$1" -lt "1" ] ; then
    # Disable the policy and restart the daemon
    /usr/sbin/setsebool %{name}_disable_trans 1 &> /dev/null || :
    /sbin/service %{name} condrestart > /dev/null 2>&1 || :
    # Unload the module
    /usr/sbin/semanage port -d -t %{name}_port_t -p tcp 6767 &> /dev/null || :
    /usr/sbin/semanage port -d -t %{name}_port_t -p tcp 6769 &> /dev/null || :
    /usr/sbin/semanage port -d -t %{name}_port_t -p udp 32771 &> /dev/null || :
    for variant in %{selinux_variants} ; do
        /usr/sbin/semodule -s ${variant} -r %{name} &> /dev/null || :
    done
    # Set the context back
    /sbin/fixfiles -R %{name} restore || :
fi

%postun
if [ "$1" -ge "1" ]; then
    /sbin/service cyphesis condrestart >/dev/null 2>&1
fi

%postun selinux
if [ "$1" -ge "1" ] ; then
    # Replace the module if it is already loaded. semodule -u also
    # checks the module version
    for variant in %{selinux_variants} ; do
        /usr/sbin/semodule -u %{_datadir}/selinux/${variant}/%{name}.pp || :
    done
fi

%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING README NEWS THANKS TODO
%{_bindir}/cy*
%{_mandir}/man1/*.1.gz
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/*
%{_sysconfdir}/init.d/%{name}
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%{_datadir}/%{name}

%files logwatch
%defattr(-,root,root,-)
%{logwatch_conf}/logfiles/%{name}.conf
%{logwatch_conf}/services/%{name}.conf
%{logwatch_scripts}/services/%{name}
%{logwatch_scripts}/shared/applycyphesisdate

%files selinux
%defattr(-,root,root,-)
%doc SELinux/*.??
%{_datadir}/selinux/*/%{name}.pp


%changelog
* Sat Feb 25 2007 Wart <wart at kobold.org> 0.5.11-2
- Add logwatch subpackage
- Move log file to /var/log directory

* Wed Jan 24 2007 Wart <wart at kobold.org> 0.5.11-1
- Update to 0.5.11 with builtin python 2.5 support
- Updated selinux policy

* Mon Aug 28 2006 Wart <wart at kobold.org> 0.5.9-2
- Use more globs in %%files section
- Remove unused -devel subpackage declaration

* Sat Aug 26 2006 Wart <wart at kobold.org> 0.5.9-1
- Update to 0.5.9

* Sat Aug 5 2006 Wart <wart at kobold.org> 0.5.8-5
- Move semanage calls to the init script so that we can be sure they are
  called if a system manager turns selinux on or off between installing
  the package and starting it.
- Remove FC4 bits from the spec file
- unghost the .pyo files per the recent packaging committee decision
- Don't bother explicitly creating a group for the cyphesis user

* Thu Aug 3 2006 Wart <wart at kobold.org> 0.5.8-4
- Use find+sed in %%install instead of enumerating directories in %%files
- Remove the use of fedora-usermgmt.  There's no need.

* Tue Aug 1 2006 Wart <wart at kobold.org> 0.5.8-3
- Clean up %%files

* Tue Aug 1 2006 Wart <wart at kobold.org> 0.5.8-2
- Fix -init patch that was missing some key changes.

* Tue Aug 1 2006 Wart <wart at kobold.org> 0.5.8-1
- Initial spec file for Fedora Extras