~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/archivepublisher/debian_installer.py

  • Committer: Steve Alexander
  • Date: 2006-08-23 14:18:50 UTC
  • mfrom: (3691.1.255 launchpad)
  • Revision ID: steve.alexander@canonical.com-20060823141850-59a63d2b6f9872ec
merge from rf

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
import stat
15
15
import shutil
16
16
 
17
 
from sourcerer.deb.version import Version as DebianVersion
 
17
from sourcerer.deb.version import Version as make_version
18
18
 
19
19
 
20
20
class DebianInstallerError(Exception):
28
28
        message = ('%s build %s for architecture %s already exists' %
29
29
                   (build_type, arch, version))
30
30
        DebianInstallerError.__init__(self, message)
31
 
        self.build_type = build_type
32
 
        self.arch = arch
33
 
        self.version = version
34
31
 
35
32
 
36
33
class DebianInstallerTarError(DebianInstallerError):
38
35
    def __init__(self, tarfile_path, tar_error):
39
36
        message = 'Problem reading tarfile %s: %s' % (tarfile_path, tar_error)
40
37
        DebianInstallerError.__init__(self, message)
41
 
        self.tarfile_path = tarfile_path
42
 
        self.tar_error = tar_error
43
38
 
44
39
 
45
40
class DebianInstallerInvalidTarfile(DebianInstallerError):
48
43
        message = ('Tarfile %s did not contain expected directory %s' %
49
44
                   (tarfile_path, expected_dir))
50
45
        DebianInstallerError.__init__(self, message)
51
 
        self.tarfile_path = tarfile_path
52
 
        self.expected_dir = expected_dir
53
46
 
54
47
 
55
48
def extract_filename_parts(tarfile_path):
61
54
    return tarfile_base, version, arch
62
55
 
63
56
 
64
 
def process_debian_installer(archive_root, tarfile_path, distrorelease,
65
 
                             make_version=DebianVersion):
66
 
    """Process a raw-installer tarfile, unpacking it into the given archive
67
 
    for the given distrorelease.
68
 
 
69
 
    make_version is a callable which converts version numbers into python
70
 
    objects which can be compared nicely. This defaults to sourcerer's version
71
 
    type for deb packages. It does exactly what we want for now.
72
 
 
 
57
def process_debian_installer(archive_root, tarfile_path, distrorelease):
 
58
    """Process a raw-installer tarfile.
 
59
 
 
60
    Unpacking it into the given archive for the given distrorelease.
73
61
    Raises DebianInstallerError (or some subclass thereof) if anything goes
74
62
    wrong.
75
63
    """
127
115
    # Get an appropriately-sorted list of the installer directories now
128
116
    # present in the target.
129
117
    versions = [inst for inst in os.listdir(target) if inst != 'current']
130
 
    if make_version is not None:
131
 
        versions.sort(key=make_version, reverse=True)
132
 
    else:
133
 
        versions.reverse()
 
118
    versions.sort(key=make_version, reverse=True)
134
119
 
135
120
    # Make sure the 'current' symlink points to the most recent version
136
121
    # The most recent version is in versions[0]