Backout 4e611b5e2508 "Do a 3-way version check (upstream, debian, specfile)"

It's broken in various ways. Closes #228338, #228339.

authorJulien Cristau <julien.cristau@logilab.fr>
changeset38e4c77fc54c
branchdefault
phasepublic
hiddenno
parent revision#7f4bcc9df36a Added tag logilab-devtools-version-0.22.1, logilab-devtools-debian-version-0.22.1-1 for changeset 78342090cc96
child revision#ea6a14e55914 0.22.2
files modified by this revision
lgp/build.py
lgp/setupinfo.py
lgp/utils.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1394637303 -3600
# Wed Mar 12 16:15:03 2014 +0100
# Node ID 38e4c77fc54cc57249fdea1294a2baf1f2807445
# Parent 7f4bcc9df36adb14c9ec5395022e0d445695e070
Backout 4e611b5e2508 "Do a 3-way version check (upstream, debian, specfile)"

It's broken in various ways. Closes #228338, #228339.

diff --git a/lgp/build.py b/lgp/build.py
@@ -226,24 +226,13 @@
1 
2          .. see::
3              http://www.debian.org/doc/debian-policy/ch-source.html
4          """
5          has_debian_dir = osp.isdir('debian')
6 -        # Ugly code, does the job for the moment
7 -        specfile = self.config.specfile
8 -        if specfile is None:
9 -            specfiles = glob('*.spec')
10 -            try:
11 -                specfile, = specfiles
12 -            except ValueError:
13 -                pass
14          if has_debian_dir:
15 -            self._check_debian_version_mismatch()
16 -        if specfile is not None:
17 -            self._check_rpm_version_mismatch(specfile)
18 -
19 -        if has_debian_dir:
20 +            # _check_version_mismatch() is 100% Debian-specific
21 +            self._check_version_mismatch()
22              is_initial_debian_revision = self.is_initial_debian_revision()
23          else:
24              # always rebuild the source/orig tarball if debian/ is missing,
25              # skip uscan altogether
26              is_initial_debian_revision = True
@@ -328,11 +317,11 @@
27              except ValueError:
28                  if not specfiles:
29                      self.logger.error("unable to find the '.spec' file")
30                  else:
31                      self.logger.error("more than one spec file found")
32 -                self.logger.error("please use the '--spec' option")
33 +                self.logger.error("please use the '--specfile' option")
34                  raise LGPException("cannot build source distribution")
35          specfile = osp.abspath(specfile)
36 
37          # change directory to build source package
38          # note: call os.chdir() HERE is needed in make_rpm_binary_package() below
diff --git a/lgp/setupinfo.py b/lgp/setupinfo.py
@@ -19,11 +19,10 @@
39 
40  import errno
41  import sys
42  import os
43  import stat
44 -from glob import glob
45  import os.path as osp
46  import logging
47  from string import Template
48  from distutils.core import run_setup
49  #from pkg_resources import FileMetadata
@@ -378,29 +377,20 @@
50 
51      def get_versions(self):
52          versions = self.get_debian_version().rsplit('-', 1)
53          return versions
54 
55 -    def _check_debian_version_mismatch(self):
56 +    def _check_version_mismatch(self):
57          upstream_version = self.get_upstream_version()
58 +        #debian_upstream_version = self.get_versions()[0]
59          debian_upstream_version = self.get_debian_version().rsplit('-', 1)[0]
60          assert debian_upstream_version == self.get_versions()[0], "get_versions() failed"
61          if upstream_version != debian_upstream_version:
62              msg = "version mismatch: upstream says '%s' and debian/changelog says '%s'"
63              msg %= (upstream_version, debian_upstream_version)
64              raise LGPException(msg)
65 
66 -    def _check_rpm_version_mismatch(self, specfile):
67 -        upstream_version = self.get_upstream_version()
68 -        rpm_upstream_version = utils.parse_rpm_version(specfile)
69 -        self.logger.debug('retrieve rpm version from %s: %s' %
70 -                          (specfile, rpm_upstream_version))
71 -        if upstream_version != rpm_upstream_version:
72 -            msg = "version mismatch: upstream says '%s' and spec file says '%s'"
73 -            msg %= (upstream_version, rpm_upstream_version)
74 -            raise LGPException(msg)
75 -
76      def get_basetgz(self, distrib, arch, check=True):
77          basetgz = osp.join(self.config.basetgz, "%s-%s.tgz" % (distrib, arch))
78          if check and not osp.exists(basetgz):
79              msg = "lgp image '%s' not found. Please create it with lgp setup"
80              raise LGPException(msg % basetgz)
diff --git a/lgp/utils.py b/lgp/utils.py
@@ -27,15 +27,10 @@
81  import logging
82 
83  from debian.deb822 import Deb822
84  from debian.changelog import Changelog, ChangelogParseError
85 
86 -try:
87 -    import rpm
88 -except ImportError:
89 -    rpm = None
90 -
91  from logilab.devtools.lgp import LGP_SUITES
92  from logilab.devtools.lgp.exceptions import (ArchitectureException,
93                                               DistributionException,
94                                               SetupException,
95                                               LGPException)
@@ -236,20 +231,10 @@
96          clog.parse_changelog(open(changelog), max_blocks=1)
97          return clog.package
98      except ChangelogParseError:
99          raise LGPException("Malformed Debian changelog '%s'" % changelog)
100 
101 -def parse_rpm_version(specfile):
102 -    if rpm is None:
103 -        raise LGPException('rpm unsupported: missing rpm python module')
104 -    try:
105 -        spec = rpm.spec(specfile)
106 -        return spec.sourceHeader['version']
107 -    except rpm.error:
108 -        raise LGPException('python-rpm specfile error: '
109 -                           'cannot determine version')
110 -
111  @contextmanager
112  def tempdir(keep_tmpdir=False):
113      """create new build temporary context
114 
115      Catches exceptions in the context-managed block to take the keep_tmpdir