build: run createrepo after building rpms

Closes #145330

authorJulien Cristau <julien.cristau@logilab.fr>
changeset77986689e383
branchstable
phasepublic
hiddenno
parent revision#45e9a24818bd build: if a distrib's name starts with epel or fedora, assume we want rpms
child revision#65da79f25422 build: fix misuse of LGPCommandException (closes #145329)
files modified by this revision
lgp/build.py
test/unittest_build.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1370860702 -7200
# Mon Jun 10 12:38:22 2013 +0200
# Branch stable
# Node ID 77986689e3836db4dfbba6efad6a84cbb8e91e21
# Parent 45e9a24818bd0d7acebc30ade4b6826abcb70e22
build: run createrepo after building rpms

Closes #145330

diff --git a/lgp/build.py b/lgp/build.py
@@ -187,17 +187,19 @@
1                  for distrib in  self.distributions:
2                      with tempdir(self.config.keep_tmpdir) as src_tmpdir:
3                          if self.config.rpm or distrib.startswith(('fedora', 'epel')):
4                              srpm = self.make_rpm_source_package(distrib, src_tmpdir)
5                              self.make_rpm_binary_package(distrib, srpm)
6 +                            if self.config.post_treatments:
7 +                                self.run_rpm_post_treatments(distrib)
8                          else:
9                              # create a debian source package
10                              dscfile = self.make_debian_source_package(distrib, src_tmpdir)
11                              if self.make_debian_binary_package(distrib, dscfile):
12                                  # do post-treatments only for a successful binary build
13                                  if self.packages and self.config.post_treatments:
14 -                                    self.run_post_treatments(distrib)
15 +                                    self.run_deb_post_treatments(distrib)
16                  # report files to the console
17                  if self.packages:
18                      self.logger.info("recent files from build:\n* %s"
19                                       % '\n* '.join(sorted(set(self.packages))))
20              except LGPException, exc:
@@ -642,11 +644,11 @@
21          # if no default value for distribution, use list from existing images
22          if self.config.distrib is None:
23              self.config.distrib = 'all'
24          super(Builder, self).guess_environment()
25 
26 -    def run_post_treatments(self, distrib):
27 +    def run_deb_post_treatments(self, distrib):
28          """ Run actions after package compiling """
29          # dpkg-scanpackages i386 /dev/null | gzip -9c > 386/Packages.gz
30          # dpkg-scanpackages amd64 /dev/null | gzip -9c > amd64/Packages.gz
31          # dpkg-scansources source /dev/null | gzip -9c > source/Sources.gz
32          resultdir = self.get_distrib_dir(distrib)
@@ -660,10 +662,17 @@
33                                  % resultdir)
34          else:
35              self.logger.debug("Debian trivial repository in '%s' updated."
36                                % packages_file)
37 
38 +    def run_rpm_post_treatments(self, distrib):
39 +        resultdir = self.get_distrib_dir(distrib)
40 +        try:
41 +            check_call(['createrepo', '--update', '.'], cwd=resultdir)
42 +        except CalledProcessError, err:
43 +            self.logger.warning('cannot update rpm repository for %s', resultdir)
44 +
45      def prepare_source_archive(self, tmpdir, current_distrib):
46          """prepare and extract the upstream tarball
47 
48          FIXME replace by TarFile Object
49          """
diff --git a/test/unittest_build.py b/test/unittest_build.py
@@ -81,11 +81,11 @@
50          builder.go_into_package_dir([])
51          resultdir = tempfile.gettempdir()
52          builder.config.dist_dir = resultdir
53          package_file = osp.join(resultdir, "lenny", "Packages.gz")
54          self.assertFalse(osp.isfile(package_file))
55 -        builder.run_post_treatments("lenny")
56 +        builder.run_deb_post_treatments("lenny")
57          self.assertTrue(osp.isfile(package_file))
58 
59 
60  class SignTC(TestCase):
61      def test_check_sign(self):