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: crossfire
Version: 1.10.0
Release: 1%{?dist}
Summary: Server for hosting crossfire games
Group: Amusements/Games
License: GPL
URL: http://crossfire.real-time.com
Source0: http://downloads.sourceforge.net/crossfire/%{name}-%{version}.tar.gz
Source1: http://downloads.sourceforge.net/crossfire/%{name}-%{version}.arch.tar.gz
Source2: crossfire.init
Source3: crossfire.sysconfig
Source4: crossfire.logrotate
Source5: crossfire.te
Source6: crossfire.fc
Source7: crossfire.if
Source8: logwatch.logconf.crossfire
Source9: logwatch.script.crossfire
Source10: logwatch.serviceconf.crossfire
Patch0:  crossfire-1.9.1-logtimestamp.patch
Patch1:  crossfire-1.10.0-log-login.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires:       crossfire-maps
BuildRequires:  checkpolicy selinux-policy-devel hardlink
BuildRequires:  libXt-devel
BuildRequires:  libXext-devel
BuildRequires:  libXaw-devel
BuildRequires:  python-devel
Requires: %{name}-plugins

Requires(post): /sbin/chkconfig
Requires(post): /sbin/service
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
Requires(postun): /sbin/service

%description
Crossfire is a highly graphical role-playing adventure game with
characteristics reminiscent of rogue, nethack, omega, and gauntlet. 
It has multiplayer capability and presently runs under X11.

This package contains the server for hosting crossfire games over a
public or private network.

%package doc
Summary: Documentation files for Crossfire
Group: Documentation
# Don't require the base package.  The docs can be used without the
# base package, and in fact include docs for both the client and
# server packages.
%description doc
Documentation files for the crossfire game.

%package devel
Summary: Development files for writing crossfire plugins
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
Development files for writing crossfire plugins.

%package plugins
Summary: Plugin modules for the crossfire game server
Group: Amusements/Games
Requires: %{name} = %{version}-%{release}
%description plugins
Plugin modules for the crossfire game server.

%package client-images
Summary: Image cache for crossfire clients
Group: Amusements/Games
# crossfire-client provides a directory needed by the images.
# No version dependency for the client since the images are pretty
# ignorant of the client version.
Requires: crossfire-client
%description client-images
Image files that can be used with the crossfire clients so that they
don't have to be downloaded from the server.

%package selinux
Summary: SELinux policy files for crossfire
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 Crossfire game server

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

%prep
%setup -q
%setup -q -a 1
%patch0 -p0
%patch1 -p0
mkdir SELinux
cp  %{SOURCE5} %{SOURCE6} %{SOURCE7} SELinux

mv arch/ lib/

%{__sed} -i 's#\r##' utils/player_dl.pl.in
# Don't use a hardcoded /tmp directory for building the image archive
%{__sed} -i "s#^\$TMPDIR=.*#\$TMPDIR=\"`pwd`\";#" lib/adm/collect_images.pl
# Don't map stdio streams to /
# This is fixed in CVS, but didn't make it into the 1.9.1 release.
%{__sed} -i 's#    (void) open ("/", O_RDONLY);#    (void) open ("/var/log/crossfire/crossfire.log", O_RDONLY);#' server/daemon.c

# Change the location of the tmp directory
%{__sed} -i "s@^#define TMPDIR \"/tmp\"@#define TMPDIR \"%{_var}/games/%{name}/tmp\"@" include/config.h

%build
# Change the localstatedir so that the variable data files are
# put in /var/games/crossfire instead of /var/crossfire.  This is
# in agreement with the FHS.
%configure --localstatedir=%{_var}/games --disable-static

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

# This will create a tarball of the images for the client.
cd lib && adm/collect_images.pl -archive

%install
rm -rf $RPM_BUILD_ROOT

make DESTDIR=$RPM_BUILD_ROOT install

# Install the client images
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/%{name}/%{name}-client
tar xf %{name}-images.tar -C $RPM_BUILD_ROOT/%{_datadir}/%{name}/%{name}-client
# Nuke the installation instructions for the image archive.
rm $RPM_BUILD_ROOT/%{_datadir}/%{name}/%{name}-client/README

install -pD -m 0755 %{SOURCE2} $RPM_BUILD_ROOT%{_initrddir}/crossfire

# Move some rarely-used binaries out of /usr/bin and into a
# tools directory.
mkdir $RPM_BUILD_ROOT%{_datadir}/%{name}/tools

# This utility restarts crossfire at periodic intervals.
mv $RPM_BUILD_ROOT%{_bindir}/crossloop.pl $RPM_BUILD_ROOT%{_datadir}/%{name}/tools

# This submits core files to the developers.
mv $RPM_BUILD_ROOT%{_bindir}/crossloop.web $RPM_BUILD_ROOT%{_datadir}/%{name}/tools

# Allows players to download their player files from a web
# server. This feature relies on a properly configured web server
# which is not handled by this rpm release.
mv $RPM_BUILD_ROOT%{_bindir}/player_dl.pl $RPM_BUILD_ROOT%{_datadir}/%{name}/tools

# Binary for running a crossfire metaserver.  Requires interaction with
# a web server, so we disable this for now.
rm $RPM_BUILD_ROOT%{_libdir}/%{name}/metaserver.pl

# I have no idea what this is for.
mv $RPM_BUILD_ROOT%{_libdir}/%{name}/mktable.script $RPM_BUILD_ROOT%{_datadir}/%{name}/tools

# This is not needed anymore based on comments at the top of
# the file itself.
rm $RPM_BUILD_ROOT%{_libdir}/%{name}/add_throw.perl

# /usr/bin is a better place for the standalone random map generator
mv $RPM_BUILD_ROOT%{_libdir}/%{name}/random_map $RPM_BUILD_ROOT%{_bindir}/cross_random_map

rm -f $RPM_BUILD_ROOT%{_libdir}/%{name}/plugins/*.la

# Create the log directory
mkdir -p $RPM_BUILD_ROOT%{_var}/log/%{name}

install -p -D -m 644 %{SOURCE3} \
    $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/%{name}

install -p -D -m 644 %{SOURCE4} \
    $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/%{name}

mkdir $RPM_BUILD_ROOT%{_var}/games/%{name}/tmp

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

# Install logwatch files
install -pD -m 0644 %{SOURCE8} $RPM_BUILD_ROOT%{logwatch_conf}/logfiles/%{name}.conf
install -pD -m 0755 %{SOURCE9} $RPM_BUILD_ROOT%{logwatch_scripts}/services/%{name}
install -pD -m 0644 %{SOURCE10} $RPM_BUILD_ROOT%{logwatch_conf}/services/%{name}.conf


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

%post
/sbin/chkconfig --add crossfire

%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 13327 || :
/sbin/fixfiles -R %{name} restore || :
/sbin/service %{name} condrestart > /dev/null 2>&1 || :

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

%preun selinux
if [ "$1" -lt "1" ] ; then
    # Disable the policy and restart the daemon
    /usr/sbin/setsebool %{name}_disable_trans 1
    /sbin/service %{name} condrestart > /dev/null 2>&1 || :
    # Unload the module
    /usr/sbin/semanage port -d -t %{name}_port_t -p tcp 13327 || :
    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 crossfire 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 $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%{_bindir}/crossedit
%{_bindir}/crossfire
%{_bindir}/crossloop
%{_bindir}/cross_random_map
%{_datadir}/%{name}
%exclude %{_datadir}/%{name}/%{name}-client
%dir %{_libdir}/%{name}
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/ban_file
%config(noreplace) %{_sysconfdir}/%{name}/dm_file
%config(noreplace) %{_sysconfdir}/%{name}/exp_table
%config(noreplace) %{_sysconfdir}/%{name}/forbid
%config(noreplace) %{_sysconfdir}/%{name}/motd
%config(noreplace) %{_sysconfdir}/%{name}/news
%config(noreplace) %{_sysconfdir}/%{name}/rules
%config(noreplace) %{_sysconfdir}/%{name}/settings
%attr(-,crossfire,root) %{_var}/games/%{name}
%attr(-,crossfire,root) %{_var}/log/%{name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%{_mandir}/man6/*
%{_initrddir}/%{name}
%doc README NEWS DEVELOPERS AUTHORS COPYING

%files doc
%defattr(-,root,root,-)
%doc doc/*.doc doc/*.ps doc/SurvivalGuide
%doc doc/PlayerStats doc/RunTimeCommands doc/spellcasters_guide_to_runes

%files devel
%defattr(-,root,root,-)
%{_bindir}/crossfire-config
%doc doc/plugins

%files plugins
%defattr(-,root,root,-)
%{_libdir}/%{name}/plugins

%files client-images
%defattr(-,root,root,-)
%{_datadir}/%{name}/%{name}-client

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

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


%changelog
* Tue May 22 2007 Wart <wart@kobold.org> 1.10.0-1
- Update to 1.10.0
- Drop patch that was accepted upstream
- Add logwatch subpackage

* Fri Dec 8 2006 Wart <wart@kobold.org> 1.9.1-3
- Rebuild for new python 2.5

* Thu Aug 31 2006 Wart <wart@kobold.org> 1.9.1-2
- Added upstream patch to fix configure bug.
- Added selinux security policy
- Don't use /tmp for the map file cache

* Thu Jul 6 2006 Wart <wart@kobold.org> 1.9.1-1
- Update to 1.9.1

* Tue May 16 2006 Wart <wart@kobold.org> 1.9.0-4
- Added -doc subpackage
- Own /etc/crossfire
- Add crossfire-client dependency for crossfire-client-images

* Tue May 16 2006 Wart <wart@kobold.org> 1.9.0-3
- Added patch to fix missing stdout problem with python plugin.

* Mon May 15 2006 Wart <wart@kobold.org> 1.9.0-2
- Generate the -client-images subpackage here instead of relying
  on upstream's missing -client-images tarball.

* Thu Mar 9 2006 Wart <wart@kobold.org> 1.9.0-1
- Initial spec file following Fedora Extras conventions