# TODO
# - lighttpd integration possible <http://wiki.lighttpd.net/33.html>.
+# - theoretically mysql,mysqli,pgsql,sqlite connectors are possible.
-# snapshot: DATE
-%define _snap 2005-02-20
-
-%if 0%{?_snap}
-%define _source http://snaps.cowiki.org/%{name}-%{version}-dev-%{_snap}.tar.gz
-%else
-%define _source http://cowiki.org/download/%{name}-%{version}.tar.gz
-%endif
-%define _rel 0.20
-
+%define _snap 2006-05-08
+%define _rel 0.17
Summary: Web collaboration tool
+Summary(pl.UTF-8): Narzędzie do współpracy i współtworzenia w sieci
Name: cowiki
-Version: 0.3.4
-Release: %{?_snap:0.%(echo %{_snap} | tr -d -).}%{_rel}
-Epoch: 0
+Version: 0.4.0
+Release: %{?_snap:1.%(echo %{_snap} | tr -d -).}%{_rel}
License: GPL
Group: Applications/WWW
-Source0: %{_source}
-# Source0-md5: 6351667cdfbf3b6e8937af855a4414ba
+Source0: http://snaps.cowiki.org/%{name}-%{version}-interim-%{_snap}.tar.gz
+# Source0-md5: f2843189fc24c854414a3e23a4b9ac95
+Source1: %{name}.conf
Patch0: %{name}-FHS.patch
-URL: http://cowiki.org/
-BuildRequires: rpmbuild(macros) >= 1.177
-Requires: php >= 5.0.2
-Requires: php-mysql
+Patch1: %{name}-config.patch
+Patch2: %{name}-https.patch
+Patch3: %{name}-includepath.patch
+Patch4: %{name}-tz.patch
+Patch5: %{name}-webapps.patch
+URL: http://www.cowiki.org/
+BuildRequires: rpmbuild(macros) >= 1.268
+Requires: apache(mod_dir)
+Requires: diffutils
+Requires: php(dom)
+Requires: php(mysqli)
+Requires: php(pcre)
+Requires: webapps
+Requires: webserver(php) >= 5.0.2
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
-%define _appdir %{_datadir}/%{name}
-%define _sysconfdir /etc/%{name}
-%define _apache1dir /etc/apache
-%define _apache2dir /etc/httpd
+%define _webapps /etc/webapps
+%define _webapp %{name}
+%define _sysconfdir %{_webapps}/%{_webapp}
+%define _appdir %{_datadir}/%{_webapp}
%description
coWiki is a sophisticated but easy to use web collaboration tool that
documentation of your brainstorming without having to concentrate on
complicated structural syntaxes.
+%description -l pl.UTF-8
+coWiki to wyszukane, ale łatwe w użyciu narzędzie do pracy zespołowej
+przez WWW pomagające współpracownikom tworzyć i organizować dokumenty
+WWW, weblogi, bazy wiedzy lub dowolne inne struktury dokumentów
+bezpośrednio w przeglądarce HTML. Można rozwijać idee i otrzymywać
+towarzyszącą dokumentację XML burzy mózgów bez potrzeby koncentrowania
+się na skomplikowanej składni strukturalnej.
+
+%package setup
+Summary: coWiki setup package
+Summary(pl.UTF-8): Pakiet do wstępnej konfiguracji coWiki
+Group: Applications/WWW
+Requires: %{name} = %{version}-%{release}
+
+%description setup
+Install this package to configure initial coWiki installation. You
+should uninstall this package when you're done, as it considered
+insecure to keep the setup files in place.
+
+%description setup -l pl.UTF-8
+Ten pakiet należy zainstalować w celu wstępnej konfiguracji coWiki po
+pierwszej instalacji. Potem należy go odinstalować, jako że
+pozostawienie plików instalacyjnych mogłoby być niebezpieczne.
+
%prep
-%setup -q %{?_snap:-n %{name}-%{version}-dev-%{_snap}}
+%setup -q %{?_snap:-n %{name}-%{version}-interim-%{_snap}}
%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
mv includes/cowiki/core.conf-dist .
-rm -f {htdocs,includes/cowiki}/.cvsignore
+rm {htdocs,includes/cowiki}/.cvsignore
mv htdocs/.htaccess .
+rm htdocs/setup/LICENSE # GPL
+rm -f htdocs/include.path
-%install
-rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_appdir},%{_sysconfdir},/var/lib/%{name}}
-
-cp -a htdocs includes $RPM_BUILD_ROOT%{_appdir}
+cat <<'EOF' > misc/database/mysql-grant.sql
+# this schema will grant MySQL database access
+GRANT SELECT, INSERT, UPDATE, DELETE ON cowiki.* TO 'cowiki'@'localhost' IDENTIFIED BY 'password
+';
+EOF
-sed -e '
- s,CHECK_INTERVAL = .*,CHECK_INTERVAL = "-1",
- s,RETURN_PATH = .*,RETURN_PATH = "your.bounce.email@localhost",
- s,ABUSE_PATH = .*,ABUSE_PATH = "abuse@localhost",
- s,ROOT_PASSWD = .*,ROOT_PASSWD = "XXX",
- s,LOOKUP_DNS = .*,LOOKUP_DNS = off,
- s,TEMP = .*,TEMP = "/var/lib/%{name}/",
+cat <<'EOF' > php.ini
+[PHP]
+; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
+allow_url_fopen = On
+EOF
-' core.conf-dist > $RPM_BUILD_ROOT%{_sysconfdir}/core.conf
-echo -e '\n; vim: ft=dosini' >> $RPM_BUILD_ROOT%{_sysconfdir}/core.conf
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT{%{_appdir},%{_sysconfdir},/var/cache/%{name}}
+install -d $RPM_BUILD_ROOT/etc/php/apache{,2handler}.d
-# unfortunately cowiki works only as vhost root
-cat <<EOF >> $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
-<Directory /usr/share/cowiki/htdocs>
- Allow from all
-</Directory>
+cp -a htdocs includes misc $RPM_BUILD_ROOT%{_appdir}
+install core.conf-dist $RPM_BUILD_ROOT%{_sysconfdir}/core.conf
+install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
+install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/httpd.conf
-<VirtualHost *>
- ServerName cowiki
- DocumentRoot /usr/share/cowiki/htdocs
+cp -a php.ini $RPM_BUILD_ROOT/etc/php/apache.d/%{name}.ini
+cp -a php.ini $RPM_BUILD_ROOT/etc/php/apache2handler.d/%{name}.ini
-EOF
-sed -ne '/BEGIN/,/END/p' .htaccess >> $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
-cat <<EOF >> $RPM_BUILD_ROOT%{_sysconfdir}/apache.conf
-</VirtualHost>
-EOF
+# for setup
+install LICENSE $RPM_BUILD_ROOT%{_appdir}/htdocs/setup
+install core.conf-dist $RPM_BUILD_ROOT%{_appdir}/includes/cowiki/core.conf-dist
+touch $RPM_BUILD_ROOT%{_appdir}/htdocs/install.seal
%clean
rm -rf $RPM_BUILD_ROOT
%post
-# apache1
-if [ -d %{_apache1dir}/conf.d ]; then
- ln -sf %{_sysconfdir}/apache.conf %{_apache1dir}/conf.d/99_%{name}.conf
- if [ -f /var/lock/subsys/apache ]; then
- /etc/rc.d/init.d/apache restart 1>&2
- fi
-fi
-# apache2
-if [ -d %{_apache2dir}/httpd.conf ]; then
- ln -sf %{_sysconfdir}/apache.conf %{_apache2dir}/httpd.conf/99_%{name}.conf
- if [ -f /var/lock/subsys/httpd ]; then
- /etc/rc.d/init.d/httpd restart 1>&2
- fi
-fi
-
if [ "$1" = 1 ]; then
%banner %{name} -e <<EOF
Install the database using the appropriate "misc/database/*.sql" schema.
-You must setup authorization and root password in:
+You must setup authorization and coWiki root password in:
- %{_sysconfdir}/core.conf
EOF
%preun
if [ "$1" = "0" ]; then
- # apache1
- if [ -f %{_apache1dir}/apache.conf ]; then
- rm -f %{_apache1dir}/conf.d/99_%{name}.conf
- if [ -f /var/lock/subsys/apache ]; then
- /etc/rc.d/init.d/apache restart 1>&2
- fi
- fi
- # apache2
- if [ -d %{_apache2dir}/httpd.conf ]; then
- rm -f %{_apache2dir}/httpd.conf/99_%{name}.conf
- if [ -f /var/lock/subsys/httpd ]; then
- /etc/rc.d/init.d/httpd restart 1>&2
- fi
- fi
-
# nuke cache
# FIXME could suffer too many arguments error
- rm -f /var/lib/%{name}/*
+ rm -f /var/cache/%{name}/*
+fi
+
+%post setup
+chgrp http %{_appdir}/{htdocs,includes/cowiki}
+chmod g+w %{_appdir}/{htdocs,includes/cowiki}
+rm -f %{_appdir}/htdocs/install.seal
+
+%postun setup
+if [ "$1" = "0" ]; then
+ chgrp root %{_appdir}/{htdocs,includes/cowiki}
+ chmod g-w %{_appdir}/{htdocs,includes/cowiki}
+ touch %{_appdir}/htdocs/install.seal
fi
+%triggerin -- apache1 < 1.3.37-3, apache1-base
+%webapp_register apache %{_webapp}
+
+%triggerun -- apache1 < 1.3.37-3, apache1-base
+%webapp_unregister apache %{_webapp}
+
+%triggerin -- apache < 2.2.0, apache-base
+%webapp_register httpd %{_webapp}
+
+%triggerun -- apache < 2.2.0, apache-base
+%webapp_unregister httpd %{_webapp}
+
%files
%defattr(644,root,root,755)
-%doc ChangeLog INSTALL* NEWS
+%doc ChangeLog INSTALL* NEWS
%doc README.IDIOM README.PLUGIN SKEL.PLUGIN
%doc misc/database
-%dir %{_sysconfdir}
+%dir %attr(750,root,http) %{_sysconfdir}
%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/apache.conf
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/httpd.conf
%attr(640,root,http) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/core.conf
-%{_appdir}
-%dir %attr(770,root,http) /var/lib/%{name}
+%config(noreplace) %verify(not md5 mtime size) /etc/php/apache.d/%{name}.ini
+%config(noreplace) %verify(not md5 mtime size) /etc/php/apache2handler.d/%{name}.ini
+
+%dir %{_appdir}
+%{_appdir}/misc
+%dir %{_appdir}/includes
+%dir %{_appdir}/includes/cowiki
+%{_appdir}/includes/cowiki/class
+%{_appdir}/includes/cowiki/locale
+%{_appdir}/includes/cowiki/plugin
+%{_appdir}/includes/cowiki/*.php
+%dir %{_appdir}/htdocs
+%{_appdir}/htdocs/img
+%{_appdir}/htdocs/tpl
+%{_appdir}/htdocs/*.txt
+%{_appdir}/htdocs/*.php
+%{_appdir}/htdocs/favicon.ico
+
+%dir %attr(770,root,http) /var/cache/%{name}
+
+# setup seal
+%config(noreplace,missingok) %verify(not md5 mtime size) %{_appdir}/htdocs/install.seal
+
+%files setup
+%defattr(644,root,root,755)
+%{_appdir}/htdocs/setup
+%{_appdir}/htdocs/install.pending
+%{_appdir}/includes/cowiki/core.conf-dist