Changes of Revision 4
[-] | Changed | apache2-mod_pagespeed.spec |
x 1
2 %define pkgname apache2-mod_pagespeed 3 %define apa_moddir %{_libdir}/apache2 4 %define apa_confdir %{_sysconfdir}/apache2/conf.d 5 -Requires: apache2 >= 2.2 6 +Requires: apache2 >= 2.2 cron 7 BuildRequires: apache2 >= 2.2 8 %endif 9 %if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version} 10 %define pkgname mod_pagespeed 11 %define apa_moddir %{_libdir}/httpd/modules 12 %define apa_confdir %{_sysconfdir}/httpd/conf.d 13 -Requires: httpd >= 2.2 14 +Requires: httpd >= 2.2 cron 15 BuildRequires: httpd >= 2.2 16 %endif 17 18
19 Summary: Apache2 mod_pagespeed 20 License: Apache License 2.0 21 Source0: mod_pagespeed.tar.bz2 22 +Source1: pagespeed.conf.rh 23 +Source2: mod-pagespeed.crondaily 24 Group: Productivity/Networking/Web/Servers 25 BuildRoot: %{_tmppath}/%{name}-%{version}-root 26 BuildRequires: gcc-c++ make subversion python 27
28 %__make BUILDTYPE=Release 29 30 %install 31 +%__install -d %{buildroot}/var/mod_pagespeed/cache 32 +%__install -d %{buildroot}/var/mod_pagespeed/files 33 +%__install -D -m0755 %{S:2} %{buildroot}%{_sysconfdir}/cron.daily/mod-pagespeed 34 %__install -D -m0755 out/Release/libmod_pagespeed.so %{buildroot}%{apa_moddir}/libmod_pagespeed.so 35 +%if 0%{?suse_version} 36 %__install -D -m0644 out/Release/install/common/pagespeed.conf.template %{buildroot}%{apa_confdir}/pagespeed.conf 37 +%endif 38 +%if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version} 39 +mkdir -p %{buildroot}%{apa_confdir} 40 +cat %{S:1} | sed -e s@"%LIBDIR%"@"%{_libdir}"@g > %{buildroot}%{apa_confdir}/pagespeed.conf 41 +%endif 42 43 %clean 44 rm -rf %{buildroot} 45
46 %defattr(-,root,root) 47 %{apa_moddir}/libmod_pagespeed.so 48 %config(noreplace) %{apa_confdir}/pagespeed.conf 49 +%config %{_sysconfdir}/cron.daily/mod-pagespeed 50 +%defattr(0777,root,root) 51 +%dir /var/mod_pagespeed/cache 52 +%dir /var/mod_pagespeed/files 53 54 %changelog 55 * Thu Nov 04 2010 Carsten Schoene <cs@linux-administrator.com> - 0.0.136 56 |
||
[+] | Added | mod-pagespeed.crondaily ^ |
@@ -0,0 +1,364 @@ +#!/bin/sh +# +# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# This script is part of the mod-pagespeed package. +# +# It creates the repository configuration file for package updates, since +# we cannot do this during the mod-pagespeed installation since the repository +# is locked. +# +# This functionality can be controlled by creating the $DEFAULTS_FILE and +# setting "repo_add_once" to "true" or "false" as desired. An empty +# $DEFAULTS_FILE is the same as setting the value to "false". + +# System-wide package configuration. +DEFAULTS_FILE="/etc/default/mod-pagespeed" + +# sources.list setting for mod-pagespeed updates. +REPOCONFIG="http://dl.google.com/linux/mod-pagespeed/rpm/stable" + +# Install the repository signing key (see also: +# http://www.google.com/linuxrepositories/aboutkey.html) +install_rpm_key() { + # Check to see if key already exists. + rpm -q gpg-pubkey-7fac5991-4615767f > /dev/null 2>&1 + if [ "$?" -eq "0" ]; then + # Key already exists + return 0 + fi + # This is to work around a bug in RPM 4.7.0. (see http://crbug.com/22312) + rpm -q gpg-pubkey-7fac5991-45f06f46 > /dev/null 2>&1 + if [ "$?" -eq "0" ]; then + # Key already exists + return 0 + fi + + # RPM on Mandriva 2009 is dumb and does not understand "rpm --import -" + TMPKEY=$(mktemp /tmp/google.sig.XXXXXX) + if [ -n "$TMPKEY" ]; then + cat > "$TMPKEY" <<KEYDATA +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.2.2 (GNU/Linux) + +mQGiBEXwb0YRBADQva2NLpYXxgjNkbuP0LnPoEXruGmvi3XMIxjEUFuGNCP4Rj/a +kv2E5VixBP1vcQFDRJ+p1puh8NU0XERlhpyZrVMzzS/RdW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FB/wKqaycjWAZwIe98Yt0qHsdkpmIbarD9fGiA6kfkK/UxjL/k7tmS4Vm +CljrrDZkPSQ/19mpdRcGXtb0NI9+nyM5trweTvtPw+HPkDiJlTaiCcx+izg79Fj9 +KcofuNb3lPdXZb9tzf5oDnmm/B+4vkeTuEZJ//IFty8cmvCpzvY+DAz1Vo9rA+Zn +cpWY1n6z6oSS9AsyT/IFlWWBZZ17SpMHu+h4Bxy62+AbPHKGSujEGQhWq8ZRoJAT +G0KSObnmZ7FwFWu1e9XFoUCt0bSjiJWTIyaObMrWu/LvJ3e9I87HseSJStfw6fki +5og9qFEkMrIrBCp3QGuQWBq/rTdMuwNFiEkEGBECAAkFAkXwb0sCGwwACgkQoECD +D3+sWZF/WACfeNAu1/1hwZtUo1bR+MWiCjpvHtwAnA1R3IHqFLQ2X3xJ40XPuAyY +/FJG +=Quqp +-----END PGP PUBLIC KEY BLOCK----- +KEYDATA + rpm --import "$TMPKEY" + rc=$? + rm -f "$TMPKEY" + if [ "$rc" -eq "0" ]; then + return 0 + fi + fi + return 1 +} + +determine_rpm_package_manager() { + local RELEASE + LSB_RELEASE="$(which lsb_release 2> /dev/null)" + if [ -x "$LSB_RELEASE" ]; then + RELEASE=$(lsb_release -i 2> /dev/null) + case $DISTRIB_ID in + "Fedora") + PACKAGEMANAGER=yum + ;; + "MandrivaLinux") + PACKAGEMANAGER=urpmi + ;; + "SUSE LINUX") + PACKAGEMANAGER=yast + ;; + esac + fi + + if [ "$PACKAGEMANAGER" ]; then + return + fi + + # Fallback methods that are probably unnecessary on modern systems. + if [ -f "/etc/lsb-release" ]; then + # file missing on Fedora, does not contain DISTRIB_ID on OpenSUSE. + eval $(sed -e '/DISTRIB_ID/!d' /etc/lsb-release) + case $DISTRIB_ID in + MandrivaLinux) + PACKAGEMANAGER=urpmi + ;; + esac + fi + + if [ "$PACKAGEMANAGER" ]; then + return + fi + + if [ -f "/etc/fedora-release" ] || [ -f "/etc/redhat-release" ]; then + PACKAGEMANAGER=yum + elif [ -f "/etc/SuSE-release" ]; then + PACKAGEMANAGER=yast + elif [ -f "/etc/mandriva-release" ]; then + PACKAGEMANAGER=urpmi + fi +} + +DEFAULT_ARCH="i386" +YUM_REPO_FILE="/etc/yum.repos.d/mod-pagespeed.repo" +ZYPPER_REPO_FILE="/etc/zypp/repos.d/mod-pagespeed.repo" +URPMI_REPO_FILE="/etc/urpmi/urpmi.cfg" + +install_yum() { + install_rpm_key + + if [ ! "$REPOCONFIG" ]; then + return 0 + fi + + if [ -d "/etc/yum.repos.d" ]; then +cat > "$YUM_REPO_FILE" << REPOCONTENT +[mod-pagespeed] +name=mod-pagespeed +baseurl=$REPOCONFIG/$DEFAULT_ARCH +enabled=1 +gpgcheck=1 +REPOCONTENT + fi +} + +# This is called by the cron job, rather than in the RPM postinstall. +# We cannot do this during the install when urpmi is running due to +# database locking. We also need to enable the repository, and we can +# only do that while we are online. +# see: https://qa.mandriva.com/show_bug.cgi?id=31893 +configure_urpmi() { + if [ ! "$REPOCONFIG" ]; then + return 0 + fi + + urpmq --list-media | grep -q -s "^mod-pagespeed$" + if [ "$?" -eq "0" ]; then + # Repository already configured + return 0 + fi + urpmi.addmedia --update \ + "mod-pagespeed" "$REPOCONFIG/$DEFAULT_ARCH" +} + +install_urpmi() { + # urpmi not smart enough to pull media_info/pubkey from the repository? + install_rpm_key + + # Defer urpmi.addmedia to configure_urpmi() in the cron job. + # See comment there. + # + # urpmi.addmedia --update \ + # "mod-pagespeed" "$REPOCONFIG/$DEFAULT_ARCH" +} + +install_yast() { + if [ ! "$REPOCONFIG" ]; then + return 0 + fi + + # We defer adding the key to later. See comment in the cron job. + + # Ideally, we would run: zypper addrepo -t YUM -f \ + # "$REPOCONFIG/$DEFAULT_ARCH" "mod-pagespeed" + # but that does not work when zypper is running. + if [ -d "/etc/zypp/repos.d" ]; then +cat > "$ZYPPER_REPO_FILE" << REPOCONTENT +[mod-pagespeed] +name=mod-pagespeed +enabled=1 +autorefresh=1 | ||
[+] | Added | pagespeed.conf.rh ^ |
@@ -0,0 +1,101 @@ +LoadModule pagespeed_module %LIBDIR%/httpd/modules/mod_pagespeed.so + +# Only attempt to load mod_deflate if it hasn't been loaded already. +<IfModule !mod_deflate.c> +LoadModule deflate_module %LIBDIR%/httpd/modules/mod_deflate.so +</IfModule> +<IfModule pagespeed_module> + SetOutputFilter MOD_PAGESPEED_OUTPUT_FILTER + ModPagespeed on + + # ModPagespeedUrlPrefix is the prefix assigned to some types of + # rewritten resources. This directive will be removed in a future + # release. For now, you must specify a URL and path for a hostname + # that is served by this Apache + # instance. http://yourhostname/mod_pagespeed is a good default + # value (replace localhost, below, with the hostname of your + # Apache instance). + ModPagespeedUrlPrefix "http://localhost/mod_pagespeed/" + + # The ModPagespeedFileCachePath and + # ModPagespeedGeneratedFilePrefix directories must exist and be + # writable by the apache user (as specified by the User + # directive). + ModPagespeedFileCachePath "/var/mod_pagespeed/cache/" + ModPagespeedGeneratedFilePrefix "/var/mod_pagespeed/files/" + + # Override the mod_pagespeed 'rewrite level'. The default level + # "CoreFilters" uses a set of rewrite filters that are generally + # safe for most web pages. Most sites should not need to change + # this value and can instead fine-tune the configuration using the + # ModPagespeedDisableFilters and ModPagespeedEnableFilters + # directives, below. Valid values for ModPagespeedRewriteLevel are + # PassThrough and CoreFilters. + # + # ModPagespeedRewriteLevel CoreFilters + + # Explicitly disables specific filters. This is useful in + # conjuction with ModPagespeedRewriteLevel. For instance, if one + # of the filters in the CoreFilters needs to be disabled for a + # site, that filter can be added to + # ModPagespeedDisableFilters. This directive contains a + # comma-separated list of filter names, and can be repeated. + # + # ModPagespeedDisableFilters rewrite_javascript + + # Explicitly enables specific filters. This is useful in + # conjuction with ModPagespeedRewriteLevel. For instance, filters + # not included in the CoreFilters may be enabled using this + # directive. This directive contains a comma-separated list of + # filter names, and can be repeated. + # + # ModPagespeedEnableFilters collapse_whitespace,elide_attributes + + # ModPagespeedDomain + # authorizes rewriting of JS, CSS, and Image files found in this + # domain. By default only resources with the same origin as the + # HTML file are rewritten. For example: + # + # ModPagespeedDomain cdn.myhost.com + # + # This will allow resources found on http://cdn.myhost.com to be + # rewritten in addition to those in the same domain as the HTML. + # + # Wildcards (* and ?) are allowed in the domain specification. Be + # careful when using them as if you rewrite domains that do not + # send you traffic, then the site receiving the traffic will not + # know how to serve the rewritten content. + + # Enables server-side instrumentation and statistics. If this rewriter is + # enabled, then each rewritten HTML page will have instrumentation javacript + # added that sends latency beacons to /mod_pagespeed_beacon. These + # statistics can be accessed at /mod_pagespeed_statistics. You must also + # enable the mod_pagespeed_statistics and mod_pagespeed_beacon handlers + # below. + # + # ModPagespeedEnableFilters add_instrumentation + + + # This handles the client-side instrumentation callbacks which are injected + # by the add_instrumentation filter. + # You can use a different location by adding the ModPagespeedBeaconUrl + # directive; see the documentation on add_instrumentation. + # + # <Location /mod_pagespeed_beacon> + # SetHandler mod_pagespeed_beacon + # </Location> + + # This page lets you view statistics about the mod_pagespeed module. + <Location /mod_pagespeed_statistics> + Order allow,deny + # You may insert other "Allow from" lines to add hosts you want to + # allow to look at generated statistics. Another possibility is + # to comment out the "Order" and "Allow" options from the config + # file, to allow any client that can reach your server to examine + # statistics. This might be appropriate in an experimental setup or + # if the Apache server is protected by a reverse proxy that will + # filter URLs in some fashion. + Allow from localhost + SetHandler mod_pagespeed_statistics + </Location> +</IfModule> |