File unrealircd.spec of Package unrealircd-3.2.9

Name:           unrealircd
Version:        3.2.9
Release:        1.1
License:        GPL
Summary:        Unreal IRCd - the next generation ircd
Group:          Productivity/Networking/IRC
Source:         Unreal%{version}.tar.gz
Source1:        unrealircd
Source2:        ircd
Source3:        unrealircd.apparmor
# PATCH-FIX-OPENSUSE -- create the tmp and cache dir if they do not exist on the right places
Patch2:         unrealircd-tmpdir.patch
# PATCH-FIX-OPENSUSE -- add the output from makenet to the right file
Patch3:         unrealircd-makenet.patch
Patch5:         Unreal3.2.9_compiler_warnings.patch
Patch6:         Unreal3.2.9_change_user.patch
Patch7:         joindeop_add_prototype.patch
BuildRequires:  gcc
BuildRequires:  curl-devel
BuildRequires:  glibc-devel
BuildRequires:  libcares-devel
BuildRequires:  make
BuildRequires:  openssl-devel
BuildRequires:  pkg-config
BuildRequires:  tre-devel
BuildRequires:  zlib-devel
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%define _initddir %{_sysconfdir}/init.d
%define configdir %{_sysconfdir}/Unreal
%define modulesdir %{_libdir}/Unreal
%define logdir /var/log/Unreal
%define homedir /var/lib/Unreal
%define rundir /var/run/Unreal
%define ircddir %{_sbindir}
%define datadir %{_datadir}/Unreal
%define docdir %{_defaultdocdir}/Unreal
%define firewall %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services
# keep in sync with Unreal3.2.9_change_user.patch
%define ircd_group %{name}
%define ircd_user %{name}

Unreal IRCd - the next generation ircd


%setup -q -n Unreal3.2 -a 4
#sed -i "s|
#||g" ./doc/coding-guidelines
%patch2 -p0
%patch3 -p1
%patch5 -p0
%patch6 -p0
%patch7 -p0
cp joindeop.c src/modules/

export CFLAGS="%{optflags} -Wno-unused -DCLEAN_COMPILE"
%configure \
	--with-listen=5 \
	--with-dpath=%{configdir} \
	--with-spath=%{ircddir}/ircd \
	--with-nick-history=2000 \
	--with-sendq=3000000 \
	--with-bufferpool=18 \
	--with-permissions=0640 \
	--with-fd-setsize=1024 \
	--enable-dynamic-linking \
	--enable-hub \
	--enable-nospoof \
	--enable-ziplinks \
	--with-system-tre \
	--with-system-cares \
	--disable-ssl \
	--disable-libcurl \
make %{?_smp_flags} all custommodule MODULEFILE=joindeop

install -m 755 -d %{buildroot}%{configdir}/aliases
install -m 755 -d %{buildroot}%{modulesdir}
install -m 755 -d %{buildroot}%{datadir}/aliases
install -m 755 -d %{buildroot}%{datadir}/networks
install -m 750 -d %{buildroot}%{homedir}
install -m 755 -d %{buildroot}%{docdir}
install -m 755 -d %{buildroot}%{logdir}
install -m 755 -d %{buildroot}%{rundir}/tmp
install -m 755 -d %{buildroot}%{rundir}/cache
install -m 755 -d %{buildroot}%{ircddir}
install -m 755 -d %{buildroot}%{firewall}
install -m 755 -d %{buildroot}%{_initddir}
install -m 755 -d %{buildroot}%{_sbindir}
install -m 0750 src/ircd %{buildroot}%{ircddir}/ircd
install src/modules/*.so %{buildroot}%{modulesdir}
install -m 644 README Donation %{buildroot}%{docdir}
install -m 644 doc/Authors doc/coding-guidelines doc/tao.of.irc doc/translations.txt doc/*html %{buildroot}%{docdir}
install -m 644 doc/technical/005.txt doc/technical/base64.txt doc/technical/protoctl.txt doc/technical/token.txt doc/technical/vl.txt %{buildroot}%{docdir}
install -m 644 doc/example.conf %{buildroot}%{datadir}/unrealircd.conf
install -m 644 badwords.*.conf %{buildroot}%{datadir}
install -m 644 help.conf %{buildroot}%{datadir}
install -m 644 spamfilter.conf %{buildroot}%{datadir}
install -m 644 aliases/*.conf %{buildroot}%{datadir}/aliases
install -m 644 networks/*.network %{buildroot}%{datadir}/networks
install -m 644 networks/networks.ndx %{buildroot}%{datadir}/networks
install -m 755 networks/makenet %{buildroot}%{datadir}/networks
install -m 644 %{SOURCE2} %{buildroot}%{firewall}
install -m 755 %{SOURCE1} %{buildroot}%{_initddir}
install -m 644 -D %{SOURCE3} %{buildroot}/etc/apparmor.d/usr.sbin.ircd-unrealircd
ln -s ../..%{_initddir}/unrealircd %{buildroot}%{_sbindir}/rcunrealircd
install -m 644 %{buildroot}/%{datadir}/aliases/aliases.conf %{buildroot}/%{configdir}/aliases
install -m 644 %{buildroot}/%{datadir}/aliases/anope.conf %{buildroot}/%{configdir}/aliases
install -m 644 %{buildroot}/%{datadir}/aliases/auspice.conf %{buildroot}/%{configdir}/aliases
install -m 644 %{buildroot}/%{datadir}/aliases/cygnus.conf %{buildroot}/%{configdir}/aliases
install -m 644 %{buildroot}/%{datadir}/aliases/epona.conf %{buildroot}/%{configdir}/aliases
install -m 644 %{buildroot}/%{datadir}/aliases/generic.conf %{buildroot}/%{configdir}/aliases
install -m 644 %{buildroot}/%{datadir}/aliases/genericstats.conf %{buildroot}/%{configdir}/aliases
install -m 644 %{buildroot}/%{datadir}/aliases/ircservices.conf %{buildroot}/%{configdir}/aliases
install -m 644 %{buildroot}/%{datadir}/aliases/operstats.conf %{buildroot}/%{configdir}/aliases
install -m 644 %{buildroot}/%{datadir}/ %{buildroot}/%{configdir}
install -m 644 %{buildroot}/%{datadir}/badwords.message.conf %{buildroot}/%{configdir}
install -m 644 %{buildroot}/%{datadir}/badwords.quit.conf %{buildroot}/%{configdir}
install -m 644 %{buildroot}/%{datadir}/help.conf %{buildroot}/%{configdir}
install -m 644 %{buildroot}/%{datadir}/spamfilter.conf %{buildroot}/%{configdir}
sed "s|^//loadmodule \"src/modules/\";|loadmodule \"%{_libdir}/Unreal/\";|g; \
	 s|^//loadmodule \"src/modules/\";|loadmodule \"%{_libdir}/Unreal/\";|g; \
	 s|^log \"ircd.log\" {|log \"/var/log/Unreal/ircd.log\" {|g; \
	 s||ircd.motd|g; \
	 s||ircd.rules|g" \
     %{buildroot}/%{datadir}/unrealircd.conf > %{buildroot}/%{configdir}/unrealircd.conf
touch %{buildroot}/%{configdir}/ircd.motd
touch %{buildroot}/%{configdir}/ircd.rules
touch %{buildroot}/%{homedir}/ircd.tune
chmod 0640 %{buildroot}/%{homedir}/ircd.tune
touch %{buildroot}%{logdir}/ircd.log
chmod -R u=rwX,g=rX,o= %{buildroot}/%{configdir}

	 #s|mask.*fr$;|mask *@*;g; \

rm -rf %{buildroot}

    getent group %{ircd_group} >/dev/null
    : OK group %{ircd_group} already present
    groupadd -r %{ircd_group} 2>/dev/null || :
    id %{ircd_user} > /dev/null 2>&1
    : OK user %{ircd_user} already present
    useradd  -r -o -g %{ircd_group} -s /bin/false -c "User for %{name}" -d %{rundir} %{ircd_user} 2> /dev/null || :

%if ! 0%{?suse_version}
/sbin/insserv /etc/init.d/unrealircd
%{fillup_and_insserv unrealircd}


%restart_on_update unrealircd

%defattr(-, root, root)
%dir /etc/apparmor.d/
%config(noreplace) /etc/apparmor.d/usr.sbin.ircd-unrealircd
%config %{firewall}/ircd
%config(noreplace) %{_initddir}/unrealircd
%attr(-,root,%{ircd_group}) %{ircddir}/ircd
%dir %{logdir}
%config(noreplace) %attr(600,%{ircd_user},%{ircd_group}) %{logdir}/ircd.log
%attr(-,%{ircd_user},root) %{homedir}
%attr(-,root,%{ircd_group}) %config(noreplace) %{configdir}/
%ghost %dir %attr(770,%{ircd_user},root) %{rundir}
%ghost %dir %attr(770,%{ircd_user},root) %{rundir}/tmp
%ghost %dir %attr(770,%{ircd_user},root) %{rundir}/cache

* Mon Apr  2 2012
- actually set the UNREALIRCD_CONFIG variable before using it
- added comment in the example config not to use the pid file
  setting as we have a proper default at compile time
* Mon Apr  2 2012
- drop sysconfig file:
  It doesnt make any sense to have those values really configurable
  - user/group -> hardcoded at compile time.
  - config file could be debated but for now it isnt configurable
  - pid file -> change the config file. the init script only used
    it do find /var/run/Unreal ... replaced that with a variable
    for the dir.
* Sun Apr  1 2012
- enable sysconfig file again (even if we can currently not
  change much there)
* Fri Mar 30 2012
- added joindeop_add_prototype.patch: the function is not in the
  normal unreal ircd headers. as a quick solution move the
  prototype into the file.
* Fri Mar 30 2012
- added deop on join module from
* Wed Mar 21 2012
- added /var/lib/Unreal for ircd.tune file
* Wed Mar 21 2012
- drop pathnames patch:
  merged missing chunks into tmpfile patch
- added apparmor profile
* Wed Mar 21 2012
- simplified start() in the init script
- marked is as config
* Wed Mar 21 2012
- make it always change to user/group unrealircd
- disable ssl for now. it always seems to require certs even
  without ssl links
- disable curl when using cares. configure complainsa about
  possible stalls on reload.
* Wed Mar 21 2012
- Fix some compiler warnings:
  - Added Unreal3.2.9_compiler_warnings.patch
  - added -DCLEAN_COMPILE -Wno-unused to the cflags
* Thu Feb  9 2012
- update 3.2.9
- rework of the specfile:
  + "susify" the spec and init script
- compile with optflags
- create /var/run/Unreal on demand as /var/run can be tmpfs on
  newer systems
* Fri Feb 20 2009
- Intial build