#!/bin/sh # # Copyright 2009 The Chromium Authors # 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, and it # monitors that config to see if it has been disabled by the overly aggressive # distro upgrade process (e.g. intrepid -> jaunty). When this situation is # detected, the respository will be re-enabled. If the respository is disabled # for any other reason, this won't re-enable it. # # This functionality can be controlled by creating the $DEFAULTS_FILE and # setting "repo_reenable_on_distupgrade" to "true" or "false" as desired. # An empty $DEFAULTS_FILE is the same as setting it to "false". # # The $DEFAULTS_FILE also has a setting "repo_add_once" which can be set # to "false" to prevent the package install from adding the repo altogether. # System-wide package configuration. DEFAULTS_FILE="/etc/default/google-chrome" # sources.list setting for google-chrome updates. REPOCONFIG="deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" REPOCONFIGREGEX="deb (\[arch=[^]]*\bamd64\b[^]]*\][[:space:]]*) https?://dl.google.com/linux/chrome/deb/ stable main" # This file is automatically generated by update_key_include.py # Do not edit this file directly. # This is used as a priority value for the key file, so newer # keyrings should always take priority. PGP_KEY_VERSION=3 # pub rsa4096 2016-04-12 [SC] # EB4C1BFD4F042F6DDDCCEC917721F63BD38B4796 # uid [ unknown] Google Inc. (Linux Packages Signing Authority) # sub rsa4096 2024-01-30 [S] [expires: 2027-01-29] # sub rsa4096 2025-01-07 [S] [expires: 2028-01-07] # sub rsa4096 2026-03-10 [S] [expires: 2029-03-09] PGP_KEY_DATA=$(cat <"$GPG_FILE.$$.tmp" chmod 644 "$GPG_FILE.$$.tmp" mv "$GPG_FILE.$$.tmp" "$GPG_FILE" } uninstall_key() { rm -f "$GPG_FILE" } remove_legacy_key() { find_apt_trusted rm -f "$APT_TRUSTEDDIR/google-chrome.gpg" } remove_legacy_list() { find_apt_sources LEGACY_LIST="$APT_SOURCESDIR/google-chrome.list" if [ ! -f "$LEGACY_LIST" ]; then return fi # Check for other sources (strict check for 'ours') # If there are any lines starting with 'deb' (commented or not) that do NOT # match our strict regex, keep the file. if grep -E "^[[:space:]]*#?[[:space:]]*deb" "$LEGACY_LIST" | grep -v -E \ "^[[:space:]]*#?[[:space:]]*$REPOCONFIGREGEX" >/dev/null; then # Other sources exist, comment out ours (strict match) sed -i -E "s|^[[:space:]]*($REPOCONFIGREGEX)|# \1|" "$LEGACY_LIST" else # No other sources, safe to remove rm -f "$LEGACY_LIST" fi } # Generate the content of the .sources file gen_sources_content() { cat <"$SOURCES_FILE.$$.tmp" chmod 644 "$SOURCES_FILE.$$.tmp" mv "$SOURCES_FILE.$$.tmp" "$SOURCES_FILE" if [ -r "$DEFAULTS_FILE" ]; then if grep -q "^[[:space:]]*repo_add_once=" "$DEFAULTS_FILE"; then sed -i -e \ 's/^[[:space:]]*repo_add_once=.*/repo_add_once="false"/' \ "$DEFAULTS_FILE" else echo 'repo_add_once="false"' >>"$DEFAULTS_FILE" fi fi } # Remove our custom sources file. clean_sources_lists() { find_apt_sources rm -f "$SOURCES_FILE" } install_deb822_sources() { find_apt_sources LEGACY_LIST="$APT_SOURCESDIR/google-chrome.list" SHOULD_INSTALL_SOURCES=0 # Detect new installs. if [ -r "$DEFAULTS_FILE" ]; then if grep -E -q \ '^[[:space:]]*repo_add_once=[[:space:]]*["'\'']?true["'\'']?' \ "$DEFAULTS_FILE"; then SHOULD_INSTALL_SOURCES=1 fi else SHOULD_INSTALL_SOURCES=1 echo 'repo_add_once="true"' >"$DEFAULTS_FILE" echo 'repo_reenable_on_distupgrade="true"' >>"$DEFAULTS_FILE" fi if [ -f "$SOURCES_FILE" ]; then # The new .sources file already exists. Recreate it in case it got disabled # during a dist upgrade. SHOULD_INSTALL_SOURCES=1 elif [ -f "$LEGACY_LIST" ]; then # Migrate a legacy .list file to the new .sources format. if grep -E -q "^[[:space:]]*$REPOCONFIGREGEX" "$LEGACY_LIST"; then SHOULD_INSTALL_SOURCES=1 elif grep -E -q \ "^[[:space:]]*#[[:space:]]*$REPOCONFIGREGEX[[:space:]]*# disabled on \ upgrade to .*" \ "$LEGACY_LIST"; then SHOULD_INSTALL_SOURCES=1 fi fi if [ "$SHOULD_INSTALL_SOURCES" -eq 1 ]; then create_sources_lists fi } ## MAIN ## if [ -r "$DEFAULTS_FILE" ]; then . "$DEFAULTS_FILE" fi install_key if [ "$repo_add_once" = "true" ]; then create_sources_lists elif [ "$repo_reenable_on_distupgrade" = "true" ]; then install_deb822_sources fi