Merge lp:~jelmer/launchpad/sync-tbz2 into lp:launchpad/db-devel

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~jelmer/launchpad/sync-tbz2
Merge into: lp:launchpad/db-devel
Diff against target: 916 lines (+303/-297)
7 files modified
lib/canonical/launchpad/scripts/logger.py (+1/-1)
lib/lp/soyuz/scripts/ftpmaster.py (+27/-27)
lib/lp/soyuz/scripts/tests/sync_source_home/Debian_incoming_main_Sources (+28/-0)
lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0-1.dsc (+37/-0)
lib/lp/soyuz/scripts/tests/test_sync_source.py (+105/-28)
scripts/ftpmaster-tools/dak_utils.py (+3/-153)
scripts/ftpmaster-tools/sync-source.py (+102/-88)
To merge this branch: bzr merge lp:~jelmer/launchpad/sync-tbz2
Reviewer Review Type Date Requested Status
Guilherme Salgado (community) code Approve
Review via email: mp+18615@code.launchpad.net

Commit message

Fixes support for syncing packages in the the version 3 source format.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Fixes support for syncing packages in the the version 3 source format (bug 225151).

This patch adds support for .orig.tar.bz2 files as well as multiple component orig tarballs in the script that syncs source packages from Debian. These new file formats are used by the new Debian source package format, v3.0.

This branch also refactors sync-source.py to use code from lp.soyuz.scripts.ftpmaster (well unit tested) rather its local copy (no tests). It also removes duplicate code for parsing dsc files from lp.soyuz.scripts.dak_utils in favor of the Dsc parser in debian_bundle.deb822.

Revision history for this message
Guilherme Salgado (salgado) wrote :
Download full text (10.4 KiB)

Hi Jelmer,

I have just a few comments/questions below, but this looks good. And
thanks a lot for getting rid of the untested/duplicated code.

 review approve code

On Thu, 2010-02-04 at 16:24 +0000, Jelmer Vernooij wrote:

> === modified file 'lib/canonical/launchpad/scripts/logger.py'
> --- lib/canonical/launchpad/scripts/logger.py 2009-10-16 18:07:01 +0000
> +++ lib/canonical/launchpad/scripts/logger.py 2010-02-04 16:24:23 +0000
[...]
> @@ -847,19 +854,14 @@
> Return the fetched filename if it was present in Librarian or None
> if it wasn't.
> """
> - # XXX cprov 2007-01-10 bug=78683: Looking for files within ubuntu
> - # only. It doesn't affect the usual sync-source procedure. However
> - # it needs to be revisited for derivation, we probably need
> - # to pass the target distribution in order to make proper lookups.
> - ubuntu = getUtility(IDistributionSet)['ubuntu']

Does this mean the bug above will be fixed too?

> try:
> - libraryfilealias = ubuntu.getFileByName(
> + libraryfilealias = self.todistro.getFileByName(
> filename, source=True, binary=False)
> except NotFoundError:
> return None
>
> - self.debug(
> - "\t%s: already in distro - downloading from librarian" %
> + self.logger.info(
> + "%s: already in distro - downloading from librarian" %
> filename)
>
> output_file = open(filename, 'w')
> @@ -871,23 +873,23 @@
> """Try to fetch files from Librarian.
>
> It raises SyncSourceError if anything else then an
> - 'orig.tar.gz' was found in Librarian.
> - Return a boolean indicating whether or not the 'orig.tar.gz' is
> - required in the upload.
> + orig tarball was found in Librarian.
> + Return the names of the files retrieved from the librarian.
> """
> - orig_filename = None
> + retrieved = []
> for filename in self.files.keys():
> if not self.fetchFileFromLibrarian(filename):
> continue
> + file_type = determine_source_file_type(filename)
> # set the return code if an orig was, in fact,
> # fetched from Librarian
> - if filename.endswith("orig.tar.gz"):
> - orig_filename = filename
> - else:
> + if not file_type in (SourcePackageFileType.ORIG_TARBALL,
> + SourcePackageFileType.COMPONENT_ORIG_TARBALL):

The indentation above is a bit odd; the two elements of the tuple should
be lined up.

> raise SyncSourceError(
> - 'Oops, only orig.tar.gz can be retrieved from librarian')
> + 'Oops, only orig tarball can be retrieved from librarian.')
> + retrieved.append(filename)
>
> - return orig_filename
> + return retrieved
>
> def fetchSyncFiles(self):
> """Fetch files from the original sync source.

>
> === modified file 'scripts/ftpmaster-tools/sync-source.py'
> --- scripts/ftpmaster-tools/sync-source.py 2010-02...

review: Approve (code)
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Hi Guilherme,

Thanks for the review.

On Fri, 2010-02-05 at 17:48 +0000, Guilherme Salgado wrote:
> On Thu, 2010-02-04 at 16:24 +0000, Jelmer Vernooij wrote:
> > === modified file 'lib/canonical/launchpad/scripts/logger.py'
> > --- lib/canonical/launchpad/scripts/logger.py 2009-10-16 18:07:01 +0000
> > +++ lib/canonical/launchpad/scripts/logger.py 2010-02-04 16:24:23 +0000
> [...]
> > @@ -847,19 +854,14 @@
> > Return the fetched filename if it was present in Librarian or None
> > if it wasn't.
> > """
> > - # XXX cprov 2007-01-10 bug=78683: Looking for files within ubuntu
> > - # only. It doesn't affect the usual sync-source procedure. However
> > - # it needs to be revisited for derivation, we probably need
> > - # to pass the target distribution in order to make proper lookups.
> > - ubuntu = getUtility(IDistributionSet)['ubuntu']
> Does this mean the bug above will be fixed too?
Partially - bug 78683 is about sync-source only working with Ubuntu, and
this change gets us further in that direction but there are still some
places where we hardcode 'ubuntu' in scripts/ftp-master/sync-source.py.

I've addressed the style issue you've raised and I'll ec2 land after I
finish testing on dogfood.

Cheers,

Jelmer

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/scripts/logger.py'
--- lib/canonical/launchpad/scripts/logger.py 2009-10-16 18:07:01 +0000
+++ lib/canonical/launchpad/scripts/logger.py 2010-02-11 16:55:27 +0000
@@ -5,7 +5,7 @@
55
6"""Logging setup for scripts.6"""Logging setup for scripts.
77
8Don't import from this module. Import it from canonical.scripts.8Don't import from this module. Import it from canonical.launchpad.scripts.
99
10Parts of this may be moved into canonical.launchpad somewhere if it is10Parts of this may be moved into canonical.launchpad somewhere if it is
11to be used for non-script stuff.11to be used for non-script stuff.
1212
=== modified file 'lib/lp/soyuz/scripts/ftpmaster.py'
--- lib/lp/soyuz/scripts/ftpmaster.py 2009-12-13 11:55:40 +0000
+++ lib/lp/soyuz/scripts/ftpmaster.py 2010-02-11 16:55:27 +0000
@@ -36,11 +36,14 @@
36from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities36from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
37from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet37from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
38from canonical.launchpad.webapp.interfaces import NotFoundError38from canonical.launchpad.webapp.interfaces import NotFoundError
39from lp.archiveuploader.utils import (
40 determine_source_file_type)
39from lp.registry.interfaces.distribution import IDistributionSet41from lp.registry.interfaces.distribution import IDistributionSet
40from lp.registry.interfaces.series import SeriesStatus42from lp.registry.interfaces.series import SeriesStatus
41from lp.registry.interfaces.person import IPersonSet43from lp.registry.interfaces.person import IPersonSet
42from lp.registry.interfaces.pocket import (44from lp.registry.interfaces.pocket import (
43 PackagePublishingPocket, pocketsuffix)45 PackagePublishingPocket, pocketsuffix)
46from lp.registry.interfaces.sourcepackage import SourcePackageFileType
44from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet47from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet
45from lp.soyuz.interfaces.binarypackagerelease import IBinaryPackageReleaseSet48from lp.soyuz.interfaces.binarypackagerelease import IBinaryPackageReleaseSet
46from lp.soyuz.interfaces.publishing import PackagePublishingStatus49from lp.soyuz.interfaces.publishing import PackagePublishingStatus
@@ -803,12 +806,14 @@
803 pocket_chroot.chroot.open()806 pocket_chroot.chroot.open()
804 copy_and_close(pocket_chroot.chroot, local_file)807 copy_and_close(pocket_chroot.chroot, local_file)
805808
809
806class SyncSourceError(Exception):810class SyncSourceError(Exception):
807 """Raised when an critical error occurs inside SyncSource.811 """Raised when an critical error occurs inside SyncSource.
808812
809 The entire procedure should be aborted in order to avoid unknown problems.813 The entire procedure should be aborted in order to avoid unknown problems.
810 """814 """
811815
816
812class SyncSource:817class SyncSource:
813 """Sync Source procedure helper class.818 """Sync Source procedure helper class.
814819
@@ -818,20 +823,22 @@
818 'aptMD5Sum' is provided as a classmethod during the integration time.823 'aptMD5Sum' is provided as a classmethod during the integration time.
819 """824 """
820825
821 def __init__(self, files, origin, debug, downloader):826 def __init__(self, files, origin, logger, downloader, todistro):
822 """Store local context.827 """Store local context.
823828
824 files: a dictionary where the keys are the filename and the829 files: a dictionary where the keys are the filename and the
825 value another dictionary with the file informations.830 value another dictionary with the file informations.
826 origin: a dictionary similar to 'files' but where the values831 origin: a dictionary similar to 'files' but where the values
827 contain information for download files to be synchronized832 contain information for download files to be synchronized
828 debug: a debug function, 'debug(message)'833 logger: a logger
829 downloader: a callable that fetchs URLs, 'downloader(url, destination)'834 downloader: a callable that fetchs URLs, 'downloader(url, destination)'
835 todistro: target distribution object
830 """836 """
831 self.files = files837 self.files = files
832 self.origin = origin838 self.origin = origin
833 self.debug = debug839 self.logger = logger
834 self.downloader = downloader840 self.downloader = downloader
841 self.todistro = todistro
835842
836 @classmethod843 @classmethod
837 def generateMD5Sum(self, filename):844 def generateMD5Sum(self, filename):
@@ -847,19 +854,14 @@
847 Return the fetched filename if it was present in Librarian or None854 Return the fetched filename if it was present in Librarian or None
848 if it wasn't.855 if it wasn't.
849 """856 """
850 # XXX cprov 2007-01-10 bug=78683: Looking for files within ubuntu
851 # only. It doesn't affect the usual sync-source procedure. However
852 # it needs to be revisited for derivation, we probably need
853 # to pass the target distribution in order to make proper lookups.
854 ubuntu = getUtility(IDistributionSet)['ubuntu']
855 try:857 try:
856 libraryfilealias = ubuntu.getFileByName(858 libraryfilealias = self.todistro.getFileByName(
857 filename, source=True, binary=False)859 filename, source=True, binary=False)
858 except NotFoundError:860 except NotFoundError:
859 return None861 return None
860862
861 self.debug(863 self.logger.info(
862 "\t%s: already in distro - downloading from librarian" %864 "%s: already in distro - downloading from librarian" %
863 filename)865 filename)
864866
865 output_file = open(filename, 'w')867 output_file = open(filename, 'w')
@@ -871,23 +873,23 @@
871 """Try to fetch files from Librarian.873 """Try to fetch files from Librarian.
872874
873 It raises SyncSourceError if anything else then an875 It raises SyncSourceError if anything else then an
874 'orig.tar.gz' was found in Librarian.876 orig tarball was found in Librarian.
875 Return a boolean indicating whether or not the 'orig.tar.gz' is877 Return the names of the files retrieved from the librarian.
876 required in the upload.
877 """878 """
878 orig_filename = None879 retrieved = []
879 for filename in self.files.keys():880 for filename in self.files.keys():
880 if not self.fetchFileFromLibrarian(filename):881 if not self.fetchFileFromLibrarian(filename):
881 continue882 continue
883 file_type = determine_source_file_type(filename)
882 # set the return code if an orig was, in fact,884 # set the return code if an orig was, in fact,
883 # fetched from Librarian885 # fetched from Librarian
884 if filename.endswith("orig.tar.gz"):886 if not file_type in (SourcePackageFileType.ORIG_TARBALL,
885 orig_filename = filename887 SourcePackageFileType.COMPONENT_ORIG_TARBALL):
886 else:
887 raise SyncSourceError(888 raise SyncSourceError(
888 'Oops, only orig.tar.gz can be retrieved from librarian')889 'Oops, only orig tarball can be retrieved from librarian.')
890 retrieved.append(filename)
889891
890 return orig_filename892 return retrieved
891893
892 def fetchSyncFiles(self):894 def fetchSyncFiles(self):
893 """Fetch files from the original sync source.895 """Fetch files from the original sync source.
@@ -896,21 +898,19 @@
896 """898 """
897 dsc_filename = None899 dsc_filename = None
898 for filename in self.files.keys():900 for filename in self.files.keys():
901 file_type = determine_source_file_type(filename)
902 if file_type == SourcePackageFileType.DSC:
903 dsc_filename = filename
899 if os.path.exists(filename):904 if os.path.exists(filename):
905 self.logger.info(" - <%s: cached>" % (filename))
900 continue906 continue
901 self.debug(907 self.logger.info(
902 " - <%s: downloading from %s>" %908 " - <%s: downloading from %s>" %
903 (filename, self.origin["url"]))909 (filename, self.origin["url"]))
904 download_f = ("%s%s" % (self.origin["url"],910 download_f = ("%s%s" % (self.origin["url"],
905 self.files[filename]["remote filename"]))911 self.files[filename]["remote filename"]))
906 sys.stdout.flush()912 sys.stdout.flush()
907 self.downloader(download_f, filename)913 self.downloader(download_f, filename)
908 # only set the dsc_filename if the DSC was really downloaded.
909 # this loop usually includes the other files for the upload,
910 # DIFF and ORIG.
911 if filename.endswith(".dsc"):
912 dsc_filename = filename
913
914 return dsc_filename914 return dsc_filename
915915
916 def checkDownloadedFiles(self):916 def checkDownloadedFiles(self):
917917
=== modified file 'lib/lp/soyuz/scripts/tests/sync_source_home/Debian_incoming_main_Sources'
--- lib/lp/soyuz/scripts/tests/sync_source_home/Debian_incoming_main_Sources 2008-02-14 12:38:50 +0000
+++ lib/lp/soyuz/scripts/tests/sync_source_home/Debian_incoming_main_Sources 2010-02-11 16:55:27 +0000
@@ -10,3 +10,31 @@
10 fc1464e5985b962a042d5354452f361d 164 bar_1.0.orig.tar.gz10 fc1464e5985b962a042d5354452f361d 164 bar_1.0.orig.tar.gz
11 a259bf88aedcdeded4e5d94ad4af3b4a 610 bar_1.0-1.diff.gz11 a259bf88aedcdeded4e5d94ad4af3b4a 610 bar_1.0-1.diff.gz
1212
13Format: 3.0 (quilt)
14Package: sample1
15Binary: sample1
16Architecture: all
17Version: 1.0-1
18Maintainer: Raphael Hertzog <hertzog@debian.org>
19Standards-Version: 3.8.1
20Checksums-Sha1:
21 724e3cdad5f4af13383e5d71f525465add1ce897 1741 sample1_1.0-1.dsc
22 296cb89762668772c3ae4799bd9ce7973f4154b2 171 sample1_1.0.orig-component1.tar.bz2
23 ccb198be27c065880696cbeb6fb5aebf190c8544 157 sample1_1.0.orig-component2.tar.lzma
24 ea3c0c6ee23410a9c454d9b35681a80460343456 201 sample1_1.0.orig-component3.tar.gz
25 c62b2496d3ff0c64dcf6488c95e1d5cbc9f5f30d 201 sample1_1.0.orig.tar.gz
26 b3c92ffaabc2e3e95e5f74e1de94351fddcb065c 1327 sample1_1.0-1.debian.tar.gz
27Checksums-Sha256:
28 d5390b56d3d5ea301bb565487eded8a6739d29ea5d680389f35b87b30f846412 1741 sample1_1.0-1.dsc
29 a0871b73922a228ef8c1f4c1a7e1aef94d8a59d919218242655b7faae352d5c9 171 sample1_1.0.orig-component1.tar.bz2
30 39963ed90d70e918a6cae8d73c81f42dcb7f0dc283a4715f032a1e28b98d1a25 157 sample1_1.0.orig-component2.tar.lzma
31 dc174acae810faf5f9a679e042f480905622fe4a854510dad6e200dbe6381c8d 201 sample1_1.0.orig-component3.tar.gz
32 9c0f0b42f6283614b204a47600cb9b0d8b19dfa4cb43c69e6a0a40f3d1064e0e 201 sample1_1.0.orig.tar.gz
33 6864ceeb315ad7b6a59636a0251525cbd8e9b76c6e934f3746271d4ebce5da3c 1327 sample1_1.0-1.debian.tar.gz
34Files:
35 aea108574786aa670dc5ef26dc225be2 1741 sample1_1.0-1.dsc
36 8a90ee77cf3c68c32bdb5c55d40d06f4 171 sample1_1.0.orig-component1.tar.bz2
37 3535d4766df47e531372802a0c2ddb82 157 sample1_1.0.orig-component2.tar.lzma
38 673b42066e8e858208b5d0c7a006c5fb 201 sample1_1.0.orig-component3.tar.gz
39 9047a93bf12a7c749045e9bc9ff9ee99 201 sample1_1.0.orig.tar.gz
40 9404bc99cdb06876a988d4c2262c073e 1327 sample1_1.0-1.debian.tar.gz
1341
=== added file 'lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0-1.debian.tar.gz'
14Binary files lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0-1.debian.tar.gz 1970-01-01 00:00:00 +0000 and lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0-1.debian.tar.gz 2010-02-11 16:55:27 +0000 differ42Binary files lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0-1.debian.tar.gz 1970-01-01 00:00:00 +0000 and lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0-1.debian.tar.gz 2010-02-11 16:55:27 +0000 differ
=== added file 'lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0-1.dsc'
--- lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0-1.dsc 1970-01-01 00:00:00 +0000
+++ lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0-1.dsc 2010-02-11 16:55:27 +0000
@@ -0,0 +1,37 @@
1-----BEGIN PGP SIGNED MESSAGE-----
2Hash: SHA1
3
4Format: 3.0 (quilt)
5Source: sample1
6Binary: sample1
7Architecture: all
8Version: 1.0-1
9Maintainer: Raphael Hertzog <hertzog@debian.org>
10Standards-Version: 3.8.1
11Build-Depends: quilt, debhelper (>= 7)
12Checksums-Sha1:
13 296cb89762668772c3ae4799bd9ce7973f4154b2 171 sample1_1.0.orig-component1.tar.bz2
14 ccb198be27c065880696cbeb6fb5aebf190c8544 157 sample1_1.0.orig-component2.tar.lzma
15 ea3c0c6ee23410a9c454d9b35681a80460343456 201 sample1_1.0.orig-component3.tar.gz
16 c62b2496d3ff0c64dcf6488c95e1d5cbc9f5f30d 201 sample1_1.0.orig.tar.gz
17 b3c92ffaabc2e3e95e5f74e1de94351fddcb065c 1327 sample1_1.0-1.debian.tar.gz
18Checksums-Sha256:
19 a0871b73922a228ef8c1f4c1a7e1aef94d8a59d919218242655b7faae352d5c9 171 sample1_1.0.orig-component1.tar.bz2
20 39963ed90d70e918a6cae8d73c81f42dcb7f0dc283a4715f032a1e28b98d1a25 157 sample1_1.0.orig-component2.tar.lzma
21 dc174acae810faf5f9a679e042f480905622fe4a854510dad6e200dbe6381c8d 201 sample1_1.0.orig-component3.tar.gz
22 9c0f0b42f6283614b204a47600cb9b0d8b19dfa4cb43c69e6a0a40f3d1064e0e 201 sample1_1.0.orig.tar.gz
23 6864ceeb315ad7b6a59636a0251525cbd8e9b76c6e934f3746271d4ebce5da3c 1327 sample1_1.0-1.debian.tar.gz
24Files:
25 8a90ee77cf3c68c32bdb5c55d40d06f4 171 sample1_1.0.orig-component1.tar.bz2
26 3535d4766df47e531372802a0c2ddb82 157 sample1_1.0.orig-component2.tar.lzma
27 673b42066e8e858208b5d0c7a006c5fb 201 sample1_1.0.orig-component3.tar.gz
28 9047a93bf12a7c749045e9bc9ff9ee99 201 sample1_1.0.orig.tar.gz
29 9404bc99cdb06876a988d4c2262c073e 1327 sample1_1.0-1.debian.tar.gz
30
31-----BEGIN PGP SIGNATURE-----
32Version: GnuPG v1.4.10 (GNU/Linux)
33
34iEYEARECAAYFAktq7/kACgkQPa9Uoh7vUnahEQCgmRTupXtrHegzFOb5jQMOCSXS
35/p4AoIroJtmjVryFpWqAABZTFGjeWo85
36=vwh8
37-----END PGP SIGNATURE-----
038
=== added file 'lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component1.tar.bz2'
1Binary files lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component1.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component1.tar.bz2 2010-02-11 16:55:27 +0000 differ39Binary files lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component1.tar.bz2 1970-01-01 00:00:00 +0000 and lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component1.tar.bz2 2010-02-11 16:55:27 +0000 differ
=== added file 'lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component2.tar.lzma'
2Binary files lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component2.tar.lzma 1970-01-01 00:00:00 +0000 and lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component2.tar.lzma 2010-02-11 16:55:27 +0000 differ40Binary files lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component2.tar.lzma 1970-01-01 00:00:00 +0000 and lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component2.tar.lzma 2010-02-11 16:55:27 +0000 differ
=== added file 'lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component3.tar.gz'
3Binary files lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component3.tar.gz 1970-01-01 00:00:00 +0000 and lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component3.tar.gz 2010-02-11 16:55:27 +0000 differ41Binary files lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component3.tar.gz 1970-01-01 00:00:00 +0000 and lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig-component3.tar.gz 2010-02-11 16:55:27 +0000 differ
=== added file 'lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig.tar.gz'
4Binary files lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig.tar.gz 1970-01-01 00:00:00 +0000 and lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig.tar.gz 2010-02-11 16:55:27 +0000 differ42Binary files lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig.tar.gz 1970-01-01 00:00:00 +0000 and lib/lp/soyuz/scripts/tests/sync_source_home/sample1_1.0.orig.tar.gz 2010-02-11 16:55:27 +0000 differ
=== modified file 'lib/lp/soyuz/scripts/tests/test_sync_source.py'
--- lib/lp/soyuz/scripts/tests/test_sync_source.py 2009-06-25 04:06:00 +0000
+++ lib/lp/soyuz/scripts/tests/test_sync_source.py 2010-02-11 16:55:27 +0000
@@ -1,7 +1,7 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""ChrootManager facilities tests."""4"""SyncSource facilities tests."""
55
6__metaclass__ = type6__metaclass__ = type
77
@@ -12,11 +12,15 @@
12import tempfile12import tempfile
13from unittest import TestCase, TestLoader13from unittest import TestCase, TestLoader
1414
15from lp.archiveuploader.tagfiles import parse_tagfile15from zope.component import getUtility
16
16from canonical.config import config17from canonical.config import config
18from canonical.launchpad.scripts import BufferLogger
17from canonical.librarian.ftests.harness import (19from canonical.librarian.ftests.harness import (
18 fillLibrarianFile, cleanupLibrarianFiles)20 fillLibrarianFile, cleanupLibrarianFiles)
19from canonical.testing import LaunchpadZopelessLayer21from canonical.testing import LaunchpadZopelessLayer
22from lp.archiveuploader.tagfiles import parse_tagfile
23from lp.registry.interfaces.distribution import IDistributionSet
20from lp.soyuz.scripts.ftpmaster import (24from lp.soyuz.scripts.ftpmaster import (
21 SyncSource, SyncSourceError)25 SyncSource, SyncSourceError)
2226
@@ -37,7 +41,7 @@
37 self._home = os.path.abspath('')41 self._home = os.path.abspath('')
38 self._jail = tempfile.mkdtemp()42 self._jail = tempfile.mkdtemp()
39 os.chdir(self._jail)43 os.chdir(self._jail)
40 self.messages = []44 self.logger = BufferLogger()
41 self.downloads = []45 self.downloads = []
4246
43 def tearDown(self):47 def tearDown(self):
@@ -54,9 +58,9 @@
54 """Return a list of files present in jail."""58 """Return a list of files present in jail."""
55 return os.listdir(self._jail)59 return os.listdir(self._jail)
5660
57 def local_debug(self, message):61 def get_messages(self):
58 """Store debug messages for future inspection."""62 """Retrieve the messages sent using the logger."""
59 self.messages.append(message)63 return self.logger.buffer.getvalue().splitlines()
6064
61 def local_downloader(self, url, filename):65 def local_downloader(self, url, filename):
62 """Store download requests for future inspections."""66 """Store download requests for future inspections."""
@@ -72,8 +76,9 @@
72 them later.76 them later.
73 """77 """
74 sync_source = SyncSource(78 sync_source = SyncSource(
75 files=files, origin=origin, debug=self.local_debug,79 files=files, origin=origin, logger=self.logger,
76 downloader=self.local_downloader)80 downloader=self.local_downloader,
81 todistro=getUtility(IDistributionSet)['ubuntu'])
77 return sync_source82 return sync_source
7883
79 def testInstantiate(self):84 def testInstantiate(self):
@@ -86,8 +91,8 @@
86 self.assertEqual(sync_source.files, files)91 self.assertEqual(sync_source.files, files)
87 self.assertEqual(sync_source.origin, origin)92 self.assertEqual(sync_source.origin, origin)
8893
89 sync_source.debug('opa')94 sync_source.logger.debug('opa')
90 self.assertEqual(self.messages, ['opa'])95 self.assertEqual(self.get_messages(), ['DEBUG: opa'])
9196
92 sync_source.downloader('somewhere', 'foo')97 sync_source.downloader('somewhere', 'foo')
93 self.assertEqual(self.downloads, [('somewhere', 'foo')])98 self.assertEqual(self.downloads, [('somewhere', 'foo')])
@@ -159,26 +164,26 @@
159 test_file is skipped.164 test_file is skipped.
160 """165 """
161 files = {166 files = {
162 'foo.diff.gz': {'remote filename': 'xxx'},167 'foo_0.1.diff.gz': {'remote filename': 'xxx'},
163 'foo.dsc': {'remote filename': 'yyy'},168 'foo_0.1.dsc': {'remote filename': 'yyy'},
164 'foo.orig.gz': {'remote filename': 'zzz'},169 'foo_0.1.orig.gz': {'remote filename': 'zzz'},
165 }170 }
166 origin = {'url': 'http://somewhere/'}171 origin = {'url': 'http://somewhere/'}
167172
168 sync_source = self._getSyncSource(files, origin)173 sync_source = self._getSyncSource(files, origin)
169174
170 test_file = open('foo.diff.gz', 'w')175 test_file = open('foo_0.1.diff.gz', 'w')
171 test_file.write('nahhh')176 test_file.write('nahhh')
172 test_file.close()177 test_file.close()
173178
174 dsc_filename = sync_source.fetchSyncFiles()179 dsc_filename = sync_source.fetchSyncFiles()
175180
176 self.assertEqual(dsc_filename, 'foo.dsc')181 self.assertEqual(dsc_filename, 'foo_0.1.dsc')
177182
178 self.assertEqual(183 self.assertEqual(
179 self.downloads,184 self.downloads,
180 [('http://somewhere/yyy', 'foo.dsc'),185 [('http://somewhere/zzz', 'foo_0.1.orig.gz'),
181 ('http://somewhere/zzz', 'foo.orig.gz')])186 ('http://somewhere/yyy', 'foo_0.1.dsc')])
182187
183 for filename in files.keys():188 for filename in files.keys():
184 self.assertTrue(os.path.exists(filename))189 self.assertTrue(os.path.exists(filename))
@@ -196,13 +201,13 @@
196 origin = {}201 origin = {}
197 sync_source = self._getSyncSource(files, origin)202 sync_source = self._getSyncSource(files, origin)
198203
199 orig_filename = sync_source.fetchLibrarianFiles()204 librarian_files = sync_source.fetchLibrarianFiles()
200205
201 self.assertEqual(orig_filename, 'netapplet_1.0.0.orig.tar.gz')206 self.assertEqual(librarian_files, ['netapplet_1.0.0.orig.tar.gz'])
202 self.assertEqual(self._listFiles(), ['netapplet_1.0.0.orig.tar.gz'])207 self.assertEqual(self._listFiles(), ['netapplet_1.0.0.orig.tar.gz'])
203 self.assertEqual(208 self.assertEqual(
204 self.messages,209 self.get_messages(),
205 ['\tnetapplet_1.0.0.orig.tar.gz: already in distro '210 ['INFO: netapplet_1.0.0.orig.tar.gz: already in distro '
206 '- downloading from librarian'])211 '- downloading from librarian'])
207212
208 def testFetchLibrarianFilesGotDuplicatedDSC(self):213 def testFetchLibrarianFilesGotDuplicatedDSC(self):
@@ -224,8 +229,8 @@
224 sync_source.fetchLibrarianFiles)229 sync_source.fetchLibrarianFiles)
225230
226 self.assertEqual(231 self.assertEqual(
227 self.messages,232 self.get_messages(),
228 ['\tfoobar-1.0.dsc: already in distro '233 ['INFO: foobar-1.0.dsc: already in distro '
229 '- downloading from librarian'])234 '- downloading from librarian'])
230 self.assertEqual(self._listFiles(), ['foobar-1.0.dsc'])235 self.assertEqual(self._listFiles(), ['foobar-1.0.dsc'])
231236
@@ -261,7 +266,7 @@
261 stdout, stderr = process.communicate()266 stdout, stderr = process.communicate()
262 return (process.returncode, stdout, stderr)267 return (process.returncode, stdout, stderr)
263268
264 def testSyncSourceRun(self):269 def testSyncSourceRunV1(self):
265 """Try a simple sync-source.py run.270 """Try a simple sync-source.py run.
266271
267 It will run in a special tree prepared to cope with sync-source272 It will run in a special tree prepared to cope with sync-source
@@ -288,15 +293,17 @@
288 self.assertEqual(293 self.assertEqual(
289 err.splitlines(),294 err.splitlines(),
290 ['W: Could not find blacklist file on '295 ['W: Could not find blacklist file on '
291 '/srv/launchpad.net/dak/sync-blacklist.txt'])296 '/srv/launchpad.net/dak/sync-blacklist.txt',
297 'INFO - <bar_1.0-1.diff.gz: cached>',
298 'INFO - <bar_1.0.orig.tar.gz: cached>',
299 'INFO - <bar_1.0-1.dsc: cached>',
300 ])
292 self.assertEqual(301 self.assertEqual(
293 out.splitlines(),302 out.splitlines(),
294 ['Getting binaries for hoary...',303 ['Getting binaries for hoary...',
295 '[Updating] bar (0 [Ubuntu] < 1.0-1 [Debian])',304 '[Updating] bar (0 [Ubuntu] < 1.0-1 [Debian])',
296 ' * Trying to add bar...',305 ' * Trying to add bar...',
297 ' - <bar_1.0-1.diff.gz: cached>',306 ])
298 ' - <bar_1.0.orig.tar.gz: cached>',
299 ' - <bar_1.0-1.dsc: cached>'])
300307
301 expected_changesfile = 'bar_1.0-1_source.changes'308 expected_changesfile = 'bar_1.0-1_source.changes'
302 self.assertTrue(309 self.assertTrue(
@@ -331,6 +338,76 @@
331338
332 os.unlink(expected_changesfile)339 os.unlink(expected_changesfile)
333340
341 def testSyncSourceRunV3(self):
342 """Try a simple sync-source.py run with a version 3 source format
343 package.
344
345 It will run in a special tree prepared to cope with sync-source
346 requirements (see `setUp`). It contains a usable archive index
347 named as '$distribution_$suite_$component_Sources' and the
348 'etherwake' source files.
349
350 Check that:
351 * return code is ZERO,
352 * check standard error and standard output,
353 * check if the expected changesfile was generated,
354 * parse and inspect the changesfile using the archiveuploader
355 component (the same approach adopted by Soyuz).
356 * delete the changesfile.
357 """
358 returncode, out, err = self.runSyncSource(
359 extra_args=['-b', 'cprov', '-D', 'debian', '-C', 'main',
360 '-S', 'incoming', 'sample1'])
361
362 self.assertEqual(
363 0, returncode, "\nScript Failed:%s\nStdout:\n%s\nStderr\n%s\n"
364 % (returncode, out, err))
365
366 self.assertEqual(
367 err.splitlines(),
368 ['W: Could not find blacklist file on '
369 '/srv/launchpad.net/dak/sync-blacklist.txt',
370 'INFO - <sample1_1.0.orig-component3.tar.gz: cached>',
371 'INFO - <sample1_1.0-1.dsc: cached>',
372 'INFO - <sample1_1.0-1.debian.tar.gz: cached>',
373 'INFO - <sample1_1.0.orig-component1.tar.bz2: cached>',
374 'INFO - <sample1_1.0.orig-component2.tar.lzma: cached>',
375 'INFO - <sample1_1.0.orig.tar.gz: cached>'])
376 self.assertEqual(
377 out.splitlines(),
378 ['Getting binaries for hoary...',
379 '[Updating] sample1 (0 [Ubuntu] < 1.0-1 [Debian])',
380 ' * Trying to add sample1...',
381 ])
382
383 expected_changesfile = 'sample1_1.0-1_source.changes'
384 self.assertTrue(
385 os.path.exists(expected_changesfile),
386 "Couldn't find %s." % expected_changesfile)
387
388 # Parse the generated unsigned changesfile.
389 parsed_changes = parse_tagfile(
390 expected_changesfile, allow_unsigned=True)
391
392 # It refers to the right source/version.
393 self.assertEqual(parsed_changes['source'], 'sample1')
394 self.assertEqual(parsed_changes['version'], '1.0-1')
395
396 # It includes the correct 'origin' and 'target' information.
397 self.assertEqual(parsed_changes['origin'], 'Debian/incoming')
398 self.assertEqual(parsed_changes['distribution'], 'hoary')
399
400 # And finally, 'maintainer' role was preserved and 'changed-by'
401 # role was assigned as specified in the sync-source command-line.
402 self.assertEqual(
403 parsed_changes['maintainer'],
404 'Raphael Hertzog <hertzog@debian.org>')
405 self.assertEqual(
406 parsed_changes['changed-by'],
407 'Celso Providelo <celso.providelo@canonical.com>')
408
409 os.unlink(expected_changesfile)
410
334411
335def test_suite():412def test_suite():
336 return TestLoader().loadTestsFromName(__name__)413 return TestLoader().loadTestsFromName(__name__)
337414
=== modified file 'scripts/ftpmaster-tools/dak_utils.py'
--- scripts/ftpmaster-tools/dak_utils.py 2009-11-18 02:58:23 +0000
+++ scripts/ftpmaster-tools/dak_utils.py 2010-02-11 16:55:27 +0000
@@ -34,156 +34,6 @@
34re_no_epoch = re.compile(r"^\d+\:")34re_no_epoch = re.compile(r"^\d+\:")
35re_extract_src_version = re.compile(r"(\S+)\s*\((.*)\)")35re_extract_src_version = re.compile(r"(\S+)\s*\((.*)\)")
3636
37changes_parse_error_exc = "Can't parse line in .changes file"
38invalid_dsc_format_exc = "Invalid .dsc file"
39nk_format_exc = "Unknown Format: in .changes file";
40no_files_exc = "No Files: field in .dsc or .changes file.";
41
42################################################################################
43
44def parse_changes(filename, signing_rules=0):
45 """Parses a changes file and returns a dictionary where each field is a
46key. The mandatory first argument is the filename of the .changes
47file.
48
49signing_rules is an optional argument:
50
51 o If signing_rules == -1, no signature is required.
52 o If signing_rules == 0 (the default), a signature is required.
53 o If signing_rules == 1, it turns on the same strict format checking
54 as dpkg-source.
55
56The rules for (signing_rules == 1)-mode are:
57
58 o The PGP header consists of "-----BEGIN PGP SIGNED MESSAGE-----"
59 followed by any PGP header data and must end with a blank line.
60
61 o The data section must end with a blank line and must be followed by
62 "-----BEGIN PGP SIGNATURE-----".
63"""
64
65 error = ""
66 changes = {}
67
68 changes_in = open(filename)
69 lines = changes_in.readlines()
70
71 if not lines:
72 raise changes_parse_error_exc, "[Empty changes file]"
73
74 # Reindex by line number so we can easily verify the format of
75 # .dsc files...
76 index = 0
77 indexed_lines = {}
78 for line in lines:
79 index += 1
80 indexed_lines[index] = line[:-1]
81
82 inside_signature = 0
83
84 num_of_lines = len(indexed_lines.keys())
85 index = 0
86 first = -1
87 while index < num_of_lines:
88 index += 1
89 line = indexed_lines[index]
90 if line == "":
91 if signing_rules == 1:
92 index += 1
93 if index > num_of_lines:
94 raise invalid_dsc_format_exc, index
95 line = indexed_lines[index]
96 if not line.startswith("-----BEGIN PGP SIGNATURE"):
97 raise invalid_dsc_format_exc, index
98 inside_signature = 0
99 break
100 else:
101 continue
102 if line.startswith("-----BEGIN PGP SIGNATURE"):
103 break
104 if line.startswith("-----BEGIN PGP SIGNED MESSAGE"):
105 inside_signature = 1
106 if signing_rules == 1:
107 while index < num_of_lines and line != "":
108 index += 1
109 line = indexed_lines[index]
110 continue
111 # If we're not inside the signed data, don't process anything
112 if signing_rules >= 0 and not inside_signature:
113 continue
114 slf = re_single_line_field.match(line)
115 if slf:
116 field = slf.groups()[0].lower()
117 changes[field] = slf.groups()[1]
118 first = 1
119 continue
120 if line == " .":
121 changes[field] += '\n'
122 continue
123 mlf = re_multi_line_field.match(line)
124 if mlf:
125 if first == -1:
126 raise changes_parse_error_exc, "'%s'\n [Multi-line field continuing on from nothing?]" % (line)
127 if first == 1 and changes[field] != "":
128 changes[field] += '\n'
129 first = 0
130 changes[field] += mlf.groups()[0] + '\n'
131 continue
132 error += line
133
134 if signing_rules == 1 and inside_signature:
135 raise invalid_dsc_format_exc, index
136
137 changes_in.close()
138 changes["filecontents"] = "".join(lines)
139
140 if error:
141 raise changes_parse_error_exc, error
142
143 return changes
144
145################################################################################
146
147def build_file_list(changes, is_a_dsc=0):
148 files = {};
149
150 # Make sure we have a Files: field to parse...
151 if not changes.has_key("files"):
152 raise no_files_exc;
153
154 # Make sure we recognise the format of the Files: field
155 format = changes.get("format", "");
156 if format != "":
157 format = float(format.split()[0]);
158 if not is_a_dsc and (format < 1.5 or format > 2.0):
159 raise nk_format_exc, format;
160
161 # Parse each entry/line:
162 for i in changes["files"].split('\n'):
163 if not i:
164 break;
165 s = i.split();
166 section = priority = "";
167 try:
168 if is_a_dsc:
169 (md5, size, name) = s;
170 else:
171 (md5, size, section, priority, name) = s;
172 except ValueError:
173 raise changes_parse_error_exc, i;
174
175 if section == "":
176 section = "-";
177 if priority == "":
178 priority = "-";
179
180 (section, component) = extract_component_from_section(section);
181
182 files[name] = Dict(md5sum=md5, size=size, section=section,
183 priority=priority, component=component);
184
185 return files
186
187################################################################################37################################################################################
18838
189def fubar(msg, exit_code=1):39def fubar(msg, exit_code=1):
@@ -309,9 +159,9 @@
309################################################################################159################################################################################
310160
311def join_with_commas_and(list):161def join_with_commas_and(list):
312 if len(list) == 0: return "nothing";162 if len(list) == 0: return "nothing";
313 if len(list) == 1: return list[0];163 if len(list) == 1: return list[0];
314 return ", ".join(list[:-1]) + " and " + list[-1];164 return ", ".join(list[:-1]) + " and " + list[-1];
315165
316################################################################################166################################################################################
317167
318168
=== modified file 'scripts/ftpmaster-tools/sync-source.py'
--- scripts/ftpmaster-tools/sync-source.py 2010-02-02 22:34:39 +0000
+++ scripts/ftpmaster-tools/sync-source.py 2010-02-11 16:55:27 +0000
@@ -18,6 +18,7 @@
1818
19import apt_pkg19import apt_pkg
20import commands20import commands
21from debian_bundle.deb822 import Dsc
21import errno22import errno
22import optparse23import optparse
23import os24import os
@@ -25,7 +26,6 @@
25import shutil26import shutil
26import stat27import stat
27import string28import string
28import sys
29import tempfile29import tempfile
30import time30import time
31import urllib31import urllib
@@ -44,6 +44,7 @@
44from canonical.librarian.client import LibrarianClient44from canonical.librarian.client import LibrarianClient
45from canonical.lp import initZopeless45from canonical.lp import initZopeless
46from lp.registry.interfaces.pocket import PackagePublishingPocket46from lp.registry.interfaces.pocket import PackagePublishingPocket
47from lp.soyuz.scripts.ftpmaster import SyncSource, SyncSourceError
4748
4849
49reject_message = ""50reject_message = ""
@@ -130,7 +131,7 @@
130131
131def generate_changes(dsc, dsc_files, suite, changelog, urgency, closes,132def generate_changes(dsc, dsc_files, suite, changelog, urgency, closes,
132 lp_closes, section, priority, description,133 lp_closes, section, priority, description,
133 have_orig_tar_gz, requested_by, origin):134 files_from_librarian, requested_by, origin):
134 """Generate a .changes as a string"""135 """Generate a .changes as a string"""
135136
136 # XXX cprov 2007-07-03:137 # XXX cprov 2007-07-03:
@@ -164,7 +165,7 @@
164 changes += changelog165 changes += changelog
165 changes += "Files: \n"166 changes += "Files: \n"
166 for filename in dsc_files:167 for filename in dsc_files:
167 if filename.endswith(".orig.tar.gz") and have_orig_tar_gz:168 if filename in files_from_librarian:
168 continue169 continue
169 changes += " %s %s %s %s %s\n" % (dsc_files[filename]["md5sum"],170 changes += " %s %s %s %s %s\n" % (dsc_files[filename]["md5sum"],
170 dsc_files[filename]["size"],171 dsc_files[filename]["size"],
@@ -361,13 +362,91 @@
361 source, source_component, binary, current_version,362 source, source_component, binary, current_version,
362 current_component)363 current_component)
363364
365def split_gpg_and_payload(sequence):
366 """Return a (gpg_pre, payload, gpg_post) tuple
367
368 Each element of the returned tuple is a list of lines (with trailing
369 whitespace stripped).
370 """
371 # XXX JRV 20100211: Copied from deb822.py in python-debian. When
372 # Launchpad switches to Lucid this copy should be removed.
373 # bug=520508
374
375 gpg_pre_lines = []
376 lines = []
377 gpg_post_lines = []
378 state = 'SAFE'
379 gpgre = re.compile(r'^-----(?P<action>BEGIN|END) PGP (?P<what>[^-]+)-----$')
380 blank_line = re.compile('^$')
381 first_line = True
382
383 for line in sequence:
384 line = line.strip('\r\n')
385
386 # skip initial blank lines, if any
387 if first_line:
388 if blank_line.match(line):
389 continue
390 else:
391 first_line = False
392
393 m = gpgre.match(line)
394
395 if not m:
396 if state == 'SAFE':
397 if not blank_line.match(line):
398 lines.append(line)
399 else:
400 if not gpg_pre_lines:
401 # There's no gpg signature, so we should stop at
402 # this blank line
403 break
404 elif state == 'SIGNED MESSAGE':
405 if blank_line.match(line):
406 state = 'SAFE'
407 else:
408 gpg_pre_lines.append(line)
409 elif state == 'SIGNATURE':
410 gpg_post_lines.append(line)
411 else:
412 if m.group('action') == 'BEGIN':
413 state = m.group('what')
414 elif m.group('action') == 'END':
415 gpg_post_lines.append(line)
416 break
417 if not blank_line.match(line):
418 if not lines:
419 gpg_pre_lines.append(line)
420 else:
421 gpg_post_lines.append(line)
422
423 if len(lines):
424 return (gpg_pre_lines, lines, gpg_post_lines)
425 else:
426 raise EOFError('only blank lines found in input')
427
364428
365def import_dsc(dsc_filename, suite, previous_version, signing_rules,429def import_dsc(dsc_filename, suite, previous_version, signing_rules,
366 have_orig_tar_gz, requested_by, origin, current_sources,430 files_from_librarian, requested_by, origin, current_sources,
367 current_binaries):431 current_binaries):
368 dsc = dak_utils.parse_changes(dsc_filename, signing_rules)432 dsc_file = open(dsc_filename, 'r')
369 dsc_files = dak_utils.build_file_list(dsc, is_a_dsc=1)\433 dsc = Dsc(dsc_file)
370434
435 if signing_rules.startswith("must be signed"):
436 dsc_file.seek(0)
437 # XXX JRV 20100211: When Launchpad starts depending on Lucid,
438 # use dsc.split_gpg_and_payload() instead.
439 # bug=520508
440 (gpg_pre, payload, gpg_post) = split_gpg_and_payload(dsc_file)
441 if gpg_pre == [] and gpg_post == []:
442 dak_utils.fubar("signature required for %s but not present"
443 % dsc_filename)
444 if signing_rules == "must be signed and valid":
445 if (gpg_pre[0] != "-----BEGIN PGP SIGNED MESSAGE-----" or
446 gpg_post[0] != "-----BEGIN PGP SIGNATURE-----"):
447 dak_utils.fubar("signature for %s invalid %r %r" % (dsc_filename, gpg_pre, gpg_post))
448
449 dsc_files = dict((entry['name'], entry) for entry in dsc['files'])
371 check_dsc(dsc, current_sources, current_binaries)450 check_dsc(dsc, current_sources, current_binaries)
372451
373 # Add the .dsc itself to dsc_files so it's listed in the Files: field452 # Add the .dsc itself to dsc_files so it's listed in the Files: field
@@ -400,7 +479,7 @@
400479
401 changes = generate_changes(480 changes = generate_changes(
402 dsc, dsc_files, suite, changelog, urgency, closes, lp_closes,481 dsc, dsc_files, suite, changelog, urgency, closes, lp_closes,
403 section, priority, description, have_orig_tar_gz, requested_by,482 section, priority, description, files_from_librarian, requested_by,
404 origin)483 origin)
405484
406 # XXX cprov 2007-07-03: Soyuz wants an unsigned changes485 # XXX cprov 2007-07-03: Soyuz wants an unsigned changes
@@ -565,86 +644,21 @@
565 if not Sources.has_key(pkg):644 if not Sources.has_key(pkg):
566 dak_utils.fubar("%s doesn't exist in the Sources file." % (pkg))645 dak_utils.fubar("%s doesn't exist in the Sources file." % (pkg))
567646
568 have_orig_tar_gz = False647 syncsource = SyncSource(Sources[pkg]["files"], origin, Log,
569648 urllib.urlretrieve, Options.todistro)
570 # Fetch the source649 try:
571 files = Sources[pkg]["files"]650 files_from_librarian = syncsource.fetchLibrarianFiles()
572 for filename in files:651 dsc_filename = syncsource.fetchSyncFiles()
573 # First see if we can find the source in the librarian652 syncsource.checkDownloadedFiles()
574 archive_ids = [a.id for a in Options.todistro.all_distro_archives]653 except SyncSourceError, e:
575 query = """654 dak_utils.fubar("Fetching files failed: %s" % (str(e),))
576 SELECT DISTINCT ON (LibraryFileContent.sha1, LibraryFileContent.filesize)655
577 LibraryFileAlias.id656 if dsc_filename is None:
578 FROM SourcePackageFilePublishing, LibraryFileAlias, LibraryFileContent657 dak_utils.fubar("No dsc filename in %r" % Sources[pkg]["files"].keys())
579 WHERE658
580 LibraryFileAlias.id = SourcePackageFilePublishing.libraryfilealias AND659 import_dsc(os.path.abspath(dsc_filename), suite, previous_version,
581 LibraryFileContent.id = LibraryFileAlias.content AND660 origin["dsc"], files_from_librarian, requested_by, origin,
582 SourcePackageFilePublishing.libraryfilealiasfilename = %s AND661 current_sources, current_binaries)
583 SourcePackageFilePublishing.archive IN %s
584 """ % sqlvalues(filename, archive_ids)
585 cur = cursor()
586 cur.execute(query)
587 results = cur.fetchall()
588 if results:
589 if not filename.endswith("orig.tar.gz"):
590 dak_utils.fubar(
591 "%s (from %s) is in the DB but isn't an orig.tar.gz. "
592 "(Probably published in an older release)"
593 % (filename, pkg))
594 if len(results) > 1:
595 dak_utils.fubar(
596 "%s (from %s) returns multiple IDs (%s) for "
597 "orig.tar.gz. Help?" % (filename, pkg, results))
598 have_orig_tar_gz = filename
599 print (" - <%s: already in distro - downloading from librarian>"
600 % (filename))
601 output_file = open(filename, 'w')
602 librarian_input = Library.getFileByAlias(results[0][0])
603 output_file.write(librarian_input.read())
604 output_file.close()
605 continue
606
607 # Download the file
608 download_f = (
609 "%s%s" % (origin["url"], files[filename]["remote filename"]))
610 if not os.path.exists(filename):
611 print " - <%s: downloading from %s>" % (filename, origin["url"])
612 sys.stdout.flush()
613 urllib.urlretrieve(download_f, filename)
614 else:
615 print " - <%s: cached>" % (filename)
616
617 # Check md5sum and size match Source
618 actual_md5sum = md5sum_file(filename)
619 expected_md5sum = files[filename]["md5sum"]
620 if actual_md5sum != expected_md5sum:
621 dak_utils.fubar(
622 "%s: md5sum check failed (%s [actual] vs. %s [expected])."
623 % (filename, actual_md5sum, expected_md5sum))
624 actual_size = os.stat(filename)[stat.ST_SIZE]
625 expected_size = int(files[filename]["size"])
626 if actual_size != expected_size:
627 dak_utils.fubar(
628 "%s: size mismatch (%s [actual] vs. %s [expected])."
629 % (filename, actual_size, expected_size))
630
631 # Remember the name of the .dsc file
632 if filename.endswith(".dsc"):
633 dsc_filename = os.path.abspath(filename)
634
635 if origin["dsc"] == "must be signed and valid":
636 signing_rules = 1
637 elif origin["dsc"] == "must be signed":
638 signing_rules = 0
639 else:
640 signing_rules = -1
641
642 import_dsc(dsc_filename, suite, previous_version, signing_rules,
643 have_orig_tar_gz, requested_by, origin, current_sources,
644 current_binaries)
645
646 if have_orig_tar_gz:
647 os.unlink(have_orig_tar_gz)
648662
649663
650def do_diff(Sources, Suite, origin, arguments, current_binaries):664def do_diff(Sources, Suite, origin, arguments, current_binaries):

Subscribers

People subscribed via source and target branches

to status/vote changes: