1 @@include@@variables.include
3 # Install the repository signing key (see also:
4 # http://www.google.com/linuxrepositories/aboutkey.html)
6 # Check to see if key already exists.
7 rpm -q gpg-pubkey-7fac5991-4615767f > /dev/null 2>&1
8 if [ "$?" -eq "0" ]; then
12 # This is to work around a bug in RPM 4.7.0. (see http://crbug.com/22312)
13 rpm -q gpg-pubkey-7fac5991-45f06f46 > /dev/null 2>&1
14 if [ "$?" -eq "0" ]; then
19 # RPM on Mandriva 2009 is dumb and does not understand "rpm --import -"
20 TMPKEY=$(mktemp /tmp/google.sig.XXXXXX)
21 if [ -n "$TMPKEY" ]; then
22 cat > "$TMPKEY" <<KEYDATA
23 -----BEGIN PGP PUBLIC KEY BLOCK-----
24 Version: GnuPG v1.4.2.2 (GNU/Linux)
26 mQGiBEXwb0YRBADQva2NLpYXxgjNkbuP0LnPoEXruGmvi3XMIxjEUFuGNCP4Rj/a
27 kv2E5VixBP1vcQFDRJ+p1puh8NU0XERlhpyZrVMzzS/RdWdyXf7E5S8oqNXsoD1z
28 fvmI+i9b2EhHAA19Kgw7ifV8vMa4tkwslEmcTiwiw8lyUl28Wh4Et8SxzwCggDcA
29 feGqtn3PP5YAdD0km4S4XeMEAJjlrqPoPv2Gf//tfznY2UyS9PUqFCPLHgFLe80u
30 QhI2U5jt6jUKN4fHauvR6z3seSAsh1YyzyZCKxJFEKXCCqnrFSoh4WSJsbFNc4PN
31 b0V0SqiTCkWADZyLT5wll8sWuQ5ylTf3z1ENoHf+G3um3/wk/+xmEHvj9HCTBEXP
32 78X0A/0Tqlhc2RBnEf+AqxWvM8sk8LzJI/XGjwBvKfXe+l3rnSR2kEAvGzj5Sg0X
33 4XmfTg4Jl8BNjWyvm2Wmjfet41LPmYJKsux3g0b8yzQxeOA4pQKKAU3Z4+rgzGmf
34 HdwCG5MNT2A5XxD/eDd+L4fRx0HbFkIQoAi1J3YWQSiTk15fw7RMR29vZ2xlLCBJ
35 bmMuIExpbnV4IFBhY2thZ2UgU2lnbmluZyBLZXkgP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"
58 if [ "$rc" -eq "0" ]; then
65 determine_rpm_package_manager() {
67 LSB_RELEASE="$(which lsb_release 2> /dev/null)"
68 if [ -x "$LSB_RELEASE" ]; then
69 RELEASE=$(lsb_release -i 2> /dev/null | sed 's/:\t/:/' | cut -d ':' -f 2-)
74 "Mageia"|"MandrivaLinux")
83 if [ "$PACKAGEMANAGER" ]; then
87 # Fallback methods that are probably unnecessary on modern systems.
88 if [ -f "/etc/lsb-release" ]; then
89 # file missing on Fedora, does not contain DISTRIB_ID on OpenSUSE.
90 eval $(sed -e '/DISTRIB_ID/!d' /etc/lsb-release)
98 if [ "$PACKAGEMANAGER" ]; then
102 if [ -f "/etc/fedora-release" ] || [ -f "/etc/redhat-release" ]; then
104 elif [ -f "/etc/SuSE-release" ]; then
106 elif [ -f "/etc/mandriva-release" ]; then
111 DEFAULT_ARCH="@@ARCHITECTURE@@"
112 YUM_REPO_FILE="/etc/yum.repos.d/@@PACKAGE@@.repo"
113 ZYPPER_REPO_FILE="/etc/zypp/repos.d/@@PACKAGE@@.repo"
114 URPMI_REPO_FILE="/etc/urpmi/urpmi.cfg"
119 if [ ! "$REPOCONFIG" ]; then
123 if [ -d "/etc/yum.repos.d" ]; then
124 cat > "$YUM_REPO_FILE" << REPOCONTENT
127 baseurl=$REPOCONFIG/$DEFAULT_ARCH
134 # This is called by the cron job, rather than in the RPM postinstall.
135 # We cannot do this during the install when urpmi is running due to
136 # database locking. We also need to enable the repository, and we can
137 # only do that while we are online.
138 # see: https://qa.mandriva.com/show_bug.cgi?id=31893
140 if [ ! "$REPOCONFIG" ]; then
144 urpmq --list-media | grep -q -s "^@@PACKAGE@@$"
145 if [ "$?" -eq "0" ]; then
146 # Repository already configured
149 urpmi.addmedia --update \
150 "@@PACKAGE@@" "$REPOCONFIG/$DEFAULT_ARCH"
154 # urpmi not smart enough to pull media_info/pubkey from the repository?
157 # Defer urpmi.addmedia to configure_urpmi() in the cron job.
160 # urpmi.addmedia --update \
161 # "@@PACKAGE@@" "$REPOCONFIG/$DEFAULT_ARCH"
165 if [ ! "$REPOCONFIG" ]; then
169 # We defer adding the key to later. See comment in the cron job.
171 # Ideally, we would run: zypper addrepo -t YUM -f \
172 # "$REPOCONFIG/$DEFAULT_ARCH" "@@PACKAGE@@"
173 # but that does not work when zypper is running.
174 if [ -d "/etc/zypp/repos.d" ]; then
175 cat > "$ZYPPER_REPO_FILE" << REPOCONTENT
180 baseurl=$REPOCONFIG/$DEFAULT_ARCH
187 # Check if the automatic repository configuration is done, so we know when to
190 # It's probably enough to see that the repo configs have been created. If they
191 # aren't configured properly, update_bad_repo should catch that when it's run.
194 [ -f "$YUM_REPO_FILE" ]
197 [ -f "$ZYPPER_REPO_FILE" ]
200 urpmq --list-url | grep -q -s "\b@@PACKAGE@@\b"
205 # Update the Google repository if it's not set correctly.
207 if [ ! "$REPOCONFIG" ]; then
211 determine_rpm_package_manager
213 case $PACKAGEMANAGER in
215 update_repo_file "$YUM_REPO_FILE"
218 update_repo_file "$ZYPPER_REPO_FILE"
229 # Don't do anything if the file isn't there, since that probably means the
231 if [ ! -r "$REPO_FILE" ]; then
235 # Check if the correct repository configuration is in there.
236 REPOMATCH=$(grep "^baseurl=$REPOCONFIG/$DEFAULT_ARCH" "$REPO_FILE" \
238 # If it's there, nothing to do
239 if [ "$REPOMATCH" ]; then
243 # Check if it's there but disabled by commenting out (as opposed to using the
244 # 'enabled' setting).
245 MATCH_DISABLED=$(grep "^[[:space:]]*#.*baseurl=$REPOCONFIG/$DEFAULT_ARCH" \
246 "$REPO_FILE" 2>/dev/null)
247 if [ "$MATCH_DISABLED" ]; then
248 # It's OK for it to be disabled, as long as nothing bogus is enabled in its
250 ACTIVECONFIGS=$(grep "^baseurl=.*" "$REPO_FILE" 2>/dev/null)
251 if [ ! "$ACTIVECONFIGS" ]; then
256 # If we get here, the correct repository wasn't found, or something else is
257 # active, so fix it. This assumes there is a 'baseurl' setting, but if not,
258 # then that's just another way of disabling, so we won't try to add it.
259 sed -i -e "s,^baseurl=.*,baseurl=$REPOCONFIG/$DEFAULT_ARCH," "$REPO_FILE"
263 REPOCFG=$(urpmq --list-url | grep "\b@@PACKAGE@@\b")
264 if [ ! "$REPOCFG" ]; then
265 # Don't do anything if the repo isn't there, since that probably means the
270 # See if it's the right repo URL
271 REPOMATCH=$(echo "$REPOCFG" | grep "\b$REPOCONFIG/$DEFAULT_ARCH\b")
272 # If so, nothing to do
273 if [ "$REPOMATCH" ]; then
277 # Looks like it's the wrong URL, so recreate it.
278 urpmi.removemedia "@@PACKAGE@@" && \
279 urpmi.addmedia --update "@@PACKAGE@@" "$REPOCONFIG/$DEFAULT_ARCH"
282 # We only remove the repository configuration during a purge. Since RPM has
283 # no equivalent to dpkg --purge, the code below is actually never used. We
284 # keep it only for reference purposes, should we ever need it.
287 # rm -f "$YUM_REPO_FILE"
291 # # Ideally, we would run: urpmi.removemedia "@@PACKAGE@@"
292 # # but that does not work when urpmi is running.
293 # # Sentinel comment text does not work either because urpmi.update removes
294 # # all comments. So we just delete the entry that matches what we originally
295 # # inserted. If such an entry was added manually, that's tough luck.
296 # if [ -f "$URPMI_REPO_FILE" ]; then
297 # sed -i '\_^@@PACKAGE@@ $REPOCONFIG/$DEFAULT_ARCH {$_,/^}$/d' "$URPMI_REPO_FILE"
302 # # Ideally, we would run: zypper removerepo "@@PACKAGE@@"
303 # # but that does not work when zypper is running.
304 # rm -f /etc/zypp/repos.d/@@PACKAGE@@.repo
307 DEFAULT_ARCH="@@ARCHITECTURE@@"
310 if [ "$DEFAULT_ARCH" = "i386" ]; then
312 elif [ "$DEFAULT_ARCH" = "x86_64" ]; then
315 echo Unknown CPU Architecture: "$DEFAULT_ARCH"