From: Mike O'Connor Date: Fri, 13 Mar 2009 16:41:26 +0000 (-0400) Subject: fail on first error in scan_package X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa661dc56e7ed99df0c89d77f9b1a50c03a1a066;p=dak fail on first error in scan_package Signed-off-by: Mike O'Connor --- diff --git a/daklib/binary.py b/daklib/binary.py index a079763b..18079b54 100755 --- a/daklib/binary.py +++ b/daklib/binary.py @@ -167,33 +167,34 @@ class Binary(object): @return True if the deb is valid and contents were imported """ rejected = not self.valid_deb() - self.__unpack() + if not rejected: + self.__unpack() - result = False + result = False - cwd = os.getcwd() - if not rejected and self.tmpdir: - try: - os.chdir(self.tmpdir) - if self.chunks[1] == "control.tar.gz": - control = tarfile.open(os.path.join(self.tmpdir, "control.tar.gz" ), "r:gz") - control.extract('./control', self.tmpdir ) - if self.chunks[2] == "data.tar.gz": - data = tarfile.open(os.path.join(self.tmpdir, "data.tar.gz"), "r:gz") - elif self.chunks[2] == "data.tar.bz2": - data = tarfile.open(os.path.join(self.tmpdir, "data.tar.bz2" ), "r:bz2") - - if bootstrap_id: - result = DBConn().insert_content_paths(bootstrap_id, [tarinfo.name for tarinfo in data if not tarinfo.isdir()]) - else: - pkgs = deb822.Packages.iter_paragraphs(file(os.path.join(self.tmpdir,'control'))) - pkg = pkgs.next() - result = DBConn().insert_pending_content_paths(pkg, [tarinfo.name for tarinfo in data if not tarinfo.isdir()]) - - except: - traceback.print_exc() + cwd = os.getcwd() + if not rejected and self.tmpdir: + try: + os.chdir(self.tmpdir) + if self.chunks[1] == "control.tar.gz": + control = tarfile.open(os.path.join(self.tmpdir, "control.tar.gz" ), "r:gz") + control.extract('./control', self.tmpdir ) + if self.chunks[2] == "data.tar.gz": + data = tarfile.open(os.path.join(self.tmpdir, "data.tar.gz"), "r:gz") + elif self.chunks[2] == "data.tar.bz2": + data = tarfile.open(os.path.join(self.tmpdir, "data.tar.bz2" ), "r:bz2") + + if bootstrap_id: + result = DBConn().insert_content_paths(bootstrap_id, [tarinfo.name for tarinfo in data if not tarinfo.isdir()]) + else: + pkgs = deb822.Packages.iter_paragraphs(file(os.path.join(self.tmpdir,'control'))) + pkg = pkgs.next() + result = DBConn().insert_pending_content_paths(pkg, [tarinfo.name for tarinfo in data if not tarinfo.isdir()]) + + except: + traceback.print_exc() - os.chdir(cwd) + os.chdir(cwd) return result def check_utf8_package(self, package):