summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-06-05 11:43:43 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2012-06-05 11:43:43 +0200
commita8ec7c4c6430e69953ea8f8f3925d1b0fb4ac63a (patch)
treef0314c312e3428fe63180de588f59e7bb9552a72
parent621372f543a4d0547f3637889da11665b628df14 (diff)
downloadpython-apt-a8ec7c4c6430e69953ea8f8f3925d1b0fb4ac63a.tar.gz
apt/auth.py: create _TMPDIR on demand
-rw-r--r--apt/auth.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/apt/auth.py b/apt/auth.py
index 04aae908..d8c602fa 100644
--- a/apt/auth.py
+++ b/apt/auth.py
@@ -36,8 +36,7 @@ from apt_pkg import gettext as _
# Create a temporary dir to store secret keying and trust database.
# APT doesn't use a secrect key ring but GnuPG fails without it.
-_TMPDIR = tempfile.mkdtemp()
-atexit.register(shutil.rmtree, _TMPDIR)
+_TMPDIR = None
class TrustedKey(object):
@@ -57,6 +56,10 @@ class TrustedKey(object):
def _get_gpg_command(keyring=None):
"""Return the gpg command"""
+ global _TMPDIR
+ if _TMPDIR is None:
+ _TMPDIR = tempfile.mkdtemp()
+ atexit.register(shutil.rmtree, _TMPDIR)
cmd = [apt_pkg.config.find_file("Dir::Bin::Gpg", "/usr/bin/gpg"),
"--ignore-time-conflict",
"--no-default-keyring",