| Server IP : 134.236.29.77 / Your IP : 216.73.217.92 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/20619/cwd/proc/6265/task/3227/cwd/etc/cron.daily/ |
Upload File : |
#!/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 google-chrome package.
#
# It creates the repository configuration file for package updates, since
# we cannot do this during the google-chrome 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/google-chrome"
# sources.list setting for google-chrome updates.
REPOCONFIG="http://dl.google.com/linux/chrome/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
kv2E5VixBP1vcQFDR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h4dtIAqPwAX8xn36JAYG
2vgLAAMFB/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/google-chrome.repo"
ZYPPER_REPO_FILE="/etc/zypp/repos.d/google-chrome.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
[google-chrome]
name=google-chrome
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 "^google-chrome$"
if [ "$?" -eq "0" ]; then
# Repository already configured
return 0
fi
urpmi.addmedia --update \
"google-chrome" "$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 \
# "google-chrome" "$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" "google-chrome"
# but that does not work when zypper is running.
if [ -d "/etc/zypp/repos.d" ]; then
cat > "$ZYPPER_REPO_FILE" << REPOCONTENT
[google-chrome]
name=google-chrome
enabled=1
autorefresh=1
baseurl=$REPOCONFIG/$DEFAULT_ARCH
type=rpm-md
keeppackages=0
REPOCONTENT
fi
}
# Check if the automatic repository configuration is done, so we know when to
# stop trying.
verify_install() {
# It's probably enough to see that the repo configs have been created. If they
# aren't configured properly, update_bad_repo should catch that when it's run.
case $1 in
"yum")
[ -f "$YUM_REPO_FILE" ]
;;
"yast")
[ -f "$ZYPPER_REPO_FILE" ]
;;
"urpmi")
urpmq --list-url | grep -q -s "\bgoogle-chrome\b"
;;
esac
}
# Update the Google repository if it's not set correctly.
update_bad_repo() {
if [ ! "$REPOCONFIG" ]; then
return 0
fi
determine_rpm_package_manager
case $PACKAGEMANAGER in
"yum")
update_repo_file "$YUM_REPO_FILE"
;;
"yast")
update_repo_file "$ZYPPER_REPO_FILE"
;;
"urpmi")
update_urpmi_cfg
;;
esac
}
update_repo_file() {
REPO_FILE="$1"
# Don't do anything if the file isn't there, since that probably means the
# user disabled it.
if [ ! -r "$REPO_FILE" ]; then
return 0
fi
# Check if the correct repository configuration is in there.
REPOMATCH=$(grep "^baseurl=$REPOCONFIG/$DEFAULT_ARCH" "$REPO_FILE" \
2>/dev/null)
# If it's there, nothing to do
if [ "$REPOMATCH" ]; then
return 0
fi
# Check if it's there but disabled by commenting out (as opposed to using the
# 'enabled' setting).
MATCH_DISABLED=$(grep "^[[:space:]]*#.*baseurl=$REPOCONFIG/$DEFAULT_ARCH" \
"$REPO_FILE" 2>/dev/null)
if [ "$MATCH_DISABLED" ]; then
# It's OK for it to be disabled, as long as nothing bogus is enabled in its
# place.
ACTIVECONFIGS=$(grep "^baseurl=.*" "$REPO_FILE" 2>/dev/null)
if [ ! "$ACTIVECONFIGS" ]; then
return 0
fi
fi
# If we get here, the correct repository wasn't found, or something else is
# active, so fix it. This assumes there is a 'baseurl' setting, but if not,
# then that's just another way of disabling, so we won't try to add it.
sed -i -e "s,^baseurl=.*,baseurl=$REPOCONFIG/$DEFAULT_ARCH," "$REPO_FILE"
}
update_urpmi_cfg() {
REPOCFG=$(urpmq --list-url | grep "\bgoogle-chrome\b")
if [ ! "$REPOCFG" ]; then
# Don't do anything if the repo isn't there, since that probably means the
# user deleted it.
return 0
fi
# See if it's the right repo URL
URLMATCH=$(echo "$REPOCFG" | grep "\b$REPOCONFIG/$DEFAULT_ARCH\b")
# If so, nothing to do
if [ "$REPOMATCH" ]; then
return 0
fi
# Looks like it's the wrong URL, so recreate it.
urpmi.removemedia "google-chrome" && \
urpmi.addmedia --update "google-chrome" "$REPOCONFIG/$DEFAULT_ARCH"
}
# We only remove the repository configuration during a purge. Since RPM has
# no equivalent to dpkg --purge, the code below is actually never used. We
# keep it only for reference purposes, should we ever need it.
#
#remove_yum() {
# rm -f "$YUM_REPO_FILE"
#}
#
#remove_urpmi() {
# # Ideally, we would run: urpmi.removemedia "google-chrome"
# # but that does not work when urpmi is running.
# # Sentinel comment text does not work either because urpmi.update removes
# # all comments. So we just delete the entry that matches what we originally
# # inserted. If such an entry was added manually, that's tough luck.
# if [ -f "$URPMI_REPO_FILE" ]; then
# sed -i '\_^google-chrome $REPOCONFIG/$DEFAULT_ARCH {$_,/^}$/d' "$URPMI_REPO_FILE"
# fi
#}
#
#remove_yast() {
# # Ideally, we would run: zypper removerepo "google-chrome"
# # but that does not work when zypper is running.
# rm -f /etc/zypp/repos.d/google-chrome.repo
#}
get_lib_dir() {
if [ "$DEFAULT_ARCH" = "i386" ]; then
LIBDIR=lib
elif [ "$DEFAULT_ARCH" = "x86_64" ]; then
LIBDIR=lib64
else
echo Unknown CPU Architecture: "$DEFAULT_ARCH"
exit 1
fi
}
NSS_FILES="libnspr4.so.0d libplds4.so.0d libplc4.so.0d libssl3.so.1d \
libnss3.so.1d libsmime3.so.1d libnssutil3.so.1d"
add_nss_symlinks() {
get_lib_dir
for f in $NSS_FILES
do
target=$(echo $f | sed 's/\.[01]d$//')
if [ -f "/$LIBDIR/$target" ]; then
ln -snf "/$LIBDIR/$target" "/opt/google/chrome/$f"
elif [ -f "/usr/$LIBDIR/$target" ]; then
ln -snf "/usr/$LIBDIR/$target" "/opt/google/chrome/$f"
else
echo $f not found in "/$LIBDIR/$target" or "/usr/$LIBDIR/$target".
exit 1
fi
done
}
remove_nss_symlinks() {
for f in $NSS_FILES
do
rm -rf "/opt/google/chrome/$f"
done
}
LIBBZ2_1=libbz2.so.1
LIBBZ2_1_0=libbz2.so.1.0
add_bzip2_symlinks() {
get_lib_dir
if [ -f "/$LIBDIR/$LIBBZ2_1_0" -o -f "/usr/$LIBDIR/$LIBBZ2_1_0" ]; then
return 0
fi
# Most RPM distros do not provide libbz2.so.1.0, i.e.
# https://bugzilla.redhat.com/show_bug.cgi?id=461863
# so we create a symlink and point it to libbz2.so.1.
# This is technically wrong, but it'll work since we do
# not anticipate a new version of bzip2 with a different
# minor version number anytime soon.
if [ -f "/$LIBDIR/$LIBBZ2_1" -a ! -f "/$LIBDIR/$LIBBZ2_1_0" ]; then
ln -snf "/$LIBDIR/$LIBBZ2_1" "/opt/google/chrome/$LIBBZ2_1_0"
elif [ -f "/usr/$LIBDIR/$LIBBZ2_1" -a ! -f "/usr/$LIBDIR/$LIBBZ2_1_0" ];
then
ln -snf "/usr/$LIBDIR/$LIBBZ2_1" "/opt/google/chrome/$LIBBZ2_1_0"
else
echo "$LIBBZ2_1" not found in "$LIBDIR" or "/usr/$LIBDIR".
exit 1
fi
}
remove_bzip2_symlinks() {
rm -rf "/opt/google/chrome/$LIBBZ2_1_0"
}
## MAIN ##
DEFAULTS_FILE="/etc/default/google-chrome"
if [ -r "$DEFAULTS_FILE" ]; then
. "$DEFAULTS_FILE"
fi
if [ "$repo_add_once" = "true" ]; then
determine_rpm_package_manager
case $PACKAGEMANAGER in
"urpmi")
# We need to configure urpmi after the install has finished.
# See configure_urpmi() for details.
configure_urpmi
;;
"yast")
# It looks as though yast/zypper has a lock on the RPM DB during
# postinstall, so we cannot add the signing key with install_rpm_key().
# Instead, we attempt to do this here. If the user attempt to update before
# the cron job imports the key, Yast will grab the key from our server and
# prompt the user to accept the key.
install_rpm_key
;;
esac
if [ $? -eq 0 ]; then
# Before we quit auto-configuration, check that everything looks sane, since
# part of this happened during package install and we don't have the return
# value of that process.
verify_install $PACKAGEMANAGER
if [ $? -eq 0 ]; then
sed -i -e 's/[[:space:]]*repo_add_once=.*/repo_add_once="false"/' \
"$DEFAULTS_FILE"
fi
fi
else
update_bad_repo
fi