LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File awstats.spec of Package awstats (Project network:utilities)

# 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:        7.1.1
Release:        0
License:        GNU General Public License (GPL)
Group:          Productivity/Networking/Web/Utilities
Url:            http://awstats.sourceforge.net
AutoReqProv:    on
%if 0%{?suse_version}
BuildRequires:  java2-devel-packages
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
%if 0%{?fedora_version}
BuildRequires:  httpd-devel
Requires:       httpd
Requires:       perl
Requires:       logrotate
Requires:       cron
Source:         awstats-%{version}.tar.bz2
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
Patch2:         %{name}-FSF-address.patch
Patch3:         %{name}-3473378-urldecode.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)

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

%setup -q
%patch1 -p0
%patch2 -p1
%patch3 -p1
find -type f -name .cvsignore -print0 | xargs -r0 rm -v

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

function create_config(){
	# 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"|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

# 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/
install -Dm755 wwwroot/cgi-bin/awstats.pl         %{buildroot}%{apache_cgidir}/

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

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

# 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 /awstats/icon/ "%{_datadir}/awstats/icon/"
	<Directory "%{_datadir}/awstats/icon">
    	Options Indexes MultiViews
    	AllowOverride None
    	Order allow,deny
    	Allow from all

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

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

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

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

# 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)
install -m644 README.TXT %{buildroot}%{_defaultdocdir}/%{name}/
cp -r docs %{buildroot}%{_defaultdocdir}/%{name}/
chmod -x   %{buildroot}%{_defaultdocdir}/%{name}/docs/*.pdf
chmod -x   %{buildroot}%{_defaultdocdir}/%{name}/docs/*.html
chmod -x   %{buildroot}%{_defaultdocdir}/%{name}/docs/images/*
chmod -x   %{buildroot}%{_defaultdocdir}/%{name}/docs/*.txt 
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


%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
%dir %{_var}/cache/awstats