Bug#921972: lintian-brush: when d/compat is missing

2019-02-10 Thread Jelmer Vernooij
On Mon, Feb 11, 2019 at 12:14:41AM +, Jelmer Vernooij wrote:
> On Sun, Feb 10, 2019 at 07:08:52PM +, Dmitry Bogatov wrote:
> > By the way, it is quite unfortunate, that fixer API disallow early
> > sys.exit(0).
> Agreed, that would be good to fix. A workaround is to
> use sys.exit(2) to exit early without a description.
This should be fixed in master; a fixer can now not provide a description so
long as it doesn't make any changes.



Bug#921972: lintian-brush: when d/compat is missing

2019-02-10 Thread Jelmer Vernooij
On Sun, Feb 10, 2019 at 07:08:52PM +, Dmitry Bogatov wrote:
> please consider following patch to avoid warnings, when there is no
> `debian/compat'.
Thanks for the patch! Applied in master.

> By the way, it is quite unfortunate, that fixer API disallow early
> sys.exit(0).
Agreed, that would be good to fix. A workaround is to
use sys.exit(2) to exit early without a description.

Jelmer



Bug#921972: lintian-brush: when d/compat is missing

2019-02-10 Thread Dmitry Bogatov

Package: lintian-brush
Version: 0.12
Severity: wishlist

Dear Maintainer,

please consider following patch to avoid warnings, when there is no
`debian/compat'.

By the way, it is quite unfortunate, that fixer API disallow early
sys.exit(0).

From 984f18ecf19eec6df94cb7c5701f62f35de88785 Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov 
Date: Sun, 10 Feb 2019 00:05:54 +
Subject: [PATCH] Do not throw exception on packages without d/compat

Previosly, following error message was triggered by missing `debian/compat':

 Some fixer scripts failed to run: 
{'package-needs-versioned-debhelper-build-depends'}. Run with --verbose for 
details.

Running with --verbose exposed Python exceptions to user, which is not
supposed to understand Python.
---
 ...e-needs-versioned-debhelper-build-depends.py | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/fixers/package-needs-versioned-debhelper-build-depends.py 
b/fixers/package-needs-versioned-debhelper-build-depends.py
index a48d768..c4a50ca 100755
--- a/fixers/package-needs-versioned-debhelper-build-depends.py
+++ b/fixers/package-needs-versioned-debhelper-build-depends.py
@@ -1,23 +1,26 @@
 #!/usr/bin/python3
 
+import sys
 from lintian_brush.control import (
 ensure_minimum_version,
 update_control,
 )
-
-
-with open('debian/compat', 'r') as f:
-minimum_version = f.read().strip()
-
-
 def bump_debhelper(control):
 control["Build-Depends"] = ensure_minimum_version(
 control["Build-Depends"],
 "debhelper",
 "%s~" % minimum_version)
 
+# Debian source package is not obliged to contain `debian/control'.
+# Firstly, it may not use debhelper; secondly it may use modern
+# `debhelper-compat' dependency style.
+try:
+with open('debian/compat', 'r') as f:
+minimum_version = f.read().strip()
+update_control(source_package_cb=bump_debhelper)
+except FileNotFoundError:
+minimum_version =  # Not used anyway.
 
-update_control(source_package_cb=bump_debhelper)
 print("Bump debhelper dependency to >= %s, since that's what is "
   "used in debian/compat." % minimum_version)
 print("Fixed-Lintian-Tags: package-needs-versioned-debhelper-build-depends")


pgpD_o_v7G_3X.pgp
Description: PGP signature