Control: reopen -1

Hi!

On Sun, 2016-01-17 at 02:19:52 +0100, Guillem Jover wrote:
> On Thu, 2015-09-24 at 16:01:39 +0200, Guillem Jover wrote:
> > On Mon, 2015-09-14 at 16:48:58 +0000, Debian FTP Masters wrote:
> > > Processing raised an exception: global name 'reject' is not defined.
> > > Traceback (most recent call last):
> > >   File "/srv/ftp-master.debian.org/dak/dak/daklib/archive.py", line 955, 
> > > in check
> > >     chk().check(self)
> > >   File "/srv/ftp-master.debian.org/dak/dak/daklib/checks.py", line 497, 
> > > in check
> > >     rejects = utils.check_dsc_files(dsc_fn, control, source.files.keys())
> > >   File "/srv/ftp-master.debian.org/dak/dak/daklib/utils.py", line 341, in 
> > > check_dsc_files
> > >     reject("%s: unexpected source file '%s'" % (dsc_filename, f))
> > > NameError: global name 'reject' is not defined

(I've also actually tried to fix this issue at its root.)

> I think I've fixed this with the attached patch. I'd like enable support
> for this in dpkg-source, after it has been enabled in dak, but otherwise
> I might just add it anyway.
> 
> (I've noticed that the ‘.’ are not escaped for the three first
> regexes, and they are already covered by subsequent ones, they might
> deserve to be removed. Also it could make sense to merge the «.asc»
> addition to the existing orig.tar regexes so that they don't get out
> of sync, let me know if you'd prefer that, or change it yourself if
> it's more convenient.)

I've tried uploading libmd with detached signatures and unfortunately
this patch was not enough. Attached an untested patch series hopefully
fixing all current issues. But please review and test!

Thanks,
Guillem
From 6d9b03ee8ddcbdd7b388ecf913ee40357a6bdd5c Mon Sep 17 00:00:00 2001
From: Guillem Jover <[email protected]>
Date: Thu, 11 Feb 2016 10:26:57 +0100
Subject: [PATCH 1/4] Escape dots in file type check in check_dsc_files

---
 daklib/utils.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/daklib/utils.py b/daklib/utils.py
index 5ac015c..1b878e2 100644
--- a/daklib/utils.py
+++ b/daklib/utils.py
@@ -311,9 +311,9 @@ def check_dsc_files(dsc_filename, dsc, dsc_files):
     has = defaultdict(lambda: 0)
 
     ftype_lookup = (
-        (r'orig.tar.gz',               ('orig_tar_gz', 'orig_tar')),
-        (r'diff.gz',                   ('debian_diff',)),
-        (r'tar.gz',                    ('native_tar_gz', 'native_tar')),
+        (r'orig\.tar\.gz',             ('orig_tar_gz', 'orig_tar')),
+        (r'diff\.gz',                  ('debian_diff',)),
+        (r'tar\.gz',                   ('native_tar_gz', 'native_tar')),
         (r'debian\.tar\.(gz|bz2|xz)',  ('debian_tar',)),
         (r'orig\.tar\.(gz|bz2|xz)',    ('orig_tar',)),
         (r'orig\.tar\.(gz|bz2|xz)\.asc', ('orig_tar_sig',)),
-- 
2.7.0.79.gdc08a19

From fa5323e8cdff81a8026d6bf59f6f7e1a3c65a028 Mon Sep 17 00:00:00 2001
From: Guillem Jover <[email protected]>
Date: Thu, 11 Feb 2016 10:27:10 +0100
Subject: [PATCH 2/4] Remove unused re_source_ext import

---
 dak/show_new.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/dak/show_new.py b/dak/show_new.py
index 64ea228..af1b8a6 100755
--- a/dak/show_new.py
+++ b/dak/show_new.py
@@ -33,7 +33,6 @@ import examine_package
 from daklib import policy
 from daklib.dbconn import *
 from daklib import utils
-from daklib.regexes import re_source_ext
 from daklib.config import Config
 from daklib import daklog
 from daklib.dakmultiprocessing import DakProcessPool, PROC_STATUS_SUCCESS, PROC_STATUS_SIGNALRAISED
-- 
2.7.0.79.gdc08a19

From 4805e73b2d564306046c863138280aac99dcdb57 Mon Sep 17 00:00:00 2001
From: Guillem Jover <[email protected]>
Date: Thu, 11 Feb 2016 10:27:13 +0100
Subject: [PATCH 3/4] Stop using undefined reject function in check_dsc_files

When there's an unknown file in a source package, the function spits
this:

  ,---
  Processing raised an exception: global name 'reject' is not defined.
  Traceback (most recent call last):
    File "/srv/ftp-master.debian.org/dak/dak/daklib/archive.py", line 966, in check
      chk().check(self)
    File "/srv/ftp-master.debian.org/dak/dak/daklib/checks.py", line 497, in check
      rejects = utils.check_dsc_files(dsc_fn, control, source.files.keys())
    File "/srv/ftp-master.debian.org/dak/dak/daklib/utils.py", line 343, in check_dsc_files
      reject("%s: unexpected source file '%s'" % (dsc_filename, f))
  NameError: global name 'reject' is not defined
  `---

Just set the reject message and break from the loop.
---
 daklib/utils.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/daklib/utils.py b/daklib/utils.py
index 1b878e2..ce72a2c 100644
--- a/daklib/utils.py
+++ b/daklib/utils.py
@@ -340,7 +340,8 @@ def check_dsc_files(dsc_filename, dsc, dsc_files):
 
         # File does not match anything in lookup table; reject
         if not matched:
-            reject("%s: unexpected source file '%s'" % (dsc_filename, f))
+            rejmsg.append("%s: unexpected source file '%s'" % (dsc_filename, f))
+            break
 
     # Check for multiple files
     for file_type in ('orig_tar', 'orig_tar_sig', 'native_tar', 'debian_tar', 'debian_diff'):
-- 
2.7.0.79.gdc08a19

From dc97c1fd7401c68ec7cff9422fcabefb43c63350 Mon Sep 17 00:00:00 2001
From: Guillem Jover <[email protected]>
Date: Thu, 11 Feb 2016 10:27:16 +0100
Subject: [PATCH 4/4] Fix support for detached upstream signatures
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We should only allow upstream tarballs with detached signatures, but not
native tarballs, «<source>_<version>.orig.asc» or «<source>_<version>.asc»
filenames. We also need to allow this on all relevant regexes. This commit
fixes and refactors the regexes to implement the above, and to make it
easier to modify a single place in the future.

Fixes commit 4911282cbf231b116872a6f16eb838f7862ebc36.

Closes: #759401
---
 daklib/regexes.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/daklib/regexes.py b/daklib/regexes.py
index 40b4a74..3dccbba 100644
--- a/daklib/regexes.py
+++ b/daklib/regexes.py
@@ -45,8 +45,9 @@ re_no_epoch = re.compile(r"^\d+\:")
 re_extract_src_version = re.compile (r"(\S+)\s*\((.*)\)")
 re_isadeb = re.compile (r"(.+?)_(.+?)_(.+)\.u?deb$")
 
-orig_source_ext_re = r"orig(?:-.+)?\.tar\.(?:gz|bz2|xz)"
-re_source_ext = re.compile("(" + orig_source_ext_re + r"|debian\.tar\.(?:gz|bz2|xz)|diff\.gz|tar\.(?:gz|bz2|xz)|dsc|asc)$")
+orig_source_ext_re = r"orig(?:-[a-zA-Z0-9-]+)?\.tar\.(?:gz|bz2|xz)(?:\.asc)?"
+file_source_ext_re = "(" + orig_source_ext_re + r"|(?:debian\.)?tar\.(?:gz|bz2|xz)|diff\.gz)"
+re_source_ext = re.compile("(" + file_source_ext_re + r"|dsc)$")
 re_issource = re.compile(r"(.+)_(.+?)\." + re_source_ext.pattern)
 
 re_single_line_field = re.compile(r"^(\S*?)\s*:\s*(.*)")
@@ -135,11 +136,11 @@ re_file_dsc = re.compile(_re_file_prefix + r'\.dsc$')
 
 # Match other source files
 # Groups: package, version
-re_file_source = re.compile(_re_file_prefix + r'(?:(?:\.orig(?:-[a-zA-Z0-9-]+)?|\.debian)?\.tar\.(?:bz2|gz|xz)|\.diff\.gz|\.asc)$')
+re_file_source = re.compile(_re_file_prefix + r'\.' + file_source_ext_re)
 
 # Match upstream tarball
 # Groups: package, version
-re_file_orig = re.compile(_re_file_prefix + r'\.orig(?:-[a-zA-Z0-9-]+)?(?:\.tar\.(?:bz2|gz|xz)|\.asc)')
+re_file_orig = re.compile(_re_file_prefix + r'\.' + orig_source_ext_re)
 
 # Match buildinfo file
 # Groups: package, version, suffix
-- 
2.7.0.79.gdc08a19

Reply via email to