| @@include@@variables.include |
| |
| # Install the repository signing key (see also: |
| # https://www.google.com/linuxrepositories/) |
| install_rpm_key() { |
| KEY_PACKAGE="gpg-pubkey-d38b4796-570c8cd3" |
| # Check to see if all keys already exists. |
| # Make sure all the most recent signing subkeys are installed. |
| NEED_KEYS=0 |
| |
| # 2016 signing subkey |
| rpm -q ${KEY_PACKAGE} --qf '%{Pubkeys:armor}\n' | \ |
| gpg --with-colons - 2>/dev/null | \ |
| grep -q 1397BC53640DB551 |
| if [ "$?" -ne "0" ]; then |
| NEED_KEYS=1 |
| fi |
| |
| # 2017 signing subkey |
| rpm -q ${KEY_PACKAGE} --qf '%{Pubkeys:armor}\n' | \ |
| gpg --with-colons - 2>/dev/null | \ |
| grep -q 6494C6D6997C215E |
| if [ "$?" -ne "0" ]; then |
| NEED_KEYS=1 |
| fi |
| |
| if [ $NEED_KEYS -ne 1 ]; then |
| return |
| fi |
| |
| # Make sure no older version of the key is installed because it appears |
| # 'rpm --import' won't overwrite an existing key package. |
| rpm -q ${KEY_PACKAGE} >/dev/null 2>&1 |
| if [ "$?" -eq "0" ]; then |
| # Note, if this is run during the package install, it will fail because rpm |
| # can't recursively run rpm, but it should work when run later as part of |
| # the installed cron job (and probably nothing needs the new keys before |
| # then). |
| rpm -e --allmatches ${KEY_PACKAGE} >/dev/null 2>&1 || return |
| 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/RdWdyXf7E5S8oqNXsoD1z |
| fvmI+i9b2EhHAA19Kgw7ifV8vM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SoHPLBcIxtIKp30LJ0PEkat8SG7G2wgtv1Rdh |
| mcZEBV05vMnrGGO991e+pKzRNPYH8rD3VQKJlvaFwsJuBTW42gZ3KfpUNKI2ugCc |
| nRNpoHFWNCrzlJ0CFI48LMlmUSs+7i/l+QGleaLKQxRTNNpAmevLrS7ga4Iq0IEq |
| xey6VW6RSk/Z1Z37J8B7PISSR0rZn6TeyQgFWf/FOLw6OtwOquGmMeGSqj2Uzxyb |
| ygtsvUZz0BxYymoWFd4F8sp43oL2TXU6Wp7QIpBaFgkSf/UQxfR6wcQ3ivafeS1l |
| g8vUFuMfuMLto6T0JiZw8uKSuDWltSReF+FXVnhawz72BZMy8RIoshGdpWHn/YbN |
| 6L+JOuxZnvkMAZvSLT3c0H4XCDYtEfK2mJMqD2ynX5tGR8Fy3GAaEjhx36TvzTjC |
| XRmJ+FnlSW1p77x+UjFUFcpY8skv+f0Gip30iynAb1hoAdibIDab612OWi/4vX0D |
| aM6t68Uq8rsabeJYsZG4 |
| =lzV/ |
| -----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 | sed 's/:\t/:/' | cut -d ':' -f 2-) |
| case $RELEASE in |
| "Fedora") |
| PACKAGEMANAGERS=(yum) |
| ;; |
| "Mageia") |
| PACKAGEMANAGERS=(urpmi) |
| if [ "$(lsb_release -rs 2> /dev/null)" -ge "6" ]; then |
| PACKAGEMANAGERS=(yum urpmi) |
| fi |
| ;; |
| "MandrivaLinux") |
| PACKAGEMANAGERS=(urpmi) |
| ;; |
| "SUSE LINUX") |
| PACKAGEMANAGERS=(yast) |
| ;; |
| esac |
| fi |
| |
| if [ "$PACKAGEMANAGERS" ]; 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) |
| PACKAGEMANAGERS=(urpmi) |
| ;; |
| esac |
| fi |
| |
| if [ "$PACKAGEMANAGERS" ]; then |
| return |
| fi |
| |
| if [ -f "/etc/fedora-release" ] || [ -f "/etc/redhat-release" ]; then |
| PACKAGEMANAGERS=(yum) |
| elif [ -f "/etc/SuSE-release" ]; then |
| PACKAGEMANAGERS=(yast) |
| elif [ -f "/etc/mandriva-release" ]; then |
| PACKAGEMANAGERS=(urpmi) |
| fi |
| } |
| |
| DEFAULT_ARCH="@@ARCHITECTURE@@" |
| YUM_REPO_FILE="/etc/yum.repos.d/@@PACKAGE@@.repo" |
| ZYPPER_REPO_FILE="/etc/zypp/repos.d/@@PACKAGE@@.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 |
| [@@PACKAGE@@] |
| name=@@PACKAGE@@ |
| baseurl=$REPOCONFIG/$DEFAULT_ARCH |
| enabled=1 |
| gpgcheck=1 |
| gpgkey=https://dl.google.com/linux/linux_signing_key.pub |
| 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 "^@@PACKAGE@@$" |
| if [ "$?" -eq "0" ]; then |
| # Repository already configured |
| return 0 |
| fi |
| urpmi.addmedia --update \ |
| "@@PACKAGE@@" "$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 \ |
| # "@@PACKAGE@@" "$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" "@@PACKAGE@@" |
| # but that does not work when zypper is running. |
| if [ -d "/etc/zypp/repos.d" ]; then |
| cat > "$ZYPPER_REPO_FILE" << REPOCONTENT |
| [@@PACKAGE@@] |
| name=@@PACKAGE@@ |
| 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 "\b@@PACKAGE@@\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 |
| |
| for PACKAGEMANAGER in ${PACKAGEMANAGERS[*]} |
| do |
| case $PACKAGEMANAGER in |
| "yum") |
| update_repo_file "$YUM_REPO_FILE" |
| ;; |
| "yast") |
| update_repo_file "$ZYPPER_REPO_FILE" |
| ;; |
| "urpmi") |
| update_urpmi_cfg |
| ;; |
| esac |
| done |
| } |
| |
| 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 "\b@@PACKAGE@@\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 |
| REPOMATCH=$(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 "@@PACKAGE@@" && \ |
| urpmi.addmedia --update "@@PACKAGE@@" "$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 "@@PACKAGE@@" |
| # # 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 '\_^@@PACKAGE@@ $REPOCONFIG/$DEFAULT_ARCH {$_,/^}$/d' "$URPMI_REPO_FILE" |
| # fi |
| #} |
| # |
| #remove_yast() { |
| # # Ideally, we would run: zypper removerepo "@@PACKAGE@@" |
| # # but that does not work when zypper is running. |
| # rm -f /etc/zypp/repos.d/@@PACKAGE@@.repo |
| #} |
| |
| DEFAULT_ARCH="@@ARCHITECTURE@@" |
| |
| 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 |
| } |