changeset 367:fb92f3c1b238

treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
author Bjoern Ricks <bricks@intevation.de>
date Mon, 31 May 2010 10:20:25 +0000
parents fee68f1a35e8
children 8bb8d8de12a2
files test/test_packager.py treepkg/packager.py
diffstat 2 files changed, 130 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/test/test_packager.py	Mon May 31 09:54:31 2010 +0000
+++ b/test/test_packager.py	Mon May 31 10:20:25 2010 +0000
@@ -263,6 +263,114 @@
                           [("702432", "2"), ("704195", "0")])
 
 
+class TestSourcePackager(unittest.TestCase, FileTestMixin):
+
+    def test_debian_source_format_3_0_1(self):
+        trackdir = self.create_files("track",
+                                     [("debian",
+                                       [("source",
+                                         [("format", ("3.0 (quilt)"))]
+                                       )]
+                                     ),
+                                     ("pkg",
+                                       [("704195-0",
+                                         [("status", 
+                                            ("TreePackagerStatus 0.0\n"
+                                            "status: binary_package_created\n"
+                                            "start: 2007-09-10 17:16:48\n"
+                                            "stop: 2007-09-11 00:07:36\n")),
+                                          ("src", []),
+                                          ("binary", [])
+                                         ]
+                                        )]
+                                      )]
+                                   )
+        track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
+        revpkg = RevisionPackager(track, 704195, 0)
+        srcpkg = SourcePackager(revpkg)
+
+        pkgbasedir = trackdir
+        format = srcpkg.get_debian_source_format(pkgbasedir)
+        self.assertEqual("3.0 (quilt)", format)
+
+    def test_debian_source_format_3_0_2(self):
+        trackdir = self.create_files("track",
+                                     [("debian",
+                                       [("source",
+                                         [("format", ("3.0 (quilt)\nabc"))]
+                                       )]
+                                     ),
+                                     ("pkg",
+                                       [("704195-0",
+                                         [("status",
+                                            ("TreePackagerStatus 0.0\n"
+                                            "status: binary_package_created\n"
+                                            "start: 2007-09-10 17:16:48\n"
+                                            "stop: 2007-09-11 00:07:36\n")),
+                                          ("src", []),
+                                          ("binary", [])
+                                         ]
+                                        )]
+                                      )]
+                                   )
+        track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
+        revpkg = RevisionPackager(track, 704195, 0)
+        srcpkg = SourcePackager(revpkg)
+
+        pkgbasedir = trackdir
+        format = srcpkg.get_debian_source_format(pkgbasedir)
+        self.assertEqual("3.0 (quilt)", format)
+
+    def test_debian_source_format_1_0_1(self):
+        trackdir = self.create_files("track",
+                                     [("debian",
+                                       [("source","")]
+                                     ),
+                                     ("pkg",
+                                       [("704195-0",
+                                         [("status",
+                                            ("TreePackagerStatus 0.0\n"
+                                            "status: binary_package_created\n"
+                                            "start: 2007-09-10 17:16:48\n"
+                                            "stop: 2007-09-11 00:07:36\n")),
+                                          ("src", []),
+                                          ("binary", [])
+                                         ]
+                                        )]
+                                      )]
+                                   )
+        track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
+        revpkg = RevisionPackager(track, 704195, 0)
+        srcpkg = SourcePackager(revpkg)
+
+        pkgbasedir = trackdir
+        format = srcpkg.get_debian_source_format(pkgbasedir)
+        self.assertEqual("1.0", format)
+
+    def test_debian_source_format_1_0_2(self):
+        trackdir = self.create_files("track",
+                                     [("debian", ""),
+                                     ("pkg",
+                                       [("704195-0",
+                                         [("status",
+                                            ("TreePackagerStatus 0.0\n"
+                                            "status: binary_package_created\n"
+                                            "start: 2007-09-10 17:16:48\n"
+                                            "stop: 2007-09-11 00:07:36\n")),
+                                          ("src", []),
+                                          ("binary", [])
+                                         ]
+                                        )]
+                                      )]
+                                   )
+        track = PackageTrack("testtrack", trackdir, "", "", "", "", "")
+        revpkg = RevisionPackager(track, 704195, 0)
+        srcpkg = SourcePackager(revpkg)
+
+        pkgbasedir = trackdir
+        format = srcpkg.get_debian_source_format(pkgbasedir)
+        self.assertEqual("1.0", format)
+
 class TestRevisionPackager(unittest.TestCase, FileTestMixin):
 
     def test_list_source_files(self):
--- a/treepkg/packager.py	Mon May 31 09:54:31 2010 +0000
+++ b/treepkg/packager.py	Mon May 31 10:20:25 2010 +0000
@@ -153,12 +153,33 @@
         dpkg_source_log = os.path.join(self.log_dir, "dpkg_source.txt")
         logging.info("Creating new source package; logging to %s",
                      dpkg_source_log)
-        run.call(cmdexpand("dpkg-source -b $directory $tarball",
+        
+        format = self.get_debian_source_format(pkgbasedir)
+        if format == "1.0":
+            run.call(cmdexpand("dpkg-source -b $directory $tarball",
                            directory=os.path.basename(pkgbasedir),
                            tarball=os.path.basename(origtargz)),
                  cwd=os.path.dirname(pkgbasedir),
                  logfile=dpkg_source_log,
                  env=self.track.debian_environment())
+        elif format == "3.0 (quilt)":
+            run.call(cmdexpand("dpkg-source -b $directory",
+                           directory=os.path.basename(pkgbasedir)),
+                 cwd=os.path.dirname(pkgbasedir),
+                 logfile=dpkg_source_log,
+                 env=self.track.debian_environment())
+        else:
+            raise RuntimeError("debian source format %s is not supported by treepkg" % format)
+
+    def get_debian_source_format(self, pkgbasedir):
+        formatfile = os.path.join(pkgbasedir, "debian", "source", "format")
+        if not os.path.exists(formatfile):
+            return "1.0"
+        else:
+            file = open(formatfile, "r")
+            line = file.readline()
+            file.close()
+            return line.strip()
 
     def move_source_package(self, pkgbasename):
         """Moves the new source package from the work_dir to the src_dir"""
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)