Fix handling of lgp build's --sign option (closes #69466)

  • self.config.sign is now a boolean, not a string
  • drop handling of 'sign' in the 'BUILD' section, it wasn't used for the actual signing anyway

Reported-by: Nicolas Chauvat <nicolas.chauvat@logilab.fr>

authorJulien Cristau <julien.cristau@logilab.fr>
changesete47789457d5e
branchdefault
phasepublic
hiddenno
parent revision#96e89a2b9bcd check: catch output of grep in copyright check in a logger call
child revision#5d1fe38f50ce Remove dead code from LGPCommandLine::run()
files modified by this revision
lgp/build.py
lgp/check.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1308808598 -7200
# Thu Jun 23 07:56:38 2011 +0200
# Node ID e47789457d5ed608ce1cd081ad2545dff9bc48ee
# Parent 96e89a2b9bcd425e137853d1849ea1120a4c66fd
Fix handling of lgp build's --sign option (closes #69466)

- self.config.sign is now a boolean, not a string
- drop handling of 'sign' in the 'BUILD' section, it wasn't used for the
actual signing anyway

Reported-by: Nicolas Chauvat <nicolas.chauvat@logilab.fr>

diff --git a/lgp/build.py b/lgp/build.py
@@ -96,10 +96,11 @@
1                 ('sign',
2                  {'type': 'yn',
3                   'default': False,
4                   'short': 's',
5                   'dest' : "sign",
6 +                 'metavar' : '<yes|no>',
7                   'help': "try to sign Debian package(s) just built",
8                   'group': 'Debian'
9                  }),
10                 ('post-treatments',
11                  {'type': 'yn',
@@ -434,11 +435,11 @@
12          :todo: define API and/or integrate software (dput, curl, scp) ?
13          """
14          assert isinstance(filelist, list), "must be a list to be able to extend"
15 
16          def _sign_file(filename):
17 -            if self.config.sign and self.config.sign.lower() == "yes":
18 +            if self.config.sign:
19                  check_debsign(self)
20                  try:
21                      check_call(["debsign", filename], stdout=sys.stdout)
22                  except CalledProcessError, err:
23                      self.logger.error("lgp cannot debsign '%s' automatically" % filename)
diff --git a/lgp/check.py b/lgp/check.py
@@ -24,12 +24,10 @@
24  import logging
25  import itertools
26  import subprocess
27  from os.path import basename, join, exists, isdir, isfile
28  from glob import glob
29 -import warnings
30 -import ConfigParser
31 
32  from logilab.devtools import BASE_EXCLUDE, __path__
33  from logilab.devtools.lgp import LGP, LGP_CONFIG_FILE, utils
34  from logilab.devtools.lgp.setupinfo import SetupInfo
35  from logilab.devtools.lgp.exceptions import LGPException
@@ -530,37 +528,20 @@
36              checker.logger.warn('a junk extension is matched: %s' % filename)
37      return status
38 
39  def check_debsign(checker):
40      """check requirements (~/.devscripts or gpg-agent) to sign packages"""
41 -    config = ConfigParser.ConfigParser()
42 -    config_sign = "no"
43 -    try:
44 -        config.readfp(open(LGP_CONFIG_FILE))
45 -        msg = 'retrieve sign option value from %s: "sign=%s"'
46 -        if config.has_option("BUILD", "sign"):
47 -            config_sign = config.get("BUILD", "sign")
48 -            warnmsg = "Please, move 'sign=%s' option into new [DEBIAN] section"
49 -            warnings.warn(warnmsg % config_sign, DeprecationWarning)
50 -        if config.has_option("DEBIAN", "sign"):
51 -            config_sign = config.get("DEBIAN", "sign")
52 -        checker.logger.debug(msg % (LGP_CONFIG_FILE, config_sign))
53 -    except IOError:
54 -        return OK # no config file
55 +    if not getattr(checker.config, 'sign', True):
56 +        return OK
57 
58 -    enabled = config_sign[0].lower() == "y"
59 -    if getattr(checker.config, "sign", None):
60 -        enabled = True
61 -
62 -    if enabled:
63 -        if not os.path.exists(os.path.expanduser("~/.devscripts")):
64 -            msg = "please, export your DEBSIGN_KEYID in ~/.devscripts (read `debsign` manual)"
65 -            checker.logger.error(msg)
66 -            return NOK
67 -        if 'GPG_AGENT_INFO' not in os.environ:
68 -            checker.logger.error('enable your gpg-agent to sign packages automatically')
69 -            return NOK
70 +    if not os.path.exists(os.path.expanduser("~/.devscripts")):
71 +        msg = "please, export your DEBSIGN_KEYID in ~/.devscripts (read `debsign` manual)"
72 +        checker.logger.error(msg)
73 +        return NOK
74 +    if 'GPG_AGENT_INFO' not in os.environ:
75 +        checker.logger.error('enable your gpg-agent to sign packages automatically')
76 +        return NOK
77      return OK
78 
79  def check_package_info(checker):
80      """check package information"""
81      status = OK