1
# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
1
# Copyright 2009 Canonical Ltd. This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
4
"""Specific models for uploaded files"""
19
19
'splitComponentAndSection',
24
from debian.deb822 import Deb822Dict
30
from debian.deb822 import Deb822Dict
31
31
from zope.component import getUtility
33
from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
33
34
from canonical.librarian.utils import filechunks
34
35
from lp.app.errors import NotFoundError
35
36
from lp.archiveuploader.utils import (
47
48
from lp.buildmaster.enums import BuildStatus
48
49
from lp.services.encoding import guess as guess_encoding
49
from lp.services.librarian.interfaces import ILibraryFileAliasSet
50
50
from lp.soyuz.enums import (
51
51
BinaryPackageFormat,
52
52
PackagePublishingPriority,
706
706
yield UploadError(
707
707
"%s: second chunk is %s, expected control.tar.gz." % (
708
708
self.filename, control_tar))
709
if data_tar not in ("data.tar.gz", "data.tar.bz2", "data.tar.lzma",
709
if data_tar not in ("data.tar.gz", "data.tar.bz2", "data.tar.lzma"):
711
710
yield UploadError(
712
711
"%s: third chunk is %s, expected data.tar.gz, "
713
"data.tar.bz2, data.tar.lzma or data.tar.xz." %
714
(self.filename, data_tar))
716
# xz-compressed debs must pre-depend on dpkg >= 1.15.6~.
717
XZ_REQUIRED_DPKG_VER = '1.15.6~'
718
if data_tar == "data.tar.xz":
721
parsed_deps = apt_pkg.ParseDepends(
722
self.control['Pre-Depends'])
723
except (ValueError, TypeError):
725
"Can't parse Pre-Depends in the control file.")
728
# Go past the for loop and yield the error below.
731
for token in parsed_deps:
733
name, version, relation = token[0]
735
yield("APT error processing token '%r' from Pre-Depends.")
739
# VersionCompare returns values similar to cmp;
740
# negative if first < second, zero if first ==
741
# second and positive if first > second.
742
if apt_pkg.VersionCompare(
743
version, XZ_REQUIRED_DPKG_VER) >= 0:
744
# Pre-Depends dpkg is fine.
748
"Pre-Depends dpkg version should be >= %s "
749
"when using xz compression." %
750
XZ_REQUIRED_DPKG_VER)
754
"Require Pre-Depends: dpkg (>= %s) when using xz "
755
"compression." % XZ_REQUIRED_DPKG_VER)
712
"data.tar.bz2 or data.tar.lzma." % (self.filename, data_tar))
757
714
def verifyDebTimestamp(self):
758
715
"""Check specific DEB format timestamp checks."""
770
727
"control.tar.gz")
771
728
# Only one of these files is present in the archive, so loop
772
729
# until we find one of them, otherwise fail.
773
data_files = ("data.tar.gz", "data.tar.bz2", "data.tar.lzma",
730
data_files = ("data.tar.gz", "data.tar.bz2", "data.tar.lzma")
775
731
for file in data_files:
848
805
"Unable to find source package %s/%s in %s" % (
849
806
self.source_name, self.source_version, distroseries.name))
851
809
def verifySourcePackageRelease(self, sourcepackagerelease):
852
810
"""Check if the given ISourcePackageRelease matches the context."""
853
811
assert 'source' in self.changes.architectures, (