| 184 |
- |
1 |
#!/bin/sh
|
|
|
2 |
#
|
|
|
3 |
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
|
|
4 |
# Use of this source code is governed by a BSD-style license that can be
|
|
|
5 |
# found in the LICENSE file.
|
|
|
6 |
#
|
|
|
7 |
# This script is part of the mod-pagespeed package.
|
|
|
8 |
#
|
|
|
9 |
# It creates the repository configuration file for package updates, since
|
|
|
10 |
# we cannot do this during the mod-pagespeed installation since the repository
|
|
|
11 |
# is locked.
|
|
|
12 |
#
|
|
|
13 |
# This functionality can be controlled by creating the $DEFAULTS_FILE and
|
|
|
14 |
# setting "repo_add_once" to "true" or "false" as desired. An empty
|
|
|
15 |
# $DEFAULTS_FILE is the same as setting the value to "false".
|
|
|
16 |
|
|
|
17 |
# System-wide package configuration.
|
|
|
18 |
DEFAULTS_FILE="/etc/default/mod-pagespeed"
|
|
|
19 |
|
|
|
20 |
# sources.list setting for mod-pagespeed updates.
|
|
|
21 |
REPOCONFIG="http://dl.google.com/linux/mod-pagespeed/rpm/stable"
|
|
|
22 |
|
|
|
23 |
# Install the repository signing key (see also:
|
|
|
24 |
# http://www.google.com/linuxrepositories/aboutkey.html)
|
|
|
25 |
install_rpm_key() {
|
|
|
26 |
# Check to see if key already exists.
|
|
|
27 |
rpm -q gpg-pubkey-7fac5991-4615767f > /dev/null 2>&1
|
|
|
28 |
if [ "$?" -eq "0" ]; then
|
|
|
29 |
# Key already exists
|
|
|
30 |
return 0
|
|
|
31 |
fi
|
|
|
32 |
# This is to work around a bug in RPM 4.7.0. (see http://crbug.com/22312)
|
|
|
33 |
rpm -q gpg-pubkey-7fac5991-45f06f46 > /dev/null 2>&1
|
|
|
34 |
if [ "$?" -eq "0" ]; then
|
|
|
35 |
# Key already exists
|
|
|
36 |
return 0
|
|
|
37 |
fi
|
|
|
38 |
|
|
|
39 |
# RPM on Mandriva 2009 is dumb and does not understand "rpm --import -"
|
|
|
40 |
TMPKEY=$(mktemp /tmp/google.sig.XXXXXX)
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dgx9YdNfjsCM3hvQvykaWMALeZIpzbXxV118Y9QQUIRe2L+4X
|
|
|
134 |
ZACEAhWjj2K1wP7ODGTQrrM4q4sIw1l3l7yO9aXXN7likAAddT4WEpGV0CiorReO
|
|
|
135 |
J1y/sKJRJSI/npN1UK7wMazZ+yzhxN0qzG8sqREKJQnNuuGQQ/qIGb/oe4dPO0Fi
|
|
|
136 |
hAUGkWoa0bgtGVijN5fQSbMbV50kZYqaa9GnNQRnchmZb+pK2xLcK85hD1np37/A
|
|
|
137 |
m5o2ggoONj3qI3JaRHsZaOs1qPQcyd46OyIFUpHJIfk4nezDCoQYd93bWUGqDwxI
|
|
|
138 |
/n/CsdO0365yqDO/ADscehlVqdAupVv2
|
|
|
139 |
=dmoF
|
|
|
140 |
-----END PGP PUBLIC KEY BLOCK-----
|
|
|
141 |
KEYDATA
|
|
|
142 |
rpm --import "$TMPKEY"
|
|
|
143 |
rc=$?
|
|
|
144 |
rm -f "$TMPKEY"
|
|
|
145 |
if [ "$rc" -eq "0" ]; then
|
|
|
146 |
return 0
|
|
|
147 |
fi
|
|
|
148 |
fi
|
|
|
149 |
return 1
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
determine_rpm_package_manager() {
|
|
|
153 |
local RELEASE
|
|
|
154 |
LSB_RELEASE="$(which lsb_release 2> /dev/null)"
|
|
|
155 |
if [ -x "$LSB_RELEASE" ]; then
|
|
|
156 |
RELEASE=$(lsb_release -i 2> /dev/null)
|
|
|
157 |
case $DISTRIB_ID in
|
|
|
158 |
"Fedora")
|
|
|
159 |
PACKAGEMANAGER=yum
|
|
|
160 |
;;
|
|
|
161 |
"MandrivaLinux")
|
|
|
162 |
PACKAGEMANAGER=urpmi
|
|
|
163 |
;;
|
|
|
164 |
"SUSE LINUX")
|
|
|
165 |
PACKAGEMANAGER=yast
|
|
|
166 |
;;
|
|
|
167 |
esac
|
|
|
168 |
fi
|
|
|
169 |
|
|
|
170 |
if [ "$PACKAGEMANAGER" ]; then
|
|
|
171 |
return
|
|
|
172 |
fi
|
|
|
173 |
|
|
|
174 |
# Fallback methods that are probably unnecessary on modern systems.
|
|
|
175 |
if [ -f "/etc/lsb-release" ]; then
|
|
|
176 |
# file missing on Fedora, does not contain DISTRIB_ID on OpenSUSE.
|
|
|
177 |
eval $(sed -e '/DISTRIB_ID/!d' /etc/lsb-release)
|
|
|
178 |
case $DISTRIB_ID in
|
|
|
179 |
MandrivaLinux)
|
|
|
180 |
PACKAGEMANAGER=urpmi
|
|
|
181 |
;;
|
|
|
182 |
esac
|
|
|
183 |
fi
|
|
|
184 |
|
|
|
185 |
if [ "$PACKAGEMANAGER" ]; then
|
|
|
186 |
return
|
|
|
187 |
fi
|
|
|
188 |
|
|
|
189 |
if [ -f "/etc/fedora-release" ] || [ -f "/etc/redhat-release" ]; then
|
|
|
190 |
PACKAGEMANAGER=yum
|
|
|
191 |
elif [ -f "/etc/system-release" ] && \
|
|
|
192 |
grep -q "Amazon Linux AMI" /etc/system-release ; then
|
|
|
193 |
PACKAGEMANAGER=yum
|
|
|
194 |
elif [ -f "/etc/SuSE-release" ]; then
|
|
|
195 |
PACKAGEMANAGER=yast
|
|
|
196 |
elif [ -f "/etc/mandriva-release" ]; then
|
|
|
197 |
PACKAGEMANAGER=urpmi
|
|
|
198 |
fi
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
DEFAULT_ARCH="x86_64"
|
|
|
202 |
YUM_REPO_FILE="/etc/yum.repos.d/mod-pagespeed.repo"
|
|
|
203 |
ZYPPER_REPO_FILE="/etc/zypp/repos.d/mod-pagespeed.repo"
|
|
|
204 |
URPMI_REPO_FILE="/etc/urpmi/urpmi.cfg"
|
|
|
205 |
|
|
|
206 |
install_yum() {
|
|
|
207 |
install_rpm_key
|
|
|
208 |
|
|
|
209 |
if [ ! "$REPOCONFIG" ]; then
|
|
|
210 |
return 0
|
|
|
211 |
fi
|
|
|
212 |
|
|
|
213 |
if [ -d "/etc/yum.repos.d" ]; then
|
|
|
214 |
cat > "$YUM_REPO_FILE" << REPOCONTENT
|
|
|
215 |
[mod-pagespeed]
|
|
|
216 |
name=mod-pagespeed
|
|
|
217 |
baseurl=$REPOCONFIG/$DEFAULT_ARCH
|
|
|
218 |
enabled=1
|
|
|
219 |
gpgcheck=1
|
|
|
220 |
REPOCONTENT
|
|
|
221 |
fi
|
|
|
222 |
}
|
|
|
223 |
|
|
|
224 |
# This is called by the cron job, rather than in the RPM postinstall.
|
|
|
225 |
# We cannot do this during the install when urpmi is running due to
|
|
|
226 |
# database locking. We also need to enable the repository, and we can
|
|
|
227 |
# only do that while we are online.
|
|
|
228 |
# see: https://qa.mandriva.com/show_bug.cgi?id=31893
|
|
|
229 |
configure_urpmi() {
|
|
|
230 |
if [ ! "$REPOCONFIG" ]; then
|
|
|
231 |
return 0
|
|
|
232 |
fi
|
|
|
233 |
|
|
|
234 |
urpmq --list-media | grep -q -s "^mod-pagespeed$"
|
|
|
235 |
if [ "$?" -eq "0" ]; then
|
|
|
236 |
# Repository already configured
|
|
|
237 |
return 0
|
|
|
238 |
fi
|
|
|
239 |
urpmi.addmedia --update \
|
|
|
240 |
"mod-pagespeed" "$REPOCONFIG/$DEFAULT_ARCH"
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
install_urpmi() {
|
|
|
244 |
# urpmi not smart enough to pull media_info/pubkey from the repository?
|
|
|
245 |
install_rpm_key
|
|
|
246 |
|
|
|
247 |
# Defer urpmi.addmedia to configure_urpmi() in the cron job.
|
|
|
248 |
# See comment there.
|
|
|
249 |
#
|
|
|
250 |
# urpmi.addmedia --update \
|
|
|
251 |
# "mod-pagespeed" "$REPOCONFIG/$DEFAULT_ARCH"
|
|
|
252 |
}
|
|
|
253 |
|
|
|
254 |
install_yast() {
|
|
|
255 |
if [ ! "$REPOCONFIG" ]; then
|
|
|
256 |
return 0
|
|
|
257 |
fi
|
|
|
258 |
|
|
|
259 |
# We defer adding the key to later. See comment in the cron job.
|
|
|
260 |
|
|
|
261 |
# Ideally, we would run: zypper addrepo -t YUM -f \
|
|
|
262 |
# "$REPOCONFIG/$DEFAULT_ARCH" "mod-pagespeed"
|
|
|
263 |
# but that does not work when zypper is running.
|
|
|
264 |
if [ -d "/etc/zypp/repos.d" ]; then
|
|
|
265 |
cat > "$ZYPPER_REPO_FILE" << REPOCONTENT
|
|
|
266 |
[mod-pagespeed]
|
|
|
267 |
name=mod-pagespeed
|
|
|
268 |
enabled=1
|
|
|
269 |
autorefresh=1
|
|
|
270 |
baseurl=$REPOCONFIG/$DEFAULT_ARCH
|
|
|
271 |
type=rpm-md
|
|
|
272 |
keeppackages=0
|
|
|
273 |
REPOCONTENT
|
|
|
274 |
fi
|
|
|
275 |
}
|
|
|
276 |
|
|
|
277 |
# Check if the automatic repository configuration is done, so we know when to
|
|
|
278 |
# stop trying.
|
|
|
279 |
verify_install() {
|
|
|
280 |
# It's probably enough to see that the repo configs have been created. If they
|
|
|
281 |
# aren't configured properly, update_bad_repo should catch that when it's run.
|
|
|
282 |
case $1 in
|
|
|
283 |
"yum")
|
|
|
284 |
[ -f "$YUM_REPO_FILE" ]
|
|
|
285 |
;;
|
|
|
286 |
"yast")
|
|
|
287 |
[ -f "$ZYPPER_REPO_FILE" ]
|
|
|
288 |
;;
|
|
|
289 |
"urpmi")
|
|
|
290 |
urpmq --list-url | grep -q -s "\bmod-pagespeed\b"
|
|
|
291 |
;;
|
|
|
292 |
esac
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
# Update the Google repository if it's not set correctly.
|
|
|
296 |
update_bad_repo() {
|
|
|
297 |
if [ ! "$REPOCONFIG" ]; then
|
|
|
298 |
return 0
|
|
|
299 |
fi
|
|
|
300 |
|
|
|
301 |
determine_rpm_package_manager
|
|
|
302 |
|
|
|
303 |
case $PACKAGEMANAGER in
|
|
|
304 |
"yum")
|
|
|
305 |
update_repo_file "$YUM_REPO_FILE"
|
|
|
306 |
;;
|
|
|
307 |
"yast")
|
|
|
308 |
update_repo_file "$ZYPPER_REPO_FILE"
|
|
|
309 |
;;
|
|
|
310 |
"urpmi")
|
|
|
311 |
update_urpmi_cfg
|
|
|
312 |
;;
|
|
|
313 |
esac
|
|
|
314 |
}
|
|
|
315 |
|
|
|
316 |
update_repo_file() {
|
|
|
317 |
REPO_FILE="$1"
|
|
|
318 |
|
|
|
319 |
# Don't do anything if the file isn't there, since that probably means the
|
|
|
320 |
# user disabled it.
|
|
|
321 |
if [ ! -r "$REPO_FILE" ]; then
|
|
|
322 |
return 0
|
|
|
323 |
fi
|
|
|
324 |
|
|
|
325 |
# Check if the correct repository configuration is in there.
|
|
|
326 |
REPOMATCH=$(grep "^baseurl=$REPOCONFIG/$DEFAULT_ARCH" "$REPO_FILE" \
|
|
|
327 |
2>/dev/null)
|
|
|
328 |
# If it's there, nothing to do
|
|
|
329 |
if [ "$REPOMATCH" ]; then
|
|
|
330 |
return 0
|
|
|
331 |
fi
|
|
|
332 |
|
|
|
333 |
# Check if it's there but disabled by commenting out (as opposed to using the
|
|
|
334 |
# 'enabled' setting).
|
|
|
335 |
MATCH_DISABLED=$(grep "^[[:space:]]*#.*baseurl=$REPOCONFIG/$DEFAULT_ARCH" \
|
|
|
336 |
"$REPO_FILE" 2>/dev/null)
|
|
|
337 |
if [ "$MATCH_DISABLED" ]; then
|
|
|
338 |
# It's OK for it to be disabled, as long as nothing bogus is enabled in its
|
|
|
339 |
# place.
|
|
|
340 |
ACTIVECONFIGS=$(grep "^baseurl=.*" "$REPO_FILE" 2>/dev/null)
|
|
|
341 |
if [ ! "$ACTIVECONFIGS" ]; then
|
|
|
342 |
return 0
|
|
|
343 |
fi
|
|
|
344 |
fi
|
|
|
345 |
|
|
|
346 |
# If we get here, the correct repository wasn't found, or something else is
|
|
|
347 |
# active, so fix it. This assumes there is a 'baseurl' setting, but if not,
|
|
|
348 |
# then that's just another way of disabling, so we won't try to add it.
|
|
|
349 |
sed -i -e "s,^baseurl=.*,baseurl=$REPOCONFIG/$DEFAULT_ARCH," "$REPO_FILE"
|
|
|
350 |
}
|
|
|
351 |
|
|
|
352 |
update_urpmi_cfg() {
|
|
|
353 |
REPOCFG=$(urpmq --list-url | grep "\bmod-pagespeed\b")
|
|
|
354 |
if [ ! "$REPOCFG" ]; then
|
|
|
355 |
# Don't do anything if the repo isn't there, since that probably means the
|
|
|
356 |
# user deleted it.
|
|
|
357 |
return 0
|
|
|
358 |
fi
|
|
|
359 |
|
|
|
360 |
# See if it's the right repo URL
|
|
|
361 |
REPOMATCH=$(echo "$REPOCFG" | grep "\b$REPOCONFIG/$DEFAULT_ARCH\b")
|
|
|
362 |
# If so, nothing to do
|
|
|
363 |
if [ "$REPOMATCH" ]; then
|
|
|
364 |
return 0
|
|
|
365 |
fi
|
|
|
366 |
|
|
|
367 |
# Looks like it's the wrong URL, so recreate it.
|
|
|
368 |
urpmi.removemedia "mod-pagespeed" && \
|
|
|
369 |
urpmi.addmedia --update "mod-pagespeed" "$REPOCONFIG/$DEFAULT_ARCH"
|
|
|
370 |
}
|
|
|
371 |
|
|
|
372 |
# We only remove the repository configuration during a purge. Since RPM has
|
|
|
373 |
# no equivalent to dpkg --purge, the code below is actually never used. We
|
|
|
374 |
# keep it only for reference purposes, should we ever need it.
|
|
|
375 |
#
|
|
|
376 |
#remove_yum() {
|
|
|
377 |
# rm -f "$YUM_REPO_FILE"
|
|
|
378 |
#}
|
|
|
379 |
#
|
|
|
380 |
#remove_urpmi() {
|
|
|
381 |
# # Ideally, we would run: urpmi.removemedia "mod-pagespeed"
|
|
|
382 |
# # but that does not work when urpmi is running.
|
|
|
383 |
# # Sentinel comment text does not work either because urpmi.update removes
|
|
|
384 |
# # all comments. So we just delete the entry that matches what we originally
|
|
|
385 |
# # inserted. If such an entry was added manually, that's tough luck.
|
|
|
386 |
# if [ -f "$URPMI_REPO_FILE" ]; then
|
|
|
387 |
# sed -i '\_^mod-pagespeed $REPOCONFIG/$DEFAULT_ARCH {$_,/^}$/d' "$URPMI_REPO_FILE"
|
|
|
388 |
# fi
|
|
|
389 |
#}
|
|
|
390 |
#
|
|
|
391 |
#remove_yast() {
|
|
|
392 |
# # Ideally, we would run: zypper removerepo "mod-pagespeed"
|
|
|
393 |
# # but that does not work when zypper is running.
|
|
|
394 |
# rm -f /etc/zypp/repos.d/mod-pagespeed.repo
|
|
|
395 |
#}
|
|
|
396 |
|
|
|
397 |
## MAIN ##
|
|
|
398 |
DEFAULTS_FILE="/etc/default/mod-pagespeed"
|
|
|
399 |
if [ -r "$DEFAULTS_FILE" ]; then
|
|
|
400 |
. "$DEFAULTS_FILE"
|
|
|
401 |
fi
|
|
|
402 |
|
|
|
403 |
if [ "$repo_add_once" = "true" ]; then
|
|
|
404 |
determine_rpm_package_manager
|
|
|
405 |
|
|
|
406 |
case $PACKAGEMANAGER in
|
|
|
407 |
"urpmi")
|
|
|
408 |
# We need to configure urpmi after the install has finished.
|
|
|
409 |
# See configure_urpmi() for details.
|
|
|
410 |
configure_urpmi
|
|
|
411 |
;;
|
|
|
412 |
"yast")
|
|
|
413 |
# It looks as though yast/zypper has a lock on the RPM DB during
|
|
|
414 |
# postinstall, so we cannot add the signing key with install_rpm_key().
|
|
|
415 |
# Instead, we attempt to do this here. If the user attempt to update before
|
|
|
416 |
# the cron job imports the key, Yast will grab the key from our server and
|
|
|
417 |
# prompt the user to accept the key.
|
|
|
418 |
install_rpm_key
|
|
|
419 |
;;
|
|
|
420 |
esac
|
|
|
421 |
|
|
|
422 |
if [ $? -eq 0 ]; then
|
|
|
423 |
# Before we quit auto-configuration, check that everything looks sane, since
|
|
|
424 |
# part of this happened during package install and we don't have the return
|
|
|
425 |
# value of that process.
|
|
|
426 |
verify_install $PACKAGEMANAGER
|
|
|
427 |
if [ $? -eq 0 ]; then
|
|
|
428 |
sed -i -e 's/[[:space:]]*repo_add_once=.*/repo_add_once="false"/' \
|
|
|
429 |
"$DEFAULTS_FILE"
|
|
|
430 |
fi
|
|
|
431 |
fi
|
|
|
432 |
else
|
|
|
433 |
update_bad_repo
|
|
|
434 |
fi
|