File awstats.spec of Package awstats

#
# spec file for package awstats 
#
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#

# norootforbuild

Name:           awstats
Summary:        Advanced Web Statistics
Version:        6.95
Release:        9.1
License:        GNU General Public License (GPL)
Group:          Productivity/Networking/Web/Utilities
Url:            http://awstats.sourceforge.net
AutoReqProv:    on
%if 0%{?suse_version}
BuildRequires:  java-1_6_0-openjdk-devel
BuildRequires:  apache2-devel
Requires:       apache2 
# Needed perl modules for the plugins
Recommends:     perl-Net-DNS
Recommends:     perl-Net-IP
Recommends:     perl-URI
Recommends:     perl-Storable
Recommends:     perl-Geo-IP
%endif
%if 0%{?fedora_version}
BuildRequires:  httpd-devel
Requires:       httpd
%endif
Requires:       perl
Requires:       logrotate
Requires:       cron
Source:         awstats-%{version}.tar.gz
Source4:        cron.d.awstats
Source5:        awstats-update
Source6:        awstats-update.8
Source7:        awstats.logrotate
Source8:        awstats-rpmlintrc
Source9:        awstats.README
#Patch1:         %{name}-CVE-2006-2237_read_open.patch
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define         apache_htdocsdir %(/usr/sbin/apxs2 -q HTDOCSDIR)
%define         apache_sysconfdir %(/usr/sbin/apxs2 -q SYSCONFDIR)
%define         apache_cgidir %(/usr/sbin/apxs2 -q CGIDIR)

%description
Advanced Web Statistics (AWStats) is a powerful Web server log file
analyzer (Perl script) that shows Web statistics including visitors,
pages, hits, hours, search engines, keywords used to find your site,
broken links, robots, and more.

This log analyzer works as a CGI or from command line and shows you
all possible information your log contains, in few graphical web
pages like visits, unique vistors, authenticated users, pages,
domains/countries, OS busiest times, robot visits, type of files,
search engines,keywords and keyphrases used, visits duration,
cluster balancing, HTTP errors and also screen size, web browser
java,flash,etc support and more...
Statistics can be updated from a browser or your scheduler.
AWStats uses a partial information file to be able to process large
log files, often and quickly.

It can analyze log files from IIS (W3C log format), Apache log files
(NCSA combined/XLF/ELF log format or common/CLF log format), WebStar
and most of all web, proxy, wap, streaming servers (and ftp servers
or mail logs).
The program also supports virtual servers, plugins and a lot of
features.


%prep
%setup -q
#%patch1 -p1
find -type f -name .cvsignore -print0 | xargs -r0 rm -v

%build
# if the following command fails, then apache dependencies are not met
/usr/sbin/apxs2 -q datadir >/dev/null

%install
function create_config(){
	LOGFILE=$1
    LOGTYPE=$2
    CONFNAME=$3
    PLUGINS=$4
	# Using sed rather than a diff here, to make sure all relevant
	# options are checked (upstream defaults have moved around in
	# the past)MiscTrackerUrl="/js
	sed -e "s|^LogFile.*|LogFile=\"$LOGFILE\"|g" \
    -e 's|^LogFormat.*|LogFormat=1|g' \
    -e "s|^LogType.*|LogType=$LOGTYPE|g" \
    -e 's|^DNSLookup.*|DNSLookup=1|g' \
    -e 's|^DirData.*|DirData="%{_var}/cache/awstats"|g' \
    -e 's|^DirIcons.*|DirIcons="/awstats/icon"|g' \
    -e 's|^DirLang.*|DirLang=%{_datadir}/awstats/lang"|g' \
    -e 's|^ErrorMessages.*|ErrorMessages="An error occurred. Contact your Administrator"|g' \
    -e 's|^HostAliases.*|HostAliases="localhost 127.0.0.1"|g' \
    -e 's|^#Include\s*|Include="%{_sysconfdir}/awstats/awstats.conf.local"|g' \
    -e 's|^NotPageList.*|NotPageList="css js class gif jpg jpeg png bmp ico rss xml swf"|g' \
	-e 's|^MiscTrackerUrl.*|MiscTrackerUrl="/awstats/js/awstats_misc_tracker.js"|g' \
    -e 's|^ShowFlagLinks.*|ShowFlagLinks="de en es fr nl"|g' \
    -e 's|^StyleSheet.*|StyleSheet="/awstats/css/awstats_bw.css"|g' \
    -e 's|^AllowToUpdateStatsFromBrowser.*|AllowToUpdateStatsFromBrowser=1|g' \
    -e 's|^EnableLockForUpdate.*|EnableLockForUpdate=1|g' \
    -e 's|^SaveDatabaseFilesWithPermissionsForEveryone.*|SaveDatabaseFilesWithPermissionsForEveryone=1|g' \
    wwwroot/cgi-bin/awstats.model.conf > %{buildroot}%{_sysconfdir}/awstats/$CONFNAME
#    -e 's|^AllowAccessFromWebToAuthenticatedUsersOnly.*|AllowAccessFromWebToAuthenticatedUsersOnly=1|g' \
	for pluginname in $PLUGINS; do
		sed -i "s|^#LoadPlugin\s*=\s*\"$pluginname\"|LoadPlugin=\"$pluginname\"|g" %{buildroot}%{_sysconfdir}/awstats/$CONFNAME
	done
}

# create the directories needed for installation
mkdir -p %{buildroot}%{cgidir}/classes
mkdir -p %{buildroot}%{_sysconfdir}/awstats
mkdir -p %{buildroot}%{apache_sysconfdir}/conf.d/
mkdir -p %{buildroot}%{apache_cgidir}/classes
mkdir -p %{buildroot}%{_datadir}/awstats/classes
mkdir -p %{buildroot}%{_var}/cache/awstats
mkdir -p %{buildroot}%{_defaultdocdir}/%{name}/examples
# create some example configs
create_config "%{_var}/log/apache2/awstats.log" "W" "awstats.web.conf" "tooltips ipv6 hashfiles"
create_config "%{_var}/log/vsftpd.log" "F" "awstats.vsftp.conf" "tooltips ipv6"
create_config "%{_var}/log/mail" "M" "awstats.smtp.conf" "tooltips ipv6"
# install the files
cp -r wwwroot/{icon,css,js}              %{buildroot}%{_datadir}/awstats/
cp -r wwwroot/cgi-bin/{lang,lib,plugins} %{buildroot}%{_datadir}/awstats/
cp -r wwwroot/classes/*.jar              %{buildroot}%{_datadir}/awstats/classes/
cp -r wwwroot/cgi-bin/awstats.pl         %{buildroot}%{apache_cgidir}/

# fix permissions
chmod -x %{buildroot}%{_datadir}/awstats/plugins/*.pm

# fix wrong line encoding (dos)
for file in $(find %{buildroot}%{apache_cgidir}/plugins/ -type f -name "*.pm"); do
	sed -i 's/\r$//' $file
done
for file in $(find docs/* -maxdepth 1 -type f); do
	sed -i 's/\r$//' $file
done

# install additional sources
install -Dm644 %{SOURCE4} %{buildroot}%{_sysconfdir}/cron.d/suse.de-awstats
install -Dm755 %{SOURCE5} %{buildroot}%{_sbindir}/awstats-update
install -Dm644 %{SOURCE6} %{buildroot}%{_mandir}/man8/awstats-update.8
install -Dm644 %{SOURCE7} %{buildroot}/etc/logrotate.d/awstats
cat > %{buildroot}%{apache_sysconfdir}/conf.d/awstats.conf << EOF
#
# The location and format of the access logfile (Common Logfile Format).
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here.  Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file. In this case you have to
# modify awstats yourself to point to the correct, combined log file.
#
<IfDefine AWSTATS>
    CustomLog /var/log/apache2/awstats.log combined

    Alias /icons/awstats/ "%{_datadir}/awstats/icon/"
	<Directory "%{_datadir}/awstats/icon">
    	Options Indexes MultiViews
    	AllowOverride None
    	Order allow,deny
    	Allow from all
	</Directory>

    Alias /awstats/lang/ "%{_datadir}/awstats/lang/"
	<Directory "%{_datadir}/awstats/lang">
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

	Alias /awstats/css/ "%{_datadir}/awstats/css/"
	<Directory "%{_datadir}/awstats/css/">
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

	Alias /awstatsclasses "%{_datadir}/awstats/classes"
	<Directory "%{_datadir}/awstats/classes">
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

	Alias /awstats/js/ "%{_datadir}/awstats/js/"
	<Directory "%{_datadir}/awstats/js/">
		AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</IfDefine>
EOF

# install docu
mkdir -p %{buildroot}%{_defaultdocdir}/%{name}/examples
# install the scripts in tools into the examples dir
mv %{buildroot}%{_datadir}/awstats/plugins/example/* %{buildroot}%{_defaultdocdir}/%{name}/examples/
rm -rf %{buildroot}%{_datadir}/awstats/plugins/example
for file in $(find tools/ -name *.pl); do
	sed -e 's/\r$//' $file > %{buildroot}%{_defaultdocdir}/%{name}/examples/$(basename $file)
	chmod +x %{buildroot}%{_defaultdocdir}/%{name}/examples/$(basename $file)
done
install -m644 README.TXT %{buildroot}%{_defaultdocdir}/%{name}/
cp -r docs %{buildroot}%{_defaultdocdir}/%{name}/
install -m644 wwwroot/cgi-bin/awstats.model.conf %{buildroot}%{_defaultdocdir}/%{name}/
install -m644 %{SOURCE9} %{buildroot}%{_defaultdocdir}/%{name}/README.SuSE
rm %{buildroot}%{_defaultdocdir}/%{name}/docs/COPYING.TXT

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc %{_defaultdocdir}/%{name} 
%doc %{_mandir}/man8/awstats-update.8.gz
%dir %{_sysconfdir}/awstats
%dir %{apache_sysconfdir}/conf.d
%dir %{_datadir}/awstats
%config(noreplace) %{_sysconfdir}/logrotate.d/awstats
%config(noreplace) %{apache_sysconfdir}/conf.d/awstats.conf
%config(noreplace) %{_sysconfdir}/cron.d/suse.de-awstats
%config(noreplace) %{_sysconfdir}/awstats/awstats.web.conf
%config(noreplace) %{_sysconfdir}/awstats/awstats.vsftp.conf
%config(noreplace) %{_sysconfdir}/awstats/awstats.smtp.conf
%{_sbindir}/awstats-update
%{_datadir}/awstats/*
%{apache_cgidir}/*
%defattr(-,wwwrun,www)
%dir %{_var}/cache/awstats

%changelog
* Mon Nov 23 2009 clauded1
- update to version 6.95
- removed patch
    awstats-CVE-2006-2237_read_open.patch
* Tue Jan 13 2009 lars@linux-schulserver.de
- fix icons alias in apache config (thanks to Jan Engelhardt)
* Mon Dec 29 2008 lars@linux-schulserver.de
- enhanced the awstats-update script (chown wwwrun:www if needed)
- rename configs, so awstats-update script can find them
- don't run fdupes to avoid FollowSymlinks in apache's config
- place nearly everything under /usr/share/awstats to get a clean
  cgi-dir
* Sun Dec 28 2008 lars@linux-schulserver.de
- update to version 6.9
  + With postfix that support DSN (Delivery Status Notifications)
    we exclude some lines to avoid counting mails twice in
  maillogconvert.pl script.
  + Logresolvemerge.pl support FreeRADIUS logs or anything else using
    (the fixed length!) ctime format timestamp.
  + Add option stoponfirsteof in logresolvemerge tool.
  + Add patch to support host_proxy tag in LogFormat (for Apache
    LogFormat containing %%{X-Forwarded-For}i)
  + Renamed Add to favourites on "Hit on favicon".
  + Increase robots, search engines database (Added Google Chrome
    browser, better Vista, WII, detection, ...)
  + Update languages files.
  + Added a lot of patches from sourceforge.
- rework the specfile
- use sed to adapt the config inline (no patches any more)
- reworked awstats-CVE-2006-2237_read_open.patch
- added README.SuSE
- added perl modules for Plugins as Recommended
- Require logrotate and cron
- Removed module.awstats -> apache1 is gone
- silence the cronjob
* Sun Nov  9 2008 mrdocs@opensuse.org
- Update to version 6.8
- test patches apply
- pending backport for CVE
* Mon Jul  9 2007 mskibbe@suse.de
- update to version 6.7
  * Full support for -day option. To build different
    report for each day
  * Added virtualenamequot tag
  * Added option NotPageList
  * Addes .jobs and .mobi domains
  * Minor bug in awstats_configure.pl
  * Updated some language files
  * Updated browsers database
* Thu Mar  8 2007 mskibbe@suse.de
- awstats: missing dependency (#250629)
* Wed Oct 25 2006 ro@suse.de
- use java2-devel-packages in buildreq
* Tue Oct 10 2006 mskibbe@suse.de
- fix Bug 211218 - awstats won't load piped output
- fix Bug 211219 - awstats won't place it's icons into
  /srv/www/htdocs/icons
* Wed Sep 13 2006 mskibbe@suse.de
- install the classes directory
- fix Requires BuildRequires
* Fri Aug  4 2006 mskibbe@suse.de
- add example configs for ftp and smtp
* Mon Jul 31 2006 mskibbe@suse.de
- bugfix for geoip function (Bug #188142) which fix a syntax error
* Wed Jun 14 2006 mrueckert@suse.de
- Upgraded to version 6.6, list of new things among others:
  - RSS catcher/readers in robot database
  - Enhanced GeoIP support.
  - LevelForBrowsersDetection can accept value 'allphones' to use file browsers_phone.pm instead of browsers.pm file for AWStats database.
  - Add option ShowSummary.
  - If LogFormat is 2, AWStats autodetect log format change.
  - Add a way to set ArchiveLogRecords with same tags than LogFile to add suffix to archived log files.
- Security fix for CVE-2006-2237: missing sanitizing of the "migrate"
  parameter. #173041
- Security fix for CVE-2006-2644: missing sanitizing of the "configdir"
  parameter. #173041
- Make sure open() only opens files for read/write by adding explicit
  < and >.
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Tue Dec 27 2005 hmuelle@suse.de
- Update to official Version 6.5
- removed patch
    awstats-Secfix20050811.dif
  as it was just a backport from 6.5 beta
* Sun Aug 14 2005 hmuelle@suse.de
- Applied security fix [Bug #103788]
  AWStats ShowInfoURL Remote Command Execution Vulnerability
* Sun Jul 17 2005 hmuelle@suse.de
- Update to version 6.4
* Tue Jun  7 2005 ro@suse.de
- rename cron script to local namespace for LSB conformance
* Mon Jan 31 2005 hmuelle@suse.de
- Update to version 6.3
  the security-patch from somedays ago is no longer needed
* Thu Jan 20 2005 hmuelle@suse.de
- Applied a security fix [Bug #49967]
  Remote Command Execution Vulnerability
* Mon Nov  8 2004 hmuelle@suse.de
- Update to version 6.2
* Sun Aug 29 2004 ro@suse.de
- removed obsolete postinstall script and now obsolete prereq
* Sat Aug 28 2004 hmuelle@suse.de
- Removed sysconfig.apache-awstats , missed it by last change
* Tue Aug 17 2004 hmuelle@suse.de
- Removed old apache1 stuff, as no longer supported with newer
  versions of SUSE Linux
* Tue Aug 17 2004 hmuelle@suse.de
- Update to version 6.1
* Sun Feb 29 2004 hmuelle@suse.de
- Update to version 6.0
* Wed Feb  4 2004 hmacht@suse.de
- added option # norootforbuild in specfile
* Tue Dec  9 2003 kukuk@suse.de
- Update to version 5.9
- Add tools directory as documentation [Bug #32331]
* Tue Jul  1 2003 kukuk@suse.de
- Update to version 5.6
* Fri Jun 20 2003 ro@suse.de
- added apache2 to neededforbuild
- added directory to filelist
* Mon Mar 10 2003 poeml@suse.de
- fix path to awstats.log in awstats.logrotate, and add the apache2
  logfile. Reload both servers but only if they run.
- the "modules" mechanism via /etc/apache2/modules/* and sysconfig
  variables is no longer in use with apache2. Instead, put awstats into
  conf.d for automatic inclusion and enclose the content in
  <IfDefine AWSTATS>. It can be activated via APACHE_SERVER_FLAGS
  in sysconfig.apache.
* Mon Feb 24 2003 kukuk@suse.de
- Update to offical tar archive.
* Fri Feb 21 2003 kukuk@suse.de
- Update to new snapshot (minor bug fixes)
* Fri Feb 14 2003 kukuk@suse.de
- Update to new snapshot
* Wed Feb  5 2003 kukuk@suse.de
- Update to new snapshot (autodetect start language)
* Tue Jan 28 2003 kukuk@suse.de
- Update to new snapshot (small bug fixes)
* Fri Jan 17 2003 kukuk@suse.de
- Update to new snapshot
- Use different sysconfig Variables for Apache 1.x and 2.x
* Thu Jan  9 2003 kukuk@suse.de
- Enable DNS reverse lookup
- Enable tooltips
* Wed Jan  8 2003 kukuk@suse.de
- Update to 5.4 beta
- Fix path to log files
* Sun Dec 15 2002 kukuk@suse.de
- Add support for Apache2
- Fix icon path in default conf
* Sun Dec 15 2002 kukuk@suse.de
- Update to version 5.2
* Thu Aug 15 2002 kukuk@suse.de
- Add PreRequires
* Fri Aug  2 2002 kukuk@suse.de
- Don't use apxs, it does not work with this package
- Fix new web root path in shell scripts
- Adjust default configuration
* Thu Aug  1 2002 ro@suse.de
- adapt server-root
* Tue Jul 23 2002 kukuk@suse.de
- Update to version 4.1
* Wed Mar 13 2002 kukuk@suse.de
- Add /etc/awstats
* Thu Jan 17 2002 ro@suse.de
- adapted for /etc/sysconfig/apache
* Wed Dec 12 2001 kukuk@suse.de
- Add logrotate config file
* Fri Nov  2 2001 kukuk@suse.de
- Add update script, manual page and cronjob
* Wed Oct 31 2001 kukuk@suse.de
- Update to version 3.1
- Make package noarch
* Wed Aug 29 2001 kukuk@suse.de
- Add apache config files
* Mon Aug 13 2001 kukuk@suse.de
- Initial version
openSUSE Build Service is sponsored by