Blob Blame History Raw
%define selinux_variants 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:           xpilot-ng
Version:        4.7.2
Release:        13%{?dist}
Summary:        Multiplayer space arcade game

Group:          Amusements/Games
License:        GPLv2+
URL:            http://xpilot.sourceforge.net
Source0:        http://dl.sourceforge.net/sourceforge/xpilot/xpilot-ng-%{version}.tar.gz
Source1:        xpilot-ng.png
Source2:        xpilot-ng-x11.desktop
Source3:        xpilot-ng-sdl.desktop
Source4:        xpilot-ng-server.init
Source5:        xpilot-ng.sysconfig
Source6:        xpilot-ng.logrotate
Source7:        xpilotd.te
Source8:        xpilotd.fc
Source9:        xpilotd.if
Source10:       logwatch.logconf.xpilot
Source11:       logwatch.script.xpilot
Source12:       logwatch.serviceconf.xpilot
Source13:       logwatch.shared.applyxpilotdate
Patch0:         xpilot-ng-4.7.2-scoreassert.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires:  desktop-file-utils
BuildRequires:  expat-devel SDL_ttf-devel SDL_image-devel zlib-devel
BuildRequires:  libXt-devel libGLU-devel libXxf86misc-devel
BuildRequires:  selinux-policy-devel hardlink checkpolicy

%description
A highly addictive, infinitely configurable multiplayer space
arcade game.  You pilot a spaceship around space, dodging
obstacles, shooting players and bots, collecting power-ups, and
causing general mayhem.

%package server
Summary: Server for hosting xpilot games
Group: Amusements/Games
Requires(pre): shadow-utils
Requires(post): /sbin/chkconfig
Requires(post): /sbin/service
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
Requires(postun): /sbin/service
%description server
The xpilot server.  This allows you to host xpilot games on your
computer and develop new xpilot maps.  This is required if you
are playing alone, but not required if you are joining one of the
public xpilot games hosted on the internet.

%package selinux
Summary: SELinux policy files for the xpilot-ng game server
Group: Amusements/Games
Requires: %{name}-server = %{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 xpilot-ng game server

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

%prep
%setup -q
%patch0
pushd doc/man
iconv --from=ISO-8859-1 --to=UTF-8 xpilot-ng-server.man > xpilot-ng-server.man.new
mv xpilot-ng-server.man.new xpilot-ng-server.man
iconv --from=ISO-8859-1 --to=UTF-8 xpilot-ng-x11.man > xpilot-ng-x11.man.new
mv xpilot-ng-x11.man.new xpilot-ng-x11.man
popd

mkdir SELinux
cp  %{SOURCE7} %{SOURCE8} %{SOURCE9} SELinux/

%build
CFLAGS="$RPM_OPT_FLAGS" %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 xpilotd.pp xpilotd.pp.${variant}
    make NAME=${variant} -f %{_datadir}/selinux/devel/Makefile clean
done
popd

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

chmod a+x $RPM_BUILD_ROOT/%{_datadir}/%{name}/mapconvert.py

desktop-file-install --vendor fedora                            \
        --dir ${RPM_BUILD_ROOT}%{_datadir}/applications         \
        --add-category X-Fedora                                 \
        %{SOURCE2}
desktop-file-install --vendor fedora                            \
        --dir ${RPM_BUILD_ROOT}%{_datadir}/applications         \
        --add-category X-Fedora                                 \
        %{SOURCE3}
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/icons/hicolor/48x48/apps/
install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT/%{_datadir}/icons/hicolor/48x48/apps/

install -p -D -m 755 %{SOURCE4} $RPM_BUILD_ROOT/%{_initrddir}/%{name}-server

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

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

# Copy certain configuration files to /etc so that they can be properly managed
# as config files.
install -p -D -m 644 lib/defaults.txt $RPM_BUILD_ROOT/%{_sysconfdir}/%{name}/defaults.txt
install -p -D -m 600 lib/password.txt $RPM_BUILD_ROOT/%{_sysconfdir}/%{name}/password.txt

# Install logwatch files
install -pD -m 0644 %{SOURCE10} $RPM_BUILD_ROOT%{logwatch_conf}/logfiles/%{name}.conf
install -pD -m 0755 %{SOURCE11} $RPM_BUILD_ROOT%{logwatch_scripts}/services/%{name}
install -pD -m 0644 %{SOURCE12} $RPM_BUILD_ROOT%{logwatch_conf}/services/%{name}.conf
install -pD -m 0755 %{SOURCE13} $RPM_BUILD_ROOT%{logwatch_scripts}/shared/applyxpilotdate

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

%post
touch --no-create %{_datadir}/icons/hicolor || :
if [ -x %{_bindir}/gtk-update-icon-cache ]; then
   %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
fi

%postun
touch --no-create %{_datadir}/icons/hicolor || :
if [ -x %{_bindir}/gtk-update-icon-cache ]; then
   %{_bindir}/gtk-update-icon-cache --quiet %{_datadir}/icons/hicolor || :
fi

%pre server
getent group xpilot >/dev/null || groupadd -r xpilot
getent passwd xpilot >/dev/null || \
useradd -r -g xpilot -d %{_datadir}/%{name} -s /sbin/nologin \
    -c "xpilot game server" xpilot
exit 0

%post server
/sbin/chkconfig --add xpilot-ng-server

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

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

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

%preun selinux
if [ "$1" -lt "1" ] ; then
    # Disable the policy and restart the daemon
    /usr/sbin/setsebool xpilotd_disable_trans 1 &> /dev/null || :
    /sbin/service %{name}-server condrestart > /dev/null 2>&1 || :
    # Unload the module
    /usr/sbin/semanage port -d -t xpilotd_port_t -p udp 15345 &> /dev/null || :
    /usr/sbin/semanage port -d -t xpilotd_port_t -p udp 32200-32299 &> /dev/null || :
    for variant in %{selinux_variants} ; do
        /usr/sbin/semodule -s ${variant} -r xpilotd &> /dev/null || :
    done
    # Set the context back
    /sbin/fixfiles -R %{name}-server restore || :
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}/xpilotd.pp || :
    done
fi

%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%{_bindir}/xpilot-ng-replay
%{_bindir}/xpilot-ng-sdl
%{_bindir}/xpilot-ng-x11
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/textures
%{_datadir}/%{name}/fonts
%{_datadir}/applications/*.desktop
%{_datadir}/icons/hicolor/48x48/apps/*.png
%{_mandir}/man6/xpilot-ng-replay.6.gz
%{_mandir}/man6/xpilot-ng-sdl.6.gz
%{_mandir}/man6/xpilot-ng-x11.6.gz
%doc README COPYING

%files server
%defattr(-,root,root,-)
%{_bindir}/xpilot-ng-xp-mapedit
%{_bindir}/xpilot-ng-server
%{_initrddir}/xpilot-ng-server
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}-server
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}-server
%{_datadir}/%{name}
%dir %{_sysconfdir}/%{name}
%config(noreplace) %attr(0600,xpilot,root) %{_sysconfdir}/%{name}/password.txt
%config(noreplace) %{_sysconfdir}/%{name}/defaults.txt
%{_mandir}/man6/xpilot-ng-server.6.gz
%{_mandir}/man6/xpilot-ng-xp-mapedit.6.gz
%doc README COPYING

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

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

%changelog
* Thu Aug 23 2007 Wart <wart at kobold.org> 4.7.2-13
- Minor selinux modifications for rawhide
- License tag clarification
- Fix version and category fields in .desktop files
- Use new user creation guidelines

* Fri Feb 23 2007 Wart <wart at kobold.org> 4.7.2-12
- Update logwatch script with a previously unknown log field

* Thu Feb 22 2007 Wart <wart at kobold.org> 4.7.2-11
- Add patch to prevent crash when running with robots not in idle mode
- Added logwatch files
- Switch from fedora-usermgmt to vanilla useradd

* Tue Aug 29 2006 Wart <wart at kobold.org> 4.7.2-10
- Added SELinux policies for the game server
- Don't attempt to create the xpilot user if it already exists
- Don't ghost the compiled python files anymore

* Mon Jul 17 2006 Wart <wart at kobold.org> 4.7.2-9
- Use the new xpilot user in the init.d script
- Add info on firewall configuration in the sysconfig script
- Explicitly disable reporting to the meta server (BZ #199164)
- Don't restart the server in %%postun unless it was already running.

* Tue Jul 11 2006 Wart <wart at kobold.org> 4.7.2-8
- Fix Requires: for the -server subpackage

* Wed Mar 1 2006 Wart <wart at kobold.org> 4.7.2-7
- Create an xpilot user for running the server daemon
- Fix typo in logrotate configuration file.

* Tue Feb 28 2006 Wart <wart at kobold.org> 4.7.2-6
- Added sysconfig and initrd files for starting xpilot server at boot time
- Add copies of customizable configuration files to /etc/xpilot
- More readable spacing in changelog
- Add missing ; in desktop file
- Added RPM_OPT_FLAGS to compile line

* Thu Feb 16 2006 Wart <wart at kobold.org> 4.7.2-5
- Rebuild for FC-5

* Mon Feb 6 2006 Wart <wart at kobold.org> 4.7.2-4
- Don't make duplicates of the doc files for the subpackage.
- Use version macro is source path
- Preserve timestamps when installing icons.

* Fri Feb 3 2006 Wart <wart at kobold.org> 4.7.2-3
- Add readme and license files to the server subpackage
- Set default file attributes for the server subpackage

* Fri Feb 3 2006 Wart <wart at kobold.org> 4.7.2-2
- Allow both packages to 0wn datadir/xpilot-ng
- Clean up non-utf8 man pages 

* Thu Feb 2 2006 Wart <wart at kobold.org> 4.7.2-1
- Initial submission to Fedora Extras