~evfool/aptdaemon/lp1030988

« back to all changes in this revision

Viewing changes to aptdaemon/test.py

  • Committer: Sebastian Heinlein
  • Date: 2012-06-06 13:45:25 UTC
  • Revision ID: devel@glatzor.de-20120606134525-cc3sblva27gzwdsw
Use apt.auth for test chroots

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
import unittest
33
33
 
34
34
import apt_pkg
 
35
import apt.auth
35
36
 
36
37
PY3K = sys.version_info.major > 2
37
38
 
63
64
 
64
65
        # Make apt use the new chroot
65
66
        dpkg_wrapper = os.path.join(get_tests_dir(), "dpkg-wrapper.sh")
 
67
        apt_key_wrapper = os.path.join(get_tests_dir(), "fakeroot-apt-key")
66
68
        config_path = os.path.join(self.path, "etc/apt/apt.conf.d/10chroot")
67
69
        with open(config_path, "w") as cnf:
68
70
            cnf.write("Dir::Bin::DPkg %s;" % dpkg_wrapper)
 
71
            cnf.write("Dir::Bin::Apt-Key %s;" % apt_key_wrapper)
69
72
        apt_pkg.read_config_file(apt_pkg.config, config_path)
70
73
        apt_pkg.init_system()
71
74
 
78
81
 
79
82
    def add_trusted_key(self):
80
83
        """Add glatzor's key to the trusted ones."""
81
 
        proc = subprocess.Popen(["fakeroot", "apt-key", "--keyring",
82
 
                                 "%s/etc/apt/trusted.gpg " % self.path,
83
 
                                 "add", "-"], stdin=subprocess.PIPE)
84
 
        with open(os.path.join(get_tests_dir(), "repo/glatzor.gpg")) as keyfile:
85
 
            key = keyfile.read()
86
 
        proc.communicate(key.encode("UTF-8"))
 
84
        apt.auth.add_key_from_file(os.path.join(get_tests_dir(),
 
85
                                                "repo/glatzor.gpg"))
87
86
 
88
87
    def install_debfile(self, path, force_depends=False):
89
88
        """Install a package file into the chroot."""