On 15/02/14 20:20, Raphael Hertzog wrote:
> Maybe you should put the result of os.path.join(source.unpacked,"debian")
> in a variable since you redo the same operation a few lines later.
> 
> And you might want to wrap this on 2 lines since it's very long.
> 
>> +                try:
>> +                    source_format = 
>> DebianSourceFormat.parse_file(DebianSourceFormat.format_file)
>> +                    if source_format.version == "3.0" and 
>> source_format.type == "quilt":
>> +                        shutil.rmtree("%s" 
>> %(os.path.join(source.unpacked,"debian")))
>> +                        gbp.log.info("Deleted 'debian/' directory from 
>> unpacked upstream tarball before import")
>> +                except Exception as e:
>> +                    raise GbpError("Can't determine package type: %s" % e)
> 
> What exception are you trying to catch here? You already checked that we
> have a debian/source/format file.

Yes, you are right, that try-except don't makes much sense.

Thanks for your comments.


I'm attaching a new version of the patch.
From e1f709dd117ee5e97feda9dd02d88aaabfe9b00c Mon Sep 17 00:00:00 2001
From: Carlos Alberto Lopez Perez <clo...@igalia.com>
Date: Sat, 15 Feb 2014 18:57:52 +0100
Subject: [PATCH] Filter upstream debian directory on packages 3.0 (quilt)
 (#700411)

---
 gbp/scripts/import_orig.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py
index aae93fa..d5e1d4c 100644
--- a/gbp/scripts/import_orig.py
+++ b/gbp/scripts/import_orig.py
@@ -21,11 +21,13 @@ import ConfigParser
 import os
 import sys
 import tempfile
+import shutil
 import gbp.command_wrappers as gbpc
 from gbp.deb import (DebianPkgPolicy, parse_changelog_repo)
 from gbp.deb.uscan import (Uscan, UscanError)
 from gbp.deb.changelog import ChangeLog, NoChangeLogError
 from gbp.deb.git import (GitRepositoryError, DebianGitRepository)
+from gbp.deb.format import DebianSourceFormat
 from gbp.config import GbpOptionParserDebian, GbpOptionGroup, no_upstream_branch_msg
 from gbp.errors import GbpError
 import gbp.log
@@ -292,6 +294,13 @@ def main(argv):
             tmpdir = tempfile.mkdtemp(dir='../')
             source.unpack(tmpdir, options.filters)
             gbp.log.debug("Unpacked '%s' to '%s'" % (source.path, source.unpacked))
+            # wipe upstream "debian/" if package is 3.0 (quilt)
+            upstream_debiandir = os.path.join(source.unpacked, "debian")
+            if os.path.isdir(upstream_debiandir) and os.path.isfile(DebianSourceFormat.format_file):
+                source_format = DebianSourceFormat.parse_file(DebianSourceFormat.format_file)
+                if source_format.version == "3.0" and source_format.type == "quilt":
+                    shutil.rmtree(upstream_debiandir)
+                    gbp.log.info("Deleted 'debian' directory from unpacked upstream tarball before import")
 
         if source.needs_repack(options):
             gbp.log.debug("Filter pristine-tar: repacking '%s' from '%s'" % (source.path, source.unpacked))
-- 
1.8.5.3

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to