← Back to team overview

ubuntu-bugcontrol team mailing list archive

[Merge] ~alexmurray/ubuntu-qa-tools:uvt-remove-use-of-apt-key into ubuntu-qa-tools:master

 

Alex Murray has proposed merging ~alexmurray/ubuntu-qa-tools:uvt-remove-use-of-apt-key into ubuntu-qa-tools:master.

Commit message:
uvt: remove use of apt-key since it fails now on plucky

Instead import the key to a temporary GPG keyring then export it to
/etc/apt/trusted.gpg.d/uvt.gpg to ensure it is in the format expected by apt
etc.

Signed-off-by: Alex Murray <alex.murray@xxxxxxxxxxxxx>



Requested reviews:
  Ubuntu Bug Control (ubuntu-bugcontrol)

For more details, see:
https://code.launchpad.net/~alexmurray/ubuntu-qa-tools/+git/ubuntu-qa-tools/+merge/481529
-- 
Your team Ubuntu Bug Control is requested to review the proposed merge of ~alexmurray/ubuntu-qa-tools:uvt-remove-use-of-apt-key into ubuntu-qa-tools:master.
diff --git a/vm-tools/uvt b/vm-tools/uvt
index 8b6e326..33bcdaf 100755
--- a/vm-tools/uvt
+++ b/vm-tools/uvt
@@ -1198,7 +1198,11 @@ def vm_import_public_key(vm_name, key):
     if key is None:
         return False
 
-    command = "bash -c 'echo \"%(key)s\" | apt-key add -'" % { 'key': key }
+    # import then export key to ensure it is in the right format
+    command = ("bash -c 'echo \"%(key)s\" | gpg --no-default-keyring " +
+               "--keyring /tmp/key.gpg --import - && " +
+               "gpg --no-default-keyring --keyring /tmp/key.gpg --export --output /etc/apt/trusted.gpg.d/uvt.gpg &&"
+               "rm -f /tmp/key.gpg'") % { 'key': key }
     result = vm_run_command(vm_name, command, root=True, force_keys=True)
     if result == True:
         command = ("bash -c 'echo \"%(key)s\" | gpg --no-default-keyring " +
@@ -2783,8 +2787,8 @@ sed -i "s/^Prompt=.*$/Prompt=never/" /etc/update-manager/release-upgrades || tru
     key = get_gpg_public_key()
     if key is not None:
         post_script += r'''
-echo "%(key)s" | apt-key add - || true
-''' % { 'key': key }
+# import then export key to ensure it is in the right format
+echo "%(key)s" | gpg --no-default-keyring --keyring /tmp/key.gpg --import - && gpg --no-default-keyring --keyring /tmp/key.gpg --export --output /etc/apt/trusted.gpg.d/uvt.gpg && rm -f /tmp/key.gpg''' % { 'key': key }
 
     post_script += r'''
 apt-get clean

Follow ups