Zhao Chao 8057b2d926 More reliable gpg keys importing in DIB elements
We're still seeing apt-key failed to import gpg keys these days during
the images building in the gate jobs, the problem is keys.gnupg.net and
keyserver.ubuntu.com are both not stable according to [1] and [2], it's
better to adopt pool.sks-keyservers.net instead and with simple retries.

To reduce code duplication, this common apt-key importing function is
also moved to ubuntu-guest as an environment snippet.

[1] https://www.gnupg.org/faq/gnupg-faq.html#new_user_default_keyserver
[2] https://sks-keyservers.net/overview-of-pools.php

Closes-Bug: #1579094

Change-Id: I0fe200d140f6f9c4d423dd498797a225e3295a71
Signed-off-by: Zhao Chao <zhaochao1984@gmail.com>
2018-07-16 12:03:16 +08:00

27 lines
702 B
Bash
Executable File

#!/bin/bash
# CONTEXT: GUEST during PRE-CONSTRUCTION as ROOT
# PURPOSE: Setup apt-repo list so that we can connect to Percona's repo
set -e
set -o xtrace
[ -n "${GUEST_USERNAME}" ] || die "GUEST_USERNAME needs to be set to the user for the guest image"
[ -n "${RELEASE}" ] || die "RELEASE must be set to either Trusty or Precise"
# Add Percona GPG key
mkdir -p /home/${GUEST_USERNAME}/.gnupg
get_key_robust 1C4CBDCDCD2EFD2A
get_key_robust 9334A25F8507EFA5
# Add Percona repo
# Creates the Percona sources list
cat <<EOL > /etc/apt/sources.list.d/percona.list
deb http://repo.percona.com/apt $RELEASE main
deb-src http://repo.percona.com/apt $RELEASE main
EOL
# Force an update
apt-get -y update